Browse Source

# 解决定时任务执行无法生成日常维护任务问题

zhongwei
haungxing 1 year ago
parent
commit
c80f25cc90
  1. 25
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java
  2. 2
      hzims-service/operational/src/main/resources/db/1.0.1.sql

25
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java

@ -39,6 +39,7 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -65,6 +66,8 @@ public class MaintenanceTaskCreateTask {
private final DataSourceTransactionManager dataSourceTransactionManager;
private final ThreadPoolExecutor threadPoolExecutor;
private final MaintenanceService maintenanceService;
@ -111,18 +114,20 @@ public class MaintenanceTaskCreateTask {
* @return
*/
public void generateTaskByPlan(OperMaintenancePlanEntity planEntity,Boolean flag) {
OperMaintenanceTaskEntity taskEntity = BeanUtil.copy(planEntity,OperMaintenanceTaskEntity.class);
//拆分设备 每个设备生成一条任务
if(StringUtil.isNotBlank(planEntity.getEmCode())){
List<String> emCodeList = Arrays.asList(planEntity.getEmCode().split(","));
for(String emCode : emCodeList){
taskEntity.setEmCode(emCode);
threadPoolExecutor.execute(() -> {
OperMaintenanceTaskEntity taskEntity = BeanUtil.copy(planEntity,OperMaintenanceTaskEntity.class);
//拆分设备 每个设备生成一条任务
if(StringUtil.isNotBlank(planEntity.getEmCode())){
List<String> emCodeList = Arrays.asList(planEntity.getEmCode().split(","));
for(String emCode : emCodeList){
taskEntity.setEmCode(emCode);
maintenanceService.fillTask(taskEntity,planEntity,flag);
}
}
else {
maintenanceService.fillTask(taskEntity,planEntity,flag);
}
}
else {
maintenanceService.fillTask(taskEntity,planEntity,flag);
}
});
}
/**

2
hzims-service/operational/src/main/resources/db/1.0.1.sql

@ -1 +1 @@
alter table hzims_oper_maintenance_plan add station_code varchar(60) comment '站点编码'
alter table hzims_oper_maintenance_plan add column station_code varchar(60) comment '站点编码'
Loading…
Cancel
Save