Bladeren bron

河南郸城调度计划修改 bug 修复

1037015548@qq.com 11 maanden geleden
bovenliggende
commit
0392d2d031

+ 35 - 22
src/main/java/com/shkpr/service/aimodelpower/dbdao/services/WODispatchPlanDBServiceImpl.java

@@ -268,27 +268,27 @@ public class WODispatchPlanDBServiceImpl implements WODispatchPlanDBService,WODi
         woDispatchPlanMapper.updateWiths(upMap,andWhereUp,new HashMap<>(),"");
 
         //TODO 先删除所有关联再添加
-        if(model.getChufaRulsFlag()!=-1) {
-            Map<String, Object> andWhereRuls = new HashMap<>();
-            andWhereRuls.put("plan_id", model.getPlanId());
-            woDispatchPlanRulsMapper.deleteWiths(andWhereRuls, new HashMap<>(), "");
-            Map<String, Object> andWherePlanTags = new HashMap<>();
-            andWherePlanTags.put("plan_id", model.getPlanId());
-            woDispatchPlanTagsMapper.deleteWiths(andWherePlanTags, new HashMap<>(), "");
-        }
-        //删除排班
-        Map<String,Object> andWheresItems = new HashMap<>();
-        andWheresItems.put("plan_id",model.getPlanId());
-        List<DispatchCmdBatchItemModel> woMap = woDispatchCmdBatchItemDBService.listAllWithsExByDispoal("","",andWheresItems,new HashMap<>(),"handle_start_time","");
-        if(!CollectionUtils.isEmpty(woMap)){
-            for (DispatchCmdBatchItemModel item:woMap){
-                woDispatchCmdPatchItemMapper.deleteWiths(andWheresItems,new HashMap<>(),"");
-                //删除对应的处置建议
-                Map<String,Object> andWheresItemDisposals = new HashMap<>();
-                andWheresItemDisposals.put("batch_item_id",model.getPlanId());
-                woDispatchCmdPatchDisposalMapper.deleteWiths(andWheresItemDisposals,new HashMap<>(),"");
-            }
-        }
+//        if(model.getChufaRulsFlag()!=-1) {
+//            Map<String, Object> andWhereRuls = new HashMap<>();
+//            andWhereRuls.put("plan_id", model.getPlanId());
+//            woDispatchPlanRulsMapper.deleteWiths(andWhereRuls, new HashMap<>(), "");
+//            Map<String, Object> andWherePlanTags = new HashMap<>();
+//            andWherePlanTags.put("plan_id", model.getPlanId());
+//            woDispatchPlanTagsMapper.deleteWiths(andWherePlanTags, new HashMap<>(), "");
+//        }
+//        //删除排班
+//        Map<String,Object> andWheresItems = new HashMap<>();
+//        andWheresItems.put("plan_id",model.getPlanId());
+//        List<DispatchCmdBatchItemModel> woMap = woDispatchCmdBatchItemDBService.listAllWithsExByDispoal("","",andWheresItems,new HashMap<>(),"handle_start_time","");
+//        if(!CollectionUtils.isEmpty(woMap)){
+//            for (DispatchCmdBatchItemModel item:woMap){
+//                woDispatchCmdPatchItemMapper.deleteWiths(andWheresItems,new HashMap<>(),"");
+//                //删除对应的处置建议
+//                Map<String,Object> andWheresItemDisposals = new HashMap<>();
+//                andWheresItemDisposals.put("batch_item_id",model.getPlanId());
+//                woDispatchCmdPatchDisposalMapper.deleteWiths(andWheresItemDisposals,new HashMap<>(),"");
+//            }
+//        }
 
         if(model.getChufaRulsFlag()==1) {
             for (JPDispatchPlanInfoRuleSave jp : rulesList) {
@@ -309,7 +309,20 @@ public class WODispatchPlanDBServiceImpl implements WODispatchPlanDBService,WODi
                 if(!StringUtils.isEmpty(jp.getKey())) {
                     if (StringUtils.isEmpty(jp.getPlanId())) {
                         map.put(WODispatchPlanTagsTable.W_INFO.PRIMARY_KEY, model.getPlanId());
-                        woDispatchPlanTagsMapper.inserts(map);
+                        //TODO 查询该计划和key的数据是否存在, 如果存在就修改, 不存在就新增
+                        Map<String,Object> planQuery = new HashMap<>();
+                        planQuery.put("plan_id",model.getPlanId());
+                        planQuery.put("key",jp.getKey());
+                        List<Map<String,Object>> planTags = woDispatchPlanTagsMapper.batchQueryWiths("","",
+                                planQuery,new HashMap<>(),"","");
+                        if(!CollectionUtils.isEmpty(planTags)){
+                            Map<String,Object> andWheresWith = new HashMap<>();
+                            andWheresWith.put(WODispatchPlanTagsTable.W_INFO.PRIMARY_KEY,model.getPlanId());
+                            andWheresWith.put("key",jp.getKey());
+                            woDispatchPlanTagsMapper.updateWiths(map,andWheresWith,new HashMap<>(),"");
+                        }else {
+                            woDispatchPlanTagsMapper.inserts(map);
+                        }
                     } else {
                         Map<String, Object> andWheresWith = new HashMap<>();
                         andWheresWith.put(WODispatchPlanTagsTable.W_INFO.PRIMARY_KEY, jp.getPlanId());