zhuangdezheng 1 년 전
부모
커밋
b83d15fda9
1개의 변경된 파일11개의 추가작업 그리고 8개의 파일을 삭제
  1. 11 8
      src/main/java/cn/ezhizao/project/business/controller/Mrp10201Controller.java

+ 11 - 8
src/main/java/cn/ezhizao/project/business/controller/Mrp10201Controller.java

@@ -119,7 +119,7 @@ public class Mrp10201Controller extends BaseController {
             // 如果从P2中拉取到数据,则需要保存到当前数据库中
             if (mrp10201List.size() > 0) {
                 List<BizProductionPlanDetail> newPlanDetails = new ArrayList<>();
-                mrp10201List.forEach(mrp10201 -> {
+                for (Mrp10201 mrp10201:mrp10201List) {
                     BizProductionPlanDetail newPlanDetail = new BizProductionPlanDetail();
                     // 计划单号
                     newPlanDetail.setProductionPlanNo(mrp10201.getDocno());
@@ -305,17 +305,23 @@ public class Mrp10201Controller extends BaseController {
                     // 是否领料
                     newPlanDetail.setIsPeekedUp(mrp10201.getLlsta());
 
+                    // 领料日期
+                    newPlanDetail.setMaterialPickUpDate(mrp10201.getLldate());
+
                     // 有批号否?
                     newPlanDetail.setHadLotCode(mrp10201.getPhsta());
 
                     // 备注
                     newPlanDetail.setRemark(mrp10201.getRemark());
 
-                    newPlanDetails.add(newPlanDetail);
-                });
-
+                    // 防止重复 根据计划单号 和 序号 排除重复项
+                    long count = productionPlanDetailService.query().eq("production_plan_id", newPlanDetail.getProductionPlanId()).eq("line_number", newPlanDetail.getLineNumber()).count();
+                    if(count == 0){
+                        newPlanDetails.add(newPlanDetail);
+                    }
+                }
                 if (newPlanDetails.size() > 0) {
-//                    productionPlanDetailService.saveBatchByRawSql(newPlanDetails);
+//                  productionPlanDetailService.saveBatchByRawSql(newPlanDetails);
                     productionPlanDetailService.saveBatch(newPlanDetails);
                     // 当数据拉取成功,并将数据保存到 production_plan_detail 表中,则将 pull_p2_time 表中的 pull_time 属性置为当前时间
                     // 实例化 BizPullP2Time 对象
@@ -324,9 +330,6 @@ public class Mrp10201Controller extends BaseController {
                     bizPullP2Time.setPullTime(new Date());
                     // 保存数据
                     pullP2TimeService.saveOrUpdate(bizPullP2Time);
-
-
-
                 }
             }
         }