增加部署日志
This commit is contained in:
parent
e45ec45fb0
commit
649b14a739
@ -23,9 +23,6 @@ import com.qqchen.deploy.backend.workflow.dto.query.WorkflowHistoricalInstancesQ
|
|||||||
import com.qqchen.deploy.backend.workflow.repository.IWorkflowDefinitionRepository;
|
import com.qqchen.deploy.backend.workflow.repository.IWorkflowDefinitionRepository;
|
||||||
import com.qqchen.deploy.backend.workflow.repository.IWorkflowInstanceRepository;
|
import com.qqchen.deploy.backend.workflow.repository.IWorkflowInstanceRepository;
|
||||||
import com.qqchen.deploy.backend.workflow.repository.IWorkflowNodeInstanceRepository;
|
import com.qqchen.deploy.backend.workflow.repository.IWorkflowNodeInstanceRepository;
|
||||||
import com.qqchen.deploy.backend.workflow.repository.IWorkflowCategoryRepository;
|
|
||||||
import com.qqchen.deploy.backend.workflow.entity.WorkflowCategory;
|
|
||||||
import com.qqchen.deploy.backend.deploy.service.IDeployRecordService;
|
|
||||||
import com.qqchen.deploy.backend.workflow.service.IFormDataService;
|
import com.qqchen.deploy.backend.workflow.service.IFormDataService;
|
||||||
import com.qqchen.deploy.backend.workflow.service.IFormDefinitionService;
|
import com.qqchen.deploy.backend.workflow.service.IFormDefinitionService;
|
||||||
import com.qqchen.deploy.backend.workflow.service.IWorkflowInstanceService;
|
import com.qqchen.deploy.backend.workflow.service.IWorkflowInstanceService;
|
||||||
@ -89,17 +86,6 @@ public class WorkflowInstanceServiceImpl extends BaseServiceImpl<WorkflowInstanc
|
|||||||
@Resource
|
@Resource
|
||||||
private WorkflowNodeInstanceConverter workflowNodeInstanceConverter;
|
private WorkflowNodeInstanceConverter workflowNodeInstanceConverter;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private IDeployRecordService deployRecordService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private IWorkflowCategoryRepository workflowCategoryRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部署分类编码常量
|
|
||||||
*/
|
|
||||||
private static final String DEPLOYMENT_CATEGORY_CODE = "DEPLOYMENT";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkflowInstance updateInstanceStatus(String processInstanceId, WorkflowInstanceStatusEnums status, LocalDateTime endTime) {
|
public WorkflowInstance updateInstanceStatus(String processInstanceId, WorkflowInstanceStatusEnums status, LocalDateTime endTime) {
|
||||||
WorkflowInstance instance = workflowInstanceRepository.findByProcessInstanceId(processInstanceId)
|
WorkflowInstance instance = workflowInstanceRepository.findByProcessInstanceId(processInstanceId)
|
||||||
@ -108,48 +94,9 @@ public class WorkflowInstanceServiceImpl extends BaseServiceImpl<WorkflowInstanc
|
|||||||
instance.setEndTime(endTime);
|
instance.setEndTime(endTime);
|
||||||
WorkflowInstance saved = workflowInstanceRepository.save(instance);
|
WorkflowInstance saved = workflowInstanceRepository.save(instance);
|
||||||
|
|
||||||
// 同步部署记录状态(如果是部署类型的工作流)
|
|
||||||
try {
|
|
||||||
syncDeployRecordIfNeeded(saved, status);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("同步部署记录状态失败: workflowInstanceId={}, status={}",
|
|
||||||
saved.getId(), status, e);
|
|
||||||
// 不影响主流程,只记录错误
|
|
||||||
}
|
|
||||||
|
|
||||||
return saved;
|
return saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果需要,同步部署记录状态
|
|
||||||
*/
|
|
||||||
private void syncDeployRecordIfNeeded(WorkflowInstance instance, WorkflowInstanceStatusEnums status) {
|
|
||||||
// 1. 查询工作流定义
|
|
||||||
WorkflowDefinition definition = workflowDefinitionRepository.findById(instance.getWorkflowDefinitionId())
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
if (definition == null || definition.getCategoryId() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 查询分类
|
|
||||||
WorkflowCategory category = workflowCategoryRepository.findById(definition.getCategoryId())
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
if (category == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 判断是否是部署类型(通过分类code)
|
|
||||||
if (!DEPLOYMENT_CATEGORY_CODE.equals(category.getCode())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 同步部署记录状态
|
|
||||||
deployRecordService.syncStatusFromWorkflowInstance(instance, status);
|
|
||||||
log.debug("部署记录状态同步成功: workflowInstanceId={}, status={}", instance.getId(), status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkflowInstanceDTO getInstanceDetails(String processInstanceId) {
|
public WorkflowInstanceDTO getInstanceDetails(String processInstanceId) {
|
||||||
WorkflowInstance instance = workflowInstanceRepository.findByProcessInstanceId(processInstanceId)
|
WorkflowInstance instance = workflowInstanceRepository.findByProcessInstanceId(processInstanceId)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user