feat(wms): 完善退火计划钢卷绑定和解绑逻辑
- 添加钢卷映射缓存以提高查询效率 - 增加钢卷排他状态检查防止并发操作冲突 - 实现绑定计划时自动释放实际库区锁定功能 - 优化解绑操作增加数据验证和异常处理 - 修复解绑后钢卷状态更新确保一致性 - 移除冗余的批量释放库区操作提升性能
This commit is contained in:
@@ -267,6 +267,8 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService {
|
||||
// 校验钢卷必须为现存钢卷(dataType=1),历史钢卷不能被加工
|
||||
List<WmsMaterialCoil> coils = materialCoilMapper.selectBatchIds(coilIds);
|
||||
Set<Long> existingIds = coils.stream().map(WmsMaterialCoil::getCoilId).collect(Collectors.toSet());
|
||||
java.util.Map<Long, WmsMaterialCoil> coilMap = coils.stream()
|
||||
.collect(Collectors.toMap(WmsMaterialCoil::getCoilId, c -> c, (a, b) -> a));
|
||||
for (Long coilId : coilIds) {
|
||||
if (!existingIds.contains(coilId)) {
|
||||
throw new ServiceException("钢卷被删除无法执行退火");
|
||||
@@ -284,12 +286,20 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService {
|
||||
.eq(WmsFurnacePlanCoil::getCoilId, coilId)) > 0) {
|
||||
continue;
|
||||
}
|
||||
// 检查钢卷是否已被其他操作锁定(exclusiveStatus != 0)
|
||||
// exclusiveStatus=1: 分卷中, exclusiveStatus=2: 已在其他计划中
|
||||
WmsMaterialCoil coil = coilMap.get(coilId);
|
||||
if (coil != null && coil.getExclusiveStatus() != null && coil.getExclusiveStatus() != 0) {
|
||||
throw new ServiceException("钢卷" + coil.getEnterCoilNo() + "正在进行其他操作,无法绑定");
|
||||
}
|
||||
WmsFurnacePlanCoil entity = new WmsFurnacePlanCoil();
|
||||
entity.setPlanId(bo.getPlanId());
|
||||
entity.setCoilId(coilId);
|
||||
entity.setLogicWarehouseId(bo.getLogicWarehouseId());
|
||||
entity.setFurnaceLevel(bo.getFurnaceLevel());
|
||||
planCoilMapper.insert(entity);
|
||||
// 绑定计划时立即释放实际库区(锁卷)
|
||||
releaseActualWarehouse(coilId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -300,9 +310,17 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService {
|
||||
if (bo.getPlanId() == null || bo.getCoilId() == null) {
|
||||
throw new ServiceException("计划ID和钢卷ID不能为空");
|
||||
}
|
||||
return planCoilMapper.delete(Wrappers.<WmsFurnacePlanCoil>lambdaQuery()
|
||||
int deleted = planCoilMapper.delete(Wrappers.<WmsFurnacePlanCoil>lambdaQuery()
|
||||
.eq(WmsFurnacePlanCoil::getPlanId, bo.getPlanId())
|
||||
.eq(WmsFurnacePlanCoil::getCoilId, bo.getCoilId())) > 0;
|
||||
.eq(WmsFurnacePlanCoil::getCoilId, bo.getCoilId()));
|
||||
if (deleted <= 0) {
|
||||
throw new ServiceException("该钢卷未绑定到此计划,无需解绑");
|
||||
}
|
||||
// 解绑后解锁钢卷
|
||||
materialCoilMapper.update(null, Wrappers.<WmsMaterialCoil>lambdaUpdate()
|
||||
.eq(WmsMaterialCoil::getCoilId, bo.getCoilId())
|
||||
.set(WmsMaterialCoil::getExclusiveStatus, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,10 +348,6 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService {
|
||||
|
||||
updateFurnaceBusy(plan.getTargetFurnaceId(), 1);
|
||||
|
||||
List<WmsFurnacePlanCoilVo> coils = queryPlanCoils(planId);
|
||||
for (WmsFurnacePlanCoilVo coil : coils) {
|
||||
releaseActualWarehouse(coil.getCoilId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user