|
@@ -324,6 +324,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
iotRhDailyReport.setDailyOilUsage(totalOilUsage);
|
|
iotRhDailyReport.setDailyOilUsage(totalOilUsage);
|
|
|
// 根据日报关联任务车辆油耗 计算总油耗 后保存日报
|
|
// 根据日报关联任务车辆油耗 计算总油耗 后保存日报
|
|
|
iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
// 修改现有记录
|
|
// 修改现有记录
|
|
|
iotRhDailyReport.setId(existReport.getId());
|
|
iotRhDailyReport.setId(existReport.getId());
|
|
@@ -332,70 +333,75 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
// 只要保存了记录就要发送审批提醒到 提交人对应的项目经理 角色 项目部日报审批RH
|
|
// 只要保存了记录就要发送审批提醒到 提交人对应的项目经理 角色 项目部日报审批RH
|
|
|
// 根据日报的 deptId 查询上级项目部经理 角色的审批人 发送站内信 钉钉提醒
|
|
// 根据日报的 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();
|
|
return iotRhDailyReport.getId();
|
|
|
}
|
|
}
|
|
@@ -584,7 +590,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
AdminUserDO user = users.get(0);
|
|
AdminUserDO user = users.get(0);
|
|
|
String mobile = user.getMobile();
|
|
String mobile = user.getMobile();
|
|
|
String finalMsgTitle = msgTitle;
|
|
String finalMsgTitle = msgTitle;
|
|
|
- if (StrUtil.isNotBlank(mobile) && StrUtil.isNotBlank(finalMsgTitle)) {
|
|
|
|
|
|
|
+ if (StrUtil.isNotBlank(finalMsgTitle)) {
|
|
|
pmsThreadPoolTaskExecutor.execute(() -> {
|
|
pmsThreadPoolTaskExecutor.execute(() -> {
|
|
|
pmsMessage.sendMessage(dailyReport.getId(), finalMsgTitle, PmsConstants.RH_DAILY_REPORT, user.getId(), mobile);
|
|
pmsMessage.sendMessage(dailyReport.getId(), finalMsgTitle, PmsConstants.RH_DAILY_REPORT, user.getId(), mobile);
|
|
|
});
|
|
});
|