|
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 int queryFlowStatus(String processInstanceId) {
|
if(processInstanceId == null){
|
return 0;
|
}
|
int status;
|
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
.processInstanceId(processInstanceId)
|
.singleResult();
|
|
if (historicProcessInstance != null && historicProcessInstance.getEndTime() != null) {
|
// 流程已完成
|
status = 2; //已通过,有无驳回呢?
|
//检查最后一个审批结果,如果时N,那就时驳回了status = =3;
|
} else {
|
// 流程未完成
|
status = 1;
|
}
|
return status;
|
}
|
|
|
}
|