Bladeren bron

运行记录1217-运行记录非正常工单插入日报优化1

yuanchao 1 week geleden
bovenliggende
commit
9cf524998e

+ 87 - 92
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/IotOperationPlanJob.java

@@ -202,107 +202,102 @@ public class IotOperationPlanJob implements JobHandler {
         //判断是否为瑞恒特殊计划
         if(plan.getId()==153L){
             unNormalTeamInPlan(plan);
-        }
-
-        //4、根据设备ID生成子表数据
-        List<IotOpeationFillDO> deviceList = iotOpeationFillMapper.getFillDevices(devIdList);
-        List<Integer> idList = deviceList.stream().map(IotOpeationFillDO::getUserId).collect(Collectors.toList());
-        List<IotOpeationFillOrderDO> orderList1 = orderList.stream()
-                .filter(obj -> idList.contains(obj.getUserId()))
-                .collect(Collectors.toList());
-
-
-
-        Set<Long> ryIdList = new HashSet<>();
-        if(plan.getIsReport()==1){//日报
-            //瑞鹰
-            ryIdList =  deptService.getChildDeptIdListFromCache(158L);
-            ryIdList.add(158L);
-
-            List<IotOpeationFillOrderDO> zxjOrderList = new ArrayList<>();
-
-            for (IotOpeationFillOrderDO orderDO:orderList1) {
-                IotDeviceRunLogDO runLogDO = new IotDeviceRunLogDO();
-                runLogDO.setDeptId(orderDO.getDeptId());
-                //获取队伍类型
-                IotDeviceRunLogDO teamType = iotOpeationFillMapper.getTeamType(runLogDO);
-
-                //如果是钻井队伍,则日报工单责任人更新为技术员
-                //修井队伍不变
-                if(teamType!=null&&teamType.getPointCode().equals("zj")){
-                    //获取技术员信息
-                    AdminUserDO userInfo = iotOpeationFillMapper.getUserInfo(runLogDO);
-                    if(userInfo!=null){
-                        orderDO.setUserName(userInfo.getUsername());
-                        orderDO.setUserId(new BigDecimal(userInfo.getId()).intValue());
-                        orderDO.setMobile(userInfo.getMobile());
-                    }
-                    zxjOrderList.add(orderDO);
-                }else if(teamType!=null&&teamType.getPointCode().equals("xj")){
-                    zxjOrderList.add(orderDO);
-                }
-            }
+        }else{
+            //4、根据设备ID生成子表数据
+            List<IotOpeationFillDO> deviceList = iotOpeationFillMapper.getFillDevices(devIdList);
+            List<Integer> idList = deviceList.stream().map(IotOpeationFillDO::getUserId).collect(Collectors.toList());
+            List<IotOpeationFillOrderDO> orderList1 = orderList.stream()
+                    .filter(obj -> idList.contains(obj.getUserId()))
+                    .collect(Collectors.toList());
 
 
-            // 按dept_id去重,保留第一个出现的元素
-            List<IotOpeationFillOrderDO> distinctOrderList = zxjOrderList.stream()
-                    .collect(Collectors.toMap(
-                            IotOpeationFillOrderDO::getDeptId,
-                            order -> {
-                                order.setId(null); // 关键:重置ID,避免与已有数据冲突
-                                return order;
-                            },
-                            (existing, replacement) -> existing
-                    ))
-                    .values()
-                    .stream()
-                    .collect(Collectors.toList());
-            //插入工单主表
-            iotOpeationFillOrderMapper.insertBatch(distinctOrderList);
-            //发送钉钉消息
-            sendDingMessage(distinctOrderList);
 
-            boolean ryContain = ryIdList.contains(plan.getDeptId());
-            //瑞鹰日报插入
-            ryReportInsert(plan,distinctOrderList,ryContain);
+            Set<Long> ryIdList = new HashSet<>();
+            if(plan.getIsReport()==1){//日报
+                //瑞鹰
+                ryIdList =  deptService.getChildDeptIdListFromCache(158L);
+                ryIdList.add(158L);
+
+                List<IotOpeationFillOrderDO> zxjOrderList = new ArrayList<>();
+
+                for (IotOpeationFillOrderDO orderDO:orderList1) {
+                    IotDeviceRunLogDO runLogDO = new IotDeviceRunLogDO();
+                    runLogDO.setDeptId(orderDO.getDeptId());
+                    //获取队伍类型
+                    IotDeviceRunLogDO teamType = iotOpeationFillMapper.getTeamType(runLogDO);
+
+                    //如果是钻井队伍,则日报工单责任人更新为技术员
+                    //修井队伍不变
+                    if(teamType!=null&&teamType.getPointCode().equals("zj")){
+                        //获取技术员信息
+                        AdminUserDO userInfo = iotOpeationFillMapper.getUserInfo(runLogDO);
+                        if(userInfo!=null){
+                            orderDO.setUserName(userInfo.getUsername());
+                            orderDO.setUserId(new BigDecimal(userInfo.getId()).intValue());
+                            orderDO.setMobile(userInfo.getMobile());
+                        }
+                        zxjOrderList.add(orderDO);
+                    }else if(teamType!=null&&teamType.getPointCode().equals("xj")){
+                        zxjOrderList.add(orderDO);
+                    }
+                }
 
-        }else{
 
-            //插入工单主表
-            iotOpeationFillOrderMapper.insertBatch(orderList1);
-            //瑞都
-            ryIdList =  deptService.getChildDeptIdListFromCache(163L);
-            ryIdList.add(163L);
-            Set<Long> rhIdList = new HashSet<>();
-            rhIdList =  deptService.getChildDeptIdListFromCache(157L);//瑞恒
-            rhIdList.add(157L);
-            boolean exist = ryIdList.contains(plan.getDeptId());
-            if(!exist){
-                boolean rhContain = rhIdList.contains(plan.getDeptId());
-                //瑞恒日报插入
-                rhReportInsert(plan, orderList1, rhContain);
-            }
-            //发送钉钉消息
-            sendDingMessage(orderList1);
-            //正常工单设备
-            for (IotOpeationFillDO device:deviceList) {
-                for (IotOpeationFillOrderDO order:orderList1) {
-                    if(device.getUserId().intValue()==order.getUserId().intValue()){
-                        device.setOrderId(order.getId());
+                // 按dept_id去重,保留第一个出现的元素
+                List<IotOpeationFillOrderDO> distinctOrderList = zxjOrderList.stream()
+                        .collect(Collectors.toMap(
+                                IotOpeationFillOrderDO::getDeptId,
+                                order -> {
+                                    order.setId(null); // 关键:重置ID,避免与已有数据冲突
+                                    return order;
+                                },
+                                (existing, replacement) -> existing
+                        ))
+                        .values()
+                        .stream()
+                        .collect(Collectors.toList());
+                //插入工单主表
+                iotOpeationFillOrderMapper.insertBatch(distinctOrderList);
+                //发送钉钉消息
+                sendDingMessage(distinctOrderList);
+
+                boolean ryContain = ryIdList.contains(plan.getDeptId());
+                //瑞鹰日报插入
+                ryReportInsert(plan,distinctOrderList,ryContain);
+
+            }else{
+
+                //插入工单主表
+                iotOpeationFillOrderMapper.insertBatch(orderList1);
+                //瑞都
+                ryIdList =  deptService.getChildDeptIdListFromCache(163L);
+                ryIdList.add(163L);
+                Set<Long> rhIdList = new HashSet<>();
+                rhIdList =  deptService.getChildDeptIdListFromCache(157L);//瑞恒
+                rhIdList.add(157L);
+                boolean exist = ryIdList.contains(plan.getDeptId());
+                if(!exist){
+                    boolean rhContain = rhIdList.contains(plan.getDeptId());
+                    //瑞恒日报插入
+                    rhReportInsert(plan, orderList1, rhContain);
+                }
+                //发送钉钉消息
+                sendDingMessage(orderList1);
+                //正常工单设备
+                for (IotOpeationFillDO device:deviceList) {
+                    for (IotOpeationFillOrderDO order:orderList1) {
+                        if(device.getUserId().intValue()==order.getUserId().intValue()){
+                            device.setOrderId(order.getId());
+                        }
                     }
                 }
+                //插入子表
+                for (IotOpeationFillDO re:deviceList) {
+                    re.setDeviceId(re.getId());
+                }
+                iotOpeationFillMapper.insertFill(deviceList);
             }
-            //插入子表
-            for (IotOpeationFillDO re:deviceList) {
-                re.setDeviceId(re.getId());
-            }
-            iotOpeationFillMapper.insertFill(deviceList);
         }
-
-
-
-
-
     }
 
     private void sendDingMessage(List<IotOpeationFillOrderDO> orderList1) {

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -1253,6 +1253,7 @@
         </foreach>
         AND asset_class IN (159, 160, 122, 106, 157, 158, 191)
         AND device_status != 'sg'
+        and deleted = 0
         GROUP BY dept_id -- 确保每个部门只返回1条记录(若多个设备,取任意1条)
         -- 可选:如需指定返回某条设备(如最新/最早),可加排序:
         -- ORDER BY create_time DESC -- 按创建时间倒序(取最新)