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();
|
}
|
|
}
|