Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

qianxb 2 gadi atpakaļ
vecāks
revīzija
9efabb9174

+ 64 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveAutoRuleWbs.java

@@ -0,0 +1,64 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+@Data
+@TableName("m_archive_auto_rule_wbs")
+@EqualsAndHashCode(callSuper = true)
+public class ArchiveAutoRuleWbs extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* wbs节点id
+	*/
+		private Long wbsId;
+	/**
+	* wbs节点根节点id
+	*/
+		private Long wbsRootId;
+	/**
+	* 规则类型 1最高 2分类并卷 3单独组卷
+	*/
+		private Integer archiveAutoType;
+	/**
+	* 分类并卷规则的分组ID
+	*/
+		private Long archiveAutoGroupId;
+	/**
+	* 项目id 系统级的为0
+	*/
+		private Long projectId;
+	/**
+	* 1删除  0正常
+	*/
+		private Integer delete;
+
+
+}

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveTree.java

@@ -141,7 +141,7 @@ public class ArchiveTree extends BaseEntity {
     @ApiModelProperty(value = "扩展关联Id")
     private Long extId;
 	/**
-	* 自动立卷类型
+	* 自动立卷类型 1最高 2分类并卷 3单独并卷
 	*/
     @ApiModelProperty(value = "自动立卷类型")
     private Integer archiveAutoType;

+ 34 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ArchiveAutoRuleWbsVO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.vo;
+
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 视图实体类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ArchiveAutoRuleWbsVO extends ArchiveAutoRuleWbs {
+	private static final long serialVersionUID = 1L;
+
+}

+ 21 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ArchiveTreeController.java

@@ -205,28 +205,36 @@ public class ArchiveTreeController extends BladeController {
     @ApiOperationSupport(order = 8)
     @ApiOperation(value = "保存立卷规则设置", notes = "传入archiveAutoType规则类型,nodeIds逗号拼接选择节点id")
     public R saveArchiveAutoRule(@ApiParam(value = "立卷规则", required = true) @RequestParam Integer archiveAutoType,
-                                 @ApiParam(value = "主键集合", required = true) @RequestParam String nodeIds) {
-        return R.status(archiveTreeService.saveArchiveAutoRule(archiveAutoType,nodeIds));
+                                 @ApiParam(value = "主键集合", required = true) @RequestParam String nodeIds,
+                                 @ApiParam(value = "是否wbs节点", required = true) @RequestParam Boolean iswbsNode) {
+        return R.status(archiveTreeService.saveArchiveAutoRule(archiveAutoType,nodeIds,iswbsNode));
     }
 
 
     /**
-     * 查看立卷规则设置
+     * 修改立卷规则设置
      */
-    @PostMapping("/getArchiveAutoRule")
-    @ApiOperationSupport(order = 9)
-    @ApiOperation(value = "查看立卷规则设置", notes = "传入节点id")
-    public R getArchiveAutoRule(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
-        Map<String, Object> ruleMap=archiveTreeService.getArchiveAutoRule(id);
-        return R.data(ruleMap);
+    @PostMapping("/updateArchiveAutoRule")
+    public R updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto,boolean iswbsNode) {
+        return R.status(archiveTreeService.updateArchiveAutoRule(dto,iswbsNode));
     }
 
     /**
-     * 修改立卷规则设置
+     * 取消立卷规则设置
      */
-    @PostMapping("/updateArchiveAutoRule")
-    public R updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto) {
-        return R.status(archiveTreeService.updateArchiveAutoRule(dto));
+    @PostMapping("/removeArchiveAutoRule")
+    public R removeArchiveAutoRule(Long nodeId,boolean iswbsNode) {
+        Map<String, String> map = archiveTreeService.removeArchiveAutoRule(nodeId, iswbsNode);
+        return R.data(map);
+    }
+
+    /**
+     * 查看立卷规则设置
+     */
+    @PostMapping("/getArchiveAutoRule")
+    public R getArchiveAutoRule(Long id,boolean iswbsNode) {
+        Map<String, Object> ruleMap=archiveTreeService.getArchiveAutoRule(id,iswbsNode);
+        return R.data(ruleMap);
     }
 
 }

+ 46 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveAutoRuleWbsMapper.java

@@ -0,0 +1,46 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.mapper;
+
+import feign.Param;
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import org.springblade.manager.vo.ArchiveAutoRuleWbsVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+public interface ArchiveAutoRuleWbsMapper extends BaseMapper<ArchiveAutoRuleWbs> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param archiveAutoRuleWbs
+	 * @return
+	 */
+	List<ArchiveAutoRuleWbsVO> selectArchiveAutoRuleWbsPage(IPage page, ArchiveAutoRuleWbsVO archiveAutoRuleWbs);
+
+	int removeNodeForArchiveAutoRule_Group(@Param("archiveAutoGroupId") Long archiveAutoGroupId,
+										   @Param("projectId") Long projectId);
+
+}

+ 36 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveAutoRuleWbsMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="archiveAutoRuleWbsResultMap" type="org.springblade.manager.entity.ArchiveAutoRuleWbs">
+        <result column="id" property="id"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="create_user" property="createUser"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="wbs_id" property="wbsId"/>
+        <result column="wbs_root_id" property="wbsRootId"/>
+        <result column="archive_auto_type" property="archiveAutoType"/>
+        <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
+        <result column="project_id" property="projectId"/>
+        <result column="delete" property="delete"/>
+    </resultMap>
+
+
+    <select id="selectArchiveAutoRuleWbsPage" resultMap="archiveAutoRuleWbsResultMap">
+        select * from m_archive_auto_rule_wbs where is_deleted = 0
+    </select>
+
+    <update id="removeNodeForArchiveAutoRule_Group">
+        /**取消同一组的分类并卷规则*/
+        update m_archive_auto_rule_wbs
+        set
+            is_deleted = 1
+        where
+          is_deleted = 0
+          and project_id = #{projectId}
+          and archive_auto_group_id = #{archiveAutoGroupId}
+    </update>
+
+</mapper>

+ 10 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.java

@@ -28,16 +28,22 @@ public interface ArchiveTreeMapper extends BaseMapper<ArchiveTree> {
      * @param tree
      * @return
      */
-    int updateAllSonNodeIdsForArchiveAutoRule(@Param("treeContract") ArchiveTree tree);
+    int updateAllSonNodeIdsForArchiveAutoRule(@Param("archiveAutoType") Integer archiveAutoType,
+                                              @Param("archiveAutoNodeId") Long archiveAutoNodeId,
+                                              @Param("archiveAutoGroupId") Long archiveAutoGroupId,
+                                              @Param("ancestors") String ancestors);
 
     /**
      * 删除立卷规则设置
      * @param tree
      * @return
      */
-    int removeAllSonNodeIdsForArchiveAutoRule_1(@Param("tree") ArchiveTree tree);
-    int removeAllSonNodeIdsForArchiveAutoRule_2(@Param("tree") ArchiveTree tree);
-    int removeAllSonNodeIdsForArchiveAutoRule_3(@Param("tree") ArchiveTree tree);
+    int removeAllSonNodeIdsForArchiveAutoRule_1(@Param("archiveAutoType") Integer archiveAutoType,
+                                                @Param("ancestors") String ancestors);
+    int removeAllSonNodeIdsForArchiveAutoRule_2(@Param("archiveAutoType") Integer archiveAutoType,
+                                                @Param("ancestors") String ancestors);
+    int removeAllSonNodeIdsForArchiveAutoRule_3(@Param("archiveAutoType") Integer archiveAutoType,
+                                                @Param("ancestors") String ancestors);
     int removeNodeForArchiveAutoRule_Group(@Param("archiveAutoGroupId") Long archiveAutoGroupId);
     /**
      * 查看分类并卷规则-获取大类所有节点

+ 17 - 17
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.xml

@@ -283,29 +283,29 @@
 
     <update id="updateAllSonNodeIdsForArchiveAutoRule">
 
-        <if test="tree.archiveAutoType ==1 ">
+        <if test="archiveAutoType ==1 ">
             update m_archive_tree
             set
-            archive_auto_node_id = #{tree.archiveAutoNodeId}
+            archive_auto_node_id = #{archiveAutoNodeId}
             where
-            is_deleted = 0 and ancestors like concat('', #{tree.ancestors}, '%');
+            is_deleted = 0 and ancestors like concat('', #{ancestors}, '%');
         </if>
 
         update m_archive_tree
         set
-        archive_auto_type= #{tree.archiveAutoType},
-        <if test="tree.archiveAutoType ==2 ">
-            archive_auto_group_id=#{tree.archiveAutoGroupId},
+        archive_auto_type= #{archiveAutoType},
+        <if test="archiveAutoType ==2 ">
+            archive_auto_group_id=#{archiveAutoGroupId},
             archive_auto_group_select=0
         </if>
         where
-        is_deleted = 0 and ancestors like concat('', #{tree.ancestors}, '%')
+        is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
         /*最高并卷规则不能覆盖 分类并卷规则,单独组卷规则*/
-        <if test="tree.archiveAutoType ==1 ">
+        <if test="archiveAutoType ==1 ">
             and archive_auto_type != 2 and archive_auto_type != 3
         </if>
         /*分类并卷规则不能覆盖单独组卷规则*/
-        <if test="tree.archiveAutoType ==2 ">
+        <if test="archiveAutoType ==2 ">
             and archive_auto_type != 3
         </if>
     </update>
@@ -316,7 +316,7 @@
             archive_auto_node_id = NULL
         where
             is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%');
+          and ancestors like concat('', #{ancestors}, '%');
 
 
         update m_archive_tree
@@ -324,9 +324,9 @@
             archive_auto_type = NULL
         where
             is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%')
+          and ancestors like concat('', #{ancestors}, '%')
             /*取消规则 只取消规则与自己一致的*/
-          and archive_auto_type = #{tree.archiveAutoType} ;
+          and archive_auto_type = #{archiveAutoType} ;
     </update>
 
     <update id="removeAllSonNodeIdsForArchiveAutoRule_3">
@@ -336,9 +336,9 @@
             archive_auto_type = 1
         where
             is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%')
+          and ancestors like concat('', #{ancestors}, '%')
             /*取消规则 只取消规则与自己一致的*/
-          and archive_auto_type = #{tree.archiveAutoType}
+          and archive_auto_type = #{archiveAutoType}
     </update>
     <update id="removeAllSonNodeIdsForArchiveAutoRule_2">
         /*取消单个节点的分类并卷规则*/
@@ -349,10 +349,10 @@
             archive_auto_group_id = NULL,
             archive_auto_group_select =NULL
         where
-            is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%')
+          is_deleted = 0
+          and ancestors like concat('', #{ancestors}, '%')
             /*取消规则 只取消规则与自己一致的*/
-          and archive_auto_type = #{tree.archiveAutoType}
+          and archive_auto_type = #{archiveAutoType}
     </update>
 
     <update id="removeNodeForArchiveAutoRule_Group">

+ 41 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IArchiveAutoRuleWbsService.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service;
+
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import org.springblade.manager.vo.ArchiveAutoRuleWbsVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+public interface IArchiveAutoRuleWbsService extends BaseService<ArchiveAutoRuleWbs> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param archiveAutoRuleWbs
+	 * @return
+	 */
+	IPage<ArchiveAutoRuleWbsVO> selectArchiveAutoRuleWbsPage(IPage<ArchiveAutoRuleWbsVO> page, ArchiveAutoRuleWbsVO archiveAutoRuleWbs);
+
+}

+ 12 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IArchiveTreeService.java

@@ -42,15 +42,24 @@ public interface IArchiveTreeService extends BaseService<ArchiveTree> {
 	 *项目级立卷规则新增
 	 * @return
 	 */
-	boolean saveArchiveAutoRule(Integer archiveAutoType,String nodeIds);
+	boolean saveArchiveAutoRule(Integer archiveAutoType,String nodeIds,boolean iswbsNode);
 
 
 
-	Map<String,Object> getArchiveAutoRule(Long id);
+	Map<String,Object> getArchiveAutoRule(Long id,boolean iswbsNode);
 
 	/**
 	 *项目级立卷规则更新
 	 * @return
 	 */
-	boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto);
+	boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto,boolean iswbsNode);
+
+
+	/**
+	 * 移除节点立卷规则
+	 * @param nodeId
+	 * @param iswbsNode
+	 * @return
+	 */
+	Map<String,String> removeArchiveAutoRule(Long nodeId,boolean iswbsNode);
 }

+ 41 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveAutoRuleWbsServiceImpl.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service.impl;
+
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import org.springblade.manager.vo.ArchiveAutoRuleWbsVO;
+import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
+import org.springblade.manager.service.IArchiveAutoRuleWbsService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+@Service
+public class ArchiveAutoRuleWbsServiceImpl extends BaseServiceImpl<ArchiveAutoRuleWbsMapper, ArchiveAutoRuleWbs> implements IArchiveAutoRuleWbsService {
+
+	@Override
+	public IPage<ArchiveAutoRuleWbsVO> selectArchiveAutoRuleWbsPage(IPage<ArchiveAutoRuleWbsVO> page, ArchiveAutoRuleWbsVO archiveAutoRuleWbs) {
+		return page.setRecords(baseMapper.selectArchiveAutoRuleWbsPage(page, archiveAutoRuleWbs));
+	}
+
+}

+ 289 - 126
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeServiceImpl.java

@@ -14,9 +14,8 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.dto.ArchiveTreeContractAutoRuleMapDTO;
 import org.springblade.manager.dto.ArchiveTreeDTO;
 import org.springblade.manager.dto.ArchiveTreeSortDTO;
-import org.springblade.manager.entity.ArchiveTree;
-import org.springblade.manager.entity.ArchiveTreeContract;
-import org.springblade.manager.entity.ProjectInfo;
+import org.springblade.manager.entity.*;
+import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
 import org.springblade.manager.service.IProjectInfoService;
 import org.springblade.manager.service.IWbsTreePrivateService;
 import org.springblade.manager.service.IWbsTreeService;
@@ -41,6 +40,8 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
     private final IWbsTreePrivateService wbsTreePrivateService;
     private final IProjectInfoService projectInfoService;
 
+    private final ArchiveAutoRuleWbsMapper archiveAutoRuleWbsMapper;
+
     @Override
     public boolean initArchiveTree() {
         QueryWrapper<ArchiveTree> queryWrapper = new QueryWrapper<>();
@@ -431,20 +432,33 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
      * @return
      */
     @Override
-    public boolean saveArchiveAutoRule(Integer archiveAutoType, String nodeIds) {
-        //项目级不需要考虑是否为wbs节点,已经同步出来了都属于归档树节点,直接按归档树节点处理
+    public boolean saveArchiveAutoRule(Integer archiveAutoType, String nodeIds,boolean iswbsNode) {
+        if(iswbsNode){
+            return saveArchiveAutoRule_WbsTreeNode(archiveAutoType, nodeIds);
+        }else{
+            return saveArchiveAutoRule_ArchiveTreeNode(archiveAutoType, nodeIds);
+        }
+    }
+
+    /**
+     * 归档树节点规则设置保存(系统级)
+     * @param archiveAutoType
+     * @param nodeIds
+     * @return
+     */
+    private Boolean saveArchiveAutoRule_ArchiveTreeNode(Integer archiveAutoType, String nodeIds){
         try{
-            //步骤1保存选择节点的立卷规则。
             String[] ids = nodeIds.split(",");
-
             Long archiveAutoGroupId=null;
-
             //分类并卷规则的需要生成个随机数,作为同一个分类赋值archiveAutoNodeId
             if(archiveAutoType==2){
-                double ran=(Math.random()*100000000) + 1;
+                double v = Math.random() * 10000;
+                int ran = (int)v;
                 archiveAutoGroupId=Long.parseLong(System.currentTimeMillis()+""+ran);
             }
+
             for(String nodeId:ids){
+                //步骤1:保存选择节点的立卷规则。
                 long nodeIdLong = Long.parseLong(nodeId);
                 ArchiveTree archiveTree = baseMapper.selectById(nodeIdLong);
                 archiveTree.setArchiveAutoType(archiveAutoType);
@@ -459,157 +473,306 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                 }
                 baseMapper.updateById(archiveTree);
 
-                //步骤2保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷>分类并卷>最高并卷)
-                baseMapper.updateAllSonNodeIdsForArchiveAutoRule(archiveTree);
+                //步骤2保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷,分类并卷>最高并卷)
+                baseMapper.updateAllSonNodeIdsForArchiveAutoRule(
+                        archiveTree.getArchiveAutoType(),
+                        archiveTree.getArchiveAutoNodeId(),
+                        archiveTree.getArchiveAutoGroupId(),
+                        archiveTree.getAncestors()
+                );
             }
 
             return true;
-
         }catch (Exception e){
             e.printStackTrace();
             return false;
         }
     }
 
-
     /**
-     * 获取节点规则查看
-     * @param id
+     * 归档树wbs节点规则设置保存(系统级)
+     * @param archiveAutoType
+     * @param nodeIds
      * @return
      */
-    @Override
-    public Map<String,Object> getArchiveAutoRule(Long id) {
-
-        Map<String,Object> map= new HashMap<>();
-
-        ArchiveTree archiveTree = baseMapper.selectById(id);
-        Integer archiveAutoType = archiveTree.getArchiveAutoType();
-        if(archiveAutoType!=null){
-            if(archiveAutoType==1){
-                //最高并卷层级 默认规则的节点 显示最高并卷层级节点
-                Long archiveAutoNodeId = archiveTree.getArchiveAutoNodeId();
-                ArchiveTree archiveAutoNode = baseMapper.selectById(archiveAutoNodeId);
-                StringBuffer allName= new StringBuffer();
-                String ancestors = archiveAutoNode.getAncestors();
-                String[] ancestorssplit = ancestors.split(",");//全路径ID
-                for(String pId:ancestorssplit){
-                    long pIdLong = Long.parseLong(pId);
-                    ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
-                    allName.append(pIdNode.getNodeName()+"/");
-                }
-                allName.append(archiveAutoNode.getNodeName());
-                ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
-                vo.setAllName(allName.toString());
-                vo.setNodeId(archiveAutoNode.getId());
-                vo.setArchiveAutoType(archiveAutoType);
-                map.put("type",archiveAutoType);
-                map.put("data",vo);
-                return map;
-            }
+    private Boolean saveArchiveAutoRule_WbsTreeNode(Integer archiveAutoType, String nodeIds){
+        try{
+            String[] ids = nodeIds.split(",");
+            Long archiveAutoGroupId=null;
+            //分类并卷规则的需要生成个随机数,作为同一个分类赋值archiveAutoNodeId
             if(archiveAutoType==2){
-                //分类并卷显示所在大类下树结构,过滤单独规则,其他分类并卷规则组节点 本节点分类组显示打钩
-                //找出当前节点大类
-                String ancestors = archiveTree.getAncestors();
-                String[] ancestorssplit = ancestors.split(",");//全路径ID
-                String nodeAncestors = ancestorssplit[0]+","+ancestorssplit[1]; //大类的ancestors
-                //获取大类下所有节点,过滤单独规则,其他分类并卷规则组节点
-                List<ArchiveTreeAutoRuleVO> nodetree = ForestNodeMerger.merge(baseMapper.getAllSonNodeforGroupView(nodeAncestors, archiveTree.getArchiveAutoNodeId()));
-                //获取与当前节点同一分类的节点
-                List<ArchiveTree> listGroup= baseMapper.selectList(Wrappers.<ArchiveTree>lambdaQuery()
-                        .eq(ArchiveTree::getArchiveAutoGroupId, archiveTree.getArchiveAutoGroupId())
-                        .orderByAsc(ArchiveTree::getSort));
-                StringBuffer nodeSelect = new StringBuffer();
-
-                for(ArchiveTree node:listGroup){
-                    nodeSelect.append(node.getId()+",");
-                }
-                map.put("type",archiveAutoType);
-                map.put("tree",nodetree);
-                map.put("data",nodeSelect.toString());
-                return map;
+                double ran=(Math.random()*100000000) + 1;
+                archiveAutoGroupId=Long.parseLong(System.currentTimeMillis()+""+ran);
             }
-            if(archiveAutoType==3){
-                //单独组卷规则 显示当前节点
-                StringBuffer allName= new StringBuffer();
-                String ancestors = archiveTree.getAncestors();
-                String[] ancestorssplit = ancestors.split(",");//全路径ID
-                for(String pId:ancestorssplit){
-                    long pIdLong = Long.parseLong(pId);
-                    ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
-                    allName.append(pIdNode.getNodeName()+"/");
+
+            for(String nodeId:ids){
+                //步骤1:保存选择节点的立卷规则。
+                long nodeIdLong = Long.parseLong(nodeId);
+                //1.1最高规则和单独规则 将选择的wbs节点ID(wbsId),规则类型(archive_auto_type), 保存表m_archive_auto_rule_wbs
+                WbsTree wbsTree = wbsTreeService.getById(nodeIdLong);
+                ArchiveAutoRuleWbs autoRuleWbs = new ArchiveAutoRuleWbs();
+                autoRuleWbs.setWbsId(nodeIdLong);
+                autoRuleWbs.setArchiveAutoType(archiveAutoType);
+                if(archiveAutoType==2){
+                    autoRuleWbs.setArchiveAutoGroupId(archiveAutoGroupId);
                 }
-                allName.append(archiveTree.getNodeName());
-                ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
-                vo.setAllName(allName.toString());
-                vo.setNodeId(archiveTree.getId());
-                vo.setArchiveAutoType(archiveAutoType);
-                map.put("type",archiveAutoType);
-                map.put("data",vo);
-                return map;
+                autoRuleWbs.setProjectId(0L);//TODO
+                autoRuleWbs.setWbsRootId(null);//TODO
+                archiveAutoRuleWbsMapper.insert(autoRuleWbs);
             }
+            return true;
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
         }
-        return map;
     }
 
 
-    public void removeArchiveAutoRule(Long nodeId){
-        ArchiveTree node = baseMapper.selectById(nodeId);
-        Integer archiveAutoType = node.getArchiveAutoType();
-        if(archiveAutoType!=null){
-            //删除默认规则
-            if(archiveAutoType==1){
-                baseMapper.removeAllSonNodeIdsForArchiveAutoRule_1(node);
-            }
-            //删除节点及所有子节点 分类并卷规则
-            if(archiveAutoType==2){
-                //删除规则
-                baseMapper.removeAllSonNodeIdsForArchiveAutoRule_2(node);
-                //TODO 验证节点的父节点是否为分类并卷规则,如是则取消。若无其他兄弟节点,继续往上验证。
-            }
-            //删除节点及所有子节点 单独并卷规则
-            if(archiveAutoType==3){
-                baseMapper.removeAllSonNodeIdsForArchiveAutoRule_3(node);
-            }
+    @Override
+    public boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto,boolean iswbsNode) {
+        if(iswbsNode){
+            return updateArchiveAutoRule_WbsTreeNode(dto);
+        }else{
+            return updateArchiveAutoRule_ArchiveTreeNode(dto);
         }
 
     }
 
+    /**
+     * 归档树节点规则更新
+     * @param dto
+     * @return
+     */
+    private boolean updateArchiveAutoRule_ArchiveTreeNode(ArchiveTreeContractAutoRuleMapDTO dto) {
+        try{
+            Integer archiveAutoType = dto.getArchiveAutoType();
+            if(archiveAutoType!=null){
+                if(archiveAutoType==2){
+                    Long groupId = dto.getArchiveAutoGroupId();
+                    String selectNodeIds = dto.getSelectNodeIds();
+                    List<String> selectNodeIdlist = Arrays.asList(selectNodeIds);
+                    //先将同一分组的节点删除配置,。
+                    baseMapper.removeNodeForArchiveAutoRule_Group(groupId);
+                    //然后再按照选择节点保存新的设置
+                    for(String nodeId:selectNodeIdlist){
+                        long nodeIdLong = Long.parseLong(nodeId);
+                        ArchiveTree archiveTree = baseMapper.selectById(nodeIdLong);
+                        archiveTree.setArchiveAutoType(archiveAutoType);
+                        //分类并卷规则 提交都是一个分类类型
+                        archiveTree.setArchiveAutoGroupId(groupId);
+                        archiveTree.setArchiveAutoGroupSelect(1);
+                        baseMapper.updateById(archiveTree);
+                        //保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷>分类并卷>最高并卷)
+                        baseMapper.updateAllSonNodeIdsForArchiveAutoRule(
+                                archiveTree.getArchiveAutoType(),
+                                archiveTree.getArchiveAutoNodeId(),
+                                archiveTree.getArchiveAutoGroupId(),
+                                archiveTree.getAncestors()
+                        );
+                    }
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
+        }
 
-    @Override
-    public boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto) {
-        //项目级不需要考虑是否为wbs节点,已经同步出来了都属于归档树节点,直接按归档树节点处理
+        return true;
+    }
 
-        Integer archiveAutoType = dto.getArchiveAutoType();
-        if(archiveAutoType!=null){
-            if(archiveAutoType==2){
-                Long groupId = dto.getArchiveAutoGroupId();
-                String selectNodeIds = dto.getSelectNodeIds();
-                List<String> selectNodeIdlist = Arrays.asList(selectNodeIds);
-                //先将同一分类的节点删除配置,。
-                baseMapper.removeNodeForArchiveAutoRule_Group(groupId);
-                //然后再按照选择节点保存新的设置
-                for(String nodeId:selectNodeIdlist){
-                    long nodeIdLong = Long.parseLong(nodeId);
-                    ArchiveTree archiveTree = baseMapper.selectById(nodeIdLong);
-                    archiveTree.setArchiveAutoType(archiveAutoType);
-                    //分类并卷规则 提交都是一个分类类型
-                    archiveTree.setArchiveAutoGroupId(groupId);
-                    archiveTree.setArchiveAutoGroupSelect(1);
-                    baseMapper.updateById(archiveTree);
-                    //保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷>分类并卷>最高并卷)
-                    baseMapper.updateAllSonNodeIdsForArchiveAutoRule(archiveTree);
+    /**
+     * 归档树wbs节点更新
+     * @param dto
+     * @return
+     */
+    private boolean updateArchiveAutoRule_WbsTreeNode(ArchiveTreeContractAutoRuleMapDTO dto) {
+        try{
+            Integer archiveAutoType = dto.getArchiveAutoType();
+            if(archiveAutoType!=null){
+                if(archiveAutoType==2){
+                    Long groupId = dto.getArchiveAutoGroupId();
+                    String selectNodeIds = dto.getSelectNodeIds();
+                    List<String> selectNodeIdlist = Arrays.asList(selectNodeIds);
+                    //先将同一分组的节点删除配置,。
+                    archiveAutoRuleWbsMapper.removeNodeForArchiveAutoRule_Group(groupId,0L);
+                    //然后再按照选择节点保存新的设置
+                    for(String nodeId:selectNodeIdlist){
+                        long nodeIdLong = Long.parseLong(nodeId);
+                        ArchiveAutoRuleWbs autoRuleWbs = new ArchiveAutoRuleWbs();
+                        autoRuleWbs.setWbsId(nodeIdLong);
+                        autoRuleWbs.setArchiveAutoType(archiveAutoType);
+                        if(archiveAutoType==2){
+                            autoRuleWbs.setArchiveAutoGroupId(groupId);
+                        }
+                        autoRuleWbs.setProjectId(0L);//TODO
+                        autoRuleWbs.setWbsRootId(null);//TODO
+                        archiveAutoRuleWbsMapper.insert(autoRuleWbs);
+                    }
                 }
             }
-            if(archiveAutoType==1){
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
 
+    /**
+     * 移除节点规则
+     * @param nodeId
+     */
+    public Map<String,String> removeArchiveAutoRule(Long nodeId,boolean iswbsNode){
+        Map<String,String> returnMap= new HashMap<>();
+        returnMap.put("code","1");
+        try{
+            if(iswbsNode){
+                ArchiveAutoRuleWbs archiveAutoRuleWbs = archiveAutoRuleWbsMapper.selectById(nodeId);
+                archiveAutoRuleWbs.setDelete(1);
+                archiveAutoRuleWbs.setUpdateTime(new Date());
+                archiveAutoRuleWbsMapper.updateById(archiveAutoRuleWbs);
+            }else{
+                ArchiveTree node = baseMapper.selectById(nodeId);
+                Integer archiveAutoType = node.getArchiveAutoType();
+                if(archiveAutoType!=null){
+                    //删除默认规则
+                    if(archiveAutoType==1){
+                        baseMapper.removeAllSonNodeIdsForArchiveAutoRule_1(node.getArchiveAutoType(),node.getAncestors());
+                    }
+                    //删除节点及所有子节点 分类并卷规则
+                    if(archiveAutoType==2){
+                        if(node.getArchiveAutoGroupSelect()==1){
+                            //删除规则  只能修改archive_auto_group_select=1的节点,
+                            // 因为分类并卷规则影响范围包括下面所有子节点,如果给archive_auto_group_select=0的节点也就是范围内的子节点单独取消规则,会造成案卷归属节点错乱。
+                            // (不理那么多,就这样限制先 。如业务非要发神经就要 TODO 验证节点的父节点是否为分类并卷规则,如是则取消。若无其他兄弟节点,继续往上验证。)
+                            baseMapper.removeAllSonNodeIdsForArchiveAutoRule_2(node.getArchiveAutoType(),node.getAncestors());
+                        }
+                        returnMap.put("code","0");
+                        returnMap.put("msg","只能取消设置的节点,不能取消设置节点范围下节点");
+                    }
+                    //删除节点及所有子节点 单独并卷规则
+                    if(archiveAutoType==3){
+                        baseMapper.removeAllSonNodeIdsForArchiveAutoRule_3(node.getArchiveAutoType(),node.getAncestors());
+                    }
+                }
             }
-            if(archiveAutoType==3){
+        }catch (Exception e){
+            e.printStackTrace();
+            returnMap.put("code","0");
+            returnMap.put("msg",e.getMessage());
+        }
+        return returnMap;
+    }
 
-            }
+    /**
+     * 获取节点规则查看
+     * @param id
+     * @return
+     */
+    @Override
+    public Map<String,Object> getArchiveAutoRule(Long id,boolean iswbsNode) {
 
+        if(iswbsNode){
+            return getArchiveAutoRule_ArchiveTreeNode(id);
+        }else{
+            return getArchiveAutoRule_WbsTreeNode(id);
         }
+    }
 
-        return false;
+    /**
+     * 查看归档树节点立卷规则
+     * @param id
+     * @return
+     */
+    private Map<String,Object> getArchiveAutoRule_ArchiveTreeNode(Long id) {
+        Map<String,Object> map= new HashMap<>();
+        try{
+            ArchiveTree archiveTree = baseMapper.selectById(id);
+            Integer archiveAutoType = archiveTree.getArchiveAutoType();
+            if(archiveAutoType!=null){
+                if(archiveAutoType==1){
+                    //最高并卷层级 默认规则的节点 显示最高并卷层级节点
+                    Long archiveAutoNodeId = archiveTree.getArchiveAutoNodeId();
+                    ArchiveTree archiveAutoNode = baseMapper.selectById(archiveAutoNodeId);
+                    StringBuffer allName= new StringBuffer();
+                    String ancestors = archiveAutoNode.getAncestors();
+                    String[] ancestorssplit = ancestors.split(",");//全路径ID
+                    for(String pId:ancestorssplit){
+                        long pIdLong = Long.parseLong(pId);
+                        ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
+                        allName.append(pIdNode.getNodeName()+"/");
+                    }
+                    allName.append(archiveAutoNode.getNodeName());
+                    ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
+                    vo.setAllName(allName.toString());
+                    vo.setNodeId(archiveAutoNode.getId());
+                    vo.setArchiveAutoType(archiveAutoType);
+                    map.put("type",archiveAutoType);
+                    map.put("data",vo);
+                    return map;
+                }
+                if(archiveAutoType==2){
+                    //分类并卷显示所在大类下树结构,过滤单独规则,其他分类并卷规则组节点 本节点分类组显示打钩
+                    //找出当前节点大类
+                    String ancestors = archiveTree.getAncestors();
+                    String[] ancestorssplit = ancestors.split(",");//全路径ID
+                    String nodeAncestors = ancestorssplit[0]+","+ancestorssplit[1]; //大类的ancestors
+                    //获取大类下所有节点,过滤单独规则,其他分类并卷规则组节点
+                    List<ArchiveTreeAutoRuleVO> nodetree = ForestNodeMerger.merge(baseMapper.getAllSonNodeforGroupView(nodeAncestors, archiveTree.getArchiveAutoNodeId()));
+                    //获取与当前节点设置同一分类分组的节点
+                    List<ArchiveTree> listGroup= baseMapper.selectList(Wrappers.<ArchiveTree>lambdaQuery()
+                            .eq(ArchiveTree::getArchiveAutoGroupId, archiveTree.getArchiveAutoGroupId())
+                            .eq(ArchiveTree::getArchiveAutoGroupSelect,1)
+                            .orderByAsc(ArchiveTree::getSort));
+                    StringBuffer nodeSelect = new StringBuffer();
+
+                    for(ArchiveTree node:listGroup){
+                        nodeSelect.append(node.getId()+",");
+                    }
+                    map.put("type",archiveAutoType);
+                    map.put("tree",nodetree);
+                    map.put("data",nodeSelect.toString());
+                    return map;
+                }
+                if(archiveAutoType==3){
+                    //单独组卷规则 显示当前节点
+                    StringBuffer allName= new StringBuffer();
+                    String ancestors = archiveTree.getAncestors();
+                    String[] ancestorssplit = ancestors.split(",");//全路径ID
+                    for(String pId:ancestorssplit){
+                        long pIdLong = Long.parseLong(pId);
+                        ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
+                        allName.append(pIdNode.getNodeName()+"/");
+                    }
+                    allName.append(archiveTree.getNodeName());
+                    ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
+                    vo.setAllName(allName.toString());
+                    vo.setNodeId(archiveTree.getId());
+                    vo.setArchiveAutoType(archiveAutoType);
+                    map.put("type",archiveAutoType);
+                    map.put("data",vo);
+                    return map;
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return map;
+        }
+        return map;
     }
 
+    /**
+     * 归档树wbs节点规则查看
+     * @param id
+     * @return
+     */
+    private Map<String,Object> getArchiveAutoRule_WbsTreeNode(Long id) {
+        Map<String,Object> map= new HashMap<>();
+        try{
+            //TODO 需要了解关联的wbs节点
+        }catch (Exception e){
+            e.printStackTrace();
+            return map;
+        }
+        return map;
+    }
 }