| | |
| | | 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.*; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.AuditStatusDTO; |
| | | import com.ruoyi.system.dto.TQaProduceReportDTO; |
| | | import com.ruoyi.system.dto.TQaProduceReportEvaluateDTO; |
| | | import com.ruoyi.system.model.TProjectTeam; |
| | | import com.ruoyi.system.model.TProjectTeamStaff; |
| | | import com.ruoyi.system.model.TQaProduceReport; |
| | | import com.ruoyi.system.model.TQaReportFile; |
| | | import com.ruoyi.system.query.TQaProduceReportQuery; |
| | | import com.ruoyi.system.service.TProjectTeamService; |
| | | import com.ruoyi.system.service.TProjectTeamStaffService; |
| | | import com.ruoyi.system.service.TQaProduceReportService; |
| | | import com.ruoyi.system.service.TQaReportFileService; |
| | | import com.ruoyi.system.vo.TQaProduceReportVO; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Api(tags = "中试、生产验证分析报告;辅料;产品报告管理") |
| | | @RestController |
| | | @RequestMapping("/t-qa-produce-report") |
| | | @RequestMapping("") |
| | | public class TQaProduceReportController { |
| | | |
| | | private final TQaProduceReportService qaProduceReportService; |
| | | private final TQaReportFileService qaReportFileService; |
| | | private final TokenService tokenService; |
| | | private final TProjectTeamService projectTeamService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | @Autowired |
| | | public TQaProduceReportController(TQaProduceReportService qaProduceReportService, TQaReportFileService qaReportFileService, TokenService tokenService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService) { |
| | | this.qaProduceReportService = qaProduceReportService; |
| | | this.qaReportFileService = qaReportFileService; |
| | | this.tokenService = tokenService; |
| | | this.projectTeamService = projectTeamService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | } |
| | | |
| | | /** |
| | | * 获取中试、生产验证分析报告;辅料;产品报告管理列表 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:qaProduceReport:list')") |
| | | @ApiOperation(value = "获取中试、生产验证分析报告;辅料;产品报告管理分页列表", response = TQaProduceReportQuery.class) |
| | | @PostMapping(value = "/api/t-qa-produce-report/pageList") |
| | | public R<PageInfo<TQaProduceReportVO>> pageList(@RequestBody String param) { |
| | | TQaProduceReportQuery query = JSON.parseObject(param, TQaProduceReportQuery.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType != 1){ |
| | | // 查询用户所在项目组 |
| | | List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | if(projectTeamStaffs.size() > 0){ |
| | | // 查询项目组id |
| | | List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList()); |
| | | query.setTeamIds(teamIds); |
| | | } |
| | | } |
| | | return R.ok(qaProduceReportService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取中试、生产验证分析报告;辅料;产品报告管理评定列表 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:qaProduceReport:evaluateList')") |
| | | @ApiOperation(value = "获取中试、生产验证分析报告;辅料;产品报告管理评定列表", response = TQaProduceReportQuery.class) |
| | | @PostMapping(value = "/api/t-qa-produce-report/evaluateList") |
| | | public R<PageInfo<TQaProduceReportVO>> evaluateList(@RequestBody String param) { |
| | | TQaProduceReportQuery query = JSON.parseObject(param, TQaProduceReportQuery.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType != 1){ |
| | | // 查询用户所在项目组 |
| | | List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | if(projectTeamStaffs.size() > 0){ |
| | | // 查询项目组id |
| | | List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList()); |
| | | query.setTeamIds(teamIds); |
| | | } |
| | | } |
| | | return R.ok(qaProduceReportService.evaluateList(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); |
| | | // 通过当前用户查询项目组 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(projectTeamStaff)){ |
| | | return R.fail("当前用户未分配项目组,无法创建项目课题方案"); |
| | | } |
| | | // 查询项目组 |
| | | TProjectTeam projectTeam = projectTeamService.getById(projectTeamStaff.getTeamId()); |
| | | if(Objects.isNull(projectTeam)){ |
| | | return R.fail("项目组不存在"); |
| | | } |
| | | if(projectTeam.getStatus() == 2){ |
| | | return R.fail("项目组已封存,无法创建项目课题方案"); |
| | | } |
| | | // 生成中试、生产验证编号 |
| | | String reportCode = ""; |
| | | switch (dto.getReportType()){ |
| | | case 1: |
| | | reportCode = projectTeam.getTeamName() + "-" + QaReportTypeEnum.TEST_PILOT.getCode(); |
| | | break; |
| | | case 2: |
| | | reportCode = projectTeam.getTeamName() + "-" + QaReportTypeEnum.PRODUCTION_VERIFICATION_ANALYSIS_REPORT.getCode(); |
| | | break; |
| | | default: |
| | | reportCode = projectTeam.getTeamName() + "-" + QaReportTypeEnum.AUXILIARY_MATERIALS.getCode(); |
| | | break; |
| | | } |
| | | |
| | | // 查询上个项目课题方案的序号 |
| | | long count = qaProduceReportService.count(Wrappers.lambdaQuery(TQaProduceReport.class) |
| | | .like(TQaProduceReport::getReportCode, reportCode)); |
| | | reportCode = reportCode + "-" + String.format("%03d", count+1); |
| | | dto.setReportCode(reportCode); |
| | | 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(); |
| | | } |
| | | |
| | | /** |
| | | * 评定QA检测项管理 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:qaTestItem:evaluate')") |
| | | @Log(title = "中试、生产验证分析报告;辅料;产品报告管理信息-评定中试、生产验证分析报告;辅料;产品报告管理信息", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "评定QA检测项管理",response = TQaProduceReportEvaluateDTO.class) |
| | | @PostMapping(value = "/api/t-qa-produce-report/evaluate") |
| | | public R<Boolean> evaluate(@RequestBody String param) { |
| | | TQaProduceReportEvaluateDTO dto = JSON.parseObject(param,TQaProduceReportEvaluateDTO.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TQaProduceReport qaProduceReport = qaProduceReportService.getById(dto); |
| | | qaProduceReport.setStatus(QAProduceReportStatusEnum.EVALUATED.getCode()); |
| | | qaProduceReport.setEvaluatePersonId(userId); |
| | | qaProduceReport.setEvaluateTime(LocalDateTime.now()); |
| | | qaProduceReport.setEvaluateScore(dto.getEvaluateScore()); |
| | | qaProduceReportService.updateById(qaProduceReport); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |