|
|
@@ -124,20 +124,30 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
// 钻井类型日报必须 填写当前井深
|
|
|
throw exception(IOT_RY_DAILY_REPORT_CURRENT_DEPTH_NOT_EXISTS);
|
|
|
}
|
|
|
- // 设置 日报填写状态 审核状态
|
|
|
- iotRyDailyReport.setStatus(1);
|
|
|
- // 设置 日报审批状态为 审批中 auditStatus = 10
|
|
|
- iotRyDailyReport.setAuditStatus(10);
|
|
|
+ // 如果是编辑状态 不要设置 日报状态 和 审核状态
|
|
|
+ if (StrUtil.isBlank(createReqVO.getEditFlag())) {
|
|
|
+ // 设置 日报填写状态 审核状态
|
|
|
+ iotRyDailyReport.setStatus(1);
|
|
|
+ // 设置 日报审批状态为 审批中 auditStatus = 10
|
|
|
+ iotRyDailyReport.setAuditStatus(10);
|
|
|
+ }
|
|
|
// 根据日报的 施工队伍 deptId 查询队伍所在的 项目 任务
|
|
|
// 根据日报的施工状态 更新 对应任务的 状态
|
|
|
Long taskId = Long.MIN_VALUE;
|
|
|
Set<Long> deviceIds = new HashSet<>();
|
|
|
+ List<IotProjectTaskDO> tasks = new ArrayList<>();
|
|
|
IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
|
|
|
- reqVO.setDeptId(createReqVO.getDeptId());
|
|
|
- // 只筛选未施工完成的任务
|
|
|
- reqVO.setJobFlag("Y");
|
|
|
+ if (ObjUtil.isEmpty(createReqVO.getTaskId())) {
|
|
|
+ reqVO.setDeptId(createReqVO.getDeptId());
|
|
|
+ // 只筛选未施工完成的任务
|
|
|
+ reqVO.setJobFlag("Y");
|
|
|
+ } else {
|
|
|
+ List<Long> taskIds = new ArrayList<>();
|
|
|
+ taskIds.add(createReqVO.getTaskId());
|
|
|
+ reqVO.setTaskIds(taskIds);
|
|
|
+ }
|
|
|
// 查询包含当前日报施工队伍的任务
|
|
|
- List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(reqVO);
|
|
|
+ tasks = iotProjectTaskMapper.selectList(reqVO);
|
|
|
// 井号
|
|
|
String wellName;
|
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
|
@@ -234,99 +244,102 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
iotRyDailyReportMapper.updateById(iotRyDailyReport);
|
|
|
}
|
|
|
// 生成消息提醒 到 项目部审批人员 站内信 钉钉
|
|
|
- Long deptId = createReqVO.getDeptId();
|
|
|
- DataPermissionUtils.executeIgnore(() -> {
|
|
|
- DeptDO dept = deptService.getDept(deptId);
|
|
|
- if (ObjUtil.isEmpty(dept)) {
|
|
|
- System.out.println("当前查询到的部门是NULL:" + deptId);
|
|
|
- }
|
|
|
- Long parentId = dept.getParentId();
|
|
|
- if (ObjUtil.isNotEmpty(parentId)) {
|
|
|
- DeptDO projectDept = deptService.getDept(parentId);
|
|
|
- // 当前部门的上级部门如果 不是项目部 再向上找一级 煤层气 项目
|
|
|
- if (!"2".equals(projectDept.getType())) {
|
|
|
- DeptDO newLevelDept = deptService.getDept(projectDept.getParentId());
|
|
|
- // 将 newLevelDept 对象 关键字段赋值给 projectDept
|
|
|
- projectDept.setId(newLevelDept.getId());
|
|
|
- projectDept.setType(newLevelDept.getType());
|
|
|
+ if (StrUtil.isBlank(createReqVO.getEditFlag())) {
|
|
|
+ // 日报管理员编辑审批后的日报 不需要发送钉钉消息提醒
|
|
|
+ Long deptId = createReqVO.getDeptId();
|
|
|
+ DataPermissionUtils.executeIgnore(() -> {
|
|
|
+ DeptDO dept = deptService.getDept(deptId);
|
|
|
+ if (ObjUtil.isEmpty(dept)) {
|
|
|
+ System.out.println("当前查询到的部门是NULL:" + deptId);
|
|
|
}
|
|
|
- // 查找队伍上级项目部 拥有‘项目部日报审批RY’角色 的审批人 如果查找不到 则使用 瑞鹰国际 下拥有‘项目部日报审批RY’角色的审批人
|
|
|
- if (ObjUtil.isNotEmpty(projectDept) && "2".equals(projectDept.getType())) {
|
|
|
- // 查询项目部下具有 项目部日报审批RY 角色的人员 如果查找不到 查询 瑞鹰国际下 拥有‘项目部日报审批RY’角色的审批人
|
|
|
- // 瑞鹰国际 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;
|
|
|
- if ("1".equals(iotRyDailyReport.getProjectClassification())) {
|
|
|
- // 钻井
|
|
|
- role = roleService.getRoleByCode("项目部日报审批RY");
|
|
|
- } else {
|
|
|
- // 修井
|
|
|
- role = roleService.getRoleByCode("项目部日报审批RYXJ");
|
|
|
- }
|
|
|
- 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;
|
|
|
- String constant;
|
|
|
- if ("1".equals(iotRyDailyReport.getProjectClassification())) {
|
|
|
- // 钻井
|
|
|
- constant = PmsConstants.RY_DAILY_REPORT_APPROVAL;
|
|
|
- } else {
|
|
|
- // 修井
|
|
|
- constant = PmsConstants.RY_XJ_DAILY_REPORT_APPROVAL;
|
|
|
- }
|
|
|
- users.forEach((userId, user) -> {
|
|
|
- pmsThreadPoolTaskExecutor.execute(() -> {
|
|
|
- try {
|
|
|
- String mobile = user.getMobile();
|
|
|
- // 没有手机号也可以发送站内信消息
|
|
|
- if (StrUtil.isNotBlank(finalMsgTitle)) {
|
|
|
- pmsMessage.sendMessage(iotRyDailyReport.getId(), finalMsgTitle, constant,
|
|
|
- userId, mobile);
|
|
|
+ Long parentId = dept.getParentId();
|
|
|
+ if (ObjUtil.isNotEmpty(parentId)) {
|
|
|
+ DeptDO projectDept = deptService.getDept(parentId);
|
|
|
+ // 当前部门的上级部门如果 不是项目部 再向上找一级 煤层气 项目
|
|
|
+ if (!"2".equals(projectDept.getType())) {
|
|
|
+ DeptDO newLevelDept = deptService.getDept(projectDept.getParentId());
|
|
|
+ // 将 newLevelDept 对象 关键字段赋值给 projectDept
|
|
|
+ projectDept.setId(newLevelDept.getId());
|
|
|
+ projectDept.setType(newLevelDept.getType());
|
|
|
+ }
|
|
|
+ // 查找队伍上级项目部 拥有‘项目部日报审批RY’角色 的审批人 如果查找不到 则使用 瑞鹰国际 下拥有‘项目部日报审批RY’角色的审批人
|
|
|
+ if (ObjUtil.isNotEmpty(projectDept) && "2".equals(projectDept.getType())) {
|
|
|
+ // 查询项目部下具有 项目部日报审批RY 角色的人员 如果查找不到 查询 瑞鹰国际下 拥有‘项目部日报审批RY’角色的审批人
|
|
|
+ // 瑞鹰国际 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;
|
|
|
+ if ("1".equals(iotRyDailyReport.getProjectClassification())) {
|
|
|
+ // 钻井
|
|
|
+ role = roleService.getRoleByCode("项目部日报审批RY");
|
|
|
+ } else {
|
|
|
+ // 修井
|
|
|
+ role = roleService.getRoleByCode("项目部日报审批RYXJ");
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ String constant;
|
|
|
+ if ("1".equals(iotRyDailyReport.getProjectClassification())) {
|
|
|
+ // 钻井
|
|
|
+ constant = PmsConstants.RY_DAILY_REPORT_APPROVAL;
|
|
|
+ } else {
|
|
|
+ // 修井
|
|
|
+ constant = PmsConstants.RY_XJ_DAILY_REPORT_APPROVAL;
|
|
|
+ }
|
|
|
+ users.forEach((userId, user) -> {
|
|
|
+ pmsThreadPoolTaskExecutor.execute(() -> {
|
|
|
+ try {
|
|
|
+ String mobile = user.getMobile();
|
|
|
+ // 没有手机号也可以发送站内信消息
|
|
|
+ if (StrUtil.isNotBlank(finalMsgTitle)) {
|
|
|
+ pmsMessage.sendMessage(iotRyDailyReport.getId(), finalMsgTitle, constant,
|
|
|
+ userId, mobile);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ latch.countDown();
|
|
|
}
|
|
|
- } finally {
|
|
|
- latch.countDown();
|
|
|
- }
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
// 返回
|
|
|
return iotRyDailyReport.getId();
|
|
|
}
|