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

View File

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

View File

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

View File

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