|
package org.springblade.mdm.program.service;
|
|
import lombok.AllArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.flowable.engine.HistoryService;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.springframework.stereotype.Service;
|
/**
|
* 程序流程装填查询
|
*
|
* @author yangys
|
*/
|
@Slf4j
|
@Service
|
@AllArgsConstructor
|
public class ProgramFlowStatusQueryService {
|
private final HistoryService historyService;
|
public static final int STATUS_NONE = 0;
|
public static final int STATUS_PROCESSING = 1;
|
public static final int STATUS_FINISHED = 2;
|
public int queryFlowStatus(String processInstanceId) {
|
if(processInstanceId == null){
|
return STATUS_NONE;
|
}
|
int status;
|
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
.processInstanceId(processInstanceId)
|
.singleResult();
|
|
if (historicProcessInstance != null && historicProcessInstance.getEndTime() != null) {
|
// 流程已完成
|
status = STATUS_FINISHED; //完成
|
} else {
|
// 流程未完成
|
status = STATUS_PROCESSING;
|
}
|
return status;
|
}
|
|
|
}
|