修改COA通知新增、编辑功能

新增直接发送功能
This commit is contained in:
funny 2026-04-17 11:07:20 +08:00
parent 8f07dbca40
commit 6a8af1f362
6 changed files with 69 additions and 46 deletions

View File

@ -51,7 +51,7 @@ public class QmsCoaTaskController extends BaseController {
}
/**
* 修改COA通知任务仅状态为0时可修改
* 修改COA通知任务只允许修改报告要求和报告模板修改后状态改为0
*/
@Transactional
@PostMapping("update")
@ -60,6 +60,16 @@ public class QmsCoaTaskController extends BaseController {
return ApiResult.success();
}
/**
* 直接发布COA通知任务状态直接变为1并填入发送时间
*/
@Transactional
@PostMapping("publish")
public ApiResult<Void> publish(@Valid @RequestBody QmsCoaTaskAddQO qo) {
coaTaskService.publish(qo);
return ApiResult.success();
}
/**
* 批量发送状态改为1填入发送时间
*

View File

@ -3,10 +3,8 @@ package com.nflg.wms.common.pojo.qo;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDate;
/**
* 修改COA通知任务参数id必传其余可选
* 修改COA通知任务参数id必传只允许修改报告要求和报告模板
*/
@Data
public class QmsCoaTaskUpdateQO {
@ -17,26 +15,11 @@ public class QmsCoaTaskUpdateQO {
@NotNull(message = "ID不能为空")
private Long id;
/**
* 供应商编号可选
*/
private String supplierCode;
/**
* 物料编号可选
*/
private String materialNo;
/**
* 报告要求可选
*/
private String requirement;
/**
* 最晚提交时间可选
*/
private LocalDate lastSubTime;
/**
* 报告模板可选
*/

View File

@ -28,6 +28,11 @@ public class QmsQualityInspectorMaterialVO {
*/
private String drawingNo;
/**
* 图纸版本号
*/
private String drawingNoVer;
/**
* 物料类别编码
*/

View File

@ -27,10 +27,15 @@ public interface IQmsCoaTaskService extends IService<QmsCoaTask> {
void delete(Long id);
/**
* 修改COA通知任务状态不为0时不可修改
* 修改COA通知任务只允许修改报告要求和报告模板修改后状态改为0
*/
void update(QmsCoaTaskUpdateQO qo);
/**
* 直接发布COA通知任务状态改为1填入发送时间
*/
void publish(QmsCoaTaskAddQO qo);
/**
* 批量发送状态改为1填入发送时间
*/

View File

@ -111,25 +111,38 @@ public class QmsCoaTaskServiceImpl extends ServiceImpl<QmsCoaTaskMapper, QmsCoaT
if (Objects.isNull(task)) {
throw new NflgException(STATE.BusinessError, "任务不存在");
}
if (!Objects.equals(task.getStatus(), 0)) {
throw new NflgException(STATE.BusinessError, "当前状态不允许修改只有待发送状态0的任务才能修改");
}
String operator = UserUtil.getUserName();
LocalDateTime now = LocalDateTime.now();
var updater = lambdaUpdate().eq(QmsCoaTask::getId, qo.getId());
// 按供应商编号更新
if (Objects.nonNull(qo.getSupplierCode()) && !qo.getSupplierCode().isEmpty()) {
// 只允许修改报告要求和报告模板
if (Objects.nonNull(qo.getRequirement()) && !qo.getRequirement().isEmpty()) {
updater.set(QmsCoaTask::getRequirement, qo.getRequirement());
}
if (Objects.nonNull(qo.getReportTemplate())) {
updater.set(QmsCoaTask::getReportTemplate, qo.getReportTemplate());
}
// 修改后状态改为0待发送
updater.set(QmsCoaTask::getStatus, 0)
.set(QmsCoaTask::getUpdateBy, operator)
.set(QmsCoaTask::getUpdateTime, now)
.update();
}
// ==================== 直接发布 ====================
@Transactional
@Override
public void publish(QmsCoaTaskAddQO qo) {
// 按供应商编号查供应商
UserSupplier supplier = userSupplierService.getByCode(qo.getSupplierCode());
if (Objects.isNull(supplier)) {
throw new NflgException(STATE.BusinessError, "供应商编号不存在:" + qo.getSupplierCode());
}
updater.set(QmsCoaTask::getSupplierId, supplier.getId());
}
// 按物料编号更新
if (Objects.nonNull(qo.getMaterialNo()) && !qo.getMaterialNo().isEmpty()) {
// 按物料编号查物料
QmsQcMaterial material = qcMaterialService.lambdaQuery()
.eq(QmsQcMaterial::getMaterialNo, qo.getMaterialNo())
.last("LIMIT 1")
@ -137,20 +150,26 @@ public class QmsCoaTaskServiceImpl extends ServiceImpl<QmsCoaTaskMapper, QmsCoaT
if (Objects.isNull(material)) {
throw new NflgException(STATE.BusinessError, "物料编号不存在:" + qo.getMaterialNo());
}
updater.set(QmsCoaTask::getMaterialId, material.getId());
}
if (Objects.nonNull(qo.getRequirement()) && !qo.getRequirement().isEmpty()) {
updater.set(QmsCoaTask::getRequirement, qo.getRequirement());
}
if (Objects.nonNull(qo.getLastSubTime())) {
updater.set(QmsCoaTask::getLastSubTime, qo.getLastSubTime());
}
if (Objects.nonNull(qo.getReportTemplate())) {
updater.set(QmsCoaTask::getReportTemplate, qo.getReportTemplate());
}
updater.set(QmsCoaTask::getUpdateBy, operator)
.set(QmsCoaTask::getUpdateTime, now)
.update();
String operator = UserUtil.getUserName();
LocalDateTime now = LocalDateTime.now();
// 直接创建状态为1已发送的任务并填入发送时间
QmsCoaTask task = new QmsCoaTask()
.setSupplierId(supplier.getId())
.setMaterialId(material.getId())
.setUserId(UserUtil.getUserId())
.setStatus(1)
.setNoticeTime(now)
.setRequirement(qo.getRequirement())
.setReportTemplate(qo.getReportTemplate())
.setLastSubTime(qo.getLastSubTime())
.setDeleted(false)
.setCreateBy(operator)
.setCreateTime(now)
.setUpdateBy(operator)
.setUpdateTime(now);
save(task);
}
// ==================== 发送 ====================

View File

@ -111,6 +111,7 @@
qi.material_id,
m.material_no,
m.drawing_no,
m.drawing_no_ver,
m.material_category_code,
m.material_category_code_path_name AS material_category_name,
m.material_desc AS material_name,