Merge remote-tracking branch 'origin/feature/NoScanning' into feature/NoScanning
This commit is contained in:
commit
6807321961
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -653,9 +653,9 @@ public class QmsFileControllerService {
|
|||
User lockedUser = userService.getById(lockedUserId);
|
||||
VUtil.trueThrowBusinessError(true).throwMessage("文件已被用户【" + lockedUser.getUserName() + "】锁定");
|
||||
}
|
||||
}else {
|
||||
redisTemplate.opsForValue().setIfAbsent(key, currentUserId, 15, TimeUnit.SECONDS);
|
||||
}
|
||||
// key 在两次 Redis 操作间隙恰好过期,仍属于锁定失败,需兜底报错
|
||||
VUtil.trueThrowBusinessError(true).throwMessage("文件已被锁定");
|
||||
} else {
|
||||
file.setCurrentLockUserName(UserUtil.getUserName());
|
||||
fileService.updateById(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;
|
||||
|
||||
/**
|
||||
* 报告要求(必传)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public interface IQmsCoaTaskService extends IService<QmsCoaTask> {
|
|||
/**
|
||||
* 直接发布COA通知任务(状态改为1,填入发送时间)
|
||||
*/
|
||||
void publish(QmsCoaTaskAddQO qo);
|
||||
Long publish(QmsCoaTaskAddQO qo);
|
||||
|
||||
/**
|
||||
* 批量发送(状态改为1,填入发送时间)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
// ==================== 发送 ====================
|
||||
|
|
|
|||
Loading…
Reference in New Issue