|
|
@@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
|
|
|
import cn.iocoder.yudao.module.pms.constant.PmsConstants;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotattachment.vo.IotAttachmentSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdailyreportfuel.vo.IotDailyReportFuelSaveReqVO;
|
|
|
@@ -2636,114 +2637,114 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// 任务为平台井时 只向主井的任务的 填报人所属部门或上级项目部下 有审批权限的人 发送消息提醒
|
|
|
// 维护 非生产时间 施工简报 时 不发送消息提醒
|
|
|
if (CollUtil.isNotEmpty(tobeSendMsgReports) && StrUtil.isBlank(nonProduct.get())) {
|
|
|
- Set<Long> deptIds = new HashSet<>();
|
|
|
- IotRdDailyReportDO tobeSendMsgReport = tobeSendMsgReports.get(0);
|
|
|
- Long deptId = tobeSendMsgReport.getDeptId();
|
|
|
- DeptDO dept = deptService.getDept(deptId);
|
|
|
- if (ObjUtil.isNotEmpty(dept)) {
|
|
|
- deptIds.add(dept.getId());
|
|
|
- String type = dept.getType();
|
|
|
- // 类型(公司级1 项目部2 队伍3)
|
|
|
- // 如果当前部门是 队伍 查找上级 项目部
|
|
|
- if ("3".equals(type)) {
|
|
|
- DeptDO projectDept = deptService.getDept(dept.getParentId());
|
|
|
- if (ObjUtil.isNotEmpty(projectDept)) {
|
|
|
- deptIds.add(projectDept.getId());
|
|
|
+ DataPermissionUtils.executeIgnore(() -> {
|
|
|
+ Set<Long> deptIds = new HashSet<>();
|
|
|
+ IotRdDailyReportDO tobeSendMsgReport = tobeSendMsgReports.get(0);
|
|
|
+ Long deptId = tobeSendMsgReport.getDeptId();
|
|
|
+ DeptDO dept = deptService.getDept(deptId);
|
|
|
+ if (ObjUtil.isNotEmpty(dept)) {
|
|
|
+ deptIds.add(dept.getId());
|
|
|
+ String type = dept.getType();
|
|
|
+ // 类型(公司级1 项目部2 队伍3)
|
|
|
+ // 如果当前部门是 队伍 查找上级 项目部
|
|
|
+ if ("3".equals(type)) {
|
|
|
+ DeptDO projectDept = deptService.getDept(dept.getParentId());
|
|
|
+ if (ObjUtil.isNotEmpty(projectDept)) {
|
|
|
+ deptIds.add(projectDept.getId());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // 查找当前部门及项目下有审批权限的人员 role 项目部日报审批RD
|
|
|
- List<AdminUserDO> receivedMsgUsers = adminUserService.getUserListByDeptIds(deptIds);
|
|
|
- //
|
|
|
- if (CollUtil.isNotEmpty(receivedMsgUsers)) {
|
|
|
- Set<Long> userIds = new HashSet<>();
|
|
|
- receivedMsgUsers.forEach(user -> {
|
|
|
- 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());
|
|
|
- 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)) {
|
|
|
- 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_APPROVAL,
|
|
|
- userId, mobile);
|
|
|
+ // 查找当前部门及项目部下的人员
|
|
|
+ List<AdminUserDO> receivedMsgUsers = adminUserService.getUserListByDeptIds(deptIds);
|
|
|
+ //
|
|
|
+ if (CollUtil.isNotEmpty(receivedMsgUsers)) {
|
|
|
+ Set<Long> userIds = new HashSet<>();
|
|
|
+ receivedMsgUsers.forEach(user -> {
|
|
|
+ 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());
|
|
|
+ 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)) {
|
|
|
+ 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_APPROVAL,
|
|
|
+ userId, mobile);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ latch.countDown();
|
|
|
}
|
|
|
- } finally {
|
|
|
- latch.countDown();
|
|
|
- }
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- // 给日报抄送人发送 4小时日报更新的 钉钉及站内信消息
|
|
|
- if (ObjUtil.isNotEmpty(detailRole)) {
|
|
|
- // 拥有日报查阅权限的人员列表
|
|
|
- Set<Long> detailRoleIds = new HashSet<>();
|
|
|
- detailRoleIds.add(detailRole.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);
|
|
|
+ // 给日报抄送人发送 4小时日报更新的 钉钉及站内信消息
|
|
|
+ if (ObjUtil.isNotEmpty(detailRole)) {
|
|
|
+ // 拥有日报查阅权限的人员列表
|
|
|
+ Set<Long> detailRoleIds = new HashSet<>();
|
|
|
+ detailRoleIds.add(detailRole.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();
|
|
|
}
|
|
|
- } finally {
|
|
|
- latch.countDown();
|
|
|
- }
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|