From 2fa7f761cf80802f54f727381b282d3b264501a7 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 08 十月 2026 11:11:26 +0800
Subject: [PATCH] 提交最新代码
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TQaTestItemReportController.java | 170 ++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 139 insertions(+), 31 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TQaTestItemReportController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TQaTestItemReportController.java
index 1f26a77..044b018 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TQaTestItemReportController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TQaTestItemReportController.java
@@ -6,29 +6,28 @@
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.QATestItemReportStatusEnum;
import com.ruoyi.common.enums.QaReportFileEnum;
+import com.ruoyi.common.enums.QaReportTypeEnum;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.AuditStatusDTO;
import com.ruoyi.system.dto.TQaTestItemReportDTO;
-import com.ruoyi.system.mapper.TQaReportFileMapper;
-import com.ruoyi.system.model.TProjectProposal;
-import com.ruoyi.system.model.TQaReportFile;
-import com.ruoyi.system.model.TQaTestItemReport;
+import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TQaTestItemReportQuery;
-import com.ruoyi.system.service.TQaReportFileService;
-import com.ruoyi.system.service.TQaTestItemReportService;
+import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.TQaTestItemReportVO;
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.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
+import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -47,60 +46,128 @@
private final TQaTestItemReportService qaTestItemReportService;
private final TQaReportFileService qaReportFileService;
private final TokenService tokenService;
+ private final TProjectTeamService projectTeamService;
+ private final TProjectTeamStaffService projectTeamStaffService;
+ private final ISysUserService sysUserService;
+ private final TQaTestItemService qaTestItemService;
+ private final TNoticeService noticeService;
@Autowired
- public TQaTestItemReportController(TQaTestItemReportService qaTestItemReportService, TQaReportFileService qaReportFileService, TokenService tokenService) {
+ public TQaTestItemReportController(TQaTestItemReportService qaTestItemReportService, TQaReportFileService qaReportFileService, TokenService tokenService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, ISysUserService sysUserService, TQaTestItemService qaTestItemService, TNoticeService noticeService) {
this.qaTestItemReportService = qaTestItemReportService;
this.qaReportFileService = qaReportFileService;
this.tokenService = tokenService;
+ this.projectTeamService = projectTeamService;
+ this.projectTeamStaffService = projectTeamStaffService;
+ this.sysUserService = sysUserService;
+ this.qaTestItemService = qaTestItemService;
+ this.noticeService = noticeService;
}
/**
* 获取QA检测项报告管理列表
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:list')")
- @ApiOperation(value = "获取QA检测项报告管理分页列表-工艺工程师使用")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:list')")
+ @ApiOperation(value = "获取QA检测项报告管理分页列表-工艺工程师使用", response = TQaTestItemReportQuery.class)
@PostMapping(value = "/api/t-qa-test-item-report/pageList")
public R<PageInfo<TQaTestItemReportVO>> pageList(@RequestBody String param) {
TQaTestItemReportQuery query = JSON.parseObject(param, TQaTestItemReportQuery.class);
+ Long userId = tokenService.getLoginUser().getUserId();
+ Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+ query.setRoleType(roleType);
+ if(roleType != 1){
+ // 查询用户所在项目组
+ List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class)
+ .eq(TProjectTeamStaff::getUserId, userId));
+ if(!projectTeamStaffs.isEmpty()){
+ // 查询项目组id
+ List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList());
+ query.setTeamIds(teamIds);
+ }
+ }
return R.ok(qaTestItemReportService.pageList(query));
}
/**
* 获取QA检测项报告管理列表
*/
- @ApiOperation(value = "获取QA检测项报告管理下拉列表-化验师使用")
+ @ApiOperation(value = "获取QA检测项报告管理下拉列表-化验师使用、评定使用")
@GetMapping(value = "/open/t-qa-test-item-report/getListByItemId")
- public R<List<TQaTestItemReport>> getListByItemId(@RequestParam String itemId) {
- List<TQaTestItemReport> list = qaTestItemReportService.list(Wrappers.lambdaQuery(TQaTestItemReport.class)
- .eq(TQaTestItemReport::getItemId, itemId));
+ public R<List<TQaTestItemReportVO>> getListByItemId(@RequestParam String itemId) {
+ List<TQaTestItemReportVO> list = qaTestItemReportService.getListByItemId(itemId);
+ if(!CollectionUtils.isEmpty(list)){
+ List<SysUser> sysUsers = sysUserService.selectList();
+ list.forEach(itemReport -> {
+ SysUser sysUser = sysUsers.stream().filter(user -> user.getUserId().equals(itemReport.getAuditPersonId())).findFirst().orElse(null);
+ if(Objects.nonNull(sysUser)){
+ itemReport.setAuditPersonName(sysUser.getNickName());
+ }
+ });
+ }
+ return R.ok(list);
+ }
+
+ /**
+ * 获取QA检测项报告管理列表 草稿箱里面的
+ */
+ @ApiOperation(value = "获取QA检测项报告管理下拉列表-化验师使用、评定使用 草稿箱里面的")
+ @GetMapping(value = "/open/t-qa-test-item-report-draft/getListByItemId")
+ public R<List<TQaTestItemReportVO>> getListByItemIdDraft(@RequestParam String itemId) {
+ List<TQaTestItemReportVO> list = qaTestItemReportService.getListByItemIdDraft(itemId);
+ if(!CollectionUtils.isEmpty(list)){
+ List<SysUser> sysUsers = sysUserService.selectList();
+ list.forEach(itemReport -> {
+ SysUser sysUser = sysUsers.stream().filter(user -> user.getUserId().equals(itemReport.getAuditPersonId())).findFirst().orElse(null);
+ if(Objects.nonNull(sysUser)){
+ itemReport.setAuditPersonName(sysUser.getNickName());
+ }
+ });
+ }
return R.ok(list);
}
/**
* 添加QA检测项报告管理管理
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:add')")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:add')")
@Log(title = "QA检测项报告管理信息-新增QA检测项报告管理", businessType = BusinessType.INSERT)
@ApiOperation(value = "添加QA检测项报告管理",response = TQaTestItemReportDTO.class)
@PostMapping(value = "/api/t-qa-test-item-report/add")
public R<Boolean> add(@RequestBody String param) {
TQaTestItemReportDTO dto = JSON.parseObject(param,TQaTestItemReportDTO.class);
- // TODO 生成编号
+ // 查询项目组
+ TProjectTeam projectTeam = projectTeamService.getById(dto.getTeamId());
+ if(Objects.isNull(projectTeam)){
+ return R.fail("项目组不存在");
+ }
+ if(projectTeam.getStatus() == 2){
+ return R.fail("项目组已封存,无法创建项目课题方案");
+ }
+ // 生成中试、生产验证编号
+ String reportCode = projectTeam.getTeamName() + "-" + QaReportTypeEnum.TEST_REPORT.getCode();
+
+ // 查询上个项目课题方案的序号
+ long count = qaTestItemReportService.count(Wrappers.lambdaQuery(TQaTestItemReport.class)
+ .like(TQaTestItemReport::getReportCode, reportCode));
+ reportCode = reportCode + "-" + String.format("%03d", count+1);
+ dto.setReportCode(reportCode);
+
qaTestItemReportService.save(dto);
// 添加检测报告文件
List<TQaReportFile> qaReportFiles = dto.getQaReportFiles();
- for (TQaReportFile qaReportFile : qaReportFiles) {
- qaReportFile.setReportId(dto.getId());
- qaReportFile.setReportType(QaReportFileEnum.TEST_REPORT.getCode());
+ if(!CollectionUtils.isEmpty(qaReportFiles)){
+ for (TQaReportFile qaReportFile : qaReportFiles) {
+ qaReportFile.setReportId(dto.getId());
+ qaReportFile.setReportType(QaReportFileEnum.TEST_REPORT.getCode());
+ }
+ qaReportFileService.saveBatch(qaReportFiles);
}
- qaReportFileService.saveBatch(qaReportFiles);
return R.ok();
}
/**
* 修改QA检测项报告管理
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:edit')")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:edit')")
@Log(title = "QA检测项报告管理信息-修改QA检测项报告管理", businessType = BusinessType.UPDATE)
@ApiOperation(value = "修改QA检测项报告管理")
@PostMapping(value = "/api/t-qa-test-item-report/update")
@@ -111,18 +178,20 @@
.eq(TQaReportFile::getReportId, dto.getId()));
// 添加检测报告文件
List<TQaReportFile> qaReportFiles = dto.getQaReportFiles();
- for (TQaReportFile qaReportFile : qaReportFiles) {
- qaReportFile.setReportId(dto.getId());
- qaReportFile.setReportType(QaReportFileEnum.TEST_REPORT.getCode());
+ if(!CollectionUtils.isEmpty(qaReportFiles)){
+ for (TQaReportFile qaReportFile : qaReportFiles) {
+ qaReportFile.setReportId(dto.getId());
+ qaReportFile.setReportType(QaReportFileEnum.TEST_REPORT.getCode());
+ }
+ qaReportFileService.saveBatch(qaReportFiles);
}
- qaReportFileService.saveBatch(qaReportFiles);
return R.ok();
}
/**
* 查看QA检测项报告管理详情
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:detail')")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:detail')")
@ApiOperation(value = "查看QA检测项报告管理详情")
@GetMapping(value = "/open/t-qa-test-item-report/getDetailById")
public R<TQaTestItemReportVO> getDetailById(@RequestParam String id) {
@@ -134,17 +203,32 @@
.eq(TQaReportFile::getReportId, id)
.eq(TQaReportFile::getReportType, QaReportFileEnum.TEST_REPORT.getCode()));
testItemReportVO.setQaReportFileList(qaReportFiles);
+ // 查询审批人姓名
+ SysUser sysUser = sysUserService.selectUserById(testItemReportVO.getAuditPersonId());
+ if(Objects.nonNull(sysUser)){
+ testItemReportVO.setAuditPersonName(sysUser.getNickName());
+ }
return R.ok(testItemReportVO);
}
/**
* 删除QA检测项报告管理
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:delete')")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:delete')")
@Log(title = "QA检测项报告管理信息-删除QA检测项报告管理", businessType = BusinessType.DELETE)
@ApiOperation(value = "删除QA检测项报告管理")
@DeleteMapping(value = "/open/t-qa-test-item-report/deleteById")
public R<Boolean> deleteById(@RequestParam String id) {
+ TQaTestItemReport report = qaTestItemReportService.getById(id);
+ if (Objects.isNull(report)) {
+ return R.fail("检测项报告不存在");
+ }
+ Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+ if (Objects.equals(roleType, 1)
+ && !Objects.equals(report.getStatus(), QATestItemReportStatusEnum.PENDING_APPROVAL.getCode())
+ && !Objects.equals(report.getStatus(), QATestItemReportStatusEnum.PASSED.getCode())) {
+ return R.fail("超级管理员只能删除待审核或已审核的报告");
+ }
// 删除QA检测项报告文件
qaReportFileService.remove(Wrappers.lambdaQuery(TQaReportFile.class).eq(TQaReportFile::getReportId, id)
.in(TQaReportFile::getReportType, QaReportFileEnum.TEST_REPORT.getCode()));
@@ -154,11 +238,22 @@
/**
* 批量删除QA检测项报告管理
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:delete')")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:delete')")
@Log(title = "QA检测项报告管理信息-删除QA检测项报告管理", businessType = BusinessType.DELETE)
@ApiOperation(value = "批量删除QA检测项报告管理")
@DeleteMapping(value = "/open/t-qa-test-item-report/deleteByIds")
public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
+ Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+ if (Objects.equals(roleType, 1)) {
+ long deletableCount = qaTestItemReportService.count(Wrappers.lambdaQuery(TQaTestItemReport.class)
+ .in(TQaTestItemReport::getId, ids)
+ .in(TQaTestItemReport::getStatus,
+ QATestItemReportStatusEnum.PENDING_APPROVAL.getCode(),
+ QATestItemReportStatusEnum.PASSED.getCode()));
+ if (deletableCount != ids.size()) {
+ return R.fail("超级管理员只能删除待审核或已审核的报告");
+ }
+ }
// 删除QA检测项报告检测报告文件
qaReportFileService.remove(Wrappers.lambdaQuery(TQaReportFile.class).in(TQaReportFile::getReportId, ids)
.in(TQaReportFile::getReportType, QaReportFileEnum.TEST_REPORT.getCode()));
@@ -168,13 +263,13 @@
/**
* 撤销QA检测项报告管理
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:revokedReport')")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:revokedReport')")
@Log(title = "QA检测项报告管理信息-撤销QA检测项报告管理状态", businessType = BusinessType.UPDATE)
@ApiOperation(value = "撤销QA检测项报告管理状态")
@PutMapping(value = "/open/t-qa-test-item-report/revokedReport")
public R<Boolean> revokedReport(@RequestParam String id) {
TQaTestItemReport testItemReport = qaTestItemReportService.getById(id);
- testItemReport.setStatus(QATestItemReportStatusEnum.REVOKED.getCode());
+ testItemReport.setStatus(QATestItemReportStatusEnum.DRAFTS.getCode());
qaTestItemReportService.updateById(testItemReport);
return R.ok();
}
@@ -182,7 +277,7 @@
/**
* 审核QA检测项报告管理
*/
- @PreAuthorize("@ss.hasPermi('system:qaTestItemReport:auditReport')")
+ //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:auditReport')")
@Log(title = "QA检测项报告管理信息-审核QA检测项报告管理状态", businessType = BusinessType.UPDATE)
@ApiOperation(value = "审核QA检测项报告管理状态")
@PostMapping(value = "/api/t-qa-test-item-report/auditReport")
@@ -195,6 +290,19 @@
testItemReport.setAuditPersonId(userId);
testItemReport.setAuditTime(LocalDateTime.now());
qaTestItemReportService.updateById(testItemReport);
+
+ // 查询检测项
+ TQaTestItem testItem = qaTestItemService.getById(testItemReport.getItemId());
+ // 查询项目组
+ TProjectTeam projectTeam = projectTeamService.getById(testItem.getTeamId());
+ // MESSAGE 添加消息
+ TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class)
+ .eq(TProjectTeamStaff::getTeamId, projectTeam.getId())
+ .eq(TProjectTeamStaff::getRoleType, 3)
+ .last("LIMIT 1"));
+ noticeService.saveNotice(teamStaff.getUserId(), "您有【1】条【项目检测项、检验包列表】等待评定", tokenService.getLoginUser().getUser().getNickName(),5);
+
+
return R.ok();
}
--
Gitblit v1.7.1