yangys
2025-08-07 bc4056543fdbef38ac8bf1648df934d5bc8e5bde
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
package org.springblade.mdm.flow.service.execute;
 
import org.flowable.task.api.Task;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.mdm.flow.constants.FlowContants;
import org.springblade.mdm.flow.service.FlowCommonService;
import org.springblade.mdm.flow.service.FlowProgramFileService;
import org.springblade.mdm.program.service.NcNodeAutoCreateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Map;
 
/**
 * 试切流程完成任务的实现
 */
@Service("tryFlowCompleteService")
public class TryFlowCompleteService extends AbstractFlowCompleteService {
    @Autowired
    private FlowProgramFileService flowProgramFileService;
 
    @Autowired
    private NcNodeAutoCreateService ncNodeAutoCreateService;
    @Autowired
    private FlowCommonService flowCommonService;
 
    @Override
    public void completeTask(String taskId, String processInstanceId, String comment, Map<String, Object> variables) {
        Task task = currentTask(taskId);
        String operateResult = this.getApproveResult(variables);
 
        if(task.getTaskDefinitionKey().equals("programmingTask")) {//编制节点
            flowProgramFileService.checkProgramFiles(processInstanceId,"Y".equals(operateResult));
        }
        if (StringUtil.isNoneBlank(processInstanceId, comment)) {
            taskService.addComment(taskId, processInstanceId, comment);
        }
        // 非空判断
        if (Func.isEmpty(variables)) {
            variables = Kv.create();
        }
        variables.put(FlowContants.LAST_STEP_USER_NICKNAME, AuthUtil.getNickName());
 
        if(!variables.containsKey("assignee")) {
            throw new ServiceException("请指定流程下一步处理人");
        }
        addApproveRecord(taskId,comment,variables);
 
        //在编制任务时,创建节点(没有节点则创建,有就直接使用
        if(task.getTaskDefinitionKey().equals("programmingTask") && "Y".equals(operateResult)) {
            ncNodeAutoCreateService.createNodeTreeWithProgram(flowCommonService.getProgramProperties(processInstanceId));
        }
        if(!"confirmIsUseableTask".equals(task.getTaskDefinitionKey())){
            variables.remove(FlowContants.PROCESS_EDITION);//TODO 临时错误是,组长提交的时候会提交一个空串,清空了内部数据
        }else{
            //升版
 
        }
        taskService.complete(taskId, variables);
    }
}