|
|
@@ -69,6 +69,7 @@ import java.time.format.DateTimeParseException;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -124,10 +125,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
public Long createIotRhDailyReport(IotRhDailyReportSaveReqVO createReqVO) {
|
|
|
// 插入
|
|
|
IotRhDailyReportDO iotRhDailyReport = BeanUtils.toBean(createReqVO, IotRhDailyReportDO.class);
|
|
|
- // 设置 日报填写状态 审核状态
|
|
|
- iotRhDailyReport.setStatus(1);
|
|
|
- // 设置 日报审批状态为 审批中 auditStatus = 10
|
|
|
- iotRhDailyReport.setAuditStatus(10);
|
|
|
+
|
|
|
LocalDateTime reportDate = createReqVO.getFillOrderCreateTime();
|
|
|
if (ObjUtil.isEmpty(reportDate)) {
|
|
|
throw exception(IOT_RH_DAILY_REPORT_NO_DATE);
|
|
|
@@ -136,6 +134,21 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
if (ObjUtil.isEmpty(deptId)) {
|
|
|
throw exception(IOT_RH_DAILY_REPORT_NO_DEPT);
|
|
|
}
|
|
|
+
|
|
|
+ DeptDO currentDept = deptService.getDept(deptId);
|
|
|
+ // 队伍下设备非施工状态,新增时需要向填报人发送 消息提醒
|
|
|
+ // 查询当前队伍下的设备的施工状态 如果是非施工,就需要向 日报 创建人发送钉钉消息
|
|
|
+ List<DeptDO> teams = new ArrayList<>();
|
|
|
+ teams.add(currentDept);
|
|
|
+ // 查询增压机状态为非施工的小队
|
|
|
+ List<IotDeviceDO> teamStatusL = iotOpeationFillMapper.selectDevStatusBatch(teams);
|
|
|
+ System.out.println("无施工设备的队伍:" + currentDept.getName());
|
|
|
+
|
|
|
+ // 设置 日报填写状态 审核状态
|
|
|
+ iotRhDailyReport.setStatus(1);
|
|
|
+ // 设置 日报审批状态为 审批中 auditStatus = 10
|
|
|
+ iotRhDailyReport.setAuditStatus(10);
|
|
|
+
|
|
|
// 根据日报的 施工队伍 deptId 查询队伍所在的 项目 任务
|
|
|
// 根据日报的施工状态 更新 对应任务的 状态
|
|
|
Long taskId = Long.MIN_VALUE;
|
|
|
@@ -258,7 +271,18 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
String yesterdayDateStr = StrUtil.EMPTY;
|
|
|
LocalDateTime yesterday = reportDate.minusDays(1);
|
|
|
yesterdayDateStr = LocalDateTimeUtil.format(yesterday, DatePattern.NORM_DATE_PATTERN);
|
|
|
+
|
|
|
+ // 标识是否是设备无施工状态的设备队伍
|
|
|
+ AtomicBoolean noDeviceTeam = new AtomicBoolean(false);
|
|
|
+
|
|
|
if (ObjUtil.isEmpty(existReport)) {
|
|
|
+
|
|
|
+ // 新增日报记录 如果是 无施工设备的队伍 status auditStatus 需要单独处理
|
|
|
+ if (CollUtil.isNotEmpty(teamStatusL)) {
|
|
|
+ iotRhDailyReport.setStatus(0);
|
|
|
+ iotRhDailyReport.setAuditStatus(0);
|
|
|
+ }
|
|
|
+
|
|
|
// 今天下午4点
|
|
|
LocalDateTime today4pm = reportDate.withHour(16).withMinute(0).withSecond(0).withNano(0);
|
|
|
// 昨天下午4点
|
|
|
@@ -325,16 +349,51 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
// 根据日报关联任务车辆油耗 计算总油耗 后保存日报
|
|
|
iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(teamStatusL)) {
|
|
|
+ // 说明队伍下的设备类别为非施工状态,需要向 日报填报人发送 消息提醒
|
|
|
+ Set<Long> targetUserIds = new HashSet<>();
|
|
|
+ targetUserIds.add(Long.valueOf(iotRhDailyReport.getCreator()));
|
|
|
+ System.out.println("日报创建人:" + iotRhDailyReport.getCreator());
|
|
|
+ Map<Long, AdminUserRespDTO> users = adminUserApi.getUserMap(targetUserIds);
|
|
|
+ // 给多个用户发送 相同 的 提醒消息
|
|
|
+ if (CollUtil.isNotEmpty(users)) {
|
|
|
+ // 生成消息提醒标题 部门名称-井号
|
|
|
+ String msgTitle = currentDept.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)) {
|
|
|
+ noDeviceTeam.set(true);
|
|
|
+ System.out.println("向日报创建人发送消息");
|
|
|
+ pmsMessage.sendMessage(iotRhDailyReport.getId(), finalMsgTitle, PmsConstants.RH_DAILY_REPORT,
|
|
|
+ userId, mobile);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
// 修改现有记录
|
|
|
iotRhDailyReport.setId(existReport.getId());
|
|
|
+ iotRhDailyReport.setCreator(existReport.getCreator());
|
|
|
iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
|
}
|
|
|
// 只要保存了记录就要发送审批提醒到 提交人对应的项目经理 角色 项目部日报审批RH
|
|
|
// 根据日报的 deptId 查询上级项目部经理 角色的审批人 发送站内信 钉钉提醒
|
|
|
// 此时需要判断下当前队伍下有无增压机,如果 ‘当前队伍下无增压机’ 或 ‘增压机的状态不是施工’ 需要新增空白记录 向填报人推送消息。
|
|
|
// 暂时添加判断条件 创建人 是 null 的话 不发送 站内信及钉钉消息
|
|
|
- if (StrUtil.isNotBlank(iotRhDailyReport.getCreator())) {
|
|
|
+ if (StrUtil.isNotBlank(iotRhDailyReport.getCreator()) && !noDeviceTeam.get()) {
|
|
|
|
|
|
DeptDO dept = deptService.getDept(deptId);
|
|
|
Long parentId = dept.getParentId();
|