feat(warehouse): 添加实际库区/库位释放功能

- 在IWmsActualWarehouseService接口中新增releaseActualWarehouse方法
- 在WmsActualWarehouseController控制器中新增释放库区的REST接口
- 在WmsActualWarehouseServiceImpl服务实现中完成释放逻辑的具体实现
- 实现将库区设置为未被占用状态(isEnabled=1)
- 实现清空钢卷表中绑定此库区的现存记录的actual_warehouse_id字段
- 添加权限注解和异常处理机制
This commit is contained in:
2026-01-13 15:02:16 +08:00
parent 7b28174c9b
commit 491a007e2e
3 changed files with 58 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package com.klp.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.klp.common.exception.ServiceException;
import com.klp.common.utils.StringUtils;
@@ -46,6 +47,38 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService
return baseMapper.selectVoById(actualWarehouseId);
}
/**
* 释放实际库区/库位:
* 1) 将该库区设置为未被占用isEnabled=1
* 2) 清空钢卷表中绑定此库区且为现存(data_type=1)、未删除(del_flag=0)的记录的 actual_warehouse_id
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void releaseActualWarehouse(Long actualWarehouseId) {
if (actualWarehouseId == null || actualWarehouseId <= 0) {
throw new ServiceException("参数actualWarehouseId不合法");
}
// 1) 设置库区为启用(未被占用)
WmsActualWarehouse update = new WmsActualWarehouse();
update.setActualWarehouseId(actualWarehouseId);
update.setIsEnabled(1);
int affected = baseMapper.updateById(update);
if (affected <= 0) {
// 不存在也提示
throw new ServiceException("实际库区不存在或更新失败: " + actualWarehouseId);
}
// 2) 清空钢卷绑定(仅现存且未删除)- 使用UpdateWrapper进行更新
UpdateWrapper<WmsMaterialCoil> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("actual_warehouse_id", actualWarehouseId)
.eq("data_type", 1)
.eq("del_flag", 0)
.set("actual_warehouse_id", null);
wmsMaterialCoilMapper.update(null, updateWrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int batchGenerateLocations(WmsActualWarehouseBatchGenerateBo bo) {