refactor(qms): 修改COA任务发布功能的物料标识方式

- 将QmsCoaTaskAddQO中的物料字段从materialNo改为materialId
- 更新publish方法返回值类型为Long,返回任务ID
- 移除按物料编号查询物料的逻辑,直接使用传入的物料ID
- 调整控制器中待办事项标题的生成方式,使用物料编号显示
- 修改新增和发布流程中物料ID的设置方式,统一使用qo.getMaterialId()
This commit is contained in:
曹鹏飞 2026-06-10 08:33:07 +08:00
parent 7bd3cb7134
commit 2f60e99f3b
4 changed files with 41 additions and 28 deletions

View File

@ -14,9 +14,11 @@ import com.nflg.wms.common.pojo.vo.QmsCoaTaskVO;
import com.nflg.wms.common.util.UserUtil; import com.nflg.wms.common.util.UserUtil;
import com.nflg.wms.common.util.VUtil; import com.nflg.wms.common.util.VUtil;
import com.nflg.wms.repository.entity.QmsCoaTask; import com.nflg.wms.repository.entity.QmsCoaTask;
import com.nflg.wms.repository.entity.QmsQcMaterial;
import com.nflg.wms.repository.entity.QmsTodoItem; import com.nflg.wms.repository.entity.QmsTodoItem;
import com.nflg.wms.repository.service.IDictionaryItemService; import com.nflg.wms.repository.service.IDictionaryItemService;
import com.nflg.wms.repository.service.IQmsCoaTaskService; import com.nflg.wms.repository.service.IQmsCoaTaskService;
import com.nflg.wms.repository.service.IQmsQcMaterialService;
import com.nflg.wms.repository.service.IQmsTodoItemService; import com.nflg.wms.repository.service.IQmsTodoItemService;
import com.nflg.wms.starter.BaseController; import com.nflg.wms.starter.BaseController;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -47,6 +49,9 @@ public class QmsCoaTaskController extends BaseController {
@Resource @Resource
private IDictionaryItemService dictionaryItemService; private IDictionaryItemService dictionaryItemService;
@Resource
private IQmsQcMaterialService qcMaterialService;
/** /**
* 新增COA通知任务 * 新增COA通知任务
* 状态默认为0待发送 * 状态默认为0待发送
@ -85,15 +90,16 @@ public class QmsCoaTaskController extends BaseController {
@Transactional @Transactional
@PostMapping("publish") @PostMapping("publish")
public ApiResult<Void> publish(@Valid @RequestBody QmsCoaTaskAddQO qo) { public ApiResult<Void> publish(@Valid @RequestBody QmsCoaTaskAddQO qo) {
coaTaskService.publish(qo); Long taskId = coaTaskService.publish(qo);
Long dictionaryItemServiceId = dictionaryItemService.getIdByCode("MessageType", "COANotificationSent"); Long dictionaryItemServiceId = dictionaryItemService.getIdByCode("MessageType", "COANotificationSent");
VUtil.trueThrowBusinessError(Objects.isNull(dictionaryItemServiceId)).throwMessage("消息类型不存在"); VUtil.trueThrowBusinessError(Objects.isNull(dictionaryItemServiceId)).throwMessage("消息类型不存在");
// 推送COA通知 // 推送COA通知
QmsQcMaterial qcMaterial = qcMaterialService.getById(qo.getMaterialId());
todoItemService.add(new QmsTodoItem() todoItemService.add(new QmsTodoItem()
.setTitle("COA通知" + qo.getMaterialNo()) .setTitle("物料" + qcMaterial.getMaterialNo() + "需要上传COA报告")
.setCode(basdeSerialNumberControllerService.generateSerialNumber(32)) .setCode(basdeSerialNumberControllerService.generateSerialNumber(32))
.setSourceTypeId(dictionaryItemServiceId) .setSourceTypeId(dictionaryItemServiceId)
.setSourceId(coaTaskService.lambdaQuery().eq(QmsCoaTask::getMaterialId, qo.getMaterialNo()).one().getId()) .setSourceId(taskId)
.setCreateUserId(UserUtil.getUserId()) .setCreateUserId(UserUtil.getUserId())
.setCreateUserName(UserUtil.getUserName()) .setCreateUserName(UserUtil.getUserName())
.setCreateTime(java.time.LocalDateTime.now()) .setCreateTime(java.time.LocalDateTime.now())

View File

@ -19,11 +19,17 @@ public class QmsCoaTaskAddQO {
@NotBlank(message = "供应商编号不能为空") @NotBlank(message = "供应商编号不能为空")
private String supplierCode; private String supplierCode;
// /**
// * 物料编号必传用于查询 qms_qc_material.id
// */
// @NotBlank(message = "物料编号不能为空")
// private String materialNo;
/** /**
* 物料编号必传用于查询 qms_qc_material.id * 物料ID
*/ */
@NotBlank(message = "物料编号不能为空") @NotNull(message = "物料ID不能为空")
private String materialNo; private Long materialId;
/** /**
* 报告要求必传 * 报告要求必传

View File

@ -36,7 +36,7 @@ public interface IQmsCoaTaskService extends IService<QmsCoaTask> {
/** /**
* 直接发布COA通知任务状态改为1填入发送时间 * 直接发布COA通知任务状态改为1填入发送时间
*/ */
void publish(QmsCoaTaskAddQO qo); Long publish(QmsCoaTaskAddQO qo);
/** /**
* 批量发送状态改为1填入发送时间 * 批量发送状态改为1填入发送时间

View File

@ -57,19 +57,19 @@ public class QmsCoaTaskServiceImpl extends ServiceImpl<QmsCoaTaskMapper, QmsCoaT
if (Objects.isNull(supplier)) { if (Objects.isNull(supplier)) {
throw new NflgException(STATE.BusinessError, "供应商编号不存在:" + qo.getSupplierCode()); throw new NflgException(STATE.BusinessError, "供应商编号不存在:" + qo.getSupplierCode());
} }
// 按物料编号查物料 // // 按物料编号查物料
QmsQcMaterial material = qcMaterialService.lambdaQuery() // QmsQcMaterial material = qcMaterialService.lambdaQuery()
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo()) // .eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
.last("LIMIT 1") // .last("LIMIT 1")
.one(); // .one();
if (Objects.isNull(material)) { // if (Objects.isNull(material)) {
throw new NflgException(STATE.BusinessError, "物料编号不存在:" + qo.getMaterialNo()); // throw new NflgException(STATE.BusinessError, "物料编号不存在:" + qo.getMaterialNo());
} // }
// 校验同供应商+同物料是否已存在未删除的任务 // 校验同供应商+同物料是否已存在未删除的任务
boolean duplicate = lambdaQuery() boolean duplicate = lambdaQuery()
.eq(QmsCoaTask::getSupplierId, supplier.getId()) .eq(QmsCoaTask::getSupplierId, supplier.getId())
.eq(QmsCoaTask::getMaterialId, material.getId()) .eq(QmsCoaTask::getMaterialId, qo.getMaterialId())
.ne(QmsCoaTask::getDeleted, true) .ne(QmsCoaTask::getDeleted, true)
.exists(); .exists();
if (duplicate) { if (duplicate) {
@ -81,7 +81,7 @@ public class QmsCoaTaskServiceImpl extends ServiceImpl<QmsCoaTaskMapper, QmsCoaT
QmsCoaTask task = new QmsCoaTask() QmsCoaTask task = new QmsCoaTask()
.setSupplierId(supplier.getId()) .setSupplierId(supplier.getId())
.setMaterialId(material.getId()) .setMaterialId(qo.getMaterialId())
.setUserId(UserUtil.getUserId()) .setUserId(UserUtil.getUserId())
.setStatus(0) .setStatus(0)
.setRequirement(qo.getRequirement()) .setRequirement(qo.getRequirement())
@ -154,25 +154,25 @@ public class QmsCoaTaskServiceImpl extends ServiceImpl<QmsCoaTaskMapper, QmsCoaT
@Transactional @Transactional
@Override @Override
public void publish(QmsCoaTaskAddQO qo) { public Long publish(QmsCoaTaskAddQO qo) {
// 按供应商编号查供应商 // 按供应商编号查供应商
UserSupplier supplier = userSupplierService.getByCode(qo.getSupplierCode()); UserSupplier supplier = userSupplierService.getByCode(qo.getSupplierCode());
if (Objects.isNull(supplier)) { if (Objects.isNull(supplier)) {
throw new NflgException(STATE.BusinessError, "供应商编号不存在:" + qo.getSupplierCode()); throw new NflgException(STATE.BusinessError, "供应商编号不存在:" + qo.getSupplierCode());
} }
// 按物料编号查物料 // // 按物料编号查物料
QmsQcMaterial material = qcMaterialService.lambdaQuery() // QmsQcMaterial material = qcMaterialService.lambdaQuery()
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo()) // .eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
.last("LIMIT 1") // .last("LIMIT 1")
.one(); // .one();
if (Objects.isNull(material)) { // if (Objects.isNull(material)) {
throw new NflgException(STATE.BusinessError, "物料编号不存在:" + qo.getMaterialNo()); // throw new NflgException(STATE.BusinessError, "物料编号不存在:" + qo.getMaterialNo());
} // }
// 校验同供应商+同物料是否已存在未删除的任务 // 校验同供应商+同物料是否已存在未删除的任务
boolean duplicate = lambdaQuery() boolean duplicate = lambdaQuery()
.eq(QmsCoaTask::getSupplierId, supplier.getId()) .eq(QmsCoaTask::getSupplierId, supplier.getId())
.eq(QmsCoaTask::getMaterialId, material.getId()) .eq(QmsCoaTask::getMaterialId, qo.getMaterialId())
.ne(QmsCoaTask::getDeleted, true) .ne(QmsCoaTask::getDeleted, true)
.exists(); .exists();
if (duplicate) { if (duplicate) {
@ -185,7 +185,7 @@ public class QmsCoaTaskServiceImpl extends ServiceImpl<QmsCoaTaskMapper, QmsCoaT
// 直接创建状态为1已发送的任务并填入发送时间 // 直接创建状态为1已发送的任务并填入发送时间
QmsCoaTask task = new QmsCoaTask() QmsCoaTask task = new QmsCoaTask()
.setSupplierId(supplier.getId()) .setSupplierId(supplier.getId())
.setMaterialId(material.getId()) .setMaterialId(qo.getMaterialId())
.setUserId(UserUtil.getUserId()) .setUserId(UserUtil.getUserId())
.setStatus(1) .setStatus(1)
.setNoticeTime(now) .setNoticeTime(now)
@ -198,6 +198,7 @@ public class QmsCoaTaskServiceImpl extends ServiceImpl<QmsCoaTaskMapper, QmsCoaT
.setUpdateBy(operator) .setUpdateBy(operator)
.setUpdateTime(now); .setUpdateTime(now);
save(task); save(task);
return task.getId();
} }
// ==================== 发送 ==================== // ==================== 发送 ====================