yangys
2025-09-15 7bc1d0f521c1d59246f29bcadcc4343f88ceef1c
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
71
72
73
74
75
76
package org.springblade.mdm.flow.excution.cure;
 
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.springblade.core.oss.OssTemplate;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.mdm.flow.excution.dispatch.FinishDataHandler;
import org.springblade.mdm.flow.service.FlowCommonService;
import org.springblade.mdm.flow.service.FlowProgramFileService;
import org.springblade.mdm.flow.service.FlowProgramProperties;
import org.springblade.mdm.program.entity.NcNode;
import org.springblade.mdm.program.service.NcNodeAutoCreateService;
import org.springblade.mdm.program.service.NcNodeHisService;
import org.springblade.mdm.program.service.NcNodeService;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
 
import java.io.IOException;
import java.util.Date;
 
@Slf4j
@Component("cureFinishOperateTask")
@AllArgsConstructor
public class CureFinishOperateTask {
    private final NcNodeService nodeService;
    private final NcNodeHisService nodeHisService;
    private final FlowCommonService flowCommonService;
    private final NormalCureFinishDataHandler normalCureFinishDataHandler;
    private final DeviationCureFinishDataHandler deviationCureFinishDataHandler;
 
    /**
     * 固化审批通过处理任务,
     *
     * @param execution 流程execution
     */
    @Transactional
    public void execute(DelegateExecution execution) throws IOException {
        log.info("执行固化程序任务服务,流程实例id={}", execution.getProcessInstanceId());
        Date time = DateUtil.now();
        //固化程序检查有效期,
        dealWithNode(execution.getProcessInstanceId());
 
        nodeHisService.mergeNodeToHisGeTime(time);
    }
 
    /**
     * 处理node状态。
     *
     * @param processInstanceId 流程实例id
     */
    void dealWithNode(String processInstanceId) throws IOException {
        //程序包节点和下属程序节点(包括历史节点非最新版本的)从试切挪到固化下面
        //程序包节点 设置未已固化
        NcNode pkgNode = nodeService.lambdaQuery().eq(NcNode::getProcessInstanceId,  processInstanceId).one();
        FlowProgramProperties flowProps = flowCommonService.getProgramProperties(processInstanceId);
        getDataHandler(pkgNode).handleData(flowProps);
 
    }
 
    /**
     * 获取数据处理其
     * @param pkgNode
     * @return
     */
    FinishDataHandler getDataHandler(NcNode pkgNode) {
        if (pkgNode.isDeviationProgram()) {
            return deviationCureFinishDataHandler;
        }else{
            return normalCureFinishDataHandler;
 
        }
    }
}