jinlin
2024-01-23 52a302b11c08cbc564ff3931038ae57a305a95d6
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/**
 * 版权所有,侵权必究!
 */
 
package com.zt.modules.workflow.controller;
 
import com.zt.common.servlet.Result;
import com.zt.modules.workflow.model.WfRunInstance;
import com.zt.modules.workflow.model.WfRunTask;
import com.zt.modules.workflow.service.WfRunInstanceService;
import com.zt.modules.workflow.service.WorkflowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Map;
 
/**
 * 工作流controller
 *
 * @author 朱曙光
 * @since 1.0.0
 */
@RestController
@RequestMapping("wf")
@Api(value = "工作流", tags = "工作流")
public class WorkflowController {
    @Autowired
    private WorkflowService workflowService;
    @Autowired
    private WfRunInstanceService wfRunInstanceService;
 
//    @PostMapping("queryAllSteps")
//    @ApiOperation("查询steps")
//    public Result queryAllSteps(@RequestBody WorkflowDto workflowDto) {
//        List<WfDefStep> list = null;
//        try {
//            list = workflowService.queryAllSteps(workflowDto.getWfCode());
//        } catch (RuntimeException e) {
//            return Result.error(e.getLocalizedMessage());
//        }
//        return Result.ok(list);
//    }
//
//    @PostMapping("queryAllSteps2")
//    @ApiOperation("查询steps")
//    public Result queryAllSteps2(@RequestBody WorkflowDto workflowDto) {
//        List<WfDefStep> list = null;
//        try {
//            list = workflowService.queryAllSteps2(workflowDto.getWfCode(), new Long(workflowDto.getWfRunLog().getBizId()));
//        } catch (RuntimeException e) {
//            return Result.error(e.getLocalizedMessage());
//        }
//        return Result.ok(list);
//    }
//
//    @PostMapping("queryWfCurrentInfo")
//    @ApiOperation("查询流程当前信息")
//    public Result queryWfCurrentInfo(@RequestBody WorkflowDto workflowDto) {
//        QueryWfInfoDto dto = null;
//        try {
//            dto = workflowService.queryWfCurrentInfo(workflowDto.getWfCode(), new Long(workflowDto.getWfRunLog().getBizId()));
//        } catch (RuntimeException e) {
//            return Result.error(e.getLocalizedMessage());
//        }
//        return Result.ok(dto);
//    }
//
//    @PostMapping("approve")
//    @ApiOperation("提交同意")
//    public Result approve(@RequestBody WorkflowDto workflowDto) {
//        try {
//            workflowService.startProcess(workflowDto.getWfCode(), new Long(workflowDto.getWfRunLog().getBizId()));
//            if ("no".equalsIgnoreCase(workflowDto.getWfRunLog().getApproveAction())) {
//                workflowService.refuse(workflowDto.getWfCode(), workflowDto.getWfRunLog());
//            } else {
//                workflowService.approve(workflowDto.getWfCode(), workflowDto.getWfRunLog());
//            }
//        } catch (RuntimeException e) {
//            return Result.error(e.getLocalizedMessage());
//        }
//        return Result.ok();
//    }
//
//
//
//    @PostMapping("refuse")
//    @ApiOperation("回退")
//    @LogOperation("回退")
//    public Result refuse(@RequestBody WorkflowDto workflowDto, HttpServletResponse response) throws Exception {
//        workflowService.refuse(workflowDto.getWfCode(), workflowDto.getWfRunLog());
//        return Result.ok();
//    }
//
//    @PostMapping("queryFirstStep")
//    @ApiOperation("查询第一步")
//    @LogOperation("查询第一步")
//    public Result<WfDefStep> queryFirstStep(@RequestBody WorkflowDto workflowDto, HttpServletResponse response) throws Exception {
//        WfDefStep step = workflowService.queryFirstStep(workflowDto.getWfCode());
//        return Result.ok(step);
//    }
//
//    @PostMapping("queryCurrentStep")
//    @ApiOperation("查询当前步")
//    @LogOperation("查询当前步")
//    public Result<WfDefStep> queryCurrentStep(@RequestBody WorkflowDto workflowDto, HttpServletResponse response) throws Exception {
//        WfDefStep step = workflowService.queryCurrentStep(workflowDto.getWfCode(), new Long(workflowDto.getWfRunLog().getBizId()));
//        return Result.ok(step);
//    }
 
//    @PostMapping("saveDraft")
//    @ApiOperation("保存审批草稿数据")
//    @LogOperation("保存审批草稿数据")
//    public Result<WfDefStep> saveDraft(@RequestBody WorkflowDto workflowDto, HttpServletResponse response) throws Exception {
//        if (workflowDto.getWfRunLog().getApproverIds() == null || StringUtils.isEmpty(workflowDto.getWfRunLog().getApproverIds())) {
//            workflowDto.getWfRunLog().setApproverIds(UserContext.getUserId().toString());
//        }
//        workflowService.saveDraft(workflowDto);
//        return Result.ok(null);
//    }
 
//    @PostMapping("queryDraft")
//    @ApiOperation("查询审批草稿数据")
//    @LogOperation("查询审批草稿数据")
//    public Result<WfRunLogDraft> queryDraft(@RequestBody WorkflowDto workflowDto, HttpServletResponse response) throws Exception {
//        if (workflowDto.getWfRunLog().getApproverIds() == null || StringUtils.isEmpty(workflowDto.getWfRunLog().getApproverIds())) {
//            workflowDto.getWfRunLog().setApproverIds(UserContext.getUserId().toString());
//        }
//        WfRunLogDraft draft = workflowService.queryDraft(workflowDto);
//        return Result.ok(draft);
//    }
 
 
    @GetMapping("/approvePass")
    @ApiOperation("审批通过")
    public Result<String> approvePass(@RequestParam("wfIdCode") String wfIdCode, @RequestParam("bizId") Long bizId, @RequestParam("stepIdMark") String stepIdMark) {
        workflowService.approvePass(wfIdCode, bizId, stepIdMark);
        return Result.ok("审批完成");
    }
 
    @GetMapping("/approvePass2")
    @ApiOperation("审批通过")
    public Result<String> approvePass2(@RequestParam("wfIdCode") String wfIdCode, @RequestParam("bizId") Long bizId, @RequestParam("stepIdMark") String stepIdMark,@RequestParam("nextStepIdMark") String nextStepIdMark) {
        workflowService.approvePass2(wfIdCode, bizId, stepIdMark,nextStepIdMark);
        return Result.ok("审批完成");
    }
 
    @GetMapping("/approveRefuse")
    @ApiOperation("审批驳回")
    public Result<String> approveRefuse(@RequestParam("wfIdCode") String wfIdCode, @RequestParam("bizId") Long bizId, @RequestParam("stepIdMark") String stepIdMark) {
        workflowService.approveRefuse(wfIdCode, bizId, stepIdMark);
        return Result.ok("审批完成");
    }
 
    @GetMapping("/approveRefuse2")
    @ApiOperation("审批驳回")
    public Result<String> approveRefuse2(@RequestParam("wfIdCode") String wfIdCode, @RequestParam("bizId") Long bizId, @RequestParam("stepIdMark") String stepIdMark,@RequestParam("prevStepIdMark") String prevStepIdMark) {
        workflowService.approveRefuse2(wfIdCode, bizId, stepIdMark,prevStepIdMark);
        return Result.ok("审批完成");
    }
 
    @GetMapping("/reStartFlow")
    @ApiOperation("重新启动流程")
    public Result<String> reStartFlow(@RequestParam("wfIdCode") String wfIdCode, @RequestParam("bizId") Long bizId, @RequestParam("stepIdMark") String stepIdMark,@RequestParam("prevStepIdMark") String prevStepIdMark) {
        workflowService.reStartFlow(wfIdCode, bizId, stepIdMark,prevStepIdMark);
        return Result.ok("审批完成");
    }
 
    @GetMapping("/startFlow")
    @ApiOperation("启动流程")
    public Result<Boolean> startFlow(@RequestParam("wfIdCode") String wfIdCode, @RequestParam("bizId") Long bizId) {
        Boolean result = workflowService.startFlow(wfIdCode, bizId);
        return Result.ok(result);
    }
 
    @GetMapping("/deleteFlowTask")
    @ApiOperation("删除流程")
    public Result<String> deleteFlowTask(@RequestParam("wfIdCode") String wfIdCode, @RequestParam("bizId") Long bizId) {
        workflowService.deleteFlowTask(wfIdCode, bizId);
        return Result.ok("删除完成");
    }
 
    @GetMapping("/getFlowStatus")
    @ApiOperation("类型1流程状态")
    public Result<Map<String, WfRunTask>> getFlowStatus(String wfIdCodes, Long bizId) {
        Map<String, WfRunTask> result = workflowService.getFlowStatus(wfIdCodes, bizId);
        return Result.ok(result);
    }
 
    @GetMapping("/getAllSteps")
    @ApiOperation("类型1流程状态")
    public Result<Map<String, Map<String, String>>> getAllSteps() {
        Map<String, Map<String, String>> result = workflowService.getAllSteps();
        return Result.ok(result);
    }
 
    @GetMapping("/getSingleFlowStatus")
    @ApiOperation("单个类型流程状态")
    public Result<Map<String, WfRunTask>> getSingleFlowStatus(String wfIdCodes, Long bizId) {
        Map<String, WfRunTask> result = workflowService.getSingleFlowStatus(wfIdCodes, bizId);
        return Result.ok(result);
    }
 
    @GetMapping("/getFlowStatus2")
    @ApiOperation("类型2流程状态")
    public Result<Map<String, WfRunTask>> getFlowStatus2(String wfIdCodes, Long bizId) {
        Map<String, WfRunTask> result = workflowService.getFlowStatus2(wfIdCodes, bizId);
        return Result.ok(result);
    }
 
    @GetMapping("/getPlanFlowStatus")
    @ApiOperation("计划修理总体流程状态")
    public Result<Map<String, Integer>> getPlanFlowStatus(Long bizId) {
        Map<String, Integer> result = workflowService.getPlanFlowStatus(bizId);
        return Result.ok(result);
    }
 
    @GetMapping("/getFlowStepStatus")
    @ApiOperation("流程步骤状态")
    public Result<WfRunTask> getFlowStepStatus(String wfIdCodes, Long bizId, String stepIdMark) {
        WfRunTask result = workflowService.getFlowStepStatus(wfIdCodes, bizId, stepIdMark);
        return Result.ok(result);
    }
 
    @GetMapping("/getStepCount")
    @ApiOperation("流程步骤")
    public Result<List<Map<String, Object>>> getStepCount(String wfIdCodes,Long bizId) {
         return Result.ok(workflowService.getStepCount(wfIdCodes,bizId));
    }
 
    @GetMapping("/hasExistFlow")
    @ApiOperation("流程步骤")
    public Boolean hasExistFlow(String wfIdCode,Long bizId) {
        return workflowService.hasExistFlow(wfIdCode,bizId);
    }
 
    @GetMapping("/reCallFlow")
    @ApiOperation("撤回流程")
    public Result<String> recallFlow(String flowCode, Long bizId, String stepMarker, Long id, Long prevId) {
        String result = workflowService.recallFlow(flowCode, bizId, stepMarker, id, prevId);
        return Result.ok(result);
    }
 
    @GetMapping("/getFlowInstance")
    @ApiOperation("获取流程步骤")
    public Result<WfRunInstance> getFlowInstance(String flowCode, Long bizId) {
        WfRunInstance flowInstance = wfRunInstanceService.getFlowInstance(flowCode, bizId);
        return Result.ok(flowInstance);
    }
 
    @GetMapping("/getFlowTrack")
    @ApiOperation("获取流程步骤")
    public Result<List<WfRunTask>> getFlowTrack(String flowCode, Long bizId) {
        List<WfRunTask> flowTrack = workflowService.getFlowTrack(flowCode, bizId);
        return Result.ok(flowTrack);
    }
 
    @GetMapping("/getFlowStepName")
    @ApiOperation("获取当前流程步骤名称")
    public Result<String> getFlowStepName(String wfIdCodes, Long bizId) {
        String result = workflowService.getFlowStepName(wfIdCodes, bizId);
        return Result.ok(result);
    }
 
    @GetMapping("/setTaskPartFinish2")
    @ApiOperation("审批通过")
    public Result<String> setTaskPartFinish2(@RequestParam("bizId") Long bizId, @RequestParam("receiveId") Long receiveId, @RequestParam("status") Integer status) {
        workflowService.setTaskPartFinish2(bizId, receiveId, status);
        return Result.ok("审批完成");
    }
 
    @GetMapping("/setTaskPartFinish3")
    @ApiOperation("审批通过")
    public Result<String> setTaskPartFinish3(@RequestParam("bizId") Long bizId, @RequestParam("receiveDeptId") Long receiveDeptId, @RequestParam("status") Integer status) {
        workflowService.setTaskPartFinish3(bizId, receiveDeptId, status);
        return Result.ok("审批完成");
    }
 
}