diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index a319ca00..ae88b8dd 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -253,12 +253,15 @@ public class ExceptionConstants { //商品类别编号已存在 public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003; public static final String MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG = "商品类别编号已存在"; - //根目录不支持修改 + //根类别不支持修改 public static final int MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE = 7500004; - public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG = "根目录不支持修改"; - //根目录不支持删除 + public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG = "根类别不支持修改"; + //根类别不支持删除 public static final int MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE = 7500005; - public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG = "根目录不支持删除"; + public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG = "根类别不支持删除"; + //该类别存在下级不允许删除 + public static final int MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE = 7500006; + public static final String MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG = "该类别存在下级不允许删除"; /** * 商品信息 * type = 80 @@ -422,6 +425,9 @@ public class ExceptionConstants { //根机构不允许修改 public static final int ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE = 11000005; public static final String ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG = "根机构不允许修改"; + //该机构存在下级不允许删除 + public static final int ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_CODE = 11000006; + public static final String ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_MSG = "该机构存在下级不允许删除"; /** * 机构用户关联关系 * type = 115 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/OrganizationMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/OrganizationMapperEx.java index 20e41b20..23df4003 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/OrganizationMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/OrganizationMapperEx.java @@ -23,6 +23,8 @@ public interface OrganizationMapperEx { int addOrganization(Organization org); + List getOrganizationByParentIds(@Param("ids") String ids[]); + int batchDeleteOrganizationByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]); int editOrganization(Organization org); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java index 94f5710d..270560e0 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java @@ -200,10 +200,14 @@ public class MaterialCategoryService { if(strArray.length<1){ return 0; } - try{ + List mcList = materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray); + if(mcList!=null && mcList.size()>0) { + logger.error("异常码[{}],异常提示[{}]", + ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE,ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG); + throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE, + ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG); + } else { result=materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray); - }catch(Exception e){ - JshException.writeFail(logger, e); } return result; } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/organization/OrganizationService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/organization/OrganizationService.java index 549a8307..df700b51 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/organization/OrganizationService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/organization/OrganizationService.java @@ -117,11 +117,16 @@ public class OrganizationService { User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); int result=0; - try{ + List organList = organizationMapperEx.getOrganizationByParentIds(idArray); + if(organList!=null && organList.size()>0) { + //如果存在子机构则不能删除 + logger.error("异常码[{}],异常提示[{}]", + ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_CODE,ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_MSG); + throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_CODE, + ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_MSG); + } else { result=organizationMapperEx.batchDeleteOrganizationByIds( new Date(),userInfo==null?null:userInfo.getId(),idArray); - }catch(Exception e){ - JshException.writeFail(logger, e); } return result; } diff --git a/jshERP-boot/src/main/resources/mapper_xml/OrganizationMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/OrganizationMapperEx.xml index 6f011a3f..737cb140 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/OrganizationMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/OrganizationMapperEx.xml @@ -60,6 +60,17 @@ #{parentId,jdbcType=BIGINT}, #{sort,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}) + update jsh_organization set update_Time=#{updateTime},delete_flag='1'