|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
|
|
|
+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.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
@@ -37,9 +38,11 @@ import org.springframework.stereotype.Component;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
import static cn.iocoder.yudao.module.pms.framework.config.MultiThreadConfiguration.PMS_THREAD_POOL_TASK_EXECUTOR;
|
|
import static cn.iocoder.yudao.module.pms.framework.config.MultiThreadConfiguration.PMS_THREAD_POOL_TASK_EXECUTOR;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -175,12 +178,15 @@ public class CreateRyDailyReportOrderJob implements JobHandler {
|
|
|
Map<Long, Set<Long>> taskDeptPair = new HashMap<>();
|
|
Map<Long, Set<Long>> taskDeptPair = new HashMap<>();
|
|
|
// key任务id value项目id
|
|
// key任务id value项目id
|
|
|
Map<Long, Long> taskProjectPair = new HashMap<>();
|
|
Map<Long, Long> taskProjectPair = new HashMap<>();
|
|
|
|
|
+ // key任务id value井号
|
|
|
|
|
+ Map<Long, String> taskWellNamePair = new HashMap<>();
|
|
|
Set<Long> projectIds = new HashSet<>();
|
|
Set<Long> projectIds = new HashSet<>();
|
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
|
tasks.forEach(task -> {
|
|
tasks.forEach(task -> {
|
|
|
taskDeptPair.put(task.getId(), task.getDeptIds());
|
|
taskDeptPair.put(task.getId(), task.getDeptIds());
|
|
|
projectIds.add(task.getProjectId());
|
|
projectIds.add(task.getProjectId());
|
|
|
taskProjectPair.put(task.getId(), task.getProjectId());
|
|
taskProjectPair.put(task.getId(), task.getProjectId());
|
|
|
|
|
+ taskWellNamePair.put(task.getId(), task.getWellName());
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
Map<Long, IotProjectInfoDO> projectPair = new HashMap<>();
|
|
Map<Long, IotProjectInfoDO> projectPair = new HashMap<>();
|
|
@@ -228,11 +234,47 @@ public class CreateRyDailyReportOrderJob implements JobHandler {
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(tobeAddedReports)) {
|
|
if (CollUtil.isNotEmpty(tobeAddedReports)) {
|
|
|
iotRyDailyReportMapper.insertBatch(tobeAddedReports);
|
|
iotRyDailyReportMapper.insertBatch(tobeAddedReports);
|
|
|
- }
|
|
|
|
|
- // 异步发送消息提醒 钉钉 站内信
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 异步发送消息提醒 钉钉 站内信
|
|
|
|
|
+ // 查询所有日报的创建人 userId 集合
|
|
|
|
|
+ Set<Long> userIds = new HashSet<>(convertList(tobeAddedReports, report -> Long.valueOf(report.getCreator())));
|
|
|
|
|
+ Map<Long, AdminUserRespDTO> users = adminUserApi.getUserMap(userIds);
|
|
|
|
|
+ // 建立日报与 用户手机号的 对应关系
|
|
|
|
|
+ Map<Long, String> reportMobilePair = new HashMap<>();
|
|
|
|
|
+ tobeAddedReports.forEach(report -> {
|
|
|
|
|
+ if (users.containsKey(Long.valueOf(report.getCreator()))) {
|
|
|
|
|
+ AdminUserRespDTO user = users.get(Long.valueOf(report.getCreator()));
|
|
|
|
|
+ reportMobilePair.put(report.getId(), user.getMobile());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 异步多线程发送 站内信 钉钉 消息
|
|
|
|
|
+ tobeAddedReports.forEach(report -> {
|
|
|
|
|
+ CountDownLatch latch = new CountDownLatch(tobeAddedReports.size());
|
|
|
|
|
+ // deptMap 部门集合 taskWellNamePair任务集合
|
|
|
|
|
+ Long deptId = report.getDeptId();
|
|
|
|
|
+ DeptDO dept = deptMap.get(deptId);
|
|
|
|
|
+ String msgTitle = dept.getName();
|
|
|
|
|
+ Long taskId = report.getTaskId();
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(taskId)) {
|
|
|
|
|
+ String wellName = taskWellNamePair.get(taskId);
|
|
|
|
|
+ msgTitle = StrUtil.join("-", msgTitle, wellName);
|
|
|
|
|
+ }
|
|
|
|
|
+ String finalMsgTitle = msgTitle;
|
|
|
|
|
+ pmsThreadPoolTaskExecutor.execute(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (reportMobilePair.containsKey(report.getId())) {
|
|
|
|
|
+ String mobile = reportMobilePair.get(report.getId());
|
|
|
|
|
+ pmsMessage.sendMessage(report.getId(), finalMsgTitle, PmsConstants.RY_DAILY_REPORT,
|
|
|
|
|
+ Long.valueOf(report.getCreator()), mobile);
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ latch.countDown();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return "创建成功";
|
|
return "创建成功";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|