zss
2023-09-21 2dbc49184bd74845c8da694c20d6fd03d7ac87e0
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
package com.yuanchu.mom.controller;
 
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.Opinion;
import com.yuanchu.mom.service.OpinionService;
import com.yuanchu.mom.utils.JackSonUtil;
import com.yuanchu.mom.utils.Jwt;
import com.yuanchu.mom.utils.MyUtil;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.yuanchu.mom.service.InspectUnacceptedService;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 不合格品检验表(InspectUnaccepted)表控制层
 *
 * @author zss
 * @since 2023-08-07 10:04:01
 */
@RestController
@RequestMapping("/inspectUnaccepted")
public class InspectUnacceptedController {
 
    @Autowired
    private InspectUnacceptedService inspectUnacceptedService;
 
    @Autowired
    private Jwt jwt;
 
    @Autowired
    private OpinionService opinionService;
 
    @ApiOperation(value = "不合格品管理列表", tags = "QMS管理-->不合格品管理")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "formTime", value = "来料日期", dataTypeClass = String.class),
            @ApiImplicitParam(name = "dealState", value = "处理状态(为空=全部)", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "productCategories", value = "产品大类", dataTypeClass = Integer.class),
    })
    @GetMapping("/selectUnRawInspectsList")
    public Result<?> selectUnRawInspectsList(int pageSize, int countSize, String formTime, Integer dealState, Integer productCategories) {
        IPage<Map<String, Object>> inspectionPage = inspectUnacceptedService.selectUnRawInspectsList(new Page<Object>(pageSize, countSize), formTime, dealState, productCategories);
        Map<String, Object> map = new HashMap<>();
        map.put("total", inspectionPage.getTotal());
        map.put("row", inspectionPage.getRecords());
        return Result.success(map);
    }
 
    @ApiOperation(value = "查询原材料不合格品检验单列表", tags = "QMS管理-->原材料不合格品")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "formTime", value = "来料日期", dataTypeClass = String.class),
            @ApiImplicitParam(name = "productName", value = "产品名称", dataTypeClass = String.class),
            @ApiImplicitParam(name = "supplier", value = "供应商", dataTypeClass = String.class),
            @ApiImplicitParam(name = "processingStatus", value = "处理状态", dataTypeClass = Integer.class)
    })
    @GetMapping("/selectURawMaterials")
    public Result<?> selectUnqualifiedRawMaterials(int pageSize,
                                                   int countSize,
                                                   String formTime,
                                                   String productName,
                                                   String supplier,
                                                   Integer processingStatus) {
        IPage<Map<String, Object>> inspectionPage = inspectUnacceptedService.selectUnqualifiedRawMaterials(
                new Page<Object>(pageSize, countSize),
                formTime,
                productName,
                supplier,
                processingStatus);
        Map<String, Object> map = new HashMap<>();
        map.put("total", inspectionPage.getTotal());
        map.put("row", inspectionPage.getRecords());
        return Result.success(map);
    }
 
    @ApiOperation(value = "评审", tags = "QMS管理-->原材料不合格品")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "rawId", value = "原材料Id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "passOrNo", value = "是否通过:0:不通过;1:通过", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/evaluatePassOrNo")
    public Result<?> rawEvaluate(Integer rawId, Integer passOrNo) {
        if (inspectUnacceptedService.getById(rawId).getDealState() == 1) {
            return Result.fail("已经评审过了不能再次评审!");
        }
        Integer integer = inspectUnacceptedService.rawEvaluate(rawId, passOrNo);
        if (integer >= 1) {
            return Result.success("评审成功!");
        }
        return Result.fail("评审失败!");
    }
 
    @ApiOperation(value = "不合格品分页列表", tags = "QMS管理-->不合格品处置")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "specificationModel", value = "规格型号", dataTypeClass = String.class),
            @ApiImplicitParam(name = "productName", value = "产品名称", dataTypeClass = String.class),
            @ApiImplicitParam(name = "productCategories", value = "产品大类", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "state", value = "状态", dataTypeClass = Integer.class)
    })
    @GetMapping("/selectDisposal")
    public Result<?> selectDisposal(int pageSize,
                                    int countSize,
                                    String specificationModel,
                                    String productName,
                                    Integer productCategories,
                                    Integer state) {
        IPage<Map<String, Object>> inspectionPage = inspectUnacceptedService.selectDisposal(
                new Page<Object>(pageSize, countSize),
                specificationModel,
                productName,
                productCategories,
                state);
        Map<String, Object> map = new HashMap<>();
        map.put("total", inspectionPage.getTotal());
        map.put("row", inspectionPage.getRecords());
        return Result.success(map);
    }
 
    @ApiOperation(value = "编辑意见-->确定按钮", tags = "QMS管理-->不合格品处置")
    @PostMapping("/addOpinion")
    public Result<?> updateOpinion(@RequestHeader("token") String token, @RequestBody Map<String, Object> opinion) throws Exception {
        List<?> opinion1 = JackSonUtil.unmarshal(JackSonUtil.marshal(opinion.get("opinion")), List.class);
        Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class);
        String id = data.get("id").replaceAll("\"", "");
        opinionService.updateOpinion(id, opinion1);
        return Result.success("添加成功!");
    }
 
    @ApiOperation(value = "查看编辑意见", tags = "QMS管理-->不合格品处置")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "rawUnacceptedId", value = "不合格品处置Id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/viewEditorial")
    public Result<?> viewEditorialComments(Integer rawUnacceptedId) {
        return Result.success(opinionService.viewEditorialComments(rawUnacceptedId));
    }
 
    @ApiOperation(value = "失焦更新现像描述", tags = "QMS管理-->不合格品处置")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "rawUnacceptedId", value = "不合格品处置Id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "tell", value = "现象描述", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/descriptionUpdate")
    public Result<?> descriptionUpdate(Integer rawUnacceptedId, String tell) {
        Integer isUpdateSuccess = inspectUnacceptedService.descriptionUpdate(rawUnacceptedId, tell);
        if (isUpdateSuccess == 1) {
            return Result.success("更新成功");
        }
        return Result.fail("更新失败");
    }
 
    @ApiOperation(value = "点击编辑意见触发查询", tags = "QMS管理-->不合格品处置")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "rawUnacceptedId", value = "不合格品处置Id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/clickEditing")
    public Result<?> clickEditingTriggerQuery(@RequestParam("rawUnacceptedId") Integer rawUnacceptedId) {
        return Result.success(opinionService.clickEditingTriggerQuery(rawUnacceptedId));
    }
}