fix(wms): 事务执行锁定加领料
- 修改钢卷验证条件从exclusiveStatus检查改为dataType检查 - 添加错误提示信息从"正在单步分条"改为"历史钢卷不能被操作" - 在单步分卷操作中添加待处理操作记录创建功能 - 添加领料操作类型的待处理记录插入逻辑 - 实现操作记录失败时的异常处理机制 - 注释掉重复的待处理操作检查代码以避免冲突
This commit is contained in:
@@ -130,8 +130,8 @@ public class WmsCoilPendingActionServiceImpl implements IWmsCoilPendingActionSer
|
||||
validEntityBeforeSave(add);
|
||||
if (add.getCoilId() != null){
|
||||
WmsMaterialCoil materialCoil = materialCoilMapper.selectById(add.getCoilId());
|
||||
if (materialCoil.getExclusiveStatus() !=0) {
|
||||
throw new RuntimeException("该钢卷正在单步分条,请勿重复操作!");
|
||||
if (materialCoil.getDataType() == 0) {
|
||||
throw new RuntimeException("该钢卷为历史钢卷不能被操作");
|
||||
}
|
||||
}
|
||||
// 设置默认值
|
||||
|
||||
@@ -3261,17 +3261,41 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
throw new RuntimeException("当前钢卷是历史卷");
|
||||
}
|
||||
|
||||
// 3. 检查是否已被锁定
|
||||
// 3. 检查是否已被锁定或已有相同类型的待处理操作
|
||||
if (coil.getExclusiveStatus() != null && coil.getExclusiveStatus() != 0) {
|
||||
throw new RuntimeException("钢卷正在进行其他操作,无法开始单步分卷");
|
||||
}
|
||||
|
||||
// // 3.1 检查是否已经有相同类型的待处理操作(防止重复领料)
|
||||
// LambdaQueryWrapper<WmsCoilPendingAction> pendingActionQuery = new LambdaQueryWrapper<>();
|
||||
// pendingActionQuery.eq(WmsCoilPendingAction::getCoilId, coilId)
|
||||
// .eq(WmsCoilPendingAction::getActionType, 501) // 领料操作类型
|
||||
// .ne(WmsCoilPendingAction::getActionStatus, 2); // 不是已完成的状态
|
||||
// List<WmsCoilPendingAction> existingActions = coilPendingActionMapper.selectList(pendingActionQuery);
|
||||
// if (!existingActions.isEmpty()) {
|
||||
// throw new RuntimeException("该钢卷已有待处理的领料操作,无法重复领料");
|
||||
// }
|
||||
|
||||
// 4. 设置独占状态(锁定钢卷)
|
||||
LambdaUpdateWrapper<WmsMaterialCoil> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(WmsMaterialCoil::getCoilId, coilId)
|
||||
.set(WmsMaterialCoil::getExclusiveStatus, 1); // 1表示单步分卷中
|
||||
baseMapper.update(null, updateWrapper);
|
||||
|
||||
// 5. 创建待操作记录(领料操作)
|
||||
WmsCoilPendingActionBo pendingActionBo = new WmsCoilPendingActionBo();
|
||||
pendingActionBo.setCoilId(coilId);
|
||||
pendingActionBo.setCurrentCoilNo(coil.getCurrentCoilNo());
|
||||
pendingActionBo.setActionType(501); // 领料操作类型
|
||||
pendingActionBo.setActionStatus(0); // 待处理
|
||||
pendingActionBo.setSourceType("manual"); // 手动创建
|
||||
pendingActionBo.setPriority(0); // 默认普通优先级
|
||||
|
||||
Boolean insertResult = coilPendingActionService.insertByBo(pendingActionBo);
|
||||
if (!insertResult) {
|
||||
throw new RuntimeException("创建待操作记录失败");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user