diff --git a/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/InvSubWarehouseController.java b/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/InvSubWarehouseController.java index fe38f917..3487f651 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/InvSubWarehouseController.java +++ b/api-admin/src/main/java/com/glxp/api/admin/controller/inventory/InvSubWarehouseController.java @@ -11,6 +11,7 @@ import com.glxp.api.admin.req.inventory.FilterInvSubWarehouseRequest; import com.glxp.api.admin.req.inventory.FilterInvWarehouseRequest; import com.glxp.api.admin.service.auth.CustomerService; import com.glxp.api.admin.service.inout.WarehouseBussinessTypeService; +import com.glxp.api.admin.service.inventory.InvProductService; import com.glxp.api.admin.service.inventory.InvSubWarehouseService; import com.glxp.api.admin.service.inventory.InvWarehouseService; import com.glxp.api.common.enums.ResultEnum; @@ -24,10 +25,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.validation.Valid; -import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; @RestController public class InvSubWarehouseController { @@ -40,6 +38,8 @@ public class InvSubWarehouseController { CustomerService customerService; @Resource WarehouseBussinessTypeService warehouseBussinessTypeService; + @Resource + private InvProductService invProductService; @AuthRuleAnnotation("") @GetMapping("spms/sub/inv/warehouse/filter") @@ -135,6 +135,14 @@ public class InvSubWarehouseController { if (!warehouseBussinessTypeEntities.isEmpty()) { return ResultVOUtils.error(500, "请先移除该仓库关联用户和单据类型!"); } + + //判断此分库中是否还有库存 + InvSubWarehouseEntity invSubWarehouse = invSubWarehouseService.findById(deleteRequest.getId()); + Integer count = invProductService.countByWarehouseCode(null, invSubWarehouse.getCode()); + if (count > 0) { + return ResultVOUtils.error(500, "此分库存在库存,不能删除!"); + } + boolean b = invSubWarehouseService.deleteById(deleteRequest.getId()); if (!b) { diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvProductDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvProductDao.java index f4b4661d..fa2dc3fe 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvProductDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvProductDao.java @@ -34,4 +34,14 @@ public interface InvProductDao { //库存统计查询 List stockStatistics(FilterInvProductRequest filterInvProductRequest); + /** + * 根据仓库码和分库码,统计库存记录条数 + * + * @param warehouseCode + * @param subWarehouseCode + * @return + */ + Integer countByWarehouseCode(@Param("warehouseCode") String warehouseCode, @Param("subWarehouseCode") String subWarehouseCode); + + } diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvSubWarehouseDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvSubWarehouseDao.java index a4ac6913..0bf29465 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvSubWarehouseDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/InvSubWarehouseDao.java @@ -26,4 +26,13 @@ public interface InvSubWarehouseDao { boolean deleteById(String id); boolean deleteByParentCode(@Param("code") String code); + + /** + * 根据parentId和分库名称统计仓库数量 + * + * @param parentId + * @param name + * @return + */ + int countByParentIdAndName(@Param("parentId") String parentId, @Param("name") String name); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/InvProductService.java b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/InvProductService.java index 05b418c6..4acc8380 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/InvProductService.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/InvProductService.java @@ -27,4 +27,13 @@ public interface InvProductService { //库存统计 List stockStatistics(FilterInvProductRequest filterInvProductRequest); + + /** + * 根据仓库和分库码,查询库存记录条数 + * + * @param warehouseCode + * @param subWarehouseCode + * @return + */ + Integer countByWarehouseCode(String warehouseCode, String subWarehouseCode); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvProductServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvProductServiceImpl.java index 0cd71e32..12d22dcc 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvProductServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvProductServiceImpl.java @@ -107,4 +107,9 @@ public class InvProductServiceImpl implements InvProductService { } return Collections.emptyList(); } + + @Override + public Integer countByWarehouseCode(String warehouseCode, String subWarehouseCode) { + return invProductDao.countByWarehouseCode(warehouseCode, subWarehouseCode); + } } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvSubWarehouseServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvSubWarehouseServiceImpl.java index e0794d46..ec4dd8a2 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvSubWarehouseServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/InvSubWarehouseServiceImpl.java @@ -100,4 +100,13 @@ public class InvSubWarehouseServiceImpl implements InvSubWarehouseService { public boolean deleteByParentCode(String code) { return invSubWarehouseDao.deleteByParentCode(code); } + + @Override + public boolean checkDuplicateName(String parentId, String name) { + int count = invSubWarehouseDao.countByParentIdAndName(parentId, name); + if (count > 0) { + return true; + } + return false; + } } diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml index 2ce35a28..c467f583 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml @@ -285,4 +285,16 @@ WHERE id = #{id} + + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/InvSubWarehouseDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/InvSubWarehouseDao.xml index 2c5f616c..94f3f813 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inventory/InvSubWarehouseDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/InvSubWarehouseDao.xml @@ -122,4 +122,8 @@ + + \ No newline at end of file