|
package org.springblade.mdm.program.service;
|
|
import lombok.AllArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.flowable.engine.HistoryService;
|
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.springblade.core.mp.base.BizServiceImpl;
|
import org.springblade.core.tool.utils.Func;
|
import org.springblade.mdm.flow.entity.ApproveRecord;
|
import org.springblade.mdm.flow.service.ApproveRecordService;
|
import org.springblade.mdm.program.entity.NcNode;
|
import org.springblade.mdm.program.mapper.NcNodeMapper;
|
import org.springblade.mdm.program.vo.NcNodeVO;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
/**
|
* 程序节点
|
*
|
* @author yangys
|
*/
|
@Slf4j
|
@Service
|
@AllArgsConstructor
|
public class ProgramFlowStatusQueryService {
|
private final RuntimeService runtimeService;
|
|
private final ApproveRecordService approveRecordService;
|
private final HistoryService historyService;
|
public int queryFlowStatus(String processInstanceId) {
|
|
//List<ApproveRecord> records = approveRecordService.lambdaQuery().eq(ApproveRecord::getNcProgramId, ncPogramId).orderByDesc(ApproveRecord::getCreateTime).last("limit 1").list();
|
|
if(processInstanceId == null){
|
return 0;
|
}
|
//String processInstanceId = records.get(0).getProcessInstanceId();
|
|
int status = 0;
|
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
.processInstanceId(processInstanceId)
|
.singleResult();
|
|
if (historicProcessInstance != null && historicProcessInstance.getEndTime() != null) {
|
// 流程已完成
|
status = 2; //已通过,有无驳回呢?
|
//检查最后一个审批结果,如果时N,那就时驳回了status = =3;
|
} else {
|
// 流程未完成
|
status = 1;
|
}
|
return status;
|
}
|
|
|
}
|