zhuo
2025-03-06 5d77d64f8e6a88db2b97254fde27a0f53aaec905
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
package com.ruoyi.inspect.controller;
 
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.oa.OAProcess;
import com.ruoyi.inspect.dto.PushOADto;
import com.ruoyi.inspect.dto.UnqualifiedHandlerDto;
import com.ruoyi.inspect.pojo.InsUnqualifiedHandlerFile;
import com.ruoyi.inspect.service.InsUnqualifiedHandlerFileService;
import com.ruoyi.inspect.service.InsUnqualifiedHandlerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
 
@RestController
@Api("不合格处理管理")
@RequestMapping("/unqualifiedHandler")
@AllArgsConstructor
@Slf4j
public class InsUnqualifiedHandlerController {
 
    private final InsUnqualifiedHandlerService unqualifiedHandlerService;
    private final InsUnqualifiedHandlerFileService unqualifiedHandlerFileService;
    private static final String REQUESTID = "requestId";
    private static final String CHECKRESULT = "CHECKRESULT";
 
 
 
 
    @ApiOperation(value = "提交OA")
    @PostMapping("/pushOA")
    public Result pushOA(@RequestBody PushOADto pushOADto){
        return unqualifiedHandlerService.pushOA(pushOADto);
    }
 
 
    @ApiOperation(value = "查询")
    @GetMapping("/page")
    public Result pageByUnqualified(Page page, UnqualifiedHandlerDto unqualifiedHandlerDto){
        return Result.success(unqualifiedHandlerService.pageList(page, unqualifiedHandlerDto));
    }
 
 
 
    @ApiOperation(value = "附件上传")
    @PostMapping("/uploadFileByUnqualified")
    public Result<?> uploadFileByUnqualified(Long handlerId, MultipartFile file) {
        return Result.success(unqualifiedHandlerFileService.uploadFile(handlerId, file));
    }
 
 
    @Anonymous
    @ApiOperation(value = "不合格处理OA回调")
    @RequestMapping(value = "/callback", produces = "text/plain")
    public String unqualifiedHandlerOACallback(String data){
        String msg = OAProcess.oaReturnMsg(0, "success");
        JSONObject json = JSONObject.parseObject(data);
        log.info("oa回调参数========>" + json);
        try {
            Long oaWorkId = json.getLong(REQUESTID);
            String checkResult = json.getString(CHECKRESULT);
            Object o = json.get("workflowRequestLogs");
            JSONArray objects = JSONArray.parseArray(JSONObject.toJSONString(o));
            unqualifiedHandlerService.unqualifiedHandlerOACallback(oaWorkId, checkResult,objects);
        } catch (Exception e) {
            log.error("oa回调失败: " + e.getMessage());
            msg = OAProcess.oaReturnMsg(1, "oa回调失败: " + e.getMessage());
        }
        log.info("oa回调返回结果========>" + msg);
        return msg;
    }
 
    /**
     * 下载oa附件
     * @param handlerFileId
     * @param response
     */
    @GetMapping("/downloadOAFile/{handlerFileId}")
    public void downloadOAFile(@PathVariable("handlerFileId") Long handlerFileId, HttpServletResponse response){
        unqualifiedHandlerFileService.downloadOAFile(handlerFileId,response);
    }
 
 
    @ApiOperation(value = "新增不合格处理")
    @PostMapping("/addUnqualifiedHandler")
    public Result addUnqualifiedHandler(@RequestBody UnqualifiedHandlerDto unqualifiedHandlerDto){
        return Result.success(unqualifiedHandlerService.addUnqualifiedHandler(unqualifiedHandlerDto));
    }
 
 
    @ApiOperation(value = "编辑不合格处理")
    @PostMapping("/updateUnqualifiedHandler")
    public Result updateUnqualifiedHandler(@RequestBody UnqualifiedHandlerDto unqualifiedHandlerDto){
        return Result.success(unqualifiedHandlerService.updateUnqualifiedHandler(unqualifiedHandlerDto));
    }
 
 
    @ApiOperation(value = "查看oa流程")
    @GetMapping("/getOaFlow")
    public Result getOaFlow(Integer id){
        return Result.success(unqualifiedHandlerService.getOaFlow(id));
    }
 
 
 
    @ApiOperation(value = "查看不合格处理界面")
    @GetMapping("/getUnqualifiedHandler")
    public Result getUnqualifiedHandler(Integer id){
        return Result.success(unqualifiedHandlerService.getUnqualifiedHandler(id));
    }
 
 
    @ApiOperation(value = "删除不合格处理")
    @DeleteMapping("/deleteUnqualifiedHandler")
    public Result deleteUnqualifiedHandler(Integer id) {
        return Result.success(unqualifiedHandlerService.deleteUnqualifiedHandler(id));
    }
 
 
    @ApiOperation(value = "下载附件")
    @GetMapping("/downFile")
    public Result<?> oaDownFile(Integer id) {
        InsUnqualifiedHandlerFile insUnqualifiedHandlerFile = unqualifiedHandlerFileService.getById(id);
        HashMap<String, Object> map = new HashMap<>();
        map.put("type", insUnqualifiedHandlerFile.getType());
        map.put("fileUrl", insUnqualifiedHandlerFile.getFileUrl());
        return Result.success(map);
    }
 
}