From 9dc9785111cc470f8ed128f964208d862b96bd6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Tue, 9 Nov 2021 23:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E5=92=8C=E6=9C=BA=E6=9E=84=E7=9A=84=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsh/erp/constants/ExceptionConstants.java | 14 ++++++++++---- .../datasource/mappers/OrganizationMapperEx.java | 2 ++ .../materialCategory/MaterialCategoryService.java | 10 +++++++--- .../service/organization/OrganizationService.java | 11 ++++++++--- .../resources/mapper_xml/OrganizationMapperEx.xml | 11 +++++++++++ 5 files changed, 38 insertions(+), 10 deletions(-) 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'