|
@@ -57,7 +57,7 @@ public class TimeServiceImpl implements TimeService {
|
|
|
ZonedDateTime tomorrowOfDay = tomorrow.atStartOfDay(zoneId);
|
|
|
// 获取 13 位时间戳(毫秒级)用作过滤查询排班明细
|
|
|
long nowTimestamp = nowOfDay.toInstant().toEpochMilli();
|
|
|
- long tomorrowTimestamp = tomorrowOfDay.toInstant().toEpochMilli();
|
|
|
+ long tomorrowTimestamp = tomorrowOfDay.toInstant().toEpochMilli()-1000;
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
dateList.add(String.valueOf(nowTimestamp));
|
|
|
dateList.add(String.valueOf(tomorrowTimestamp));
|
|
@@ -134,7 +134,7 @@ public class TimeServiceImpl implements TimeService {
|
|
|
ZonedDateTime tomorrowOfDay = tomorrow.atStartOfDay(zoneId);
|
|
|
// 获取 13 位时间戳(毫秒级)用作过滤查询排班明细
|
|
|
long nowTimestamp = nowOfDay.toInstant().toEpochMilli();
|
|
|
- long tomorrowTimestamp = tomorrowOfDay.toInstant().toEpochMilli();
|
|
|
+ long tomorrowTimestamp = tomorrowOfDay.toInstant().toEpochMilli()-1000;
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
dateList.add(String.valueOf(nowTimestamp));
|
|
|
dateList.add(String.valueOf(tomorrowTimestamp));
|
|
@@ -197,4 +197,79 @@ public class TimeServiceImpl implements TimeService {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public void testGenerateDailyInspections() {
|
|
|
+ // 获取当天的日期
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDate tomorrow = today.plusDays(1);
|
|
|
+ // 将当天的日期转换为当天 00:00 的时间,并指定时区(比如系统默认时区)
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
+ ZonedDateTime nowOfDay = today.atStartOfDay(zoneId);
|
|
|
+ ZonedDateTime tomorrowOfDay = tomorrow.atStartOfDay(zoneId);
|
|
|
+ // 获取 13 位时间戳(毫秒级)用作过滤查询排班明细
|
|
|
+ long nowTimestamp = nowOfDay.toInstant().toEpochMilli();
|
|
|
+ long tomorrowTimestamp = tomorrowOfDay.toInstant().toEpochMilli()-1000;
|
|
|
+ List<String> dateList = new ArrayList<>();
|
|
|
+ dateList.add(String.valueOf(nowTimestamp));
|
|
|
+ dateList.add(String.valueOf(tomorrowTimestamp));
|
|
|
+ //查询排版明细数据
|
|
|
+ List<Map> dataList = ydService.queryFormData_all(YDParam.builder().formUuid("FORM-E106F7ADC547404EBF6FF608B90AFA0A9RL9")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("dateField_mca5qhty",dateList))).build());
|
|
|
+ if (ObjectUtil.isNotNull(dataList) && dataList.size()>0){
|
|
|
+ dataList.forEach(e->{
|
|
|
+ log.info("获取排班明细:{}",e);
|
|
|
+ String workType = e.get("selectField_mc8v6f7a").toString();
|
|
|
+ List workerInfo = UtilMap.getList(e, "employeeField_mcip6gu5_id");
|
|
|
+ //根据排班明细中的工种获取
|
|
|
+ List<Map> taskList = ydService.queryFormData_all(YDParam.builder().formUuid("FORM-564B023D3ADE468984BBB99E3D7AF3F2RSOD")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_mc8v6f7a",workType))).build());
|
|
|
+ taskList.forEach(t->{
|
|
|
+ List place = UtilMap.getList(t, "multiSelectField_mc8v6f7i");
|
|
|
+ //排班巡检开始时间
|
|
|
+ long startTime = UtilMap.getLong(t, "dateField_mc8wxp8c");
|
|
|
+ //排班巡检结束时间
|
|
|
+ long endTime = UtilMap.getLong(t, "dateField_mc8wxp8d");
|
|
|
+ //间隔时长(若间隔为0则默认为1,只生成一次)
|
|
|
+ int interval = UtilMap.getInt(t, "numberField_mc8wxp8g_value") == 0 ? 1 : UtilMap.getInt(t, "numberField_mc8wxp8g_value");
|
|
|
+ // 提取开始时间的小时和分钟
|
|
|
+ Instant instant = Instant.ofEpochMilli(startTime);
|
|
|
+ LocalTime localTime = instant.atZone(zoneId).toLocalTime();
|
|
|
+ int startHour = localTime.getHour();
|
|
|
+ int startMinute = localTime.getMinute();
|
|
|
+ // 提取结束时间的小时和分钟
|
|
|
+ instant = Instant.ofEpochMilli(endTime);
|
|
|
+ localTime = instant.atZone(zoneId).toLocalTime();
|
|
|
+ int endHour = localTime.getHour();
|
|
|
+ int endMinute = localTime.getMinute();
|
|
|
+ //拼接今日日期与开始结束排班时分
|
|
|
+ LocalDateTime startLocalDateTime = today.atStartOfDay().plusHours(startHour).plusMinutes(startMinute);
|
|
|
+ startTime = startLocalDateTime.atZone(zoneId).toInstant().toEpochMilli();
|
|
|
+ LocalDateTime endLocalDateTime = today.atStartOfDay().plusHours(endHour).plusMinutes(endMinute);
|
|
|
+ endTime = endLocalDateTime.atZone(zoneId).toInstant().toEpochMilli();
|
|
|
+ //如果结束时间小于开始时间则是晚班跨日,往后推24小时
|
|
|
+ if (endTime < startTime){
|
|
|
+ endTime = endLocalDateTime.plusHours(24).atZone(zoneId).toInstant().toEpochMilli();
|
|
|
+ //重置localDateTime供while循环使用
|
|
|
+ startLocalDateTime = today.atStartOfDay().plusHours(startHour).plusMinutes(startMinute);
|
|
|
+ }
|
|
|
+ while (startTime <= endTime){
|
|
|
+ log.info("巡检开始时间:{}",startTime);
|
|
|
+ List<Map> sonList = ydService.queryDetails(YDParam.builder()
|
|
|
+ .formInstanceId(t.get("formInstanceId").toString())
|
|
|
+ .formUuid("FORM-564B023D3ADE468984BBB99E3D7AF3F2RSOD")
|
|
|
+ .tableFieldId("tableField_mc8v6f7j")
|
|
|
+ .build());
|
|
|
+
|
|
|
+ ydClient.operateData(YDParam.builder().userId(workerInfo.get(0).toString())
|
|
|
+ .formUuid("FORM-023B5FC03970483D90350B9ED528E9EA558P")
|
|
|
+ .formDataJson(JSON.toJSONString(UtilMap.map("tableField_mc8v6f7j, employeeField_mc8vbzw3, textField_mcjvgswh, dateField_mc8vbzw5, multiSelectField_mc8v6f7i"
|
|
|
+ ,sonList,workerInfo,workType,startTime,place)))
|
|
|
+ .build(), YDConf.FORM_OPERATION.create);
|
|
|
+ startLocalDateTime = startLocalDateTime.plusHours(interval);
|
|
|
+ startTime = startLocalDateTime.atZone(zoneId).toInstant().toEpochMilli();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|