yaozhixue 2 years ago
parent
commit
f73abd0e18

+ 24 - 2
src/main/java/com/zfire/jiasm/syncdata/download/order/repair/RepairBusiness.java

@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 格力品牌维修工单下载后落本地数据表
@@ -87,6 +88,9 @@ public class RepairBusiness {
 
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         List<ItfTblAssignDownload> repairRec = new ArrayList<>();
+        List<Long> pgids = new ArrayList<>();
+        List<OrderBase> orderBasesRecs = new ArrayList<>();
+        List<String> orderBaselist = new ArrayList<>();
 
         // 提取品牌信息
         Brand brand = baseService.getBrand();
@@ -112,12 +116,30 @@ public class RepairBusiness {
             return;
         }
 
+        pgids = repairRec.stream().map(ItfTblAssignDownload::getPgid).collect(Collectors.toList());
+
+        // 提取已有的订单数据
+        orderBasesRecs = orderBaseService.lambdaQuery()
+                .select(OrderBase::getPgid)
+                .in(OrderBase::getPgid,pgids).list();
+        orderBaselist = orderBasesRecs.stream().map(OrderBase::getPgid).collect(Collectors.toList());
+
         log.info("维修工单落本地表开始处理: {}",sdf.format(new Date()));
 
         // 按任务号download_task_no,按单来处理
         for (ItfTblAssignDownload item: repairRec){
-            // 新增
-            repairBusiness.addOrder(brand, item, sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap);
+            try{
+                if (orderBaselist.contains(item.getPgid())){
+                    // 修改
+
+                } else {
+                    // 新增
+                    repairBusiness.addOrder(brand, item, sysDictRefDLMap, sysDictRefXLMap, sysDictRefXiLieMap);
+                }
+            }catch (Exception ex) {
+                ex.printStackTrace();
+                log.info("维修工单落本地表失败 销售单号-派工单号:【" + item.getXsdh() + "-"+ item.getPgid()+"】");
+            }
         }
 
         log.info("维修工单落本地表处理完成: {}",sdf.format(new Date()));