|
|
@@ -91,6 +91,7 @@ public class CreateRyDailyReportOrderJob implements JobHandler {
|
|
|
Map<Long, Long> affiliatedDeptIdUserIdPair = new HashMap<>();
|
|
|
AtomicReference<String> creator = new AtomicReference<>(StrUtil.EMPTY);
|
|
|
Long userId = 0l;
|
|
|
+ Map<Long, String> updaterPair = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(deptTypes)) {
|
|
|
deptTypes.forEach(deptType -> {
|
|
|
xjDeptIds.add(deptType.getDeptId());
|
|
|
@@ -99,6 +100,10 @@ public class CreateRyDailyReportOrderJob implements JobHandler {
|
|
|
affiliatedDeptIds.add(deptType.getDeptId());
|
|
|
creator.set(deptType.getCreator());
|
|
|
}
|
|
|
+ // 瑞鹰 综合队 当天生成明天的日报
|
|
|
+ if (StrUtil.isNotBlank(deptType.getUpdater())) {
|
|
|
+ updaterPair.put(deptType.getDeptId(), deptType.getUpdater());
|
|
|
+ }
|
|
|
});
|
|
|
// 根据 用户账号 查询用户id 挂靠队伍 日报填报人
|
|
|
if (StrUtil.isNotBlank(creator.get())) {
|
|
|
@@ -147,24 +152,45 @@ public class CreateRyDailyReportOrderJob implements JobHandler {
|
|
|
IotRdDailyReportPageReqVO pageReqVO = new IotRdDailyReportPageReqVO();
|
|
|
LocalDateTime currentDate = LocalDateTime.now();
|
|
|
String currentFormatDateStr = LocalDateTimeUtil.format(currentDate, "yyyy-MM-dd");
|
|
|
+
|
|
|
+ // 查询所有瑞鹰的项目任务 以‘部门-时间’ 为唯一键 明天 创建时间 内没有生成过日报 就自动生成 新疆综合队
|
|
|
+ LocalDateTime tomorrow = currentDate.plusDays(1);
|
|
|
+ String tomorrowFormatDateStr = LocalDateTimeUtil.format(tomorrow, "yyyy-MM-dd");
|
|
|
+
|
|
|
// 前一天的日期
|
|
|
LocalDateTime yesterday = currentDate.minusDays(1);
|
|
|
// 当天已经生成日报的修井队伍deptId集合
|
|
|
Set<Long> currentDayReportedDeptIds = new HashSet<>();
|
|
|
+ // 明天 已经生成日报的修井队伍 deptId 集合
|
|
|
+ Set<Long> tomorrowReportedDeptIds = new HashSet<>();
|
|
|
if (CollUtil.isNotEmpty(ryDailyReports)) {
|
|
|
ryDailyReports.forEach(report -> {
|
|
|
// 查询当天生成的日报
|
|
|
LocalDateTime createDate = report.getCreateTime();
|
|
|
String formatDateStr = LocalDateTimeUtil.format(createDate, "yyyy-MM-dd");
|
|
|
+ // 除新疆综合队外的其它队伍
|
|
|
if (formatDateStr.equals(currentFormatDateStr)) {
|
|
|
currentDayReportedDeptIds.add(report.getDeptId());
|
|
|
}
|
|
|
+ // 查询 新疆综合队 在明天有没有创建过日报
|
|
|
+ if (formatDateStr.equals(tomorrowFormatDateStr)) {
|
|
|
+ tomorrowReportedDeptIds.add(report.getDeptId());
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ // 所有的部门id
|
|
|
+ Set<Long> reportedDeptIds = new HashSet<>();
|
|
|
+ // 今天生成日报部门id
|
|
|
+ Optional.ofNullable(currentDayReportedDeptIds)
|
|
|
+ .ifPresent(reportedDeptIds::addAll);
|
|
|
+ // 明天生成的日报部门id
|
|
|
+ Optional.ofNullable(tomorrowReportedDeptIds)
|
|
|
+ .ifPresent(reportedDeptIds::addAll);
|
|
|
+
|
|
|
// 如果当天的修井日报记录中不包含 无设备的修井队伍部门id 则生成修井队伍日报记录
|
|
|
Set<Long> tobeReportXjDeptIds = noDeviceXjDeptIds.stream()
|
|
|
- .filter(deptId -> !currentDayReportedDeptIds.contains(deptId))
|
|
|
+ .filter(deptId -> !reportedDeptIds.contains(deptId))
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
if (CollUtil.isNotEmpty(tobeReportXjDeptIds)) {
|
|
|
@@ -211,7 +237,7 @@ public class CreateRyDailyReportOrderJob implements JobHandler {
|
|
|
// 挂靠队伍 煤层气 的日报
|
|
|
noDeviceReport.setCreator(String.valueOf(userId));
|
|
|
} else {
|
|
|
- // 综合队等其它挂靠修井队
|
|
|
+ // 综合队等其它非挂靠修井队 综合队需要生成 明天 的日报
|
|
|
if (CollUtil.isNotEmpty(deptMap) && deptMap.containsKey(tobeReportXjDeptId)) {
|
|
|
DeptDO dept = deptMap.get(tobeReportXjDeptId);
|
|
|
if (ObjUtil.isNotEmpty(dept.getLeaderUserId())) {
|
|
|
@@ -219,6 +245,11 @@ public class CreateRyDailyReportOrderJob implements JobHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 如果是 新疆综合队 设置 createTime 为明天的时间
|
|
|
+ if (updaterPair.containsKey(tobeReportXjDeptId)) {
|
|
|
+ noDeviceReport.setCreateTime(tomorrow);
|
|
|
+ noDeviceReport.setUpdateTime(tomorrow);
|
|
|
+ }
|
|
|
// 设置日报的项目任务信息
|
|
|
if (CollUtil.isNotEmpty(taskDeptPair)) {
|
|
|
taskDeptPair.forEach((taskId, deptIds) -> {
|