|
|
|
@ -90,7 +90,15 @@ public class RemoteMaintInstanceServiceImpl implements RemoteMaintInstanceServic
|
|
|
|
|
if (ObjectUtils.isEmpty(result)) {
|
|
|
|
|
return R.fail();
|
|
|
|
|
} else {
|
|
|
|
|
// 【关键修复】获取流程实例ID和任务ID,区分存储
|
|
|
|
|
Long processInstanceId = result.getProcessInstanceId();
|
|
|
|
|
Long taskId = result.getTaskId();
|
|
|
|
|
|
|
|
|
|
if (processInstanceId == null) {
|
|
|
|
|
log.error("保养工作流启动失败,未获取到流程实例ID");
|
|
|
|
|
return R.fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 【简化方案】异步处理工作流推进,避免死锁
|
|
|
|
|
CompletableFuture.runAsync(TtlRunnable.get(() -> {
|
|
|
|
|
try {
|
|
|
|
@ -102,8 +110,8 @@ public class RemoteMaintInstanceServiceImpl implements RemoteMaintInstanceServic
|
|
|
|
|
|
|
|
|
|
log.info("保养工单异步线程中,当前租户ID: {}", TenantHelper.getTenantId());
|
|
|
|
|
|
|
|
|
|
// 【执行业务】更新保养工单的工作流信息
|
|
|
|
|
updateMaintWorkflow(maintInstanceId, taskId);
|
|
|
|
|
// 【执行业务】更新保养工单的工作流信息并推进
|
|
|
|
|
updateMaintWorkflow(maintInstanceId, processInstanceId, taskId);
|
|
|
|
|
|
|
|
|
|
log.info("保养工单 {} 异步工作流处理完成", maintInstanceId);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -206,7 +214,7 @@ public class RemoteMaintInstanceServiceImpl implements RemoteMaintInstanceServic
|
|
|
|
|
billsMaintDetailProject.setMaintProjectId(project.getMaintProjectId());
|
|
|
|
|
billsMaintDetailProject.setMaintProjectName(project.getMaintProjectName());
|
|
|
|
|
billsMaintDetailProject.setMaintProjectDesc(project.getMaintProjectDesc());
|
|
|
|
|
billsMaintDetailProject.setMaintProjectStatus("2");//保养项目状态(0待保养 1保养完成)
|
|
|
|
|
billsMaintDetailProject.setMaintProjectStatus("2");//FIXME:保养项目状态(0待保养 1保养完成)
|
|
|
|
|
|
|
|
|
|
//字段没有自动填充,只能代码手动填充
|
|
|
|
|
billsMaintDetailProject.setCreateBy(userId);
|
|
|
|
@ -217,25 +225,32 @@ public class RemoteMaintInstanceServiceImpl implements RemoteMaintInstanceServic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateMaintWorkflow(Long businessId, Long taskId) {
|
|
|
|
|
/**
|
|
|
|
|
* 【参考润滑工单优化】更新保养工单的工作流信息并推进工作流
|
|
|
|
|
*
|
|
|
|
|
* @param businessId 业务ID(保养实例ID)
|
|
|
|
|
* @param processInstanceId 流程实例ID
|
|
|
|
|
* @param taskId 工作流任务ID(用于推进工作流)
|
|
|
|
|
*/
|
|
|
|
|
private void updateMaintWorkflow(Long businessId, Long processInstanceId, Long taskId) {
|
|
|
|
|
try {
|
|
|
|
|
// 【关键修复】确保在工作流操作前有正确的租户上下文
|
|
|
|
|
String currentTenantId = TenantHelper.getTenantId();
|
|
|
|
|
log.info("保养工作流更新前,当前租户ID: {}", currentTenantId);
|
|
|
|
|
|
|
|
|
|
// 1. 更新工作流ID
|
|
|
|
|
// 1. 【关键修复】存储流程实例ID到wfDefinitionId字段,而不是任务ID
|
|
|
|
|
DmsBillsMaintInstance maintInstance = dmsBillsMaintInstanceMapper.selectById(businessId);
|
|
|
|
|
if (maintInstance != null) {
|
|
|
|
|
maintInstance.setWfDefinitionId(taskId);
|
|
|
|
|
maintInstance.setWfDefinitionId(processInstanceId); // 存储流程实例ID
|
|
|
|
|
int updateResult = dmsBillsMaintInstanceMapper.updateById(maintInstance);
|
|
|
|
|
if (updateResult > 0) {
|
|
|
|
|
log.info("保养工单 {} 工作流ID更新成功: {}", businessId, taskId);
|
|
|
|
|
log.info("保养工单 {} 流程实例ID更新成功: {}", businessId, processInstanceId);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("保养工单 {} 工作流ID更新失败", businessId);
|
|
|
|
|
log.error("保养工单 {} 流程实例ID更新失败", businessId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log.error("保养工单 {} 不存在,无法更新工作流ID", businessId);
|
|
|
|
|
log.error("保养工单 {} 不存在,无法更新流程实例ID", businessId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|