添加商品类型和机构选择父级的时候只能从父级或者旁级选择的控制

This commit is contained in:
qiankunpingtai
2019-03-14 15:12:09 +08:00
parent 08d3490a5f
commit bd3d8bd2bd
13 changed files with 71 additions and 62 deletions

View File

@@ -83,7 +83,14 @@ public class BusinessConstants {
/**
* 商品类别根目录id
* */
public static final Long MATERIAL_CATEGORY_ROOT_ID = 1L;
/**
* create by: qiankunpingtai
* create time: 2019/3/14 11:41
* description:
* 为了使用户可以自己建初始目录设定根目录的父级目录id为-1
*
*/
public static final Long MATERIAL_CATEGORY_ROOT_PARENT_ID = -1L;
/**
* 商品类别状态
* 0系统默认1启用2删除
@@ -101,10 +108,10 @@ public class BusinessConstants {
public static final String ORGANIZATION_STCD_BUSINESS_TERMINATED = "4";
public static final String ORGANIZATION_STCD_REMOVED = "5";
/**
* 根机构编号
* 根机构编号默认为-1
* 根机构父级编号
* 根机父级构编号默认为-1
* */
public static final String ORGANIZATION_ROOT_NO = "-1";
public static final String ORGANIZATION_ROOT_PARENT_NO = "-1";
/**
* 新增用户默认密码
* */

View File

@@ -92,9 +92,9 @@ public class MaterialCategoryController {
* @return com.alibaba.fastjson.JSONArray
*/
@RequestMapping(value = "/getMaterialCategoryTree")
public JSONArray getMaterialCategoryTree() throws Exception{
public JSONArray getMaterialCategoryTree(@RequestParam("id") Long id) throws Exception{
JSONArray arr=new JSONArray();
List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree();
List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree(id);
if(materialCategoryTree!=null&&materialCategoryTree.size()>0){
for(TreeNode node:materialCategoryTree){
String str=JSON.toJSONString(node);

View File

@@ -95,9 +95,9 @@ public class OrganizationController {
* @return com.alibaba.fastjson.JSONArray
*/
@RequestMapping(value = "/getOrganizationTree")
public JSONArray getOrganizationTree() throws Exception{
public JSONArray getOrganizationTree(@RequestParam("id") Long id) throws Exception{
JSONArray arr=new JSONArray();
List<TreeNode> organizationTree= organizationService.getOrganizationTree();
List<TreeNode> organizationTree= organizationService.getOrganizationTree(id);
if(organizationTree!=null&&organizationTree.size()>0){
for(TreeNode node:organizationTree){
String str=JSON.toJSONString(node);

View File

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Description
@@ -24,8 +25,8 @@ public interface MaterialCategoryMapperEx {
@Param("name") String name,
@Param("parentId") Integer parentId);
List<TreeNode> getNodeTree();
List<TreeNode> getNextNodeTree(@Param("id") Long id);
List<TreeNode> getNodeTree(@Param("currentId")Long currentId);
List<TreeNode> getNextNodeTree(Map<String, Object> parameterMap);
int addMaterialCategory(MaterialCategory mc);

View File

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Description
@@ -17,8 +18,8 @@ import java.util.List;
public interface OrganizationMapperEx {
List<TreeNode> getNodeTree();
List<TreeNode> getNextNodeTree(@Param("id") Long id);
List<TreeNode> getNodeTree(@Param("currentId")Long currentId);
List<TreeNode> getNextNodeTree(Map<String, Object> parameterMap);
int addOrganization(Organization org);

View File

@@ -100,8 +100,8 @@ public class MaterialCategoryService {
* @Param:
* @return java.util.List<com.jsh.erp.datasource.vo.TreeNode>
*/
public List<TreeNode> getMaterialCategoryTree() throws Exception{
return materialCategoryMapperEx.getNodeTree();
public List<TreeNode> getMaterialCategoryTree(Long id) throws Exception{
return materialCategoryMapperEx.getNodeTree(id);
}
/**
* create by: cjl
@@ -117,8 +117,8 @@ public class MaterialCategoryService {
return 0;
}
if(mc.getParentid()==null){
//没有给定父级目录的id默认设置父级目录为根目录
mc.setParentid(BusinessConstants.MATERIAL_CATEGORY_ROOT_ID);
//没有给定父级目录的id默认设置父级目录为根目录的父目录
mc.setParentid(BusinessConstants.MATERIAL_CATEGORY_ROOT_PARENT_ID);
}
//检查商品类型编号是否已存在
checkMaterialCategorySerialNo(mc);
@@ -148,40 +148,16 @@ public class MaterialCategoryService {
if(strArray.length<1){
return 0;
}
/**
* create by: qiankunpingtai
* create time: 2019/3/13 14:49
* description:
* 添加一个限制,根目录不允许删除
*/
String rootIdStr=BusinessConstants.MATERIAL_CATEGORY_ROOT_ID.toString();
for(String s:strArray){
if(rootIdStr.equals(s)){
logger.error("异常码[{}],异常提示[{}],参数,id:[{}]",
ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE,
ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG,s);
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE,
ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG);
}
}
return materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int editMaterialCategory(MaterialCategory mc) {
/**
* create by: qiankunpingtai
* create time: 2019/3/13 14:49
* description:
* 添加一个限制根目录不允许修改
*/
if(BusinessConstants.MATERIAL_CATEGORY_ROOT_ID.equals(mc.getId())){
logger.error("异常码[{}],异常提示[{}],参数,id:[{}]",
ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE,
ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG,mc.getId());
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE,
ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG);
if(mc.getParentid()==null){
//没有给定父级目录的id默认设置父级目录为根目录的父目录
mc.setParentid(BusinessConstants.MATERIAL_CATEGORY_ROOT_PARENT_ID);
}
//检查商品类型编号是否已存在
checkMaterialCategorySerialNo(mc);
//更新时间

View File

@@ -82,7 +82,7 @@ public class OrganizationService {
* 未指定父级机构的时候默认为根机构
* */
if(StringUtil.isEmpty(org.getOrgParentNo())){
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO);
}
return organizationMapperEx.addOrganization(org);
}
@@ -103,13 +103,13 @@ public class OrganizationService {
* 未指定父级机构的时候默认为根机构
* */
if(StringUtil.isEmpty(org.getOrgParentNo())){
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO);
}
return organizationMapperEx.editOrganization(org);
}
public List<TreeNode> getOrganizationTree()throws Exception {
return organizationMapperEx.getNodeTree();
public List<TreeNode> getOrganizationTree(Long id)throws Exception {
return organizationMapperEx.getNodeTree(id);
}
public List<Organization> findById(Long id) throws Exception{

View File

@@ -33,14 +33,14 @@
<resultMap id="BaseTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
<result column="id" property="id"/>
<result column="name" property="text"/>
<collection column="id" property="children" javaType="java.util.ArrayList"
<collection column="{currentId=currentId,id=id}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
<resultMap id="NextTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
<result column="id" property="id"/>
<result column="name" property="text"/>
<collection column="id" property="children" javaType="java.util.ArrayList"
<collection column="{currentId=currentId,id=id}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
@@ -50,19 +50,25 @@
<select id="getNextNodeTree" resultMap="NextTreeResultMap">
SELECT
<include refid="Base_Column_List"/>
<include refid="Base_Column_List"/>,#{currentId} as currentId
FROM jsh_materialcategory
WHERE ParentId = #{id}
<if test="currentId != null">
and id !=#{currentId}
</if>
and status !='2'
order by sort asc
</select>
<select id="getNodeTree" resultMap="BaseTreeResultMap">
SELECT
<include refid="Base_Column_List"/>
<include refid="Base_Column_List"/>,#{currentId} as currentId
FROM jsh_materialcategory
WHERE ParentId = -1
and status !='2'
<if test="currentId != null">
and id !=#{currentId}
</if>
order by sort asc
</select>
<insert id="addMaterialCategory" parameterType="com.jsh.erp.datasource.entities.MaterialCategory"

View File

@@ -6,7 +6,7 @@
<result column="id" property="id"/>
<result column="org_abr" property="text"/>
<result column="org_no" property="attributes"/>
<collection column="org_no" property="children" javaType="java.util.ArrayList"
<collection column="{currentId=currentId,org_no=org_no}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
@@ -14,7 +14,7 @@
<result column="id" property="id"/>
<result column="org_abr" property="text"/>
<result column="org_no" property="attributes"/>
<collection column="org_no" property="children" javaType="java.util.ArrayList"
<collection column="{currentId=currentId,org_no=org_no}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
@@ -24,18 +24,24 @@
<select id="getNextNodeTree" resultMap="NextTreeResultMap">
SELECT
<include refid="Base_Column_List"/>
<include refid="Base_Column_List"/>,#{currentId} as currentId
FROM jsh_organization
WHERE org_parent_no = #{org_no}
<if test="currentId != null">
and id !=#{currentId}
</if>
and org_stcd !='5'
order by sort asc
</select>
<select id="getNodeTree" resultMap="BaseTreeResultMap">
SELECT
<include refid="Base_Column_List"/>
<include refid="Base_Column_List"/>,#{currentId} as currentId
FROM jsh_organization
WHERE org_parent_no = -1
<if test="currentId != null">
and id !=#{currentId}
</if>
and org_stcd !='5'
order by sort asc
</select>