yangys
2025-08-22 9810791a41d381a10451f3e9770cfcfedf98e886
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
 
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;
    }
 
 
}