|
|
|
@ -89,6 +89,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
|
|
|
|
* @param ids |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public void createTask(List<String> ids) { |
|
|
|
|
try { |
|
|
|
|
//获取日常维护计划
|
|
|
|
@ -325,36 +326,22 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
|
|
|
|
} |
|
|
|
|
taskService.save(taskEntity); |
|
|
|
|
dataSourceTransactionManager.commit(transaction); |
|
|
|
|
|
|
|
|
|
OperMaintenanceTaskEntity[] finalTaskEntity = {taskEntity}; |
|
|
|
|
|
|
|
|
|
CompletableFuture<String> processInstanceIdCompletableFuture = CompletableFuture.supplyAsync(() -> { |
|
|
|
|
//生成工作流实例
|
|
|
|
|
String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), finalTaskEntity[0]); |
|
|
|
|
return processInstanceId; |
|
|
|
|
}, executor); |
|
|
|
|
|
|
|
|
|
//启动流程
|
|
|
|
|
CompletableFuture<OperMaintenanceTaskEntity> operMaintenanceTaskEntityCompletableFuture = processInstanceIdCompletableFuture.thenApplyAsync((processInstanceId) -> { |
|
|
|
|
finalTaskEntity[0].setProcessInstanceId(processInstanceId); |
|
|
|
|
taskService.updateById(finalTaskEntity[0]); |
|
|
|
|
finalPlanEntity.setCreateTaskTime(new Date()); |
|
|
|
|
maintenancePlanService.updateById(finalPlanEntity); |
|
|
|
|
finalTaskEntity[0] = taskService.getById(finalTaskEntity[0].getId()); |
|
|
|
|
return finalTaskEntity[0]; |
|
|
|
|
}, executor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CompletableFuture<Void> thennedAcceptAsync = operMaintenanceTaskEntityCompletableFuture.thenAcceptAsync((task) -> { |
|
|
|
|
//推送消息
|
|
|
|
|
this.pushTaskMessage(task); |
|
|
|
|
}, executor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity); |
|
|
|
|
//推送消息
|
|
|
|
|
CompletableFuture<Void> operMaintenanceTaskEntityCompletableFuture = |
|
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
|
taskEntity.setProcessInstanceId(processInstanceId); |
|
|
|
|
taskService.updateById(taskEntity); |
|
|
|
|
finalPlanEntity.setCreateTaskTime(new Date()); |
|
|
|
|
maintenancePlanService.updateById(finalPlanEntity); |
|
|
|
|
OperMaintenanceTaskEntity maintenanceTask = taskService.getById(taskEntity.getId()); |
|
|
|
|
//推送消息
|
|
|
|
|
this.pushTaskMessage(maintenanceTask); |
|
|
|
|
}, executor); |
|
|
|
|
//启动队列
|
|
|
|
|
try { |
|
|
|
|
CompletableFuture.allOf(processInstanceIdCompletableFuture, operMaintenanceTaskEntityCompletableFuture, |
|
|
|
|
thennedAcceptAsync).get(); |
|
|
|
|
CompletableFuture.allOf(operMaintenanceTaskEntityCompletableFuture).get(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|