Sfoglia il codice sorgente

pms 瑞都 生产动态明细 更新后 提醒到抄送人。

zhangcl 3 giorni fa
parent
commit
99f80a8ae9

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/constant/PmsConstants.java

@@ -14,6 +14,7 @@ public interface PmsConstants {
 
     String DAILY_REPORT = "rdDailyReport";
     String DAILY_REPORT_APPROVAL = "rdReportApproval";
+    String DAILY_REPORT_DETAIL = "rdReportDetail";
 
     String RH_DAILY_REPORT = "rhDailyReport";
     String RH_DAILY_REPORT_APPROVAL = "rhReportApproval";

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/message/PmsMessage.java

@@ -85,6 +85,9 @@ public class PmsMessage {
             if (PmsConstants.DAILY_REPORT_APPROVAL.equals(businessType)) {
                 msg = "您有新的生产日报 " + name + "需要审批,请处理。"+"["+ DateUtil.format(new Date(),"yyyy-MM-dd hh:mm:ss")+"]";
             }
+            if (PmsConstants.DAILY_REPORT_DETAIL.equals(businessType)) {
+                msg = "生产日报 " + name + "已经更新,请查阅。"+"["+ DateUtil.format(new Date(),"yyyy-MM-dd hh:mm:ss")+"]";
+            }
             if (PmsConstants.RH_DAILY_REPORT_APPROVAL.equals(businessType)) {
                 msg = "您有新的生产日报 " + name + "需要审批,请处理。"+"["+ DateUtil.format(new Date(),"yyyy-MM-dd hh:mm:ss")+"]";
             }

+ 43 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrddailyreport/IotRdDailyReportServiceImpl.java

@@ -2659,6 +2659,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         userIds.add(user.getId());
                     });
                     RoleDO role = roleService.getRoleByCode("项目部日报审批RD");
+                    // 日报查阅 瑞都 日报抄送
+                    RoleDO detailRole = roleService.getRoleByCode("日报查阅RD");
                     if (ObjUtil.isNotEmpty(role)) {
                         Set<Long> roleIds = new HashSet<>();
                         roleIds.add(role.getId());
@@ -2698,6 +2700,47 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                             }
                         }
                     }
+                    // 给日报抄送人发送 4小时日报更新的 钉钉及站内信消息
+                    if (ObjUtil.isNotEmpty(detailRole)) {
+                        // 拥有日报查阅权限的人员列表
+                        Set<Long> detailRoleIds = new HashSet<>();
+                        detailRoleIds.add(role.getId());
+                        List<UserRoleDO> userRoles = userRoleMapper.selectListByRoleIds(detailRoleIds);
+                        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)) {
+                                    CountDownLatch latch = new CountDownLatch(users.size());
+                                    users.forEach((userId, user) -> {
+                                        pmsThreadPoolTaskExecutor.execute(() -> {
+                                            try {
+                                                String mobile = user.getMobile();
+                                                if (StrUtil.isNotBlank(mobile) && StrUtil.isNotBlank(tobeSendMsgReport.getReportName())) {
+                                                    pmsMessage.sendMessage(tobeSendMsgReport.getId(), tobeSendMsgReport.getReportName(), PmsConstants.DAILY_REPORT_DETAIL,
+                                                            userId, mobile);
+                                                }
+                                            } finally {
+                                                latch.countDown();
+                                            }
+                                        });
+                                    });
+                                }
+                            }
+                        }
+                    }
                 }
             }
         }