|
|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
|
|
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
|
|
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.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
|
@@ -29,7 +30,9 @@ import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
+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;
|
|
|
|
|
|
@Component
|
|
|
@@ -140,6 +143,8 @@ public class CreateRdDailyReportOrderJob implements JobHandler {
|
|
|
report.setEndTime(LocalTime.of(8, 0, 0));
|
|
|
report.setConstructionStartDate(yesterday);
|
|
|
report.setConstructionEndDate(currentDate);
|
|
|
+ Set<Long> submitters = task.getSubmitter();
|
|
|
+ report.setCreator(String.valueOf(new ArrayList<>(submitters).get(0)));
|
|
|
report.setCreateTime(LocalDateTime.now());
|
|
|
reports.add(report);
|
|
|
}
|
|
|
@@ -172,35 +177,42 @@ public class CreateRdDailyReportOrderJob implements JobHandler {
|
|
|
iotRdDailyReportService.batchAddDailyReports(reports);
|
|
|
}
|
|
|
|
|
|
- // 向工单责任人发送 站内信及 钉钉消息
|
|
|
- /* if (CollUtil.isNotEmpty(workOrders)) {
|
|
|
- // 先查询所有工单责任人的手机号
|
|
|
- Set<Long> personIds = new HashSet<>(convertList(workOrders, order -> Long.valueOf(order.getResponsiblePerson())));
|
|
|
+ // 向日报 填报人 发送 站内信及 钉钉消息
|
|
|
+ if (CollUtil.isNotEmpty(reports)) {
|
|
|
+ List<IotRdDailyReportDO> msgReports = new ArrayList<>();
|
|
|
+ // 如果日报是平台井 只发送主井任务
|
|
|
+ reports.forEach(report -> {
|
|
|
+ if (1 == report.getPlatformWell() || 0 == report.getPlatformWell()) {
|
|
|
+ msgReports.add(report);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 先查询所有 日报填报人的手机号
|
|
|
+ Set<Long> personIds = new HashSet<>(convertList(msgReports, report -> Long.valueOf(report.getCreator())));
|
|
|
Map<Long, AdminUserRespDTO> users = adminUserApi.getUserMap(personIds);
|
|
|
- // 建立保养工单与 用户手机号的 对应关系
|
|
|
+ // 建立日报与 用户手机号的 对应关系
|
|
|
Map<Long, String> orderMobilePair = new HashMap<>();
|
|
|
- workOrders.forEach(order -> {
|
|
|
- if (users.containsKey(Long.valueOf(order.getResponsiblePerson()))) {
|
|
|
- AdminUserRespDTO user = users.get(Long.valueOf(order.getResponsiblePerson()));
|
|
|
- orderMobilePair.put(order.getId(), user.getMobile());
|
|
|
+ msgReports.forEach(report -> {
|
|
|
+ if (users.containsKey(Long.valueOf(report.getCreator()))) {
|
|
|
+ AdminUserRespDTO user = users.get(Long.valueOf(report.getCreator()));
|
|
|
+ orderMobilePair.put(report.getId(), user.getMobile());
|
|
|
}
|
|
|
});
|
|
|
// 异步多线程发送 站内信 钉钉 消息
|
|
|
- workOrders.forEach(order -> {
|
|
|
- CountDownLatch latch = new CountDownLatch(workOrders.size());
|
|
|
+ msgReports.forEach(order -> {
|
|
|
+ CountDownLatch latch = new CountDownLatch(msgReports.size());
|
|
|
pmsThreadPoolTaskExecutor.execute(() -> {
|
|
|
try {
|
|
|
if (orderMobilePair.containsKey(order.getId())) {
|
|
|
String mobile = orderMobilePair.get(order.getId());
|
|
|
- pmsMessage.sendMessage(order.getId(), order.getName(), PmsConstants.GENERATE_MAINTENANCE,
|
|
|
- Long.valueOf(order.getResponsiblePerson()), mobile);
|
|
|
+ pmsMessage.sendMessage(order.getId(), order.getReportName(), PmsConstants.DAILY_REPORT,
|
|
|
+ Long.valueOf(order.getCreator()), mobile);
|
|
|
}
|
|
|
} finally {
|
|
|
latch.countDown();
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- } */
|
|
|
+ }
|
|
|
return "创建成功";
|
|
|
}
|
|
|
}
|