|
@@ -191,7 +191,8 @@ public class InstallBusiness {
|
|
|
List<ItfGreeToFaDownloadTaskList> its = new ArrayList<>();
|
|
|
List<OrderApplyDispatch> oads = new ArrayList<>();
|
|
|
List<OrderInstallDetail> oids = new ArrayList<>();
|
|
|
- List<String> oiddels = new ArrayList<>();
|
|
|
+ List<String> delOrderProduct = new ArrayList<>();
|
|
|
+ List<String> delOrderInstallDetail = new ArrayList<>();
|
|
|
List<OrderDetailFile> odfs = new ArrayList<>();
|
|
|
|
|
|
// 提取本地订单
|
|
@@ -215,7 +216,7 @@ public class InstallBusiness {
|
|
|
|
|
|
// 获取产品明细要同步的数据 -只存在修改,减少与增加的情况不存在
|
|
|
getOrderProductsUpdate(sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap, old, newLCLS,
|
|
|
- item.getDownloadTaskNo(),mxsynreqids,orderProductsUpdate,oids,oiddels,odfs);
|
|
|
+ item.getDownloadTaskNo(),mxsynreqids,orderProductsUpdate,oids,delOrderInstallDetail,odfs,delOrderProduct);
|
|
|
|
|
|
// 获取操作明细同步数据,即反馈明细
|
|
|
addoiolList = getOrderInstallOperatingLogsadd(item, old, newLCLS, synreqids);
|
|
@@ -246,7 +247,7 @@ public class InstallBusiness {
|
|
|
// 安装工单数据修改落本地表
|
|
|
addOrUpdateOrderData(item, upInfo, own, mxsynreqids, orderProductsUpdate, synreqids,
|
|
|
addoiolList, fyqd, orderInstall, synReqYfYyIds, addoalists, getpjSynReqId,
|
|
|
- addoalist, faGreeSms,orderAppeal, its,oads,oids, oiddels,odfs);
|
|
|
+ addoalist, faGreeSms,orderAppeal, its,oads,oids, delOrderInstallDetail,odfs,delOrderProduct);
|
|
|
}
|
|
|
|
|
|
public void addOrUpdateOrderData(ItfTblAzAssignLcLsDownload item, OrderBase upInfo, OrderWorker own,
|
|
@@ -256,7 +257,7 @@ public class InstallBusiness {
|
|
|
List<OrderReAppointment> addoalists, List<Long> getpjSynReqId, List<OrderAppraise> addoalist,
|
|
|
List<FaGreeSms> faGreeSms,List<OrderAppeal> orderAppeal,List<ItfGreeToFaDownloadTaskList> its,
|
|
|
List<OrderApplyDispatch> oads,List<OrderInstallDetail> oids,
|
|
|
- List<String> oiddels,List<OrderDetailFile> odfs) {
|
|
|
+ List<String> oiddels,List<OrderDetailFile> odfs,List<String> delOrderProduct) {
|
|
|
// 同步修改订单基础表
|
|
|
if (upInfo !=null){
|
|
|
orderBaseService.updateById(upInfo);
|
|
@@ -346,11 +347,17 @@ public class InstallBusiness {
|
|
|
orderInstallDetailService.removeByIds(oiddels);
|
|
|
oiddels.clear();
|
|
|
}
|
|
|
+ // 删除产品机型
|
|
|
+ if (delOrderProduct.size()>0){
|
|
|
+ orderProductService.removeByIds(delOrderProduct);
|
|
|
+ delOrderProduct.clear();
|
|
|
+ }
|
|
|
// 新增采集附件
|
|
|
if (odfs.size()>0){
|
|
|
orderDetailFileService.saveOrUpdateBatch(odfs);
|
|
|
odfs.clear();
|
|
|
}
|
|
|
+
|
|
|
// 客户评价
|
|
|
if (getpjSynReqId.size()>0){
|
|
|
upItfTblAzAssignSatisfactionDownload(getpjSynReqId);
|
|
@@ -500,16 +507,10 @@ public class InstallBusiness {
|
|
|
List<ItfTblAzAssignMxDownload> synreqids,
|
|
|
List<OrderProduct> orderProductsUpdate,
|
|
|
List<OrderInstallDetail> oids,List<String> oiddels,
|
|
|
- List<OrderDetailFile> odfs) {
|
|
|
+ List<OrderDetailFile> odfs,
|
|
|
+ List<String> delOrderProduct) {
|
|
|
List<OrderProduct> orderProductsOld = new ArrayList<>();
|
|
|
- List<OrderInstallDetail> oldOids = new ArrayList<>();
|
|
|
- Map<String,List<OrderInstallDetail>> oldOidsMap = new HashMap<>();
|
|
|
- Map<String,List<OrderProduct>> oldProductMap = new HashMap<>();
|
|
|
-
|
|
|
- // 提取现有的采集明细数据
|
|
|
- oldOids= orderInstallDetailService.lambdaQuery()
|
|
|
- .eq(OrderInstallDetail::getOrderBaseId,old.getId()).list();
|
|
|
- oldOidsMap = oldOids.stream().collect(Collectors.groupingBy(OrderInstallDetail::getOrderProductId));
|
|
|
+ List<String> orderMxList = new ArrayList<>();
|
|
|
|
|
|
// 提取下载产品明细表
|
|
|
List<ItfTblAzAssignMxDownload> orderMx = itfTblAzAssignMxDownloadService.lambdaQuery()
|
|
@@ -517,15 +518,55 @@ public class InstallBusiness {
|
|
|
.eq(ItfTblAzAssignMxDownload::getSynStatus,0)
|
|
|
.orderByAsc(ItfTblAzAssignMxDownload::getSynReqId)
|
|
|
.list();
|
|
|
+ orderMx.stream().forEach(mx->{
|
|
|
+ orderMxList.add(mx.getPgmxid());
|
|
|
+ });
|
|
|
|
|
|
// 提取本地现有的产品机型
|
|
|
orderProductsOld = orderProductService.lambdaQuery()
|
|
|
.eq(OrderProduct::getOrderBaseId, old.getId()).list();
|
|
|
- oldProductMap = orderProductsOld.stream().collect(Collectors.groupingBy(OrderProduct::getPgmxid));
|
|
|
|
|
|
- // pgmxid主键
|
|
|
+ // 新增或是修改
|
|
|
+ if (addOrUp(sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap, old, newLCLS, synreqids,
|
|
|
+ orderProductsUpdate, oids, oiddels, odfs, orderProductsOld,orderMx)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- for (ItfTblAzAssignMxDownload mx:orderMx){
|
|
|
+ // 处理总部删除的情况
|
|
|
+ for (OrderProduct o : orderProductsOld) {
|
|
|
+ if (!orderMxList.contains(o.getPgmxid())){
|
|
|
+ // 移除产品机型
|
|
|
+ delOrderProduct.add(o.getId());
|
|
|
+ // 需要移除采集明细
|
|
|
+ // 提取 采集记录
|
|
|
+ List<OrderInstallDetail> olds = new ArrayList<>();
|
|
|
+ olds = orderInstallDetailService.lambdaQuery()
|
|
|
+ .eq(OrderInstallDetail::getOrderBaseId, o.getOrderBaseId())
|
|
|
+ .eq(OrderInstallDetail::getOrderProductId, o.getId()).list();
|
|
|
+ for (OrderInstallDetail i:olds){
|
|
|
+ oiddels.add(i.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean addOrUp(Map<String, List<SysDictRef>> sysDictRefDLMap, Map<String, List<SysDictRef>> sysDictRefXLMap,
|
|
|
+ Map<String, List<SysDictRef>> sysDictRefXiLieMap, OrderBase old, OrderBase newLCLS,
|
|
|
+ List<ItfTblAzAssignMxDownload> synreqids, List<OrderProduct> orderProductsUpdate,
|
|
|
+ List<OrderInstallDetail> oids, List<String> oiddels, List<OrderDetailFile> odfs,
|
|
|
+ List<OrderProduct> orderProductsOld,
|
|
|
+ List<ItfTblAzAssignMxDownload> orderMx) {
|
|
|
+ // 提取现有的采集明细数据
|
|
|
+ List<OrderInstallDetail> oldOids = new ArrayList<>();
|
|
|
+ Map<String,List<OrderProduct>> oldProductMap = new HashMap<>();
|
|
|
+ Map<String,List<OrderInstallDetail>> oldOidsMap = new HashMap<>();
|
|
|
+ oldOids= orderInstallDetailService.lambdaQuery()
|
|
|
+ .eq(OrderInstallDetail::getOrderBaseId,old.getId()).list();
|
|
|
+ oldOidsMap = oldOids.stream().collect(Collectors.groupingBy(OrderInstallDetail::getOrderProductId));
|
|
|
+
|
|
|
+ oldProductMap = orderProductsOld.stream().collect(Collectors.groupingBy(OrderProduct::getPgmxid));
|
|
|
+
|
|
|
+ for (ItfTblAzAssignMxDownload mx: orderMx){
|
|
|
// 这里做法为重新生成新的产品机型,然后与本地比较是新增还是修改
|
|
|
// 生成工单产品对象 获取新同步的工单机型
|
|
|
OrderProduct n = getProductInfo(sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap, newLCLS, mx);
|
|
@@ -544,60 +585,8 @@ public class InstallBusiness {
|
|
|
}
|
|
|
// 看是否已同步过的 如是已同步过来,需调整数量 调整的数据就是生成的产品机型 n
|
|
|
if (oldProductMap.containsKey(mx.getPgmxid())){
|
|
|
- OrderProduct oldOpt = oldProductMap.get(mx.getPgmxid()).get(0);
|
|
|
- if (!oldOpt.getNum().equals(shul)){
|
|
|
- // 看已采集数
|
|
|
- for (OrderInstallDetail oid : oldOidsMap.get(oldOpt.getId())) {
|
|
|
- if (oid.getStatus().equals(1)) {
|
|
|
- oldnum++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (oldnum>shul){
|
|
|
- synItfTblAzAssignMxDownload(mx.getSynReqId(),9,
|
|
|
- "总部修改的产品数不能小于已采集数,需人工处理,工单号:"+old.getId());
|
|
|
- return;
|
|
|
- }
|
|
|
- // 如果产品数量大于已采集数则可以更新产品表的数量 这里的n就是本次处理的,新增的N不可能找到
|
|
|
- n.setUndoneNum(n.getNum()-oldnum);
|
|
|
-
|
|
|
- // 比较新旧数量,如果新数量少就删除,如果多就新增
|
|
|
- // 原产品数量大于新的产品数量,删除采集记录
|
|
|
- if (oldOpt.getNum()>shul){
|
|
|
- int insertNum = 1;
|
|
|
- // 提取 采集记录
|
|
|
- List<OrderInstallDetail> olds = new ArrayList<>();
|
|
|
- olds= orderInstallDetailService.lambdaQuery()
|
|
|
- .eq(OrderInstallDetail::getOrderBaseId,old.getId())
|
|
|
- .eq(OrderInstallDetail::getOrderProductId,n.getId())
|
|
|
- .eq(OrderInstallDetail::getStatus,0)
|
|
|
- .orderByAsc(OrderInstallDetail::getOutId).list();
|
|
|
-
|
|
|
- // 存在未采集的数据删除,其他不删
|
|
|
- if (olds.size()>1){
|
|
|
- int oldssize = olds.size()-1;
|
|
|
- while (insertNum <= (oldOpt.getNum() - shul)){
|
|
|
- oiddels.add(olds.get(oldssize).getId());
|
|
|
- oldssize-- ;
|
|
|
- insertNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (oldOpt.getNum()<shul) {
|
|
|
- // 提取 采集记录
|
|
|
- List<OrderInstallDetail> olds = new ArrayList<>();
|
|
|
- OrderInstallDetail iod = new OrderInstallDetail();
|
|
|
- olds= orderInstallDetailService.lambdaQuery()
|
|
|
- .eq(OrderInstallDetail::getOrderBaseId,old.getId())
|
|
|
- .eq(OrderInstallDetail::getOrderProductId,n.getId())
|
|
|
- .orderByAsc(OrderInstallDetail::getOutId).list();
|
|
|
- // 原产品数量小于新的产品数量,需要新增记录
|
|
|
- // 生成采集明细数据+附件数据
|
|
|
- // 取最大的序
|
|
|
- int insertnum = 0;
|
|
|
- int outid = 0;
|
|
|
- insertnum =olds.get(olds.size()-1).getOutId()+1;
|
|
|
- outid = insertnum;
|
|
|
- extracted(old, oids, odfs, insertnum, outid, mx, n);
|
|
|
- }
|
|
|
+ if (upProductAndDetail(old, oids, oiddels, odfs, oldOidsMap, oldProductMap, mx, n, oldnum, shul)) {
|
|
|
+ return true;
|
|
|
}
|
|
|
} else {
|
|
|
// 这里为新增,需要新增对应的采集及附件
|
|
@@ -615,6 +604,66 @@ public class InstallBusiness {
|
|
|
mxu.setSynTime(new Date());
|
|
|
synreqids.add(mxu);
|
|
|
}
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean upProductAndDetail(OrderBase old, List<OrderInstallDetail> oids, List<String> oiddels, List<OrderDetailFile> odfs, Map<String, List<OrderInstallDetail>> oldOidsMap, Map<String, List<OrderProduct>> oldProductMap, ItfTblAzAssignMxDownload mx, OrderProduct n, int oldnum, int shul) {
|
|
|
+ OrderProduct oldOpt = oldProductMap.get(mx.getPgmxid()).get(0);
|
|
|
+ if (!oldOpt.getNum().equals(shul)){
|
|
|
+ // 看已采集数
|
|
|
+ for (OrderInstallDetail oid : oldOidsMap.get(oldOpt.getId())) {
|
|
|
+ if (oid.getStatus().equals(1)) {
|
|
|
+ oldnum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (oldnum > shul){
|
|
|
+ synItfTblAzAssignMxDownload(mx.getSynReqId(),9,
|
|
|
+ "总部修改的产品数不能小于已采集数,需人工处理,工单号:"+ old.getId());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 如果产品数量大于已采集数则可以更新产品表的数量 这里的n就是本次处理的,新增的N不可能找到
|
|
|
+ n.setUndoneNum(n.getNum()- oldnum);
|
|
|
+
|
|
|
+ // 比较新旧数量,如果新数量少就删除,如果多就新增
|
|
|
+ // 原产品数量大于新的产品数量,删除采集记录
|
|
|
+ if (oldOpt.getNum()> shul){
|
|
|
+ int insertNum = 1;
|
|
|
+ // 提取 采集记录
|
|
|
+ List<OrderInstallDetail> olds = new ArrayList<>();
|
|
|
+ olds= orderInstallDetailService.lambdaQuery()
|
|
|
+ .eq(OrderInstallDetail::getOrderBaseId, old.getId())
|
|
|
+ .eq(OrderInstallDetail::getOrderProductId, n.getId())
|
|
|
+ .eq(OrderInstallDetail::getStatus,0)
|
|
|
+ .orderByAsc(OrderInstallDetail::getOutId).list();
|
|
|
+
|
|
|
+ // 存在未采集的数据删除,其他不删
|
|
|
+ if (olds.size()>1){
|
|
|
+ int oldssize = olds.size()-1;
|
|
|
+ while (insertNum <= (oldOpt.getNum() - shul)){
|
|
|
+ oiddels.add(olds.get(oldssize).getId());
|
|
|
+ oldssize-- ;
|
|
|
+ insertNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (oldOpt.getNum()< shul) {
|
|
|
+ // 提取 采集记录
|
|
|
+ List<OrderInstallDetail> olds = new ArrayList<>();
|
|
|
+ OrderInstallDetail iod = new OrderInstallDetail();
|
|
|
+ olds= orderInstallDetailService.lambdaQuery()
|
|
|
+ .eq(OrderInstallDetail::getOrderBaseId, old.getId())
|
|
|
+ .eq(OrderInstallDetail::getOrderProductId, n.getId())
|
|
|
+ .orderByAsc(OrderInstallDetail::getOutId).list();
|
|
|
+ // 原产品数量小于新的产品数量,需要新增记录
|
|
|
+ // 生成采集明细数据+附件数据
|
|
|
+ // 取最大的序
|
|
|
+ int insertnum = 0;
|
|
|
+ int outid = 0;
|
|
|
+ insertnum =olds.get(olds.size()-1).getOutId()+1;
|
|
|
+ outid = insertnum;
|
|
|
+ extracted(old, oids, odfs, insertnum, outid, mx, n);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
|