|
@@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
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.constant.PmsConstants;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.depttype.vo.IotDeptTypePageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.depttype.vo.IotDeptTypePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplateattrs.vo.IotDeviceProperty;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplateattrs.vo.IotDeviceProperty;
|
|
@@ -126,7 +127,7 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
// 查询包含当前日报施工队伍的任务
|
|
// 查询包含当前日报施工队伍的任务
|
|
|
List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(reqVO);
|
|
List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(reqVO);
|
|
|
// 井号
|
|
// 井号
|
|
|
- String wellName = StrUtil.EMPTY;
|
|
|
|
|
|
|
+ String wellName;
|
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
|
IotProjectTaskDO task = tasks.get(0);
|
|
IotProjectTaskDO task = tasks.get(0);
|
|
|
wellName = task.getWellName();
|
|
wellName = task.getWellName();
|
|
@@ -144,6 +145,7 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
// 查询任务的设备列表
|
|
// 查询任务的设备列表
|
|
|
deviceIds = task.getDeviceIds();
|
|
deviceIds = task.getDeviceIds();
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ wellName = StrUtil.EMPTY;
|
|
|
// 当前队伍没有关联任务 不生成日报
|
|
// 当前队伍没有关联任务 不生成日报
|
|
|
// throw exception(IOT_PROJECT_TASK_NOT_RELATED);
|
|
// throw exception(IOT_PROJECT_TASK_NOT_RELATED);
|
|
|
}
|
|
}
|
|
@@ -218,65 +220,67 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
Long parentId = dept.getParentId();
|
|
Long parentId = dept.getParentId();
|
|
|
if (ObjUtil.isNotEmpty(parentId)) {
|
|
if (ObjUtil.isNotEmpty(parentId)) {
|
|
|
DeptDO projectDept = deptService.getDept(parentId);
|
|
DeptDO projectDept = deptService.getDept(parentId);
|
|
|
- // 查找队伍上级项目部 拥有‘项目部日报审批RY’角色 的审批人 如果查找不到 则使用 瑞鹰国际 下拥有‘项目部日报审批RY’角色的审批人
|
|
|
|
|
- if (ObjUtil.isNotEmpty(projectDept) && "2".equals(projectDept.getType())) {
|
|
|
|
|
- // 查询项目部下具有 项目部日报审批RH 角色的人员 如果查找不到 查询 瑞鹰国际下 拥有‘项目部日报审批RH’角色的审批人
|
|
|
|
|
- // 瑞鹰国际 158
|
|
|
|
|
- Set<Long> projectIds = new HashSet<>();
|
|
|
|
|
- projectIds.add(projectDept.getId());
|
|
|
|
|
- projectIds.add(158l);
|
|
|
|
|
- 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("项目部日报审批RY");
|
|
|
|
|
- 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(iotRyDailyReport.getId(), finalMsgTitle, PmsConstants.RY_DAILY_REPORT_APPROVAL,
|
|
|
|
|
- userId, mobile); */
|
|
|
|
|
|
|
+ DataPermissionUtils.executeIgnore(() -> {
|
|
|
|
|
+ // 查找队伍上级项目部 拥有‘项目部日报审批RY’角色 的审批人 如果查找不到 则使用 瑞鹰国际 下拥有‘项目部日报审批RY’角色的审批人
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(projectDept) && "2".equals(projectDept.getType())) {
|
|
|
|
|
+ // 查询项目部下具有 项目部日报审批RH 角色的人员 如果查找不到 查询 瑞鹰国际下 拥有‘项目部日报审批RH’角色的审批人
|
|
|
|
|
+ // 瑞鹰国际 158
|
|
|
|
|
+ Set<Long> projectIds = new HashSet<>();
|
|
|
|
|
+ projectIds.add(projectDept.getId());
|
|
|
|
|
+ projectIds.add(158l);
|
|
|
|
|
+ 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("项目部日报审批RY");
|
|
|
|
|
+ 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(iotRyDailyReport.getId(), finalMsgTitle, PmsConstants.RY_DAILY_REPORT_APPROVAL,
|
|
|
|
|
+ userId, mobile);
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ latch.countDown();
|
|
|
}
|
|
}
|
|
|
- } finally {
|
|
|
|
|
- latch.countDown();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
// 返回
|
|
// 返回
|
|
|
return iotRyDailyReport.getId();
|
|
return iotRyDailyReport.getId();
|