yangys
2025-09-17 1e2b04fabbbc4b1ae37d7951068d7ab235f5b5f9
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
package org.springblade.mdm.flow.excution.dispatch;
 
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.mdm.flow.service.FlowCommonService;
import org.springblade.mdm.flow.service.FlowProgramProperties;
import org.springblade.mdm.program.service.NcNodeHisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
/**
 * 派工审批通过执行的事件,功能:插入审批表数据
 */
@Slf4j
@Component("dispatchFinishListener")
public class DispatchFinishListener {
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private NcNodeHisService nodeHisService;
    @Autowired
    private FlowCommonService flowCommonService;
 
    @Autowired
    private DataHandlerHelper dataHandlerHelper;
    /**
     * 在流程结束时自动调用,(配置在审批结束事件的executelistener中了)
     * @param execution 执行对象
     */
    public void handle(DelegateExecution execution) {
        // 执行业务逻辑
        Date time = DateUtil.now();
 
        String instId = execution.getProcessInstanceId();
        log.info("事件名称{},instid={}" , execution.getEventName(),instId);
 
        FlowProgramProperties props = flowCommonService.getProgramProperties(instId);
        FinishDataHandler dataHandler = dataHandlerHelper.getDataHandler(props);
        try {
            dataHandler.handleData(props);
        }catch(Exception e) {
            log.error("处理错误",e);
            throw new ServiceException("派工完成处理异常"+e.getMessage());
        }
        nodeHisService.mergeNodeToHisGeTime(time);
        log.info("流程已完成in DispatchFinishListener");
    }
 
}