|
@@ -20,7 +20,6 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapp
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
|
|
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.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
-import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
@@ -35,6 +34,7 @@ import javax.annotation.Resource;
|
|
import java.lang.reflect.Type;
|
|
import java.lang.reflect.Type;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
|
+import java.time.Duration;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
@@ -131,7 +131,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
}
|
|
}
|
|
|
|
|
|
// 查询当前日报所属任务关联的设备 更新设备状态
|
|
// 查询当前日报所属任务关联的设备 更新设备状态
|
|
- if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
|
|
|
+ /* if (CollUtil.isNotEmpty(deviceIds)) {
|
|
// 查询当前任务下关联的所有设备
|
|
// 查询当前任务下关联的所有设备
|
|
IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
// deviceReqVO.setDeptId(createReqVO.getDeptId());
|
|
// deviceReqVO.setDeptId(createReqVO.getDeptId());
|
|
@@ -169,10 +169,34 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
});
|
|
});
|
|
iotDeviceMapper.updateBatch(devices);
|
|
iotDeviceMapper.updateBatch(devices);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ } */
|
|
|
|
+
|
|
|
|
+ // 根据历史当前小队历史的日报 计算 搬迁安装天数 (开工日期 - 搬迁日期)
|
|
|
|
+ // 暂时无法通过列表计算搬迁安装天数(因为需要按照任务分组同时查询当前分页所有日报的 开工日期 搬迁日期)
|
|
|
|
+ /* IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
|
|
|
|
+ reportReqVO.setTaskId(taskId);
|
|
|
|
+ List<IotRhDailyReportDO> groupedReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
|
|
|
|
+ // 将当前日报也添加到 集合groupedReports中 共同筛选开工日期 搬迁日期
|
|
|
|
+ AtomicReference<LocalDateTime> moveDate = new AtomicReference<>();
|
|
|
|
+ AtomicReference<LocalDateTime> commencementDate = new AtomicReference<>();
|
|
|
|
+ // 先当前更新的日报的 施工状态
|
|
|
|
+ if (CollUtil.isNotEmpty(groupedReports)) {
|
|
|
|
+ groupedReports.forEach(report -> {
|
|
|
|
+ // 施工状态 数据字典 constructionStatus 施工3 动迁1
|
|
|
|
+ if (3 == report.getConstructionStatus()) {
|
|
|
|
+ commencementDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ if (1 == report.getConstructionStatus()) {
|
|
|
|
+ moveDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } */
|
|
|
|
+
|
|
|
|
+ AtomicReference<LocalDateTime> moveDate = new AtomicReference<>();
|
|
|
|
+ AtomicReference<LocalDateTime> commencementDate = new AtomicReference<>();
|
|
|
|
|
|
// 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
|
|
// 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
|
|
- // deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录
|
|
|
|
|
|
+ // deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录 不能使用 LocalDateTime.now() 来查询,应该使用 运行记录工单的日期查询
|
|
IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, LocalDateTime.now());
|
|
IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, LocalDateTime.now());
|
|
if (ObjUtil.isEmpty(existReport)) {
|
|
if (ObjUtil.isEmpty(existReport)) {
|
|
// 设置任务时间范围 昨天下午4点到今天下午4点
|
|
// 设置任务时间范围 昨天下午4点到今天下午4点
|
|
@@ -184,11 +208,118 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
LocalDateTime yesterday4pm = today4pm.minusDays(1);
|
|
LocalDateTime yesterday4pm = today4pm.minusDays(1);
|
|
iotRhDailyReport.setConstructionStartDate(yesterday4pm);
|
|
iotRhDailyReport.setConstructionStartDate(yesterday4pm);
|
|
iotRhDailyReport.setConstructionEndDate(today4pm);
|
|
iotRhDailyReport.setConstructionEndDate(today4pm);
|
|
-
|
|
|
|
|
|
+ // 查询当前日报状态 是否是 施工 或 搬迁
|
|
|
|
+ if (3 == iotRhDailyReport.getConstructionStatus()) {
|
|
|
|
+ commencementDate.set(yesterday4pm);
|
|
|
|
+ }
|
|
|
|
+ if (1 == iotRhDailyReport.getConstructionStatus()) {
|
|
|
|
+ moveDate.set(yesterday4pm);
|
|
|
|
+ }
|
|
|
|
+ // 历史日报数据
|
|
|
|
+ // 根据历史当前小队历史的日报 计算 搬迁安装天数 (开工日期 - 搬迁日期)
|
|
|
|
+ // 暂时无法通过列表计算搬迁安装天数(因为需要按照任务分组同时查询当前分页所有日报的 开工日期 搬迁日期)
|
|
|
|
+ IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
|
|
|
|
+ reportReqVO.setTaskId(taskId);
|
|
|
|
+ List<IotRhDailyReportDO> groupedReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
|
|
|
|
+ // 将当前日报也添加到 集合groupedReports中 共同筛选开工日期 搬迁日期
|
|
|
|
+ // AtomicReference<LocalDateTime> moveDate = new AtomicReference<>();
|
|
|
|
+ // AtomicReference<LocalDateTime> commencementDate = new AtomicReference<>();
|
|
|
|
+ // 先当前更新的日报的 施工状态
|
|
|
|
+ if (CollUtil.isNotEmpty(groupedReports)) {
|
|
|
|
+ groupedReports.forEach(report -> {
|
|
|
|
+ // 施工状态 数据字典 constructionStatus 施工3 动迁1
|
|
|
|
+ if (3 == report.getConstructionStatus()) {
|
|
|
|
+ commencementDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ if (1 == report.getConstructionStatus()) {
|
|
|
|
+ moveDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // 开工日期 搬迁日期 都存在 才能计算 搬迁安装天数
|
|
|
|
+ if (ObjUtil.isNotEmpty(commencementDate.get()) && ObjUtil.isNotEmpty(moveDate.get())) {
|
|
|
|
+ LocalDateTime start = moveDate.get(); // 搬迁日期
|
|
|
|
+ LocalDateTime end = commencementDate.get(); // 开工日期(晚于搬迁日期)
|
|
|
|
+ // 计算时间差(Duration.between 接受 start 和 end 参数)
|
|
|
|
+ Duration duration = Duration.between(start, end);
|
|
|
|
+ // 获取总秒数(long类型)
|
|
|
|
+ long totalSeconds = duration.getSeconds();
|
|
|
|
+ // 计算总天数(包括小数部分):总秒数除以一天的秒数(24 * 3600)
|
|
|
|
+ double totalDays = totalSeconds / (24.0 * 3600.0);
|
|
|
|
+ iotRhDailyReport.setRelocationDays(new BigDecimal(totalDays));
|
|
|
|
+ }
|
|
iotRhDailyReportMapper.insert(iotRhDailyReport);
|
|
iotRhDailyReportMapper.insert(iotRhDailyReport);
|
|
} else {
|
|
} else {
|
|
// 修改现有记录
|
|
// 修改现有记录
|
|
iotRhDailyReport.setId(existReport.getId());
|
|
iotRhDailyReport.setId(existReport.getId());
|
|
|
|
+ // constructionStartDate constructionEndDate 不可修改 取数据库中已经保存的值
|
|
|
|
+ /* if (3 == iotRhDailyReport.getConstructionStatus()) {
|
|
|
|
+ commencementDate.set(iotRhDailyReport.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ if (1 == iotRhDailyReport.getConstructionStatus()) {
|
|
|
|
+ moveDate.set(iotRhDailyReport.getConstructionStartDate());
|
|
|
|
+ } */
|
|
|
|
+ // 历史日报数据
|
|
|
|
+ // 根据历史当前小队历史的日报 计算 搬迁安装天数 (开工日期 - 搬迁日期)
|
|
|
|
+ // 暂时无法通过列表计算搬迁安装天数(因为需要按照任务分组同时查询当前分页所有日报的 开工日期 搬迁日期)
|
|
|
|
+ /* IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
|
|
|
|
+ reportReqVO.setTaskId(taskId);
|
|
|
|
+ List<IotRhDailyReportDO> groupedReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO); */
|
|
|
|
+ // 将当前日报也添加到 集合groupedReports中 共同筛选开工日期 搬迁日期
|
|
|
|
+ // AtomicReference<LocalDateTime> moveDate = new AtomicReference<>();
|
|
|
|
+ // AtomicReference<LocalDateTime> commencementDate = new AtomicReference<>();
|
|
|
|
+ // 先当前更新的日报的 施工状态
|
|
|
|
+ /* if (CollUtil.isNotEmpty(groupedReports)) {
|
|
|
|
+ groupedReports.forEach(report -> {
|
|
|
|
+ // 施工状态 数据字典 constructionStatus 施工3 动迁1
|
|
|
|
+ if (3 == report.getConstructionStatus()) {
|
|
|
|
+ commencementDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ if (1 == report.getConstructionStatus()) {
|
|
|
|
+ moveDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } */
|
|
|
|
+ // 开工日期 搬迁日期 都存在 才能计算 搬迁安装天数
|
|
|
|
+ /* if (ObjUtil.isNotEmpty(commencementDate.get()) && ObjUtil.isNotEmpty(moveDate.get())) {
|
|
|
|
+ LocalDateTime start = moveDate.get(); // 搬迁日期
|
|
|
|
+ LocalDateTime end = commencementDate.get(); // 开工日期(晚于搬迁日期)
|
|
|
|
+ // 计算时间差(Duration.between 接受 start 和 end 参数)
|
|
|
|
+ Duration duration = Duration.between(start, end);
|
|
|
|
+ // 获取总秒数(long类型)
|
|
|
|
+ long totalSeconds = duration.getSeconds();
|
|
|
|
+ // 计算总天数(包括小数部分):总秒数除以一天的秒数(24 * 3600)
|
|
|
|
+ double totalDays = totalSeconds / (24.0 * 3600.0);
|
|
|
|
+ iotRhDailyReport.setRelocationDays(new BigDecimal(totalDays));
|
|
|
|
+ } */
|
|
|
|
+ iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
|
|
+ // 更新后再查询就是最新的值
|
|
|
|
+ IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
|
|
|
|
+ reportReqVO.setTaskId(taskId);
|
|
|
|
+ List<IotRhDailyReportDO> groupedReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
|
|
|
|
+ if (CollUtil.isNotEmpty(groupedReports)) {
|
|
|
|
+ groupedReports.forEach(report -> {
|
|
|
|
+ // 施工状态 数据字典 constructionStatus 施工3 动迁1
|
|
|
|
+ if (3 == report.getConstructionStatus()) {
|
|
|
|
+ commencementDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ if (1 == report.getConstructionStatus()) {
|
|
|
|
+ moveDate.set(report.getConstructionStartDate());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // 开工日期 搬迁日期 都存在 才能计算 搬迁安装天数
|
|
|
|
+ if (ObjUtil.isNotEmpty(commencementDate.get()) && ObjUtil.isNotEmpty(moveDate.get())) {
|
|
|
|
+ LocalDateTime start = moveDate.get(); // 搬迁日期
|
|
|
|
+ LocalDateTime end = commencementDate.get(); // 开工日期(晚于搬迁日期)
|
|
|
|
+ // 计算时间差(Duration.between 接受 start 和 end 参数)
|
|
|
|
+ Duration duration = Duration.between(start, end);
|
|
|
|
+ // 获取总秒数(long类型)
|
|
|
|
+ long totalSeconds = duration.getSeconds();
|
|
|
|
+ // 计算总天数(包括小数部分):总秒数除以一天的秒数(24 * 3600)
|
|
|
|
+ double totalDays = totalSeconds / (24.0 * 3600.0);
|
|
|
|
+ iotRhDailyReport.setRelocationDays(new BigDecimal(totalDays));
|
|
|
|
+ }
|
|
iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
iotRhDailyReportMapper.updateById(iotRhDailyReport);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -306,9 +437,6 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
|
|
IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
|
|
reportReqVO.setTaskId(reqVO.getTaskId());
|
|
reportReqVO.setTaskId(reqVO.getTaskId());
|
|
List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
|
|
List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
|
|
- if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
return dailyReports;
|
|
return dailyReports;
|
|
}
|
|
}
|
|
|
|
|