feat(wms): 完善钢卷操作完成接口功能
- 在completeAction方法中添加newCoilIds参数支持 - 修改updateByBo方法返回值为String类型,支持返回新钢卷ID - 添加分卷时返回逗号分隔的ID字符串,合卷时返回单个ID的功能 - 在操作完成时记录processedCoilIds信息 - 优化异常处理和返回值验证逻辑
This commit is contained in:
@@ -134,8 +134,8 @@ public class WmsCoilPendingActionController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@Log(title = "钢卷待操作", businessType = BusinessType.UPDATE)
|
@Log(title = "钢卷待操作", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/complete/{actionId}")
|
@PutMapping("/complete/{actionId}")
|
||||||
public R<Void> completeAction(@PathVariable("actionId") Long actionId) {
|
public R<Void> completeAction(@PathVariable("actionId") Long actionId, @RequestParam("newCoilIds") String newCoilIds) {
|
||||||
return toAjax(iWmsCoilPendingActionService.completeAction(actionId));
|
return toAjax(iWmsCoilPendingActionService.completeAction(actionId, newCoilIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public interface IWmsCoilPendingActionService {
|
|||||||
/**
|
/**
|
||||||
* 完成操作
|
* 完成操作
|
||||||
*/
|
*/
|
||||||
Boolean completeAction(Long actionId);
|
Boolean completeAction(Long actionId, String newCoilIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消操作
|
* 取消操作
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ public interface IWmsMaterialCoilService {
|
|||||||
* 修改钢卷物料表
|
* 修改钢卷物料表
|
||||||
* 如果newCoils不为空,则进行批量更新(分卷/合卷)
|
* 如果newCoils不为空,则进行批量更新(分卷/合卷)
|
||||||
* 如果newCoils为空,则进行单个更新
|
* 如果newCoils为空,则进行单个更新
|
||||||
|
* @return 单个更新或合卷时返回新钢卷ID,分卷时返回逗号分隔的新钢卷ID字符串
|
||||||
*/
|
*/
|
||||||
Boolean updateByBo(WmsMaterialCoilBo bo);
|
String updateByBo(WmsMaterialCoilBo bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合卷操作
|
* 合卷操作
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ public class WmsCoilPendingActionServiceImpl implements IWmsCoilPendingActionSer
|
|||||||
* 完成操作
|
* 完成操作
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean completeAction(Long actionId) {
|
public Boolean completeAction(Long actionId, String newCoilIds) {
|
||||||
// 先查询原记录,检查操作人是否为空
|
// 先查询原记录,检查操作人是否为空
|
||||||
WmsCoilPendingAction oldAction = baseMapper.selectById(actionId);
|
WmsCoilPendingAction oldAction = baseMapper.selectById(actionId);
|
||||||
if (oldAction == null) {
|
if (oldAction == null) {
|
||||||
@@ -286,6 +286,7 @@ public class WmsCoilPendingActionServiceImpl implements IWmsCoilPendingActionSer
|
|||||||
action.setActionId(actionId);
|
action.setActionId(actionId);
|
||||||
action.setActionStatus(2); // 已完成
|
action.setActionStatus(2); // 已完成
|
||||||
action.setCompleteTime(new Date());
|
action.setCompleteTime(new Date());
|
||||||
|
action.setProcessedCoilIds(newCoilIds);
|
||||||
|
|
||||||
// 如果操作人为空,设置当前登录用户为操作人
|
// 如果操作人为空,设置当前登录用户为操作人
|
||||||
if (oldAction.getOperatorId() == null || oldAction.getOperatorName() == null) {
|
if (oldAction.getOperatorId() == null || oldAction.getOperatorName() == null) {
|
||||||
|
|||||||
@@ -1150,17 +1150,17 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean updateByBo(WmsMaterialCoilBo bo) {
|
public String updateByBo(WmsMaterialCoilBo bo) {
|
||||||
// 判断是否批量更新
|
// 判断是否批量更新
|
||||||
if (bo.getNewCoils() != null && !bo.getNewCoils().isEmpty()) {
|
if (bo.getNewCoils() != null && !bo.getNewCoils().isEmpty()) {
|
||||||
// 批量更新逻辑(分卷/合卷)
|
// 批量更新逻辑(分卷/合卷)
|
||||||
return updateByBatch(bo);
|
return updateByBatch(bo); // 分卷返回逗号分隔的ID,合卷返回单个ID
|
||||||
} else {
|
} else {
|
||||||
// 单个更新逻辑,需要coilId
|
// 单个更新逻辑,需要coilId
|
||||||
if (bo.getCoilId() == null) {
|
if (bo.getCoilId() == null) {
|
||||||
throw new RuntimeException("钢卷ID不能为空");
|
throw new RuntimeException("钢卷ID不能为空");
|
||||||
}
|
}
|
||||||
return updateBySingle(bo);
|
return updateBySingle(bo); // 返回新钢卷ID字符串
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1277,8 +1277,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 单个更新
|
* 单个更新
|
||||||
|
* @return 新钢卷ID字符串
|
||||||
*/
|
*/
|
||||||
private Boolean updateBySingle(WmsMaterialCoilBo bo) {
|
private String updateBySingle(WmsMaterialCoilBo bo) {
|
||||||
// 检查独占状态
|
// 检查独占状态
|
||||||
validateCoilOperationPermission(bo.getCoilId(), "单个更新");
|
validateCoilOperationPermission(bo.getCoilId(), "单个更新");
|
||||||
|
|
||||||
@@ -1331,12 +1332,15 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
// 插入新记录
|
// 插入新记录
|
||||||
boolean flag = baseMapper.insert(newCoil) > 0;
|
boolean flag = baseMapper.insert(newCoil) > 0;
|
||||||
|
|
||||||
|
if (!flag) {
|
||||||
|
throw new RuntimeException("创建新钢卷失败");
|
||||||
|
}
|
||||||
|
|
||||||
// 如果实际库区id为-1,则清空钢卷上的实际库区绑定
|
// 如果实际库区id为-1,则清空钢卷上的实际库区绑定
|
||||||
if (bo.getActualWarehouseId() != null && bo.getActualWarehouseId().equals(-1L)) {
|
if (bo.getActualWarehouseId() != null && bo.getActualWarehouseId().equals(-1L)) {
|
||||||
clearActualWarehouseBinding(newCoil.getActualWarehouseId(), newCoil.getCoilId());
|
clearActualWarehouseBinding(newCoil.getActualWarehouseId(), newCoil.getCoilId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag) {
|
|
||||||
// 3. 更新二维码内容(添加更新步骤并更新current_coil_id)
|
// 3. 更新二维码内容(添加更新步骤并更新current_coil_id)
|
||||||
if (oldCoil.getQrcodeRecordId() != null) {
|
if (oldCoil.getQrcodeRecordId() != null) {
|
||||||
updateQrcodeContentForNormalUpdate(oldCoil, bo, newCoil.getCoilId());
|
updateQrcodeContentForNormalUpdate(oldCoil, bo, newCoil.getCoilId());
|
||||||
@@ -1372,9 +1376,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
coilAbnormalService.insertByBo(abnormalBo);
|
coilAbnormalService.insertByBo(abnormalBo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return flag;
|
// 返回新钢卷ID字符串
|
||||||
|
return String.valueOf(newCoil.getCoilId());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 更新实际库区的启用状态
|
* 更新实际库区的启用状态
|
||||||
@@ -1461,7 +1465,11 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
/**
|
/**
|
||||||
* 批量更新(分卷/合卷)
|
* 批量更新(分卷/合卷)
|
||||||
*/
|
*/
|
||||||
private Boolean updateByBatch(WmsMaterialCoilBo bo) {
|
/**
|
||||||
|
* 批量更新(分卷/合卷)
|
||||||
|
* @return 分卷时返回逗号分隔的新钢卷ID字符串,合卷时返回单个新钢卷ID字符串
|
||||||
|
*/
|
||||||
|
private String updateByBatch(WmsMaterialCoilBo bo) {
|
||||||
// 检查独占状态
|
// 检查独占状态
|
||||||
if (bo.getCoilId() != null) {
|
if (bo.getCoilId() != null) {
|
||||||
validateCoilOperationPermission(bo.getCoilId(), "批量更新");
|
validateCoilOperationPermission(bo.getCoilId(), "批量更新");
|
||||||
@@ -1627,6 +1635,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 返回分卷后的所有新钢卷ID(逗号分隔)
|
||||||
|
return childCoilIdsStr;
|
||||||
|
|
||||||
} else if (isMerge) {
|
} else if (isMerge) {
|
||||||
// 合卷:将bo作为合卷后的新钢卷,newCoils中的对象作为参与合卷的原始钢卷
|
// 合卷:将bo作为合卷后的新钢卷,newCoils中的对象作为参与合卷的原始钢卷
|
||||||
// 1. 将参与合卷的原始钢卷的二维码标记为失效,并将钢卷标记为历史数据
|
// 1. 将参与合卷的原始钢卷的二维码标记为失效,并将钢卷标记为历史数据
|
||||||
@@ -1752,9 +1763,12 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
|
|
||||||
// 合卷完成后,设置新钢卷ID到bo对象中,方便外部获取
|
// 合卷完成后,设置新钢卷ID到bo对象中,方便外部获取
|
||||||
bo.setMergedCoilId(newCoil.getCoilId());
|
bo.setMergedCoilId(newCoil.getCoilId());
|
||||||
|
|
||||||
|
// 返回合卷后的新钢卷ID
|
||||||
|
return String.valueOf(newCoil.getCoilId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
throw new RuntimeException("未知的批量更新类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2744,8 +2758,8 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 第二步:执行合卷操作
|
// 第二步:执行合卷操作
|
||||||
Boolean batchResult = updateByBatch(bo);
|
String coilIds = updateByBatch(bo);
|
||||||
if (!Boolean.TRUE.equals(batchResult)) {
|
if (coilIds == null || coilIds.isEmpty()) {
|
||||||
throw new RuntimeException("合卷操作失败");
|
throw new RuntimeException("合卷操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user