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