ezhizao_zx 11 meses atrás
pai
commit
274c3aa3ff

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

@@ -118,14 +118,18 @@ public class Mrp10201Controller extends BaseController {
             if (!mrp10201List.isEmpty()) {
                 List<BizProductionPlanDetail> newPlanDetails = new ArrayList<>();
                 for (Mrp10201 mrp10201:mrp10201List) {
-                    BizProductionPlanDetail newPlanDetail = new BizProductionPlanDetail();
+                    // 判断下是否已经有该计划单,假设已有不能新增
+                    String productionPlanNo = mrp10201.getDocno().trim();
+                    Integer lineNum = mrp10201.getDocseq();
+                    BizProductionPlanDetail newPlanDetail = productionPlanDetailService.query().eq("production_plan_no", productionPlanNo).eq("line_number", lineNum).one();
+                    if (newPlanDetail == null) {
+                        newPlanDetail = new BizProductionPlanDetail();
+                    }
                     // 计划单号
                     newPlanDetail.setProductionPlanNo(mrp10201.getDocno());
                     // 根据拿到的计划单号,获取到对应的计划单id【暂时不用】
-
                     // 计划单序号
                     newPlanDetail.setLineNumber(mrp10201.getDocseq());
-
                     // 厂别(租户id)
                     newPlanDetail.setTenantId(Long.parseLong(mrp10201.getFacno()));
 
@@ -138,7 +142,6 @@ public class Mrp10201Controller extends BaseController {
                         sysDepts = sysDeptService.selectDeptListByCode(requisitionDept);
                     }
 
-
                     // 根据领料部门编码,获取新系统中的部门id
                     if(!sysDepts.isEmpty()) {
                         newPlanDetail.setRequisitionDepartmentId(sysDepts.get(0).getDeptId());
@@ -323,7 +326,7 @@ public class Mrp10201Controller extends BaseController {
                 }
                 if (!newPlanDetails.isEmpty()) {
 //                  productionPlanDetailService.saveBatchByRawSql(newPlanDetails);
-                    productionPlanDetailService.saveBatch(newPlanDetails);
+                    productionPlanDetailService.saveOrUpdateBatch(newPlanDetails);
                     // 当数据拉取成功,并将数据保存到 production_plan_detail 表中,则将 pull_p2_time 表中的 pull_time 属性置为当前时间
                     // 实例化 BizPullP2Time 对象
                     BizPullP2Time bizPullP2Time = new BizPullP2Time();