Browse Source

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

zhoudazhuang 11 months ago
parent
commit
3a1ecd4f40

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

@@ -312,7 +312,9 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
         }
         List<PointCheckDo> pointChecks = new ArrayList<>();
         List<PointCheckItemDo> pointCheckItems = new ArrayList<>();
-        Map<PointCheckNewsVo,List<String>> notifyType = new HashMap<>();
+        Map<PointCheckDo,List<String>> notifyType = new HashMap<>();
+        List<PointCheckNewsVo> pointCheckNewsVos = new ArrayList<>();
+        //Map<String,List<String>> sendNotifyType = new HashMap<>();
         // 每班几次就生成几个任务
         for(List<CheckTemplateItemsDo> checkItems:items){
             // 点检名称 班次+模板名称+当前日期
@@ -356,6 +358,7 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
                     //添加设备名称和设备编号
                     pointCheckVo.setCheckitemname(checkItemsdo.getCheckitemname());
                     pointCheckVo.setCheckitemcode(checkItemsdo.getCheckitemcode());
+                    pointCheckNewsVos.add(pointCheckVo);
                     //设备负责人
                     List<CheckItemsDutyuserDo> checkItemsDutyusers =checkItemsDutyuserService.list(new LambdaQueryWrapper<CheckItemsDutyuserDo>()
                             .eq(BaseDo::getDeleted,"0")
@@ -364,8 +367,11 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
 
                     // 组织需要发送德消息
                     if (!checkItemsDutyusers.isEmpty()){
-                        notifyType.put(pointCheckVo,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;
@@ -452,16 +458,35 @@ 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 = k.getCheckitemname();
-                String checkitemcode = k.getCheckitemcode();
+                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()){
+//            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);