feat(wms): 添加钢卷分卷取消功能
- 在 IWmsMaterialCoilService 接口中新增 cancelSpecialSplit 方法 - 在 WmsMaterialCoilController 中添加 /specialSplit/cancel 接口 - 在 WmsMaterialCoilServiceImpl 中实现 cancelSpecialSplit 业务逻辑 - 实现分卷操作的取消功能,包括释放锁和删除待操作记录 - 添加对已完成分卷操作的校验,防止误取消 - 实现母卷状态检查和独占锁释放机制
This commit is contained in:
@@ -394,6 +394,22 @@ public class WmsMaterialCoilController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
// 取消单步分卷操作
|
||||
@Log(title = "钢卷物料表", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/specialSplit/cancel")
|
||||
public R<Map<String, Object>> cancelSpecialSplit(
|
||||
@NotNull(message = "待操作记录ID不能为空")
|
||||
@RequestParam Long pendingActionId) {
|
||||
|
||||
try {
|
||||
Map<String, Object> result = iWmsMaterialCoilService.cancelSpecialSplit(pendingActionId);
|
||||
return R.ok(result);
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail("取消分卷失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -190,5 +190,6 @@ public interface IWmsMaterialCoilService {
|
||||
*/
|
||||
Map<String, Object> completeSpecialSplit(@NotNull(message = "待操作记录ID不能为空") Long pendingActionId);
|
||||
|
||||
Map<String, Object> cancelSpecialSplit(@NotNull(message = "待操作记录ID不能为空") Long pendingActionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -3468,6 +3468,60 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
|
||||
return result;
|
||||
}
|
||||
//Map<String, Object> cancelSpecialSplit(@NotNull(message = "待操作记录ID不能为空") Long pendingActionId);
|
||||
/**
|
||||
* 单步分卷 - 取消分卷(释放锁 + 回滚子卷)
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> cancelSpecialSplit(Long pendingActionId) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("success", false);
|
||||
|
||||
// 1. 查询待操作记录
|
||||
WmsCoilPendingActionVo pendingAction = coilPendingActionService.queryById(pendingActionId);
|
||||
if (pendingAction == null) {
|
||||
throw new RuntimeException("待操作记录不存在");
|
||||
}
|
||||
|
||||
// 2. 已完成的分卷不允许取消
|
||||
if (Objects.equals(pendingAction.getActionStatus(), 2)) {
|
||||
throw new RuntimeException("该分卷操作已完成,无法取消");
|
||||
}
|
||||
|
||||
// 删除待操作记录
|
||||
coilPendingActionService.deleteWithValidByIds(Arrays.asList(pendingActionId), false);
|
||||
// 3. 查询母卷
|
||||
WmsMaterialCoil parentCoil = baseMapper.selectById(pendingAction.getCoilId());
|
||||
if (parentCoil == null) {
|
||||
throw new RuntimeException("母卷不存在");
|
||||
}
|
||||
|
||||
if (parentCoil.getDataType() == 0) {
|
||||
throw new RuntimeException("母卷已成为历史数据,无法取消分卷");
|
||||
}
|
||||
|
||||
// 4. 校验母卷是否处于“单步分卷中”
|
||||
if (Objects.equals(parentCoil.getExclusiveStatus(), 0)) {
|
||||
throw new RuntimeException("母卷未处于单步分卷状态,无法取消");
|
||||
}
|
||||
|
||||
// 释放母卷独占锁
|
||||
if (Objects.equals(parentCoil.getExclusiveStatus(), 1)) {
|
||||
LambdaUpdateWrapper<WmsMaterialCoil> parentUpdate = new LambdaUpdateWrapper<>();
|
||||
parentUpdate.eq(WmsMaterialCoil::getCoilId, parentCoil.getCoilId())
|
||||
.set(WmsMaterialCoil::getExclusiveStatus, 0);
|
||||
baseMapper.update(null, parentUpdate);
|
||||
}
|
||||
|
||||
result.put("success", true);
|
||||
result.put("message", "取消单步分卷成功");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user