zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package org.jeecg.modules.apply.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.jeecg.common.Constant;
import org.jeecg.common.base.entity.BaseTaskEntity;
import org.jeecg.common.exception.CustomException;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.utils.DictEnum;
import org.jeecg.modules.apply.mapper.ApplyProcessMapper;
import org.jeecg.modules.apply.service.ApplyProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Map;
 
/**
 * @Author: yll
 * @Date: 2019/7/24 11:06
 */
@Service
@Slf4j
public class ApplyProcessServiceImpl extends ServiceImpl<ApplyProcessMapper, BaseTaskEntity> implements ApplyProcessService {
 
    @Autowired
    private ApplyProcessMapper applyProcessMapper;
 
 
    @Override
    public void updateProcessResult(DelegateExecution delegateExecution) {
        try {
            Object variable = delegateExecution.getVariable(Constant.ACT_BASE_TASK);
            BaseTaskEntity taskEntity = JSONObject.parseObject(variable.toString(), BaseTaskEntity.class);
 
            String opinionStr = delegateExecution.getVariable(Constant.ACT_APPLY_OPINION_LIST).toString();
            String tableName = taskEntity.getFormKey();
 
            //审批最终结果
            Object flagObj = delegateExecution.getVariable(Constant.ACT_TASK_FLAG);
 
            String flag = "";
            String result = DictEnum.APPLY_RESULT_AGREE.getKey();
            if (null == flagObj) {
                result = DictEnum.APPLY_RESULT_CANCEL.getKey();
            } else {
                flag = flagObj.toString();
            }
 
            if (DictEnum.Apply_APPROVAL_OPINION_REFUSE.getKey().equals(flag)) {
                //拒绝
                result = DictEnum.APPLY_RESULT_REFUSE.getKey();
            }
            if (DictEnum.Apply_APPROVAL_OPINION_AGREE.getKey().equals(flag)) {
                //同意
                result = DictEnum.APPLY_RESULT_AGREE.getKey();
            }
//            if (DictEnum.APPLY_APPROVAL_OPINION_ABANDON.getKey().equals(flag)) {
//                //取消申请
//                result = DictEnum.APPLY_RESULT_CANCEL.getKey();
//            }
            if ( DictEnum.APPLY_APPROVAL_OPINION_CONFIRM.getKey().equals(flag)) {
                //确认即为审批通过
                result = DictEnum.APPLY_RESULT_AGREE.getKey();
            }
 
            applyProcessMapper.updateProcessResult(tableName, taskEntity.getId(), DictEnum.APPLY_STATUS_FINISH.getKey(), result, DateUtils.getDate(), opinionStr);
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("保存审批结果失败!", e);
        }
    }
 
    @Override
    public void updateContactProcessResult(DelegateExecution delegateExecution) {
        try {
            Object variable = delegateExecution.getVariable(Constant.ACT_BASE_TASK);
            BaseTaskEntity taskEntity = JSONObject.parseObject(variable.toString(), BaseTaskEntity.class);
 
            String opinionStr = delegateExecution.getVariable(Constant.ACT_APPLY_OPINION_LIST).toString();
            String tableName = taskEntity.getFormKey();
 
            //审批最终结果
            Object flagObj = delegateExecution.getVariable(Constant.ACT_TASK_FLAG);
 
            String flag = "";
            String result = DictEnum.APPLY_RESULT_AGREE.getKey();
            if (null == flagObj) {
                result = DictEnum.APPLY_RESULT_CANCEL.getKey();
            } else {
                flag = flagObj.toString();
            }
 
            if (DictEnum.Apply_APPROVAL_OPINION_REFUSE.getKey().equals(flag)) {
                //拒绝
                result = DictEnum.APPLY_RESULT_REFUSE.getKey();
            }
            if (DictEnum.Apply_APPROVAL_OPINION_AGREE.getKey().equals(flag)) {
                //同意
                result = DictEnum.APPLY_RESULT_AGREE.getKey();
            }
 
            if ( DictEnum.APPLY_APPROVAL_OPINION_CONFIRM.getKey().equals(flag)) {
                //确认即为审批通过
                result = DictEnum.APPLY_RESULT_AGREE.getKey();
            }
 
            applyProcessMapper.updateContactProcessResult(tableName, taskEntity.getId(),2,DictEnum.APPLY_STATUS_FINISH.getKey(), result, DateUtils.getDate(), opinionStr);
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("保存审批结果失败!", e);
        }
    }
 
    @Override
    public void updateProblemProcessResult(DelegateExecution delegateExecution) {
        try {
            Object variable = delegateExecution.getVariable(Constant.ACT_BASE_TASK);
            BaseTaskEntity taskEntity = JSONObject.parseObject(variable.toString(), BaseTaskEntity.class);
 
            String opinionStr = delegateExecution.getVariable(Constant.ACT_APPLY_OPINION_LIST).toString();
            String tableName = taskEntity.getFormKey();
 
            //审批最终结果
            Object flagObj = delegateExecution.getVariable(Constant.ACT_TASK_FLAG);
 
            String flag = "";
            String result = DictEnum.APPLY_RESULT_AGREE.getKey();
            if (null == flagObj) {
                result = DictEnum.APPLY_RESULT_CANCEL.getKey();
            } else {
                flag = flagObj.toString();
            }
            if (DictEnum.Apply_APPROVAL_OPINION_REFUSE.getKey().equals(flag)) {
                //拒绝
                result = DictEnum.APPLY_RESULT_REFUSE.getKey();
            }
            if (DictEnum.Apply_APPROVAL_OPINION_AGREE.getKey().equals(flag)) {
                //同意
                result = DictEnum.APPLY_RESULT_AGREE.getKey();
            }
            if ( DictEnum.APPLY_APPROVAL_OPINION_CONFIRM.getKey().equals(flag)) {
                //确认即为审批通过
                result = DictEnum.APPLY_RESULT_AGREE.getKey();
            }
            applyProcessMapper.updateContactProcessResult(tableName, taskEntity.getId(),3,DictEnum.APPLY_STATUS_FINISH.getKey(), result, DateUtils.getDate(), opinionStr);
            //判断明细是否都审核
            Map<String, Object> param = taskEntity.getParam();
            applyProcessMapper.updateContactState(3,param.get("parentId").toString());
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("保存审批结果失败!", e);
        }
    }
 
}