|
@@ -60,14 +60,24 @@ public class ScheduledTaskServiceImpl implements ScheduledTaskService {
|
|
|
int dayOfMonth = now.getDayOfMonth();
|
|
|
int currentMontLastDay = lastDate.getDayOfMonth();
|
|
|
tenantDos.forEach(data -> {
|
|
|
- ContextHolder.setValue("dsKey", data.getDskey());
|
|
|
- List<SwInspectionRouteDo> routeList = getRouteList(weekValue, monthValue, dayOfMonth, currentMontLastDay);
|
|
|
- log.debug("当前库:{}需要生成任务的数据有:{}条", data.getDskey(), routeList.size());
|
|
|
- if (!routeList.isEmpty()) {
|
|
|
- List<SwInspectionRoutePointDo> routePointDoList = swInspectionRoutePointService.getBaseMapper().selectBatchIds(routeList.stream().map(SwInspectionRouteDo::getId).collect(Collectors.toList()));
|
|
|
- routineInspectionService.dataAsyncAndSave(routeList, routePointDoList);
|
|
|
+ try {
|
|
|
+ ContextHolder.setValue("dsKey", data.getDskey());
|
|
|
+ List<SwInspectionRouteDo> routeList = getRouteList(weekValue, monthValue, dayOfMonth, currentMontLastDay);
|
|
|
+ log.debug("当前库:{}需要生成任务的数据有:{}条", data.getDskey(), routeList.size());
|
|
|
+ if (!routeList.isEmpty()) {
|
|
|
+ List<SwInspectionRoutePointDo> routePointDoList = swInspectionRoutePointService.
|
|
|
+ list(new LambdaQueryWrapper<SwInspectionRoutePointDo>()
|
|
|
+ .eq(BaseDo::getDeleted, NO_REMOVE_FLAG)
|
|
|
+ .in(SwInspectionRoutePointDo::getInspectionrouteid,
|
|
|
+ routeList.stream().map(SwInspectionRouteDo::getId).collect(Collectors.toList())));
|
|
|
+ routineInspectionService.dataAsyncAndSave(routeList, routePointDoList);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("当前库:{}生成巡检任务失败,失败原因为:{}", data.getDskey(), e.getMessage());
|
|
|
+ } finally {
|
|
|
+ ContextHolder.clear();
|
|
|
}
|
|
|
- ContextHolder.clear();
|
|
|
+
|
|
|
});
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -131,7 +141,7 @@ public class ScheduledTaskServiceImpl implements ScheduledTaskService {
|
|
|
// 每月
|
|
|
if ("month".equals(frequencys[0])) {
|
|
|
int selectMonthDay = Integer.parseInt(frequencys[1]);
|
|
|
- if(selectMonthDay==32){
|
|
|
+ if (selectMonthDay == 32) {
|
|
|
return true;
|
|
|
}
|
|
|
// 如果选择的日期比当前月份的最后一天还要大或者 当前日期和所选择的日期相同
|