xuhy
2025-04-28 ca8e1159abe02967166a622526cf489a6fb39eab
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
package com.ruoyi.web.controller.api;
 
 
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.QAProduceReportStatusEnum;
import com.ruoyi.common.enums.QaReportFileEnum;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.AuditStatusDTO;
import com.ruoyi.system.dto.TQaProduceReportDTO;
import com.ruoyi.system.model.TQaProduceReport;
import com.ruoyi.system.model.TQaReportFile;
import com.ruoyi.system.query.TQaProduceReportQuery;
import com.ruoyi.system.service.TQaProduceReportService;
import com.ruoyi.system.service.TQaReportFileService;
import com.ruoyi.system.vo.TQaProduceReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import java.time.LocalDateTime;
import java.util.List;
 
/**
 * <p>
 * 中试、生产验证分析报告;辅料;产品报告 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-04-08
 */
@Api(tags = "中试、生产验证分析报告;辅料;产品报告管理")
@RestController
@RequestMapping("/t-qa-produce-report")
public class TQaProduceReportController {
 
    private final TQaProduceReportService qaProduceReportService;
    private final TQaReportFileService qaReportFileService;
    private final TokenService tokenService;
    @Autowired
    public TQaProduceReportController(TQaProduceReportService qaProduceReportService, TQaReportFileService qaReportFileService, TokenService tokenService) {
        this.qaProduceReportService = qaProduceReportService;
        this.qaReportFileService = qaReportFileService;
        this.tokenService = tokenService;
    }
 
    /**
     * 获取中试、生产验证分析报告;辅料;产品报告管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:list')")
    @ApiOperation(value = "获取中试、生产验证分析报告;辅料;产品报告管理分页列表")
    @PostMapping(value = "/api/t-qa-produce-report/pageList")
    public R<PageInfo<TQaProduceReportVO>> pageList(@RequestBody String param) {
        TQaProduceReportQuery query = JSON.parseObject(param, TQaProduceReportQuery.class);
        return R.ok(qaProduceReportService.pageList(query));
    }
 
    /**
     * 添加中试、生产验证分析报告;辅料;产品报告管理管理
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:add')")
    @Log(title = "中试、生产验证分析报告;辅料;产品报告管理信息-新增中试、生产验证分析报告;辅料;产品报告管理", businessType = BusinessType.INSERT)
    @ApiOperation(value = "添加中试、生产验证分析报告;辅料;产品报告管理",response = TQaProduceReportDTO.class)
    @PostMapping(value = "/api/t-qa-produce-report/add")
    public R<Boolean> add(@RequestBody String param) {
        TQaProduceReportDTO dto = JSON.parseObject(param,TQaProduceReportDTO.class);
        // TODO 生成编号
        qaProduceReportService.save(dto);
        // 添加检测报告文件
        List<TQaReportFile> qaReportFiles = dto.getQaReportFiles();
        for (TQaReportFile qaReportFile : qaReportFiles) {
            qaReportFile.setReportId(dto.getId());
            switch (QaReportFileEnum.fromCode(qaReportFile.getReportType())) {
                case TEST_REPORT:
                    qaReportFile.setReportType(QaReportFileEnum.TEST_REPORT.getCode());
                    break;
                case PILOT_PRODUCTION_VALIDATION:
                    qaReportFile.setReportType(QaReportFileEnum.PILOT_PRODUCTION_VALIDATION.getCode());
                    break;
                case RAW_MATERIAL_REPORT:
                    qaReportFile.setReportType(QaReportFileEnum.RAW_MATERIAL_REPORT.getCode());
                    break;
                case PRODUCT_APPROVAL_REPORT:
                    qaReportFile.setReportType(QaReportFileEnum.PRODUCT_APPROVAL_REPORT.getCode());
                    break;
            }
        }
        qaReportFileService.saveBatch(qaReportFiles);
        return R.ok();
    }
 
    /**
     * 修改中试、生产验证分析报告;辅料;产品报告管理
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:edit')")
    @Log(title = "中试、生产验证分析报告;辅料;产品报告管理信息-修改中试、生产验证分析报告;辅料;产品报告管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改中试、生产验证分析报告;辅料;产品报告管理")
    @PostMapping(value = "/api/t-qa-produce-report/update")
    public R<Boolean> update(@RequestBody String param) {
        TQaProduceReportDTO dto = JSON.parseObject(param,TQaProduceReportDTO.class);
        qaProduceReportService.updateById(dto);
        qaReportFileService.remove(Wrappers.lambdaQuery(TQaReportFile.class)
                .eq(TQaReportFile::getReportId, dto.getId()));
        // 添加检测报告文件
        List<TQaReportFile> qaReportFiles = dto.getQaReportFiles();
        for (TQaReportFile qaReportFile : qaReportFiles) {
            qaReportFile.setReportId(dto.getId());
            switch (QaReportFileEnum.fromCode(qaReportFile.getReportType())) {
                case TEST_REPORT:
                    qaReportFile.setReportType(QaReportFileEnum.TEST_REPORT.getCode());
                    break;
                case PILOT_PRODUCTION_VALIDATION:
                    qaReportFile.setReportType(QaReportFileEnum.PILOT_PRODUCTION_VALIDATION.getCode());
                    break;
                case RAW_MATERIAL_REPORT:
                    qaReportFile.setReportType(QaReportFileEnum.RAW_MATERIAL_REPORT.getCode());
                    break;
                case PRODUCT_APPROVAL_REPORT:
                    qaReportFile.setReportType(QaReportFileEnum.PRODUCT_APPROVAL_REPORT.getCode());
                    break;
            }
        }
        qaReportFileService.saveBatch(qaReportFiles);
        return R.ok();
    }
 
    /**
     * 查看中试、生产验证分析报告;辅料;产品报告管理详情
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:detail')")
    @ApiOperation(value = "查看中试、生产验证分析报告;辅料;产品报告管理详情")
    @GetMapping(value = "/open/t-qa-produce-report/getDetailById")
    public R<TQaProduceReportVO> getDetailById(@RequestParam String id) {
        TQaProduceReport qaProduceReport = qaProduceReportService.getById(id);
        TQaProduceReportVO qaProduceReportVO = new TQaProduceReportVO();
        BeanUtils.copyProperties(qaProduceReport, qaProduceReportVO);
        // 查询报告文件
        List<TQaReportFile> qaReportFiles = qaReportFileService.list(Wrappers.lambdaQuery(TQaReportFile.class)
                .eq(TQaReportFile::getReportId, id)
                .ne(TQaReportFile::getReportType, QaReportFileEnum.TEST_REPORT.getCode()));
        qaProduceReportVO.setQaReportFileList(qaReportFiles);
        return R.ok(qaProduceReportVO);
    }
 
    /**
     * 删除中试、生产验证分析报告;辅料;产品报告管理
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:delete')")
    @Log(title = "中试、生产验证分析报告;辅料;产品报告管理信息-删除中试、生产验证分析报告;辅料;产品报告管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除中试、生产验证分析报告;辅料;产品报告管理")
    @DeleteMapping(value = "/open/t-qa-produce-report/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        // 删除中试、生产验证分析报告;辅料;产品报告管理文件
        qaReportFileService.remove(Wrappers.lambdaQuery(TQaReportFile.class).eq(TQaReportFile::getReportId, id)
                .notIn(TQaReportFile::getReportType, QaReportFileEnum.TEST_REPORT.getCode()));
        return R.ok(qaProduceReportService.removeById(id));
    }
 
    /**
     * 批量删除中试、生产验证分析报告;辅料;产品报告管理
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:delete')")
    @Log(title = "中试、生产验证分析报告;辅料;产品报告管理信息-删除中试、生产验证分析报告;辅料;产品报告管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除中试、生产验证分析报告;辅料;产品报告管理")
    @DeleteMapping(value = "/open/t-qa-produce-report/deleteByIds")
    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
        // 删除QA检测项报告检测报告
        qaReportFileService.remove(Wrappers.lambdaQuery(TQaReportFile.class).in(TQaReportFile::getReportId, ids)
                .notIn(TQaReportFile::getReportType, QaReportFileEnum.TEST_REPORT.getCode()));
        return R.ok(qaProduceReportService.removeByIds(ids));
    }
 
    /**
     * 撤销中试、生产验证分析报告;辅料;产品报告管理
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:revokedReport')")
    @Log(title = "中试、生产验证分析报告;辅料;产品报告管理信息-撤销中试、生产验证分析报告;辅料;产品报告管理状态", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "撤销中试、生产验证分析报告;辅料;产品报告管理状态")
    @PutMapping(value = "/open/t-qa-produce-report/revokedReport")
    public R<Boolean> revokedReport(@RequestParam String id) {
        TQaProduceReport qaProduceReport = qaProduceReportService.getById(id);
        qaProduceReport.setStatus(QAProduceReportStatusEnum.REVOKED.getCode());
        qaProduceReportService.updateById(qaProduceReport);
        return R.ok();
    }
 
    /**
     * 审核中试、生产验证分析报告;辅料;产品报告管理
     */
    @PreAuthorize("@ss.hasPermi('system:qaProduceReport:auditReport')")
    @Log(title = "中试、生产验证分析报告;辅料;产品报告管理信息-审核中试、生产验证分析报告;辅料;产品报告管理状态", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "审核中试、生产验证分析报告;辅料;产品报告管理状态")
    @PostMapping(value = "/api/t-qa-produce-report/auditReport")
    public R<Boolean> auditReport(@RequestBody String param) {
        Long userId = tokenService.getLoginUser().getUserId();
        AuditStatusDTO dto = JSON.parseObject(param,AuditStatusDTO.class);
        TQaProduceReport qaProduceReport = qaProduceReportService.getById(dto.getId());
        qaProduceReport.setStatus(dto.getAuditStatus());
        qaProduceReport.setAuditRemark(dto.getAuditRemark());
        qaProduceReport.setAuditPersonId(userId);
        qaProduceReport.setAuditTime(LocalDateTime.now());
        qaProduceReportService.updateById(qaProduceReport);
        return R.ok();
    }
    
}