测试修改完成
This commit is contained in:
parent
36b6dce7d6
commit
ec41c6596c
|
|
@ -52,7 +52,7 @@ public class QmsCoaReviewController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改COA审核记录
|
* 修改COA内容
|
||||||
* 状态0时都可以改,状态3时只能改COA报告
|
* 状态0时都可以改,状态3时只能改COA报告
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
@ -86,12 +86,23 @@ public class QmsCoaReviewController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询(只返回当前账号的数据)
|
* 分页查询-供应商
|
||||||
* 支持供应商编号/名称、采购单号、物料编码过滤,供应商名称模糊查询
|
* 供应商查看自己创建的审核记录
|
||||||
|
* 支持供应商编号/名称、采购单号、物料编码过滤
|
||||||
*/
|
*/
|
||||||
@PostMapping("search")
|
@PostMapping("searchForSupplier")
|
||||||
public ApiResult<PageData<QmsCoaReviewVO>> search(@Valid @RequestBody QmsCoaReviewSearchQO qo) {
|
public ApiResult<PageData<QmsCoaReviewVO>> searchForSupplier(@Valid @RequestBody QmsCoaReviewSearchQO qo) {
|
||||||
return ApiResult.success(coaReviewService.search(qo));
|
return ApiResult.success(coaReviewService.searchForSupplier(qo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询-SQE
|
||||||
|
* SQE查看待审核的记录(基于task.user_id)
|
||||||
|
* 支持供应商编号/名称、采购单号、物料编码过滤
|
||||||
|
*/
|
||||||
|
@PostMapping("searchForSqe")
|
||||||
|
public ApiResult<PageData<QmsCoaReviewVO>> searchForSqe(@Valid @RequestBody QmsCoaReviewSearchQO qo) {
|
||||||
|
return ApiResult.success(coaReviewService.searchForSqe(qo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.wms.common.pojo.qo;
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -10,7 +11,13 @@ import lombok.Data;
|
||||||
public class QmsCoaReviewAddQO {
|
public class QmsCoaReviewAddQO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料编码(必传,用于查询 qms_qc_material.id)
|
* 任务ID(关联 qms_coa_task.id,必传)
|
||||||
|
*/
|
||||||
|
@NotNull(message = "任务ID不能为空")
|
||||||
|
private Long taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编码(必传,用于与任务中的物料进行校验)
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "物料编码不能为空")
|
@NotBlank(message = "物料编码不能为空")
|
||||||
private String materialNo;
|
private String materialNo;
|
||||||
|
|
@ -21,6 +28,12 @@ public class QmsCoaReviewAddQO {
|
||||||
@NotBlank(message = "采购单号不能为空")
|
@NotBlank(message = "采购单号不能为空")
|
||||||
private String purchaseNo;
|
private String purchaseNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次号(必传)
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "批次号不能为空")
|
||||||
|
private String batchNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COA报告/文件地址(必传)
|
* COA报告/文件地址(必传)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ public class QmsCoaReviewDetailVO {
|
||||||
*/
|
*/
|
||||||
private String purchaseNo;
|
private String purchaseNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次号
|
||||||
|
*/
|
||||||
|
private String batchNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料编码
|
* 物料编码
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ public class QmsCoaReviewVO {
|
||||||
*/
|
*/
|
||||||
private String purchaseNo;
|
private String purchaseNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次号
|
||||||
|
*/
|
||||||
|
private String batchNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料编码
|
* 物料编码
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,11 @@ public class QmsCoaReview implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String purchaseNo;
|
private String purchaseNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次号
|
||||||
|
*/
|
||||||
|
private String batchNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COA审核状态:0=待提交,1=待审核,2=已通过,3=已驳回
|
* COA审核状态:0=待提交,1=待审核,2=已通过,3=已驳回
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,14 @@ public interface IQmsCoaReviewService extends IService<QmsCoaReview> {
|
||||||
void audit(QmsCoaReviewAuditQO qo);
|
void audit(QmsCoaReviewAuditQO qo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询(只返回当前账号的数据)
|
* 分页查询-供应商(供应商查看自己创建的审核记录)
|
||||||
*/
|
*/
|
||||||
PageData<QmsCoaReviewVO> search(QmsCoaReviewSearchQO qo);
|
PageData<QmsCoaReviewVO> searchForSupplier(QmsCoaReviewSearchQO qo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询-SQE(SQE查看待审核的记录,基于task.user_id)
|
||||||
|
*/
|
||||||
|
PageData<QmsCoaReviewVO> searchForSqe(QmsCoaReviewSearchQO qo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按ID查详情
|
* 按ID查详情
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.wms.repository.service.impl;
|
package com.nflg.wms.repository.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -13,11 +14,13 @@ import com.nflg.wms.common.pojo.qo.QmsCoaReviewUpdateQO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsCoaReviewDetailVO;
|
import com.nflg.wms.common.pojo.vo.QmsCoaReviewDetailVO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsCoaReviewVO;
|
import com.nflg.wms.common.pojo.vo.QmsCoaReviewVO;
|
||||||
import com.nflg.wms.common.util.UserUtil;
|
import com.nflg.wms.common.util.UserUtil;
|
||||||
|
import com.nflg.wms.repository.entity.QmsCoaTask;
|
||||||
import com.nflg.wms.repository.entity.QmsCoaReview;
|
import com.nflg.wms.repository.entity.QmsCoaReview;
|
||||||
import com.nflg.wms.repository.entity.QmsQcMaterial;
|
import com.nflg.wms.repository.entity.QmsQcMaterial;
|
||||||
import com.nflg.wms.repository.entity.User;
|
import com.nflg.wms.repository.entity.User;
|
||||||
import com.nflg.wms.repository.entity.UserSupplier;
|
import com.nflg.wms.repository.entity.UserSupplier;
|
||||||
import com.nflg.wms.repository.mapper.QmsCoaReviewMapper;
|
import com.nflg.wms.repository.mapper.QmsCoaReviewMapper;
|
||||||
|
import com.nflg.wms.repository.service.IQmsCoaTaskService;
|
||||||
import com.nflg.wms.repository.service.IQmsCoaReviewService;
|
import com.nflg.wms.repository.service.IQmsCoaReviewService;
|
||||||
import com.nflg.wms.repository.service.IQmsQcMaterialService;
|
import com.nflg.wms.repository.service.IQmsQcMaterialService;
|
||||||
import com.nflg.wms.repository.service.IUserService;
|
import com.nflg.wms.repository.service.IUserService;
|
||||||
|
|
@ -49,12 +52,34 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
@Resource
|
@Resource
|
||||||
private IUserService userService;
|
private IUserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IQmsCoaTaskService coaTaskService;
|
||||||
|
|
||||||
// ==================== 新增 ====================
|
// ==================== 新增 ====================
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void add(QmsCoaReviewAddQO qo) {
|
public void add(QmsCoaReviewAddQO qo) {
|
||||||
// 按物料编码查物料
|
Long currentUserId = UserUtil.getUserId();
|
||||||
|
|
||||||
|
// 1. 查询COA任务
|
||||||
|
QmsCoaTask task = coaTaskService.getById(qo.getTaskId());
|
||||||
|
if (Objects.isNull(task) || Boolean.TRUE.equals(task.getDeleted())) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "COA任务不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 验证任务状态:状态0(待发送)不能新建
|
||||||
|
if (Objects.equals(task.getStatus(), 0)) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "任务状态为待发送,无法新建COA审核");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 验证当前账号是否与任务中的供应商一致
|
||||||
|
UserSupplier supplier = userSupplierService.getById(task.getSupplierId());
|
||||||
|
if (Objects.isNull(supplier) || !Objects.equals(supplier.getUserId(), currentUserId)) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "当前账号与任务中的供应商不匹配,无权操作此任务");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 根据物料编码查询 qms_qc_material 表获取物料ID
|
||||||
QmsQcMaterial material = qcMaterialService.lambdaQuery()
|
QmsQcMaterial material = qcMaterialService.lambdaQuery()
|
||||||
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
|
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
|
||||||
.last("LIMIT 1")
|
.last("LIMIT 1")
|
||||||
|
|
@ -63,13 +88,32 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
throw new NflgException(STATE.BusinessError, "物料编码不存在:" + qo.getMaterialNo());
|
throw new NflgException(STATE.BusinessError, "物料编码不存在:" + qo.getMaterialNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 5. 验证物料ID是否与任务中的物料ID一致
|
||||||
|
if (!Objects.equals(task.getMaterialId(), material.getId())) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "物料编码与任务中的物料不匹配");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 校验批次号唯一性:同task_id + 同采购单号 + 同批次号 不能重复
|
||||||
|
boolean exists = lambdaQuery()
|
||||||
|
.eq(QmsCoaReview::getTaskId, qo.getTaskId())
|
||||||
|
.eq(QmsCoaReview::getPurchaseNo, qo.getPurchaseNo())
|
||||||
|
.eq(QmsCoaReview::getBatchNo, qo.getBatchNo())
|
||||||
|
.ne(QmsCoaReview::getDeleted, true)
|
||||||
|
.exists();
|
||||||
|
if (exists) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "该采购单号下已存在相同批次号,无法重复新增");
|
||||||
|
}
|
||||||
|
|
||||||
String operator = UserUtil.getUserName();
|
String operator = UserUtil.getUserName();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
QmsCoaReview review = new QmsCoaReview()
|
QmsCoaReview review = new QmsCoaReview()
|
||||||
|
.setTaskId(qo.getTaskId())
|
||||||
|
.setSupplierId(task.getSupplierId())
|
||||||
.setMaterialId(material.getId())
|
.setMaterialId(material.getId())
|
||||||
.setUserId(UserUtil.getUserId())
|
.setUserId(currentUserId)
|
||||||
.setPurchaseNo(qo.getPurchaseNo())
|
.setPurchaseNo(qo.getPurchaseNo())
|
||||||
|
.setBatchNo(qo.getBatchNo())
|
||||||
.setCoaFile(qo.getCoaFile())
|
.setCoaFile(qo.getCoaFile())
|
||||||
.setStatus(0)
|
.setStatus(0)
|
||||||
.setDeleted(false)
|
.setDeleted(false)
|
||||||
|
|
@ -89,6 +133,9 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
if (Objects.isNull(review) || Boolean.TRUE.equals(review.getDeleted())) {
|
if (Objects.isNull(review) || Boolean.TRUE.equals(review.getDeleted())) {
|
||||||
throw new NflgException(STATE.BusinessError, "记录不存在");
|
throw new NflgException(STATE.BusinessError, "记录不存在");
|
||||||
}
|
}
|
||||||
|
// 校验供应商权限
|
||||||
|
validateSupplierPermission(review.getSupplierId());
|
||||||
|
|
||||||
if (!Objects.equals(review.getStatus(), 0)) {
|
if (!Objects.equals(review.getStatus(), 0)) {
|
||||||
throw new NflgException(STATE.BusinessError, "当前状态不允许删除,只有待提交(状态0)的记录才能删除");
|
throw new NflgException(STATE.BusinessError, "当前状态不允许删除,只有待提交(状态0)的记录才能删除");
|
||||||
}
|
}
|
||||||
|
|
@ -109,6 +156,8 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
if (Objects.isNull(review) || Boolean.TRUE.equals(review.getDeleted())) {
|
if (Objects.isNull(review) || Boolean.TRUE.equals(review.getDeleted())) {
|
||||||
throw new NflgException(STATE.BusinessError, "记录不存在");
|
throw new NflgException(STATE.BusinessError, "记录不存在");
|
||||||
}
|
}
|
||||||
|
// 校验供应商权限
|
||||||
|
validateSupplierPermission(review.getSupplierId());
|
||||||
|
|
||||||
Integer status = review.getStatus();
|
Integer status = review.getStatus();
|
||||||
String operator = UserUtil.getUserName();
|
String operator = UserUtil.getUserName();
|
||||||
|
|
@ -162,24 +211,44 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
if (ids == null || ids.isEmpty()) {
|
if (ids == null || ids.isEmpty()) {
|
||||||
throw new NflgException(STATE.BusinessError, "提交ID列表不能为空");
|
throw new NflgException(STATE.BusinessError, "提交ID列表不能为空");
|
||||||
}
|
}
|
||||||
// 校验所有记录状态是否为0
|
// 校验所有记录状态是否为0,并收集taskId
|
||||||
List<QmsCoaReview> reviews = lambdaQuery()
|
List<QmsCoaReview> reviews = lambdaQuery()
|
||||||
.in(QmsCoaReview::getId, ids)
|
.in(QmsCoaReview::getId, ids)
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
|
Set<Long> taskIds = new java.util.HashSet<>();
|
||||||
for (QmsCoaReview r : reviews) {
|
for (QmsCoaReview r : reviews) {
|
||||||
if (!Objects.equals(r.getStatus(), 0)) {
|
if (!Objects.equals(r.getStatus(), 0)) {
|
||||||
throw new NflgException(STATE.BusinessError, "ID=" + r.getId() + " 的记录不是待提交状态,无法提交");
|
throw new NflgException(STATE.BusinessError, "ID=" + r.getId() + " 的记录不是待提交状态,无法提交");
|
||||||
}
|
}
|
||||||
|
// 校验供应商权限
|
||||||
|
validateSupplierPermission(r.getSupplierId());
|
||||||
|
// 收集taskId
|
||||||
|
if (Objects.nonNull(r.getTaskId())) {
|
||||||
|
taskIds.add(r.getTaskId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String operator = UserUtil.getUserName();
|
String operator = UserUtil.getUserName();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
// 更新审核记录状态为1(待审核)
|
||||||
lambdaUpdate()
|
lambdaUpdate()
|
||||||
.in(QmsCoaReview::getId, ids)
|
.in(QmsCoaReview::getId, ids)
|
||||||
.set(QmsCoaReview::getStatus, 1)
|
.set(QmsCoaReview::getStatus, 1)
|
||||||
.set(QmsCoaReview::getUpdateBy, operator)
|
.set(QmsCoaReview::getUpdateBy, operator)
|
||||||
.set(QmsCoaReview::getUpdateTime, now)
|
.set(QmsCoaReview::getUpdateTime, now)
|
||||||
.update();
|
.update();
|
||||||
|
|
||||||
|
// 更新关联的任务状态为2(已上传)
|
||||||
|
if (!taskIds.isEmpty()) {
|
||||||
|
coaTaskService.lambdaUpdate()
|
||||||
|
.in(QmsCoaTask::getId, taskIds)
|
||||||
|
.set(QmsCoaTask::getStatus, 2)
|
||||||
|
.set(QmsCoaTask::getUpdateBy, operator)
|
||||||
|
.set(QmsCoaTask::getUpdateTime, now)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 审核 ====================
|
// ==================== 审核 ====================
|
||||||
|
|
@ -195,6 +264,14 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
throw new NflgException(STATE.BusinessError, "当前状态不是待审核,无法进行审核操作");
|
throw new NflgException(STATE.BusinessError, "当前状态不是待审核,无法进行审核操作");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 校验当前用户是否与任务中的SQE用户一致
|
||||||
|
if (Objects.nonNull(review.getTaskId())) {
|
||||||
|
QmsCoaTask task = coaTaskService.getById(review.getTaskId());
|
||||||
|
if (Objects.nonNull(task) && !Objects.equals(task.getUserId(), UserUtil.getUserId())) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "当前账号与任务中的SQE用户不匹配,无权审核");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Integer newStatus = qo.getStatus();
|
Integer newStatus = qo.getStatus();
|
||||||
if (!Objects.equals(newStatus, 2) && !Objects.equals(newStatus, 3)) {
|
if (!Objects.equals(newStatus, 2) && !Objects.equals(newStatus, 3)) {
|
||||||
throw new NflgException(STATE.BusinessError, "审核状态只能为2(已通过)或3(已驳回)");
|
throw new NflgException(STATE.BusinessError, "审核状态只能为2(已通过)或3(已驳回)");
|
||||||
|
|
@ -229,21 +306,41 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
|
|
||||||
// ==================== 分页查询 ====================
|
// ==================== 分页查询 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供应商分页查询:供应商查看自己创建的审核记录
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageData<QmsCoaReviewVO> search(QmsCoaReviewSearchQO qo) {
|
public PageData<QmsCoaReviewVO> searchForSupplier(QmsCoaReviewSearchQO qo) {
|
||||||
// 当前账号只能看自己创建的数据
|
|
||||||
Long currentUserId = UserUtil.getUserId();
|
Long currentUserId = UserUtil.getUserId();
|
||||||
|
|
||||||
// 处理供应商过滤(名称模糊 or 编号精确)
|
// 获取当前用户关联的供应商ID
|
||||||
|
UserSupplier supplier = userSupplierService.lambdaQuery()
|
||||||
|
.eq(UserSupplier::getUserId, currentUserId)
|
||||||
|
.last("LIMIT 1")
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(supplier)) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "当前账号未关联供应商");
|
||||||
|
}
|
||||||
|
Long currentSupplierId = supplier.getId();
|
||||||
|
|
||||||
|
// 处理供应商过滤:连接供应商表查询ID
|
||||||
Set<Long> filteredSupplierIds = null;
|
Set<Long> filteredSupplierIds = null;
|
||||||
boolean hasSupplierFilter = (Objects.nonNull(qo.getSupplierName()) && !qo.getSupplierName().isEmpty())
|
boolean hasSupplierNameFilter = StrUtil.isNotBlank(qo.getSupplierName());
|
||||||
|| (Objects.nonNull(qo.getSupplierCode()) && !qo.getSupplierCode().isEmpty());
|
boolean hasSupplierCodeFilter = StrUtil.isNotBlank(qo.getSupplierCode());
|
||||||
if (hasSupplierFilter) {
|
|
||||||
|
if (hasSupplierNameFilter || hasSupplierCodeFilter) {
|
||||||
List<UserSupplier> suppliers = userSupplierService.lambdaQuery()
|
List<UserSupplier> suppliers = userSupplierService.lambdaQuery()
|
||||||
.like(Objects.nonNull(qo.getSupplierName()) && !qo.getSupplierName().isEmpty(),
|
.nested(i -> {
|
||||||
UserSupplier::getSupplierName, qo.getSupplierName())
|
if (hasSupplierNameFilter) {
|
||||||
.eq(Objects.nonNull(qo.getSupplierCode()) && !qo.getSupplierCode().isEmpty(),
|
i.like(UserSupplier::getSupplierName, qo.getSupplierName());
|
||||||
UserSupplier::getSupplierCode, qo.getSupplierCode())
|
}
|
||||||
|
if (hasSupplierCodeFilter) {
|
||||||
|
if (hasSupplierNameFilter) {
|
||||||
|
i.or();
|
||||||
|
}
|
||||||
|
i.eq(UserSupplier::getSupplierCode, qo.getSupplierCode());
|
||||||
|
}
|
||||||
|
})
|
||||||
.list();
|
.list();
|
||||||
filteredSupplierIds = suppliers.stream().map(UserSupplier::getId).collect(Collectors.toSet());
|
filteredSupplierIds = suppliers.stream().map(UserSupplier::getId).collect(Collectors.toSet());
|
||||||
if (filteredSupplierIds.isEmpty()) {
|
if (filteredSupplierIds.isEmpty()) {
|
||||||
|
|
@ -253,7 +350,7 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
|
|
||||||
// 处理物料编号过滤
|
// 处理物料编号过滤
|
||||||
Set<Long> filteredMaterialIds = null;
|
Set<Long> filteredMaterialIds = null;
|
||||||
if (Objects.nonNull(qo.getMaterialNo()) && !qo.getMaterialNo().isEmpty()) {
|
if (StrUtil.isNotBlank(qo.getMaterialNo())) {
|
||||||
List<QmsQcMaterial> materials = qcMaterialService.lambdaQuery()
|
List<QmsQcMaterial> materials = qcMaterialService.lambdaQuery()
|
||||||
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
|
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
|
||||||
.list();
|
.list();
|
||||||
|
|
@ -266,21 +363,122 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
final Set<Long> finalSupplierIds = filteredSupplierIds;
|
final Set<Long> finalSupplierIds = filteredSupplierIds;
|
||||||
final Set<Long> finalMaterialIds = filteredMaterialIds;
|
final Set<Long> finalMaterialIds = filteredMaterialIds;
|
||||||
|
|
||||||
IPage<QmsCoaReview> page = lambdaQuery()
|
// 构建查询:只能查看当前供应商的数据
|
||||||
.eq(QmsCoaReview::getUserId, currentUserId)
|
var query = lambdaQuery()
|
||||||
|
.eq(QmsCoaReview::getSupplierId, currentSupplierId)
|
||||||
.ne(QmsCoaReview::getDeleted, true)
|
.ne(QmsCoaReview::getDeleted, true)
|
||||||
.in(Objects.nonNull(finalSupplierIds), QmsCoaReview::getSupplierId, finalSupplierIds != null ? finalSupplierIds : List.of())
|
.eq(StrUtil.isNotBlank(qo.getPurchaseNo()), QmsCoaReview::getPurchaseNo, qo.getPurchaseNo())
|
||||||
.in(Objects.nonNull(finalMaterialIds), QmsCoaReview::getMaterialId, finalMaterialIds != null ? finalMaterialIds : List.of())
|
.orderByDesc(QmsCoaReview::getCreateTime);
|
||||||
.eq(Objects.nonNull(qo.getPurchaseNo()) && !qo.getPurchaseNo().isEmpty(),
|
|
||||||
QmsCoaReview::getPurchaseNo, qo.getPurchaseNo())
|
// 供应商ID过滤(只在有过滤条件时添加)
|
||||||
.orderByDesc(QmsCoaReview::getCreateTime)
|
if (finalSupplierIds != null && !finalSupplierIds.isEmpty()) {
|
||||||
.page(new Page<>(qo.getPage(), qo.getPageSize()));
|
query.in(QmsCoaReview::getSupplierId, finalSupplierIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 物料ID过滤(只在有过滤条件时添加)
|
||||||
|
if (finalMaterialIds != null && !finalMaterialIds.isEmpty()) {
|
||||||
|
query.in(QmsCoaReview::getMaterialId, finalMaterialIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPage<QmsCoaReview> page = query.page(new Page<>(qo.getPage(), qo.getPageSize()));
|
||||||
|
|
||||||
List<QmsCoaReview> records = page.getRecords();
|
List<QmsCoaReview> records = page.getRecords();
|
||||||
if (records.isEmpty()) {
|
if (records.isEmpty()) {
|
||||||
return buildPageData(page, List.of());
|
return buildPageData(page, List.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量查询关联数据
|
||||||
|
return buildPageDataWithRelations(page, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQE分页查询:SQE查看待审核的记录(基于task.user_id)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageData<QmsCoaReviewVO> searchForSqe(QmsCoaReviewSearchQO qo) {
|
||||||
|
Long currentUserId = UserUtil.getUserId();
|
||||||
|
|
||||||
|
// 查询当前SQE用户关联的任务ID列表
|
||||||
|
List<QmsCoaTask> tasks = coaTaskService.lambdaQuery()
|
||||||
|
.eq(QmsCoaTask::getUserId, currentUserId)
|
||||||
|
.ne(QmsCoaTask::getDeleted, true)
|
||||||
|
.list();
|
||||||
|
if (tasks.isEmpty()) {
|
||||||
|
return emptyPage(qo.getPage(), qo.getPageSize());
|
||||||
|
}
|
||||||
|
Set<Long> taskIds = tasks.stream().map(QmsCoaTask::getId).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 处理供应商过滤
|
||||||
|
Set<Long> filteredSupplierIds = null;
|
||||||
|
boolean hasSupplierNameFilter = StrUtil.isNotBlank(qo.getSupplierName());
|
||||||
|
boolean hasSupplierCodeFilter = StrUtil.isNotBlank(qo.getSupplierCode());
|
||||||
|
|
||||||
|
if (hasSupplierNameFilter || hasSupplierCodeFilter) {
|
||||||
|
List<UserSupplier> suppliers = userSupplierService.lambdaQuery()
|
||||||
|
.nested(i -> {
|
||||||
|
if (hasSupplierNameFilter) {
|
||||||
|
i.like(UserSupplier::getSupplierName, qo.getSupplierName());
|
||||||
|
}
|
||||||
|
if (hasSupplierCodeFilter) {
|
||||||
|
if (hasSupplierNameFilter) {
|
||||||
|
i.or();
|
||||||
|
}
|
||||||
|
i.eq(UserSupplier::getSupplierCode, qo.getSupplierCode());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.list();
|
||||||
|
filteredSupplierIds = suppliers.stream().map(UserSupplier::getId).collect(Collectors.toSet());
|
||||||
|
if (filteredSupplierIds.isEmpty()) {
|
||||||
|
return emptyPage(qo.getPage(), qo.getPageSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理物料编号过滤
|
||||||
|
Set<Long> filteredMaterialIds = null;
|
||||||
|
if (StrUtil.isNotBlank(qo.getMaterialNo())) {
|
||||||
|
List<QmsQcMaterial> materials = qcMaterialService.lambdaQuery()
|
||||||
|
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
|
||||||
|
.list();
|
||||||
|
filteredMaterialIds = materials.stream().map(QmsQcMaterial::getId).collect(Collectors.toSet());
|
||||||
|
if (filteredMaterialIds.isEmpty()) {
|
||||||
|
return emptyPage(qo.getPage(), qo.getPageSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Set<Long> finalSupplierIds = filteredSupplierIds;
|
||||||
|
final Set<Long> finalMaterialIds = filteredMaterialIds;
|
||||||
|
|
||||||
|
// 构建查询:只能查看属于当前SQE任务的审核记录
|
||||||
|
var query = lambdaQuery()
|
||||||
|
.in(QmsCoaReview::getTaskId, taskIds)
|
||||||
|
.ne(QmsCoaReview::getDeleted, true)
|
||||||
|
.eq(StrUtil.isNotBlank(qo.getPurchaseNo()), QmsCoaReview::getPurchaseNo, qo.getPurchaseNo())
|
||||||
|
.orderByDesc(QmsCoaReview::getCreateTime);
|
||||||
|
|
||||||
|
// 供应商ID过滤
|
||||||
|
if (finalSupplierIds != null && !finalSupplierIds.isEmpty()) {
|
||||||
|
query.in(QmsCoaReview::getSupplierId, finalSupplierIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 物料ID过滤
|
||||||
|
if (finalMaterialIds != null && !finalMaterialIds.isEmpty()) {
|
||||||
|
query.in(QmsCoaReview::getMaterialId, finalMaterialIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPage<QmsCoaReview> page = query.page(new Page<>(qo.getPage(), qo.getPageSize()));
|
||||||
|
|
||||||
|
List<QmsCoaReview> records = page.getRecords();
|
||||||
|
if (records.isEmpty()) {
|
||||||
|
return buildPageData(page, List.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildPageDataWithRelations(page, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建分页结果并填充关联数据
|
||||||
|
*/
|
||||||
|
private PageData<QmsCoaReviewVO> buildPageDataWithRelations(IPage<QmsCoaReview> page, List<QmsCoaReview> records) {
|
||||||
// 批量查询关联数据
|
// 批量查询关联数据
|
||||||
Set<Long> supplierIds = records.stream().map(QmsCoaReview::getSupplierId).filter(Objects::nonNull).collect(Collectors.toSet());
|
Set<Long> supplierIds = records.stream().map(QmsCoaReview::getSupplierId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
Set<Long> materialIds = records.stream().map(QmsCoaReview::getMaterialId).filter(Objects::nonNull).collect(Collectors.toSet());
|
Set<Long> materialIds = records.stream().map(QmsCoaReview::getMaterialId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
|
@ -314,6 +512,7 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
QmsCoaReviewDetailVO vo = new QmsCoaReviewDetailVO();
|
QmsCoaReviewDetailVO vo = new QmsCoaReviewDetailVO();
|
||||||
vo.setId(review.getId());
|
vo.setId(review.getId());
|
||||||
vo.setPurchaseNo(review.getPurchaseNo());
|
vo.setPurchaseNo(review.getPurchaseNo());
|
||||||
|
vo.setBatchNo(review.getBatchNo());
|
||||||
vo.setStatus(review.getStatus());
|
vo.setStatus(review.getStatus());
|
||||||
vo.setReviewBy(review.getReviewBy());
|
vo.setReviewBy(review.getReviewBy());
|
||||||
vo.setReviewTime(review.getReviewTime());
|
vo.setReviewTime(review.getReviewTime());
|
||||||
|
|
@ -356,6 +555,7 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
QmsCoaReviewVO vo = new QmsCoaReviewVO();
|
QmsCoaReviewVO vo = new QmsCoaReviewVO();
|
||||||
vo.setId(r.getId());
|
vo.setId(r.getId());
|
||||||
vo.setPurchaseNo(r.getPurchaseNo());
|
vo.setPurchaseNo(r.getPurchaseNo());
|
||||||
|
vo.setBatchNo(r.getBatchNo());
|
||||||
vo.setStatus(r.getStatus());
|
vo.setStatus(r.getStatus());
|
||||||
vo.setReviewBy(r.getReviewBy());
|
vo.setReviewBy(r.getReviewBy());
|
||||||
vo.setReviewTime(r.getReviewTime());
|
vo.setReviewTime(r.getReviewTime());
|
||||||
|
|
@ -397,4 +597,16 @@ public class QmsCoaReviewServiceImpl extends ServiceImpl<QmsCoaReviewMapper, Qms
|
||||||
result.setTotal(0);
|
result.setTotal(0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验当前用户是否与供应商关联
|
||||||
|
* @param supplierId 供应商ID
|
||||||
|
*/
|
||||||
|
private void validateSupplierPermission(Long supplierId) {
|
||||||
|
Long currentUserId = UserUtil.getUserId();
|
||||||
|
UserSupplier supplier = userSupplierService.getById(supplierId);
|
||||||
|
if (Objects.isNull(supplier) || !Objects.equals(supplier.getUserId(), currentUserId)) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "当前账号与供应商不匹配,无权操作");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue