|
@@ -74,6 +74,10 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
public Long createIotRhDailyReport(IotRhDailyReportSaveReqVO createReqVO) {
|
|
public Long createIotRhDailyReport(IotRhDailyReportSaveReqVO createReqVO) {
|
|
// 插入
|
|
// 插入
|
|
IotRhDailyReportDO iotRhDailyReport = BeanUtils.toBean(createReqVO, IotRhDailyReportDO.class);
|
|
IotRhDailyReportDO iotRhDailyReport = BeanUtils.toBean(createReqVO, IotRhDailyReportDO.class);
|
|
|
|
+ LocalDateTime reportDate = createReqVO.getFillOrderCreateTime();
|
|
|
|
+ if (ObjUtil.isEmpty(reportDate)) {
|
|
|
|
+ throw exception(IOT_RH_DAILY_REPORT_NOT_EXISTS);
|
|
|
|
+ }
|
|
// 根据日报的 施工队伍 deptId 查询队伍所在的 项目 任务
|
|
// 根据日报的 施工队伍 deptId 查询队伍所在的 项目 任务
|
|
// 根据日报的施工状态 更新 对应任务的 状态
|
|
// 根据日报的施工状态 更新 对应任务的 状态
|
|
if (ObjUtil.isNotEmpty(createReqVO.getDeptId())) {
|
|
if (ObjUtil.isNotEmpty(createReqVO.getDeptId())) {
|
|
@@ -171,160 +175,25 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
}
|
|
}
|
|
} */
|
|
} */
|
|
|
|
|
|
- // 根据历史当前小队历史的日报 计算 搬迁安装天数 (开工日期 - 搬迁日期)
|
|
|
|
- // 暂时无法通过列表计算搬迁安装天数(因为需要按照任务分组同时查询当前分页所有日报的 开工日期 搬迁日期)
|
|
|
|
- /* 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<>();
|
|
|
|
- LocalDateTime reportDate = createReqVO.getFillOrderCreateTime();
|
|
|
|
// 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
|
|
// 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
|
|
// deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录 不能使用 LocalDateTime.now() 来查询,应该使用 运行记录工单的创建日期查询
|
|
// deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录 不能使用 LocalDateTime.now() 来查询,应该使用 运行记录工单的创建日期查询
|
|
IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, reportDate);
|
|
IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, reportDate);
|
|
if (ObjUtil.isEmpty(existReport)) {
|
|
if (ObjUtil.isEmpty(existReport)) {
|
|
- // 设置任务时间范围 昨天下午4点到今天下午4点
|
|
|
|
- // LocalDateTime now = LocalDateTime.now();
|
|
|
|
// 今天下午4点
|
|
// 今天下午4点
|
|
LocalDateTime today4pm = reportDate.withHour(16).withMinute(0).withSecond(0).withNano(0);
|
|
LocalDateTime today4pm = reportDate.withHour(16).withMinute(0).withSecond(0).withNano(0);
|
|
// 昨天下午4点
|
|
// 昨天下午4点
|
|
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));
|
|
|
|
- } */
|
|
|
|
iotRhDailyReport.setCreateTime(reportDate);
|
|
iotRhDailyReport.setCreateTime(reportDate);
|
|
iotRhDailyReport.setUpdateTime(reportDate);
|
|
iotRhDailyReport.setUpdateTime(reportDate);
|
|
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);
|
|
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); */
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
// 返回
|
|
// 返回
|
|
return iotRhDailyReport.getId();
|
|
return iotRhDailyReport.getId();
|
|
}
|
|
}
|