diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmStorageLocationController.java b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmStorageLocationController.java index 029020a..a43807b 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmStorageLocationController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmStorageLocationController.java @@ -118,12 +118,12 @@ public class WmStorageLocationController extends BaseController @DeleteMapping("/{locationIds}") public AjaxResult remove(@PathVariable Long[] locationIds) { - //TODO:库区删除之前的逻辑校验 - - for (Long locationId: locationIds - ) { - wmStorageAreaService.deleteByLocationId(locationId); - } - return toAjax(wmStorageLocationService.deleteWmStorageLocationByLocationIds(locationIds)); +// //TODO:库区删除之前的逻辑校验 +// +// for (Long locationId: locationIds +// ) { +// wmStorageAreaService.deleteByLocationId(locationId); +// } + return wmStorageLocationService.deleteWmStorageLocationByLocationIds(locationIds); } } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmStorageLocationMapper.java b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmStorageLocationMapper.java index 9f30244..d05b891 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmStorageLocationMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmStorageLocationMapper.java @@ -2,6 +2,7 @@ package com.ktg.mes.wm.mapper; import java.util.List; import com.ktg.mes.wm.domain.WmStorageLocation; +import org.apache.ibatis.annotations.Param; /** * 库区设置Mapper接口 @@ -78,4 +79,11 @@ public interface WmStorageLocationMapper * @return */ public int deleteByWarehouseId(Long warehouseId); + + /** + * 根据locationIds查询库区数据 + * @param locationIds + * @return + */ + List selectByLocationIds(@Param("ids") Long[] locationIds); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java index 3e3427c..87f90b1 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java @@ -1,6 +1,8 @@ package com.ktg.mes.wm.service; import java.util.List; + +import com.ktg.common.core.domain.AjaxResult; import com.ktg.mes.wm.domain.WmStorageLocation; /** @@ -69,11 +71,11 @@ public interface IWmStorageLocationService /** * 批量删除库区设置 - * + * * @param locationIds 需要删除的库区设置主键集合 * @return 结果 */ - public int deleteWmStorageLocationByLocationIds(Long[] locationIds); + public AjaxResult deleteWmStorageLocationByLocationIds(Long[] locationIds); /** * 删除库区设置信息 diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java index 2339f77..d9b95bd 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java @@ -3,9 +3,10 @@ package com.ktg.mes.wm.service.impl; import java.util.List; import com.ktg.common.constant.UserConstants; +import com.ktg.common.core.domain.AjaxResult; import com.ktg.common.utils.DateUtils; import com.ktg.common.utils.StringUtils; -import org.apache.catalina.User; +import com.ktg.mes.wm.service.IWmStorageAreaService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ktg.mes.wm.mapper.WmStorageLocationMapper; @@ -24,6 +25,9 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService @Autowired private WmStorageLocationMapper wmStorageLocationMapper; + @Autowired + private IWmStorageAreaService wmStorageAreaService; + /** * 查询库区设置 * @@ -101,14 +105,28 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService /** * 批量删除库区设置 - * + * * @param locationIds 需要删除的库区设置主键 * @return 结果 */ @Override - public int deleteWmStorageLocationByLocationIds(Long[] locationIds) + public AjaxResult deleteWmStorageLocationByLocationIds(Long[] locationIds) { - return wmStorageLocationMapper.deleteWmStorageLocationByLocationIds(locationIds); + // 查询所有需要删除的数据 + List list = wmStorageLocationMapper.selectByLocationIds(locationIds); + for (WmStorageLocation item : list) { + String locationCode = item.getLocationCode(); + if (locationCode.contains("VIRTUAL")) { + return AjaxResult.error("线边库库区不能被删除"); + } + } + + for (Long locationId: locationIds + ) { + wmStorageAreaService.deleteByLocationId(locationId); + } + wmStorageLocationMapper.deleteWmStorageLocationByLocationIds(locationIds); + return AjaxResult.success(); } /** diff --git a/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml b/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml index 4a13c81..ab0d23a 100644 --- a/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml +++ b/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml @@ -144,7 +144,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete form wm_storage_area where location_id = #{locationId} + delete from wm_storage_area where location_id = #{locationId} \ No newline at end of file diff --git a/ktg-mes/src/main/resources/mapper/wm/WmStorageLocationMapper.xml b/ktg-mes/src/main/resources/mapper/wm/WmStorageLocationMapper.xml index b64c93f..c06c5e7 100644 --- a/ktg-mes/src/main/resources/mapper/wm/WmStorageLocationMapper.xml +++ b/ktg-mes/src/main/resources/mapper/wm/WmStorageLocationMapper.xml @@ -57,6 +57,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where location_name = #{locationName} and warehouse_id = #{warehouseId} limit 1 + insert into wm_storage_location