diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/warehouse/MesWmWarehouseLocationController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/warehouse/MesWmWarehouseLocationController.java index e444b47..accbb29 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/warehouse/MesWmWarehouseLocationController.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/warehouse/MesWmWarehouseLocationController.java @@ -94,20 +94,14 @@ public class MesWmWarehouseLocationController { return success(buildWarehouseLocationRespVOList(list)); } - // TODO @AI:update-by-location;方法名也改下; - @PutMapping("/update-mixing") + @PutMapping("/update-by-location-id") @Operation(summary = "批量设置库区下所有库位的混放规则") @PreAuthorize("@ss.hasPermission('mes:wm-warehouse:update')") - public CommonResult updateMixing(@RequestParam("locationId") Long locationId, - @RequestParam(value = "allowItemMixing", required = false) Boolean allowItemMixing, - @RequestParam(value = "allowBatchMixing", required = false) Boolean allowBatchMixing) { - // TODO @AI:统一放到 service 里; - if (allowItemMixing != null) { - areaService.updateAllowItemMixingByLocationId(locationId, allowItemMixing); - } - if (allowBatchMixing != null) { - areaService.updateAllowBatchMixingByLocationId(locationId, allowBatchMixing); - } + public CommonResult updateAreaByLocationId( + @RequestParam("locationId") Long locationId, + @RequestParam(value = "allowItemMixing", required = false) Boolean allowItemMixing, + @RequestParam(value = "allowBatchMixing", required = false) Boolean allowBatchMixing) { + areaService.updateByLocationId(locationId, allowItemMixing, allowBatchMixing); return success(true); } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/warehouse/MesWmWarehouseAreaMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/warehouse/MesWmWarehouseAreaMapper.java index 949518d..68ca7e2 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/warehouse/MesWmWarehouseAreaMapper.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/warehouse/MesWmWarehouseAreaMapper.java @@ -59,21 +59,11 @@ public interface MesWmWarehouseAreaMapper extends BaseMapperX() - .eq(MesWmWarehouseAreaDO::getLocationId, locationId)); - } - - /** - * 批量更新指定库区下所有库位的批次混放规则 - */ - default void updateAllowBatchMixingByLocationId(Long locationId, Boolean allowBatchMixing) { - update(new MesWmWarehouseAreaDO().setAllowBatchMixing(allowBatchMixing), - new LambdaQueryWrapperX() - .eq(MesWmWarehouseAreaDO::getLocationId, locationId)); + default void updateByLocationId(Long locationId, MesWmWarehouseAreaDO updateObj) { + update(updateObj, new LambdaQueryWrapperX() + .eq(MesWmWarehouseAreaDO::getLocationId, locationId)); } } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaService.java index b3638ec..a26d298 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaService.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaService.java @@ -101,20 +101,13 @@ public interface MesWmWarehouseAreaService { void validateWarehouseAreaExists(Long warehouseId, Long locationId, Long areaId); /** - * 批量设置指定库区下所有库位的物料混放规则 + * 批量设置指定库区下所有库位的混放规则 * * @param locationId 库区编号 - * @param allowItemMixing 是否允许物料混放 + * @param allowItemMixing 是否允许物料混放(null 表示不修改) + * @param allowBatchMixing 是否允许批次混放(null 表示不修改) */ - void updateAllowItemMixingByLocationId(Long locationId, Boolean allowItemMixing); - - /** - * 批量设置指定库区下所有库位的批次混放规则 - * - * @param locationId 库区编号 - * @param allowBatchMixing 是否允许批次混放 - */ - void updateAllowBatchMixingByLocationId(Long locationId, Boolean allowBatchMixing); + void updateByLocationId(Long locationId, Boolean allowItemMixing, Boolean allowBatchMixing); /** * 按编码获得库位(如果是虚拟线边库位编码且不存在,会自动插入) diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaServiceImpl.java index f5b8cd0..2b4b64b 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaServiceImpl.java @@ -196,13 +196,19 @@ public class MesWmWarehouseAreaServiceImpl implements MesWmWarehouseAreaService } @Override - public void updateAllowItemMixingByLocationId(Long locationId, Boolean allowItemMixing) { - areaMapper.updateAllowItemMixingByLocationId(locationId, allowItemMixing); - } - - @Override - public void updateAllowBatchMixingByLocationId(Long locationId, Boolean allowBatchMixing) { - areaMapper.updateAllowBatchMixingByLocationId(locationId, allowBatchMixing); + public void updateByLocationId(Long locationId, Boolean allowItemMixing, Boolean allowBatchMixing) { + // 校验库区存在 + locationService.validateWarehouseLocationExists(locationId); + // 构建更新对象 + MesWmWarehouseAreaDO updateObj = new MesWmWarehouseAreaDO(); + if (allowItemMixing != null) { + updateObj.setAllowItemMixing(allowItemMixing); + } + if (allowBatchMixing != null) { + updateObj.setAllowBatchMixing(allowBatchMixing); + } + // 批量更新库位 + areaMapper.updateByLocationId(locationId, updateObj); } @Override