李林
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
package com.chinaztt.mes.quality.controller;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
import com.chinaztt.mes.quality.dto.ApplyPartDTO;
import com.chinaztt.mes.quality.dto.ReportMDTO;
import com.chinaztt.mes.quality.entity.Report;
import com.chinaztt.mes.quality.service.ReportService;
import com.chinaztt.ztt.common.core.util.R;
import com.chinaztt.ztt.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
 
/**
 * 检测汇报表
 *
 * @author cxf
 * @date 2021-04-06 14:29:39
 */
@RestController
@AllArgsConstructor
@RequestMapping("/qualityReport" )
@Api(value = "qualityReport", tags = "检测汇报表管理")
public class ReportController {
 
    private final ReportService reportService;
 
    /**
     * 分页查询
     * @param page 分页对象
     * @param report 检测汇报表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('quality_report_view')" )
    public R getQualityReportPage(Page page, Report report) {
        return R.ok(reportService.page(page, QueryWrapperUtil.gen(report)));
    }
 
 
    /**
     * 通过id查询检测汇报表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('quality_report_view')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(reportService.getById(id));
    }
 
    /**
     * 新增检测汇报表
     * @param reportMDTO 检测汇报表
     * @return R
     */
    @ApiOperation(value = "新增检测汇报表", notes = "新增检测汇报表")
    @SysLog("新增检测汇报表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('quality_report_add')" )
    public R save(@RequestBody ReportMDTO reportMDTO) {
        reportMDTO.setCheckState(Report.CHECK_STATE_UNCHECK);//设置检测状态:未检测
        //通过判断前端是否传递扫码枪光标位置对业务进行分流
        if(reportMDTO.getSweepCodeGunCursorLocation() != null){
            //该功能暂停开发
            return R.ok();
        }else{
            return R.ok(reportService.save(reportMDTO));//原手动新增检测汇报主表路径
        }
 
    }
 
    /**
     * 待检零件创建检测汇报
     * @param
     * @return
     */
    @ApiOperation(value = "待检零件创建检测汇报", notes = "待检零件创建检测汇报")
    @SysLog("待检零件创建检测汇报")
    @PostMapping("/createReport")
    @PreAuthorize("@pms.hasPermission('quality_report_add')")
    public R<ApplyPartDTO> createReport(@RequestBody ReportMDTO reportMDTO){
        return R.ok(reportService.createReport(reportMDTO.getApplyPartId(), reportMDTO.getReportType(), reportMDTO.getReportPerson()));
    }
 
 
    /**
     * 修改检测汇报表
     * @param report 检测汇报表
     * @return R
     */
    @ApiOperation(value = "修改检测汇报表", notes = "修改检测汇报表")
    @SysLog("修改检测汇报表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('quality_report_edit')" )
    public R updateById(@RequestBody Report report) {
        if(reportService.isApplyReportIsSubmitByReportId(report.getId())){
            return R.failed("检测汇报已提交,冻结删除操作!");
        }else{
            return R.ok(reportService.updateById(report));
        }
    }
 
    /**
     * 通过id删除检测汇报表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除检测汇报表", notes = "通过id删除检测汇报表")
    @SysLog("通过id删除检测汇报表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('quality_report_del')" )
    public R removeById(@PathVariable Long id) {
        if(reportService.isApplyReportIsSubmitByReportId(id)){
            return R.failed("检测汇报已提交,冻结删除操作!");
        }else{
            return R.ok(reportService.removeById(id));
        }
    }
 
    /**
     * 提交检测汇报
     * @param id
     * @return
     */
    @ApiOperation(value = "提交检测汇报", notes = "提交检测汇报")
    @SysLog("提交检测汇报")
    @PutMapping("/submit/{id}")
    @PreAuthorize("@pms.hasPermission('quality_report_submit')")
    public R submit(@PathVariable Long id){
        return reportService.submit(id);
    }
 
    /**
     * 新提交检测汇报
     * @param id
     * @return
     */
    @ApiOperation(value = "新提交检测汇报", notes = "新提交检测汇报")
    @SysLog("新提交检测汇报")
    @PutMapping("/submitV2/{id}")
    @PreAuthorize("@pms.hasPermission('quality_report_submit')")
    public R submitV2(@PathVariable Long id){
        return reportService.submitV2(id);
    }
 
    /**
     * 取消提交检测汇报
     * @param id
     * @return
     */
    @ApiOperation(value = "取消提交检测汇报", notes = "取消提交检测汇报")
    @SysLog("取消提交检测汇报")
    @PutMapping("/cancelSubmit/{id}")
    @PreAuthorize("@pms.hasPermission('quality_report_cancelSubmit')")
    public R cancelSubmit(@PathVariable(name = "id") Long id){
        return reportService.cancelSubmit(id);
    }
 
    /**
     * 新取消提交检测汇报
     * @param id
     * @return
     */
    @ApiOperation(value = "新取消提交检测汇报", notes = "新取消提交检测汇报")
    @SysLog("新取消提交检测汇报")
    @PutMapping("/cancelSubmitV2/{id}")
    @PreAuthorize("@pms.hasPermission('quality_report_cancelSubmit')")
    public R cancelSubmitV2(@PathVariable(name = "id") Long id){
        return reportService.cancelSubmitV2(id);
    }
 
}