luojun %!s(int64=2) %!d(string=hai) anos
pai
achega
20297a85a5

+ 2 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java

@@ -49,8 +49,8 @@ public class ApiPlanController {
     @RequiresPermissions("core:plan:find")
     public AjaxResult hostList(@RequestBody AppPlanVo info) {
 
-        Page<AppPlan> result = appPlanService.selectPage(info);
-        return AjaxResult.success(result);
+//        Page<AppPlan> result = ;
+        return AjaxResult.success(appPlanService.selectPage(info));
     }
 
     @PostMapping("/distribute")

+ 5 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/AppPlan.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -12,6 +13,7 @@ import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 履职,安全检查计划表(core_resumption_plan)实体类
@@ -27,7 +29,8 @@ import java.util.Date;
 @AllArgsConstructor
 public class AppPlan extends Model<AppPlan> implements Serializable {
     private static final long serialVersionUID = 1L;
-
+    @TableField(exist = false)
+    private Integer orgType;
     /**
      * 主键
      */
@@ -38,6 +41,7 @@ public class AppPlan extends Model<AppPlan> implements Serializable {
      */
 
     private String planName;
+    private List<AppPlan> children;
     /**
      * 计划类型 0:履职计划,1,安全检查,2教育培训
      */

+ 1 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/AppPlanMapper.java

@@ -31,7 +31,7 @@ public interface AppPlanMapper extends BaseMapper<AppPlan> {
      * @return
      */
     Page<AppPlan> selectPage(Page<AppPlan> page, @Param("info") AppPlanVo plan);
-
+List<AppPlan> selectAll(@Param("info") AppPlanVo plan);
     /**
      *通过履职计划id获取履职任务执行机构
      * @param plan_id

+ 72 - 8
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppPlanServiceImpl.java

@@ -16,6 +16,7 @@ import com.xunmei.core.resumption.vo.appPlan.AppPlanVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleItemVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleRequestVo;
 import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.domain.SysDept;
 import com.xunmei.system.api.domain.SysOrg;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -68,15 +69,75 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
     @Override
     public Page<AppPlan> selectPage(AppPlanVo info) {
-        Page<AppPlan> page = new Page<>();
-        long current = info.getPageNum();
-        long size = info.getPageSize();
-        page.setCurrent(current);
-        page.setSize(size);
-        Page<AppPlan> result = baseMapper.selectPage(page, info);
+        //获取选择机构id
+        Long orgid = info.getOrgId();
+        //下穿计算
+        if (info.isCheckSub()) {
+            List<Long> ids = orgService.selectCheckSubOrgIdList(info.getOrgId(), SecurityConstants.INNER);
+            info.setIds(ids);
+            info.setOrgId(null);
+
+        }
+        //获取前段对应的数据库页数
+        int current = Math.toIntExact(info.getPageNum() - 1);
+        int size = Math.toIntExact(info.getPageSize());
+        Page<AppPlan> result = new Page<>();
+        //查询所有数据
+        List<AppPlan> sel = baseMapper.selectAll(info);
+        //list转树结构
+        List<AppPlan> appPlans = recursionDept(sel,orgid);
+        //计算分页所需数组起始位置
+        int start = current * size;
+        int end = Math.min(start + size, appPlans.size());
+        //封装前端需要的分页数据
+        result.setRecords(appPlans.subList(start, end));
+
+        //计算最外层数量
+        long total = appPlans.size();
+        result.setTotal(total);
+        result.setPages(total / info.getPageSize());
         return result;
     }
 
+    /**
+     * dept递归方法转换成树形结构
+     *
+     * @param treeList
+     * @return
+     */
+    public static List<AppPlan> recursionDept(List<AppPlan> treeList,Long orgid) {
+        List<AppPlan> trees = new ArrayList<>();
+        for (AppPlan tree : treeList) {
+            // 找出父节点
+            if (-1 == tree.getParentId()) {
+                // 调用递归方法填充子节点列表
+                trees.add(findChildren(tree, treeList));
+            }
+        }
+        return trees;
+    }
+
+    /**
+     * dept递归方法
+     *
+     * @param tree     父节点对象
+     * @param treeList 所有的List
+     * @return
+     */
+    public static AppPlan findChildren(AppPlan tree, List<AppPlan> treeList) {
+        for (AppPlan node : treeList) {
+            if (tree.getId().equals(node.getParentId())) {
+                if (tree.getChildren() == null) {
+                    tree.setChildren(new ArrayList<>());
+                }
+                // 递归 调用自身
+                tree.getChildren().add(findChildren(node, treeList));
+            }
+        }
+        return tree;
+    }
+
+
     @Override
     public List<Long> findExecOrgByPlan(Long plan_id) {
         return baseMapper.findExecOrgByPlan(plan_id);
@@ -94,6 +155,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
             AppPlan plan = baseMapper.selectById(dto.getId());
             plan.setOrgId(d.getOrgId().toString());
+            plan.setDistributeStatus("1");
             plan.setPlanOfOrgId(d.getOrgId().toString());
             plan.setPlanStatus(d.getStatus());
             plan.setDistributePlanStatus(d.getStatus().toString());
@@ -165,6 +227,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     public void saveOrUpdatePlan(AppPlanVo app) throws Exception {
         AppPlan plan = convertToAppPlan(app);
         if (app.getId() == null) {
+            plan.setParentId(-1L);
+            plan.setDeleted(0);
             //新增
             plan.setPlanOfOrgId(app.getPlanCreateOrgId());
             plan.setPlanOfOrgName(app.getPlanCreateOrgName());
@@ -227,7 +291,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 //
 //            }
         } else {
-            if(app.getRoleList()==null){
+            if (app.getRoleList() == null) {
                 app.setRoleList(new ArrayList<>());
             }
             //修改
@@ -245,7 +309,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             baseMapper.updateById(plan);
 
             Long id = plan.getId();
-            if(app.getRoleList().size()>0){
+            if (app.getRoleList().size() > 0) {
                 QueryWrapper<AppPlanToRole> apr = new QueryWrapper<>();
                 apr.lambda().eq(AppPlanToRole::getPlanId, id);
                 appPlanToRoleMapper.delete(apr);

+ 5 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/vo/appPlan/AppPlanVo.java

@@ -20,7 +20,7 @@ import java.util.List;
 @AllArgsConstructor
 public class AppPlanVo extends PageDto {
 
-
+private List<Long> ids;
     private Long id;
 
     /**
@@ -72,7 +72,10 @@ public class AppPlanVo extends PageDto {
     private String count;
     private String planCreateOrgId;
     private String planCreateOrgName;
-
+    /**
+     * 是否下穿
+     */
+    private boolean checkSub;
     /**
      * 备注
      */

+ 111 - 20
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppPlanMapper.xml

@@ -6,7 +6,8 @@
     </sql>
 
     <sql id="baseColumn">
-        id,plan_name,plan_type,plan_cycle,plan_exec,exec_org_type,check_org_type,check_type,exec_type,plan_status,description,create_time,modified_name,update_time,modified_by
+        id
+        ,plan_name,plan_type,plan_cycle,plan_exec,exec_org_type,check_org_type,check_type,exec_type,plan_status,description,create_time,modified_name,update_time,modified_by
     </sql>
 
     <resultMap id="appPlans" type="com.xunmei.core.resumption.domain.AppPlan">
@@ -82,6 +83,9 @@
             <if test="info.orgType != null">
                 and a.exec_org_type = #{info.orgType}
             </if>
+            <if test="info.orgId != null">
+                and a.plan_of_org_id = #{info.orgId}
+            </if>
             <if test="info.roleList != null and info.roleList.size > 0">
                 and a.id in (select plan_id from core_resumption_plan_to_role where role_id in
                 <foreach collection="info.roleList" item="roleId" index="index" open="(" separator="," close=")">
@@ -96,9 +100,16 @@
                 </foreach>
                 )
             </if>
+            <if test="info.ids!=null and info.ids.size > 0">
+                and a.plan_of_org_id in
+                <foreach collection="info.ids" item="orgId" index="index" open="(" separator="," close=")">
+                    #{orgId}
+                </foreach>
+            </if>
         </where>
     </select>
-    <select id="selectItemPage" parameterType="com.xunmei.core.resumption.vo.appPlan.RuleItemVo" resultType="com.xunmei.core.resumption.vo.appPlan.RuleItemVo">
+    <select id="selectItemPage" parameterType="com.xunmei.core.resumption.vo.appPlan.RuleItemVo"
+            resultType="com.xunmei.core.resumption.vo.appPlan.RuleItemVo">
         select
         a.id,
         a.item_id,
@@ -131,18 +142,17 @@
 
 
     <select id="selectByPlanId" resultType="com.xunmei.core.resumption.vo.appPlan.RuleItemVo">
-        SELECT
-            h.point_id as id,
-            a.item_id,
-            b.NAME AS item_name,
-            b.DESC AS item_desc,--                b.item_num,
+        SELECT h.point_id      as id,
+               a.item_id,
+               b.NAME          AS item_name,
+               b.DESC          AS item_desc,--                b.item_num,
 --                a.safe_type,
-            c.`name` area_name,
-            a.NAME AS point_name,--                a.point_num,
-            h.point_scan,
-            h.required,
-            d.NAME AS ruleName,
-            a.business_type AS businessType
+               c.`name`           area_name,
+               a.NAME          AS point_name,--                a.point_num,
+               h.point_scan,
+               h.required,
+               d.NAME          AS ruleName,
+               a.business_type AS businessType
         FROM (SELECT point_id, point_scan, required FROM core_resumption_plan_to_point WHERE plan_id = #{planId}) h
                  LEFT JOIN core_resumption_rule_point a ON h.point_id = a.id
                  LEFT JOIN core_resumption_rule_item b ON a.item_id = b.id
@@ -154,7 +164,7 @@
     <select id="findExecOrgByPlan" parameterType="Long" resultType="Long">
         select org_id
         from core_resumption_plan_to_exec_org a
-        INNER JOIN sys_org o on a.org_id=o.id and o.deleted=0 and o.is_lock=0
+                 INNER JOIN sys_org o on a.org_id = o.id and o.deleted = 0 and o.is_lock = 0
         where a.plan_id = #{plan_id}
     </select>
     <select id="findRoleByPlan" parameterType="Long" resultType="Long">
@@ -212,17 +222,98 @@
     <select id="selectPlanByName" resultMap="appPlans">
         select *
         from core_resumption_plan
-        where plan_name like CONCAT('%', #{planName}, '%') and deleted=0
-        limit 1
+        where plan_name like CONCAT('%', #{planName}, '%')
+          and deleted = 0 limit 1
     </select>
     <select id="selectPlanNameById" resultType="java.lang.String">
-        select plan_name from core_resumption_plan where id = #{planId}
+        select plan_name
+        from core_resumption_plan
+        where id = #{planId}
     </select>
     <select id="selectPlanNames" resultType="com.xunmei.common.core.vo.IdNameVo">
         select id, plan_name as name from core_resumption_plan where id in
-            <foreach collection="ids" item="id" open="(" close=")" separator=",">
-                #{id}
-            </foreach>
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
         and deleted=0
     </select>
+    <select id="selectAll" resultType="com.xunmei.core.resumption.domain.AppPlan">
+        SELECT
+        a.*,
+        d.roleNames,
+        b.orgId,
+        b.orgNames,
+        o.name as plan_of_org_name,
+        g.name as plan_create_org_name,
+        g.type as org_type
+        FROM
+        core_resumption_plan a
+        LEFT JOIN (
+        SELECT
+        m.plan_id,
+        GROUP_CONCAT( n.`name` ) orgNames,
+        GROUP_CONCAT( n.id ) orgId
+        FROM
+        core_resumption_plan_to_exec_org m
+        LEFT JOIN sys_org n ON m.org_id = n.id
+
+        GROUP BY
+        m.plan_id
+        ) b ON a.id = b.plan_id
+        LEFT JOIN (
+        SELECT
+        r.plan_id,
+        group_concat( t.`role_name` ) roleNames
+        FROM
+        core_resumption_plan_to_role r
+        LEFT JOIN sys_role t ON r.role_id = t.id
+        GROUP BY
+        r.plan_id
+        ) d ON a.id = d.plan_id
+        LEFT JOIN sys_org o ON a.plan_of_org_id = o.id
+        LEFT JOIN sys_org g ON a.plan_create_org_id = g.id
+
+        <where>
+            a.deleted=0
+            <if test="info.planName != '' and info.planName != null">
+                and a.plan_name LIKE CONCAT('%', #{info.planName}, '%' )
+            </if>
+            <if test="info.planStatus != null">
+                and a.plan_status = #{info.planStatus}
+            </if>
+            <if test="info.planCycle != null">
+                and a.plan_cycle = #{info.planCycle}
+            </if>
+            <if test="info.planExec != null">
+                and a.plan_exec = #{info.planExec}
+            </if>
+            <if test="info.orgType != null">
+                and a.exec_org_type = #{info.orgType}
+            </if>
+            <if test="info.orgId != null">
+                and a.plan_of_org_id = #{info.orgId}
+            </if>
+            <if test="info.roleList != null and info.roleList.size > 0">
+                and a.id in (select plan_id from core_resumption_plan_to_role where role_id in
+                <foreach collection="info.roleList" item="roleId" index="index" open="(" separator="," close=")">
+                    #{roleId}
+                </foreach>
+                )
+            </if>
+            <if test="info.orgList != null and info.orgList.size > 0">
+                and a.id in (select plan_id from core_resumption_plan_to_exec_org where org_id in
+                <foreach collection="info.orgList" item="orgId" index="index" open="(" separator="," close=")">
+                    #{orgId}
+                </foreach>
+                )
+            </if>
+            <if test="info.ids!=null and info.ids.size > 0">
+                and a.plan_of_org_id in
+                <foreach collection="info.ids" item="orgId" index="index" open="(" separator="," close=")">
+                    #{orgId}
+                </foreach>
+            </if>
+        </where>
+
+    </select>
 </mapper>