Răsfoiți Sursa

pms 瑞鹰 瑞恒 日报 消息提醒 无设备的队伍不发送消息。

zhangcl 1 săptămână în urmă
părinte
comite
a114fad623

+ 9 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/IotRyDailyReportController.java

@@ -457,14 +457,16 @@ public class IotRyDailyReportController {
             ids.add(pageReqVO.getDeptId());
             pageReqVO.setDeptIds(ids);
         }
-        List<IotRyDailyReportTaskCountVO> repairDeptTasks = iotRyDailyReportService.countRepairTasksByDept(pageReqVO);
-
-        if (CollUtil.isNotEmpty(repairDeptTasks)) {
-            repairDeptTasks.forEach(task -> {
-                totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
-                completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
-            });
+        if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
+            List<IotRyDailyReportTaskCountVO> repairDeptTasks = iotRyDailyReportService.countRepairTasksByDept(pageReqVO);
+            if (CollUtil.isNotEmpty(repairDeptTasks)) {
+                repairDeptTasks.forEach(task -> {
+                    totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
+                    completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
+                });
+            }
         }
+
         if (CollUtil.isNotEmpty(list)) {
             for (IotRyDailyReportDO report : list) {
                 BigDecimal dailyFootage = report.getDailyFootage();

+ 64 - 58
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -324,6 +324,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             iotRhDailyReport.setDailyOilUsage(totalOilUsage);
             // 根据日报关联任务车辆油耗 计算总油耗 后保存日报
             iotRhDailyReportMapper.updateById(iotRhDailyReport);
+
         } else {
             // 修改现有记录
             iotRhDailyReport.setId(existReport.getId());
@@ -332,70 +333,75 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         // 只要保存了记录就要发送审批提醒到 提交人对应的项目经理 角色 项目部日报审批RH
         // 根据日报的 deptId 查询上级项目部经理 角色的审批人 发送站内信 钉钉提醒
         // 此时需要判断下当前队伍下有无增压机,如果 ‘当前队伍下无增压机’ 或 ‘增压机的状态不是施工’ 需要新增空白记录 向填报人推送消息。
-        DeptDO dept = deptService.getDept(deptId);
-        Long parentId = dept.getParentId();
-        if (ObjUtil.isNotEmpty(parentId)) {
-            AtomicReference<DeptDO> projectDept = new AtomicReference<>();
-            DataPermissionUtils.executeIgnore(() -> {
-                projectDept.set(deptService.getDept(parentId));
-
-                if (ObjUtil.isNotEmpty(projectDept) && "2".equals(projectDept.get().getType())) {
-                    // 查询项目部下具有 项目部日报审批RH 角色的人员
-                    Set<Long> projectIds = new HashSet<>();
-                    projectIds.add(projectDept.get().getId());
-                    List<AdminUserDO> receivedMsgUsers = adminUserService.getUserListByDeptIds(projectIds);
-                    if (CollUtil.isNotEmpty(receivedMsgUsers)) {
-                        Set<Long> userIds = new HashSet<>();
-                        receivedMsgUsers.forEach(user -> {
-                            userIds.add(user.getId());
-                        });
-                        RoleDO role = roleService.getRoleByCode("项目部日报审批RH");
-                        if (ObjUtil.isNotEmpty(role)) {
-                            Set<Long> roleIds = new HashSet<>();
-                            roleIds.add(role.getId());
-                            List<UserRoleDO> userRoles = userRoleMapper.selectListByRoleIds(roleIds);
-                            if (CollUtil.isNotEmpty(userRoles)) {
-                                // 提取有审批角色的所有用户ID(去重+空值过滤)
-                                Set<Long> roleUserIds = userRoles.stream()
-                                        .map(UserRoleDO::getUserId)
-                                        .filter(Objects::nonNull) // 过滤空userId
-                                        .collect(Collectors.toSet());
-                                // 计算两个集合的交集,得到最终目标用户ID
-                                Set<Long> targetUserIds = userIds.stream()
-                                        .filter(roleUserIds::contains)
-                                        .collect(Collectors.toSet());
-                                // 异步发送 站内信 钉钉消息
-                                if (CollUtil.isNotEmpty(targetUserIds)) {
-                                    Map<Long, AdminUserRespDTO> users = adminUserApi.getUserMap(targetUserIds);
-                                    // 给多个用户发送 相同 的 提醒消息
-                                    if (CollUtil.isNotEmpty(users)) {
-                                        // 生成消息提醒标题 部门名称-井号
-                                        String msgTitle = dept.getName();
-                                        if (StrUtil.isNotBlank(wellName)) {
-                                            msgTitle = StrUtil.join("-", msgTitle, wellName);
-                                        }
-                                        CountDownLatch latch = new CountDownLatch(users.size());
-                                        String finalMsgTitle = msgTitle;
-                                        users.forEach((userId, user) -> {
-                                            pmsThreadPoolTaskExecutor.execute(() -> {
-                                                try {
-                                                    String mobile = user.getMobile();
-                                                    if (StrUtil.isNotBlank(mobile) && StrUtil.isNotBlank(finalMsgTitle)) {
-                                                        /* pmsMessage.sendMessage(iotRhDailyReport.getId(), finalMsgTitle, PmsConstants.RH_DAILY_REPORT_APPROVAL,
-                                                                userId, mobile); */
+        // 暂时添加判断条件 创建人 是 null 的话 不发送 站内信及钉钉消息
+        if (StrUtil.isNotBlank(iotRhDailyReport.getCreator())) {
+
+            DeptDO dept = deptService.getDept(deptId);
+            Long parentId = dept.getParentId();
+            if (ObjUtil.isNotEmpty(parentId)) {
+                AtomicReference<DeptDO> projectDept = new AtomicReference<>();
+                DataPermissionUtils.executeIgnore(() -> {
+                    projectDept.set(deptService.getDept(parentId));
+
+                    if (ObjUtil.isNotEmpty(projectDept) && "2".equals(projectDept.get().getType())) {
+                        // 查询项目部下具有 项目部日报审批RH 角色的人员
+                        Set<Long> projectIds = new HashSet<>();
+                        projectIds.add(projectDept.get().getId());
+                        List<AdminUserDO> receivedMsgUsers = adminUserService.getUserListByDeptIds(projectIds);
+                        if (CollUtil.isNotEmpty(receivedMsgUsers)) {
+                            Set<Long> userIds = new HashSet<>();
+                            receivedMsgUsers.forEach(user -> {
+                                userIds.add(user.getId());
+                            });
+                            RoleDO role = roleService.getRoleByCode("项目部日报审批RH");
+                            if (ObjUtil.isNotEmpty(role)) {
+                                Set<Long> roleIds = new HashSet<>();
+                                roleIds.add(role.getId());
+                                List<UserRoleDO> userRoles = userRoleMapper.selectListByRoleIds(roleIds);
+                                if (CollUtil.isNotEmpty(userRoles)) {
+                                    // 提取有审批角色的所有用户ID(去重+空值过滤)
+                                    Set<Long> roleUserIds = userRoles.stream()
+                                            .map(UserRoleDO::getUserId)
+                                            .filter(Objects::nonNull) // 过滤空userId
+                                            .collect(Collectors.toSet());
+                                    // 计算两个集合的交集,得到最终目标用户ID
+                                    Set<Long> targetUserIds = userIds.stream()
+                                            .filter(roleUserIds::contains)
+                                            .collect(Collectors.toSet());
+                                    // 异步发送 站内信 钉钉消息
+                                    if (CollUtil.isNotEmpty(targetUserIds)) {
+                                        Map<Long, AdminUserRespDTO> users = adminUserApi.getUserMap(targetUserIds);
+                                        // 给多个用户发送 相同 的 提醒消息
+                                        if (CollUtil.isNotEmpty(users)) {
+                                            // 生成消息提醒标题 部门名称-井号
+                                            String msgTitle = dept.getName();
+                                            if (StrUtil.isNotBlank(wellName)) {
+                                                msgTitle = StrUtil.join("-", msgTitle, wellName);
+                                            }
+                                            CountDownLatch latch = new CountDownLatch(users.size());
+                                            String finalMsgTitle = msgTitle;
+                                            users.forEach((userId, user) -> {
+                                                pmsThreadPoolTaskExecutor.execute(() -> {
+                                                    try {
+                                                        String mobile = user.getMobile();
+                                                        // 没有手机号也发送站内信消息
+                                                        if (StrUtil.isNotBlank(finalMsgTitle)) {
+                                                            pmsMessage.sendMessage(iotRhDailyReport.getId(), finalMsgTitle, PmsConstants.RH_DAILY_REPORT_APPROVAL,
+                                                                    userId, mobile);
+                                                        }
+                                                    } finally {
+                                                        latch.countDown();
                                                     }
-                                                } finally {
-                                                    latch.countDown();
-                                                }
+                                                });
                                             });
-                                        });
+                                        }
                                     }
                                 }
                             }
                         }
                     }
-                }
-            });
+                });
+            }
         }
         return iotRhDailyReport.getId();
     }
@@ -584,7 +590,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                 AdminUserDO user = users.get(0);
                 String mobile = user.getMobile();
                 String finalMsgTitle = msgTitle;
-                if (StrUtil.isNotBlank(mobile) && StrUtil.isNotBlank(finalMsgTitle)) {
+                if (StrUtil.isNotBlank(finalMsgTitle)) {
                     pmsThreadPoolTaskExecutor.execute(() -> {
                         pmsMessage.sendMessage(dailyReport.getId(), finalMsgTitle, PmsConstants.RH_DAILY_REPORT, user.getId(), mobile);
                     });

+ 12 - 9
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportServiceImpl.java

@@ -286,7 +286,8 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
                                             pmsThreadPoolTaskExecutor.execute(() -> {
                                                 try {
                                                     String mobile = user.getMobile();
-                                                    if (StrUtil.isNotBlank(mobile) && StrUtil.isNotBlank(finalMsgTitle)) {
+                                                    // 没有手机号也可以发送站内信消息
+                                                    if (StrUtil.isNotBlank(finalMsgTitle)) {
                                                         pmsMessage.sendMessage(iotRyDailyReport.getId(), finalMsgTitle, constant,
                                                                 userId, mobile);
                                                     }
@@ -856,7 +857,8 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
                     // 修井
                     constant = PmsConstants.RY_XJ_DAILY_REPORT;
                 }
-                if (StrUtil.isNotBlank(mobile) && StrUtil.isNotBlank(finalMsgTitle) && StrUtil.isNotBlank(creator)) {
+                // 没有手机号也可以发送站内信消息
+                if (StrUtil.isNotBlank(finalMsgTitle) && StrUtil.isNotBlank(creator)) {
                     pmsThreadPoolTaskExecutor.execute(() -> {
                         pmsMessage.sendMessage(dailyReport.getId(), finalMsgTitle, constant, Long.valueOf(creator), mobile);
                     });
@@ -944,13 +946,14 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
         Map<Long, BigDecimal> taskRatedProductionTimePair = new HashMap<>();
         if ("2".equals(pageReqVO.getProjectClassification())) {
             // 查询修井 累计施工井数 累计完工井数
-            List<IotRyDailyReportTaskCountVO> repairDeptTasks = iotRyDailyReportMapper.countRepairTasksByDept(pageReqVO);
-            if (CollUtil.isNotEmpty(repairDeptTasks)) {
-                repairDeptTasks.forEach(task -> {
-                    totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
-                    completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
-                });
-
+            if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
+                List<IotRyDailyReportTaskCountVO> repairDeptTasks = iotRyDailyReportMapper.countRepairTasksByDept(pageReqVO);
+                if (CollUtil.isNotEmpty(repairDeptTasks)) {
+                    repairDeptTasks.forEach(task -> {
+                        totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
+                        completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
+                    });
+                }
             }
             // 计算 运行时效 累计生产时间/累计额定生产时间
             // 查询日报关联的任务信息