李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/*
 *    Copyright (c) 2018-2025, ztt All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: ztt
 */
 
package com.chinaztt.mes.quality.controller;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
import com.chinaztt.mes.quality.dto.ReportSampleDTO;
import com.chinaztt.mes.quality.dto.ReportSampleItemDTO;
import com.chinaztt.mes.quality.entity.ReportSampleItem;
import com.chinaztt.ztt.common.core.util.R;
import com.chinaztt.ztt.common.log.annotation.SysLog;
import com.chinaztt.mes.quality.entity.ReportSample;
import com.chinaztt.mes.quality.service.ReportSampleService;
import com.chinaztt.ztt.common.security.annotation.Inner;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
 
/**
 * 检测汇报样品表
 *
 * @author cxf
 * @date 2021-04-06 14:29:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/reportSample")
@Api(value = "reportSample", tags = "检测汇报样品表管理")
public class ReportSampleController {
 
    private final ReportSampleService reportSampleService;
 
    /**
     * 分页查询
     *
     * @param page         分页对象
     * @param reportSample 检测汇报样品表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('quality_reportsample_view')")
    public R getReportSamplePage(Page page, ReportSample reportSample) {
        return R.ok(reportSampleService.page(page, Wrappers.query(reportSample)));
    }
 
    /**
     * 查询
     *
     * @param reportSampleDTO 检测汇报样品表
     * @return
     */
    @ApiOperation(value = "查询", notes = "查询")
    @GetMapping("/list")
    @PreAuthorize("@pms.hasPermission('quality_reportsample_view')")
    public R getReportSampleList(ReportSampleDTO reportSampleDTO) {
        return R.ok(reportSampleService.getReportSampleList(QueryWrapperUtil.gen(reportSampleDTO)));
    }
 
    /**
     * 通过id查询样品检测项目
     *
     * @param reportSampleDTO
     * @return R
     */
    @ApiOperation(value = "通过id查询样品检测项目", notes = "通过id查询样品检测项目")
    @PostMapping("/getSampleItemsById")
    public R getSampleItemsById(@RequestBody ReportSampleDTO reportSampleDTO) {
        return R.ok(reportSampleService.getSampleSysItemsById(reportSampleDTO));
    }
 
 
 
    /**
     * 判定合格校验
     *
     * @param reportSampleDTO
     * @return R
     */
    @ApiOperation(value = "判定合格校验", notes = "判定合格校验")
    @SysLog("判定合格校验")
    @PostMapping("/judgmentSampleCheck")
    public R judgmentSampleCheck(@RequestBody ReportSampleDTO reportSampleDTO) {
        return reportSampleService.judgmentSampleCheck(reportSampleDTO);
    }
 
    /**
     * 通过id判定合格
     *
     * @param reportSampleDTO
     * @return R
     */
    @ApiOperation(value = "通过id判定合格", notes = "通过id判定合格")
    @SysLog("通过id判定合格")
    @PostMapping("/autoJudgmentSample")
    public R autoJudgmentSample(@RequestBody ReportSampleDTO reportSampleDTO) {
        return R.ok(reportSampleService.autoJudgmentSample(reportSampleDTO));
    }
 
    /**
     * 通过id查询检测汇报样品表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('quality_reportsample_view')")
    public R getById(@PathVariable("id") Long id) {
        return R.ok(reportSampleService.getById(id));
    }
 
    /**
     * 新增检测汇报样品表
     *
     * @param reportSampleList 检测汇报样品表
     * @return R
     */
    @ApiOperation(value = "新增检测汇报样品表", notes = "新增检测汇报样品表")
    @SysLog("新增检测汇报样品表")
    @PostMapping
    @PreAuthorize("@pms.hasPermission('quality_reportsample_add')")
    public R save(@RequestBody List<ReportSample> reportSampleList) {
        return R.ok(reportSampleService.saveBatchList(reportSampleList));
    }
 
    /**
     * 修改检测汇报样品表
     *
     * @param reportSample 检测汇报样品表
     * @return R
     */
    @ApiOperation(value = "修改检测汇报样品表", notes = "修改检测汇报样品表")
    @SysLog("修改检测汇报样品表")
    @PutMapping
    @PreAuthorize("@pms.hasPermission('quality_reportsample_edit')")
    public R updateById(@RequestBody ReportSample reportSample) {
        return R.ok(reportSampleService.updateSampleById(reportSample));
    }
 
    /**
     * 新修改检测汇报样品表
     *
     * @param reportSample 检测汇报样品表
     * @return R
     */
    @ApiOperation(value = "新修改检测汇报样品表", notes = "新修改检测汇报样品表")
    @SysLog("新修改检测汇报样品表")
    @PutMapping("/V2")
    @PreAuthorize("@pms.hasPermission('quality_reportsample_edit')")
    public R updateByIdV2(@RequestBody ReportSample reportSample) {
        return R.ok(reportSampleService.updateSampleByIdV2(reportSample));
    }
 
    /**
     * 通过id删除检测汇报样品表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除检测汇报样品表", notes = "通过id删除检测汇报样品表")
    @SysLog("通过id删除检测汇报样品表")
    @DeleteMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('quality_reportsample_del')")
    public R removeById(@PathVariable Long id) {
        return R.ok(reportSampleService.deleteById(id));
    }
 
    /**
     * 样品附件文件
     *
     * @param file
     * @return
     */
    @ApiOperation(value = "样品附件文件", notes = "样品附件文件")
    @SysLog("样品附件文件")
    @PostMapping("/upload")
    public R upload(@RequestParam("sampleId") Long sampleId, @RequestParam("file") MultipartFile file) {
        return reportSampleService.uploadFile(file, sampleId);
    }
 
    /**
     * 通过文件名删除附件
     *
     * @param fileName
     * @return
     */
    @ApiOperation(value = "通过文件名删除附件", notes = "通过文件名删除附件")
    @SysLog("通过文件名删除附件")
    @DeleteMapping("/removeFile")
    public R removeFileById(String fileName) {
        return reportSampleService.deleteFile(fileName);
    }
 
    /**
     * 通过id查询检测汇报样品附件
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询检测汇报样品附件", notes = "通过id查询检测汇报样品附件")
    @GetMapping("/getReportSampleAttachment/{id}")
    public R getReportSampleAttachment(@PathVariable("id") Long id) {
        return R.ok(reportSampleService.getReportSampleAttachment(id));
    }
 
    /**
     * 获取文件
     *
     * @param bucket   桶名称
     * @param fileName 文件空间/名称
     * @param response
     * @return
     */
    @Inner(false)
    @GetMapping("/{bucket}/{fileName}")
    public void file(@PathVariable String bucket, @PathVariable String fileName, HttpServletResponse response) {
        reportSampleService.getFile(bucket, fileName, response);
    }
 
    /**
     * 新增自检结果,自动创建汇报单/汇报零件
     *
     * @param reportSampleDTO 检测汇报样品表
     * @return R
     */
//    @ApiOperation(value = "新增自检结果,自动创建汇报单/汇报零件", notes = "新增自检结果,自动创建汇报单/汇报零件")
//    @SysLog("新增自检结果,自动创建汇报单/汇报零件")
//    @PostMapping("/saveSelfSampleItem")
//    public R saveSelfSampleItem(@RequestBody ReportSampleDTO reportSampleDTO) {
//        return R.ok(reportSampleService.saveSelfSampleItem(reportSampleDTO));
//    }
 
    /**
     * 通过系统编号/制造订单号查询自检汇报样品表
     *
     * @param reportSampleDTO reportSampleDTO
     * @return R
     */
    @ApiOperation(value = "通过系统编号/制造订单号查询自检汇报样品表", notes = "通过系统编号/制造订单号查询自检汇报样品表")
    @SysLog("通过系统编号/制造订单号查询自检汇报样品表")
    @GetMapping("/getReportSampleForSelf")
    public R getReportSampleForSelf(ReportSampleDTO reportSampleDTO) {
        if (reportSampleDTO.getTestStandardId() == 0L) {
            return R.ok(null);
        }
        return R.ok(reportSampleService.getReportSampleForSelf(reportSampleDTO));
    }
 
    /**
     * 自检判定检测结果
     *
     * @param
     * @return R
     */
//    @ApiOperation(value = "自检判定检测结果", notes = "自检判定检测结果")
//    @SysLog("自检判定检测结果")
//    @PostMapping("/autoJudgmentSelf")
//    public R autoJudgmentSelf(@RequestBody ReportSampleDTO reportSampleDTO) {
//        reportSampleService.autoJudgmentSample(reportSampleDTO);
//        return R.ok(reportSampleService.autoMoveStock(reportSampleDTO));
//    }
 
    @ApiOperation(value = "自动判断单条检测参数", notes = "自动判断单条检测参数")
    @SysLog("自动判断单条检测参数")
    @PostMapping("/autoJudgmentSampleSingle")
    public R autoJudgmentSampleSingle(@RequestBody ReportSampleItemDTO reportSampleItemDTO) {
        return R.ok(reportSampleService.autoJudgmentSampleSingle(reportSampleItemDTO));
    }
 
 
 
    @ApiOperation(value = "大表数采", notes = "大表数采")
    @SysLog("大表数采")
    @GetMapping("/dataAcquisition")
    public R dataAcquisition(@RequestParam("id") Long id,@RequestParam("sn") String sn){
        return R.ok(reportSampleService.dataAcquisition(id,sn));
    }
 
    /**
     * 根据SN号或者零件号加检测类型获取检测标准编号
     */
    @ApiOperation(value = "根据SN号或者零件号加检测类型获取检测标准编号", notes = "根据SN号或者零件号加检测类型获取检测标准编号")
    @GetMapping("/getTestStandardNoBySnOrPartId")
    public R getTestStandardNoBySnOrPartId(@RequestParam(value = "partBatchNo", required = false) String partBatchNo,
                                           @RequestParam(value = "partId", required = false) Long partId,
                                           @RequestParam("testType") String testType) {
        return R.ok(reportSampleService.getTestStandardNoBySnOrPartId(partBatchNo, partId, testType));
    }
 
}