yangys
2025-08-06 1911be8941e5fe2705c2c56e74e52bd426468793
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
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;
    }
 
 
}