whycxzp
2023-09-22 90b526ef4e3fd4f20546128bf058fbfb5f1051e4
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
package com.whyc.controller;
 
import com.github.pagehelper.PageInfo;
import com.whyc.config.EnumWorksheetType;
import com.whyc.dto.Response;
import com.whyc.dto.WorksheetMainDTO;
import com.whyc.dto.WorksheetMainDTO2;
import com.whyc.pojo.DocUser;
import com.whyc.pojo.ProcedureDocApproving;
import com.whyc.pojo.WorksheetMain;
import com.whyc.service.WorksheetMainService;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
 
@RestController
@RequestMapping("worksheetMain")
@Api(tags = "工作流")
public class WorksheetMainController {
 
    @Autowired
    private WorksheetMainService service;
 
    @PostMapping("submit")
    @ApiOperation("产品图纸及bom提交")
    public Response submit(@RequestBody WorksheetMain main) throws IOException {
        DocUser user = ActionUtil.getUser();
        boolean res = service.submit(main,user);
        if(res) {
            return new Response().set(1,true, "提交完成");
        }else{
            return new Response().set(1,false,"角色无法提交图纸");
        }
    }
 
    @PostMapping("materialRelatedSubmit")
    @ApiOperation(value="物料-产品审批提交")
    public Response materialProductSubmit(@RequestBody WorksheetMainDTO mainDTO){
        DocUser user = ActionUtil.getUser();
        boolean res = service.MaterialProductSubmit(mainDTO,user);
        if(res) {
            return new Response().set(1,true, "提交完成");
        }else{
            return new Response().set(1,false,"角色无法提交审批");
        }
    }
 
    /**前端未传递过来物料文件所在路径,存在问题 TODO*/
    @PostMapping("materialSubmit")
    @ApiOperation(value="物料审批提交")
    public Response materialSubmit(@RequestBody WorksheetMain main){
        Response<Object> response = new Response<>();
        DocUser user = ActionUtil.getUser();
        Response res = service.materialSubmit(main,user);
        if(res.getCode()==1) {
            response.set(1,true, "提交完成");
        }else if(res.getCode()==3){
            response.set(1,false,"角色无法提交审批");
        }else{
            //重复提交
            Object existCAList = res.getData();
            Object existMaterialList = res.getData2();
            response.setCode(1);
            response.setData(false);
            response.setData2(existCAList);
            response.setData3(existMaterialList);
            if(res.getCode()==21){
                response.setMsg("重复提交:现有物料及正在进行审批的物料中,存在当前提交上传的散装件");
            }else if(res.getCode()==22){
                response.setMsg("重复提交:正在进行审批的物料中,存在当前提交上传的物料");
            }else{
                response.setMsg("重复提交:现有物料中,存在当前提交上传的物料");
            }
        }
        return response;
    }
 
    @PostMapping("productSoftwareSubmit")
    @ApiOperation(value="产品软件审批提交")
    public Response productSoftwareSubmit(@RequestParam MultipartFile multipartFile,@RequestParam String mainDTOString) throws IOException {
        DocUser user = ActionUtil.getUser();
        WorksheetMainDTO2 mainDTO = ActionUtil.getGson().fromJson(mainDTOString, WorksheetMainDTO2.class);
        return service.productSoftwareSubmit(multipartFile,mainDTO,user);
    }
 
    @GetMapping("statusStatistic")
    @ApiOperation("获取工作流-各角色用户对应的工作台数据分类统计")
    public Response<Map<String,Integer>> getStatusStatistic(){
        DocUser user = ActionUtil.getUser();
        Map<String,Integer> map = service.getStatusStatistic(user);
        return new Response<Map<String,Integer>>().set(1,map);
    }
 
    /*
        ======待处理/已处理/属于自己-审批中/已驳回/已审批======
 
        //属于自己-审批中/已驳回/已审批
        //待处理/已处理
     */
 
    @GetMapping("approvingListPage")
    @ApiOperation("查看分页-审批中")
    public Response<PageInfo<WorksheetMain>> getApprovingListPage(@RequestParam int pageNum,@RequestParam int pageSize){
        DocUser user = ActionUtil.getUser();
        return service.getApprovingListPage(user,pageNum,pageSize);
    }
 
    @GetMapping("rejectedListPage")
    @ApiOperation("查看分页-已驳回")
    public Response<PageInfo<WorksheetMain>> getRejectedListPage(@RequestParam int pageNum,@RequestParam int pageSize){
        DocUser user = ActionUtil.getUser();
        return service.getRejectedListPage(user,pageNum,pageSize);
    }
 
    @GetMapping("approvedListPage")
    @ApiOperation("查看分页-已审批")
    public Response<PageInfo<WorksheetMain>> getApprovedListPage(@RequestParam int pageNum, @RequestParam int pageSize){
        DocUser user = ActionUtil.getUser();
        return service.getApprovedListPage(user,pageNum,pageSize);
    }
 
    @GetMapping("handlingListPage")
    @ApiOperation(tags = "流程卡和SOP",value = "查看分页-待处理")
    public Response<PageInfo<WorksheetMain>> getHandlingListPage(@RequestParam int pageNum, @RequestParam int pageSize){
        DocUser user = ActionUtil.getUser();
        return service.getHandlingListPage(user,pageNum,pageSize);
    }
 
    @GetMapping("handledListPage")
    @ApiOperation(tags = "流程卡和SOP",value = "查看分页-已处理")
    public Response<PageInfo<WorksheetMain>> getHandledListPage(@RequestParam int pageNum, @RequestParam int pageSize){
        DocUser user = ActionUtil.getUser();
        return service.getHandledListPage(user,pageNum,pageSize);
    }
 
    @GetMapping("linkInfo")
    @ApiOperation("获取工作流-单个审核流程完整信息流")
    public Response getLinkList(@RequestParam int id){
        WorksheetMain main = service.getLinkList(id);
        return  new Response().set(1,main);
    }
 
    @PostMapping("info")
    @ApiOperation("查询工作流的标题及描述")
    public Response getInfo(@RequestParam int id){
        WorksheetMain main = service.getInfo(id);
        return new Response().set(1,main);
    }
 
    @GetMapping("myListPage")
    @ApiOperation(tags = "流程卡和SOP",value = "我的工单")
    public Response<PageInfo<WorksheetMain>> getMyList(@RequestParam int pageNum,@RequestParam int pageSize){
        DocUser user = ActionUtil.getUser();
        return service.getMyList(pageNum,pageSize,user);
    }
 
    /**
     * {@link EnumWorksheetType#getType()}
     * @param approving
     * @return
     * @throws IOException
     * @throws MessagingException
     */
    @PostMapping("productProcedureAndSOP")
    @ApiOperation(tags = "流程卡和SOP",value = "确认过程-产品流程卡及SOP提交",notes = "type:1-流程卡,2-SOP")
    public Response addProductProcedureAndSOP(@RequestBody ProcedureDocApproving approving) throws IOException, MessagingException {
        DocUser user = ActionUtil.getUser();
        return service.addProductProcedureAndSOP(approving,user);
    }
 
    @GetMapping("procedurePreview")
    @ApiOperation(tags = "流程卡和SOP",value = "确认过程-预览pdf",notes = "")
    public Response procedurePreview(HttpServletResponse response,@RequestParam int mainId) throws IOException {
        return service.procedurePreview(response,mainId);
    }
 
}