yangys
2025-09-18 0d61b9bfca526e9c3da2209de8f9f367e76fd013
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
61
62
63
64
65
66
67
68
69
70
 
package org.springblade.mdm.statreport.service;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springblade.mdm.basesetting.machine.service.MachineService;
import org.springblade.mdm.commons.service.ParamService;
import org.springblade.mdm.commons.service.UserCommonService;
import org.springblade.mdm.flow.constants.FlowVariableConstant;
import org.springblade.mdm.statreport.mapper.TaskDispatchStatMapper;
import org.springblade.mdm.statreport.vo.TaskDispatchStatVO;
import org.springblade.mdm.statreport.vo.TaskDispathStatQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
/**
 * 审批记录,用于查询执行轨迹
 *
 * @author yangys
 */
@Slf4j
@Service
public class TaskDispatchStatService {
    @Autowired
    private UserCommonService userCommonService;
    @Autowired
    private MachineService machineService;
    @Autowired
    private HistoryService historyService;
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private TaskDispatchStatMapper taskDispatchStatMapper;
 
 
    @Autowired
    private ParamService paramService;
 
    public IPage<TaskDispatchStatVO> dispatchPage(TaskDispathStatQueryVO queryVO) {
 
        IPage<TaskDispatchStatVO> voPage = taskDispatchStatMapper.pageQuery(Condition.getPage(queryVO),queryVO);
 
        voPage.getRecords().forEach(vo ->
        {
            HistoricProcessInstance hisInst = historyService.createHistoricProcessInstanceQuery().processInstanceId(vo.getProcessInstanceId()).singleResult();
            if(hisInst != null){
                vo.setProgrammerName(userCommonService.getUserNameById(Func.toLong(hisInst.getProcessVariables().get(FlowVariableConstant.PROGRAMMER))));
            }
 
 
            if(vo.getCureTime() == null){
                ProcessInstance runInst = runtimeService.createProcessInstanceQuery().processInstanceId(vo.getProcessInstanceId()).singleResult();
                if(runInst == null || runInst.isEnded()){
                    vo.setStatus(2);//固化中
                }else{
                    vo.setStatus(1);//试切中
                }
            }else{
                vo.setStatus(3);//已固化
            }
        });
        return voPage;
    }
}