浏览代码

设备子系统———testin338bug补充,修复生成点检任务中出现遗漏数据现象(优化)

zhoudazhuang 11 月之前
父节点
当前提交
2f25076955

+ 33 - 33
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/CheckTemplateServiceImpl.java

@@ -313,8 +313,8 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
         List<PointCheckDo> pointChecks = new ArrayList<>();
         List<PointCheckItemDo> pointCheckItems = new ArrayList<>();
         Map<PointCheckDo,List<String>> notifyType = new HashMap<>();
-        List<PointCheckNewsVo> pointCheckNewsVos = new ArrayList<>();
-        //Map<String,List<String>> sendNotifyType = new HashMap<>();
+//        List<PointCheckNewsVo> pointCheckNewsVos = new ArrayList<>();
+        Map<String,List<String>> sendNotifyType = new HashMap<>();
         // 每班几次就生成几个任务
         for(List<CheckTemplateItemsDo> checkItems:items){
             // 点检名称 班次+模板名称+当前日期
@@ -358,7 +358,7 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
                     //添加设备名称和设备编号
                     pointCheckVo.setCheckitemname(checkItemsdo.getCheckitemname());
                     pointCheckVo.setCheckitemcode(checkItemsdo.getCheckitemcode());
-                    pointCheckNewsVos.add(pointCheckVo);
+//                    pointCheckNewsVos.add(pointCheckVo);
                     //设备负责人
                     List<CheckItemsDutyuserDo> checkItemsDutyusers =checkItemsDutyuserService.list(new LambdaQueryWrapper<CheckItemsDutyuserDo>()
                             .eq(BaseDo::getDeleted,"0")
@@ -366,12 +366,12 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
                             .like(CheckItemsDutyuserDo::getDutyuserattribute,templatetype));
 
                     // 组织需要发送德消息
-                    if (!checkItemsDutyusers.isEmpty()){
-                        notifyType.put(pointCheckDo,checkItemsDutyusers.stream().map(CheckItemsDutyuserDo::getDutyuserid).distinct().collect(Collectors.toList()));
-                    }
 //                    if (!checkItemsDutyusers.isEmpty()){
-//                        sendNotifyType.put(pointCheckDo.getId()+"-;-"+pointCheckDo.getPointcheckname()+"-;-"+pointCheckDo.getTemplatetype()+"-;-"+checkItemsdo.getCheckitemname()+"-;-"+checkItemsdo.getCheckitemcode(),checkItemsDutyusers.stream().map(CheckItemsDutyuserDo::getDutyuserid).distinct().collect(Collectors.toList()));
+//                        notifyType.put(pointCheckDo,checkItemsDutyusers.stream().map(CheckItemsDutyuserDo::getDutyuserid).distinct().collect(Collectors.toList()));
 //                    }
+                    if (!checkItemsDutyusers.isEmpty()){
+                        sendNotifyType.put(pointCheckDo.getId()+"-;-"+pointCheckDo.getPointcheckname()+"-;-"+pointCheckDo.getTemplatetype()+"-;-"+checkItemsdo.getCheckitemname()+"-;-"+checkItemsdo.getCheckitemcode(),checkItemsDutyusers.stream().map(CheckItemsDutyuserDo::getDutyuserid).distinct().collect(Collectors.toList()));
+                    }
                     //设置点检人
 //                    String pcids = null;
 //                    String pcnames = null;
@@ -455,38 +455,38 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
             }
         }
 
-        if(!notifyType.isEmpty()){
-            List<SysDictDo> dictsByType = commonDictService.getDictsByType("template-type");
-            notifyType.forEach((k,v)-> {
-                List<PointCheckNewsVo> resultPointCheckNewsVos = pointCheckNewsVos.stream().filter(p -> p.getId().equals(k.getId())).collect(Collectors.toList());
-                String pointcheckname = k.getPointcheckname();
-                String templatetype = k.getTemplatetype();
-                //发送消息提醒添加设备名称和设备编号拼接
-                String checkitemname = "";
-                String checkitemcode = "";
-                if (resultPointCheckNewsVos.size()>0){
-                    checkitemname = resultPointCheckNewsVos.get(0).getCheckitemname();
-                    checkitemcode = resultPointCheckNewsVos.get(0).getCheckitemcode();
-                }
-                SysDictDo sysDictDo = dictsByType.stream().filter(info -> info.getValue().equals(templatetype)).findFirst().orElse(null);
-                CXCommonUtils.sendNotify(INSPECTION_TITLE, String.format(INSPECTION_CONTENT, pointcheckname,checkitemname,checkitemcode, sysDictDo == null ? "" : sysDictDo.getName()),
-                        null, v, k.getId(), INSPECTION + "-" + shift, false);
-            });
-        }
-//        if(!sendNotifyType.isEmpty()){
+//        if(!notifyType.isEmpty()){
 //            List<SysDictDo> dictsByType = commonDictService.getDictsByType("template-type");
-//            sendNotifyType.forEach((k,v)-> {
-//                String[] sendNotifyData = k.split("-;-");
-//                String pointcheckname = sendNotifyData[1];
-//                String templatetype = sendNotifyData[2];
+//            notifyType.forEach((k,v)-> {
+//                List<PointCheckNewsVo> resultPointCheckNewsVos = pointCheckNewsVos.stream().filter(p -> p.getId().equals(k.getId())).collect(Collectors.toList());
+//                String pointcheckname = k.getPointcheckname();
+//                String templatetype = k.getTemplatetype();
 //                //发送消息提醒添加设备名称和设备编号拼接
-//                String checkitemname = sendNotifyData[3];
-//                String checkitemcode = sendNotifyData[4];
+//                String checkitemname = "";
+//                String checkitemcode = "";
+//                if (resultPointCheckNewsVos.size()>0){
+//                    checkitemname = resultPointCheckNewsVos.get(0).getCheckitemname();
+//                    checkitemcode = resultPointCheckNewsVos.get(0).getCheckitemcode();
+//                }
 //                SysDictDo sysDictDo = dictsByType.stream().filter(info -> info.getValue().equals(templatetype)).findFirst().orElse(null);
 //                CXCommonUtils.sendNotify(INSPECTION_TITLE, String.format(INSPECTION_CONTENT, pointcheckname,checkitemname,checkitemcode, sysDictDo == null ? "" : sysDictDo.getName()),
-//                        null, v, sendNotifyData[0], INSPECTION + "-" + shift, false);
+//                        null, v, k.getId(), INSPECTION + "-" + shift, false);
 //            });
 //        }
+        if(!sendNotifyType.isEmpty()){
+            List<SysDictDo> dictsByType = commonDictService.getDictsByType("template-type");
+            sendNotifyType.forEach((k,v)-> {
+                String[] sendNotifyData = k.split("-;-");
+                String pointcheckname = sendNotifyData[1];
+                String templatetype = sendNotifyData[2];
+                //发送消息提醒添加设备名称和设备编号拼接
+                String checkitemname = sendNotifyData[3];
+                String checkitemcode = sendNotifyData[4];
+                SysDictDo sysDictDo = dictsByType.stream().filter(info -> info.getValue().equals(templatetype)).findFirst().orElse(null);
+                CXCommonUtils.sendNotify(INSPECTION_TITLE, String.format(INSPECTION_CONTENT, pointcheckname,checkitemname,checkitemcode, sysDictDo == null ? "" : sysDictDo.getName()),
+                        null, v, sendNotifyData[0], INSPECTION + "-" + shift, false);
+            });
+        }
         // 批量保存点检任务
         pointCheckService.saveBatch(pointChecks);
         pointCheckItemService.saveBatch(pointCheckItems);