|
|
@@ -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.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.module.pms.constant.PmsConstants;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotcarzhbd.vo.IotCarZhbdPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplateattrs.vo.IotDeviceProperty;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
@@ -28,17 +29,27 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
|
|
|
import cn.iocoder.yudao.module.pms.enums.common.FailureAuditStatusEnum;
|
|
|
import cn.iocoder.yudao.module.pms.job.IotDeviceCarFuelVO;
|
|
|
+import cn.iocoder.yudao.module.pms.message.PmsMessage;
|
|
|
import cn.iocoder.yudao.module.pms.util.ZHBDUtil;
|
|
|
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
|
|
|
+import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
|
|
+import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
import lombok.extern.log4j.Log4j;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -53,11 +64,13 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.DateTimeParseException;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.*;
|
|
|
+import static cn.iocoder.yudao.module.pms.framework.config.MultiThreadConfiguration.PMS_THREAD_POOL_TASK_EXECUTOR;
|
|
|
|
|
|
/**
|
|
|
* 瑞恒日报 Service 实现类
|
|
|
@@ -87,9 +100,20 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
private DeptService deptService;
|
|
|
@Resource
|
|
|
private IotCarZhbdMapper iotCarZhbdMapper;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private AdminUserService adminUserService;
|
|
|
@Resource
|
|
|
private IotDailyReportFuelMapper iotDailyReportFuelMapper;
|
|
|
+ @Resource
|
|
|
+ private RoleService roleService;
|
|
|
+ @Resource
|
|
|
+ private UserRoleMapper userRoleMapper;
|
|
|
+ @Resource
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+ @Resource(name = PMS_THREAD_POOL_TASK_EXECUTOR)
|
|
|
+ private ThreadPoolTaskExecutor pmsThreadPoolTaskExecutor;
|
|
|
+ @Resource
|
|
|
+ private PmsMessage pmsMessage;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -100,7 +124,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
if (ObjUtil.isEmpty(reportDate)) {
|
|
|
throw exception(IOT_RH_DAILY_REPORT_NO_DATE);
|
|
|
}
|
|
|
- if (ObjUtil.isEmpty(createReqVO.getDeptId())) {
|
|
|
+ Long deptId = createReqVO.getDeptId();
|
|
|
+ if (ObjUtil.isEmpty(deptId)) {
|
|
|
throw exception(IOT_RH_DAILY_REPORT_NO_DEPT);
|
|
|
}
|
|
|
// 根据日报的 施工队伍 deptId 查询队伍所在的 项目 任务
|
|
|
@@ -292,6 +317,64 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
iotRhDailyReport.setId(existReport.getId());
|
|
|
iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
|
}
|
|
|
+ // 只要保存了记录就要发送审批提醒到 提交人对应的项目经理 角色 项目部日报审批RH
|
|
|
+ // 根据日报的 deptId 查询上级项目部经理 角色的审批人 发送站内信 钉钉提醒
|
|
|
+ DeptDO dept = deptService.getDept(deptId);
|
|
|
+ Long parentId = dept.getParentId();
|
|
|
+ if (ObjUtil.isNotEmpty(parentId)) {
|
|
|
+ DeptDO projectDept = deptService.getDept(parentId);
|
|
|
+ if (ObjUtil.isNotEmpty(projectDept) && "2".equals(projectDept.getType())) {
|
|
|
+ // 查询项目部下具有 项目部日报审批RH 角色的人员
|
|
|
+ Set<Long> projectIds = new HashSet<>();
|
|
|
+ projectIds.add(projectDept.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)) {
|
|
|
+ // 生成消息提醒标题 部门名称-井号
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return iotRhDailyReport.getId();
|
|
|
}
|
|
|
|