jiawuxian 2 жил өмнө
parent
commit
0f5f9be021

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

@@ -1,10 +1,13 @@
 package com.xunmei.core.resumption.controller;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.security.annotation.RequiresPermissions;
+import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.core.resumption.domain.AppPlan;
 import com.xunmei.core.resumption.dto.DistributeDto;
 import com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto;
@@ -48,10 +51,12 @@ public class ApiPlanController {
      */
     @PostMapping("/find")
     @RequiresPermissions("core:plan:find")
-    public AjaxResult hostList(@RequestBody CoreResumptionPlanPageDto info) {
-
+    public TableDataInfo page(@RequestBody CoreResumptionPlanPageDto info) {
+        if(ObjectUtil.isNull(info.getOrgId())){
+            info.setOrgId(SecurityUtils.getLoginUser().getOrgId());
+        }
 //        Page<AppPlan> result = ;
-        return AjaxResult.success(appPlanService.selectPage(info));
+        return TableDataInfo.success(appPlanService.selectPage(info));
     }
 
     @PostMapping("/distribute")

+ 10 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/dto/plan/CoreResumptionPlanPageDto.java

@@ -1,14 +1,17 @@
 package com.xunmei.core.resumption.dto.plan;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.xunmei.common.core.web.domain.PageDto;
 import com.xunmei.core.resumption.domain.AppPlan;
+import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
 import java.util.List;
 @Data
-public class CoreResumptionPlanPageDto extends PageDto<AppPlan> {
+public class CoreResumptionPlanPageDto extends PageDto<ResumptionPlanPageVo> {
     /**
      * 计划名称
      */
@@ -44,4 +47,10 @@ public class CoreResumptionPlanPageDto extends PageDto<AppPlan> {
      */
 
     private Long orgId;
+
+    /**
+     * 父计划id
+     */
+    @JsonIgnore
+    private List<Long> parentId;
 }

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

@@ -7,6 +7,7 @@ import com.xunmei.core.resumption.domain.AppPlan;
 import com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto;
 import com.xunmei.core.resumption.vo.appPlan.AppPlanVo;
 import com.xunmei.core.resumption.vo.appPlan.ObjectDataClass;
+import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleItemVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -32,9 +33,16 @@ public interface AppPlanMapper extends BaseMapper<AppPlan> {
      * @param plan
      * @return
      */
-    Page<AppPlan> selectPage(Page<AppPlan> page, @Param("info") CoreResumptionPlanPageDto plan);
+    Page<ResumptionPlanPageVo> selectPage(Page<ResumptionPlanPageVo> page, @Param("info") CoreResumptionPlanPageDto plan);
 
-    List<AppPlan> selectAll(@Param("info") CoreResumptionPlanPageDto plan);
+    /**
+     *
+     * @param plan
+     * @return
+     */
+    List<ResumptionPlanPageVo> selectChildren(@Param("info") CoreResumptionPlanPageDto plan);
+
+//    List<AppPlan> selectAll(@Param("info") CoreResumptionPlanPageDto plan);
 
     /**
      * 通过履职计划id获取履职任务执行机构

+ 2 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/AppPlanService.java

@@ -6,6 +6,7 @@ import com.xunmei.core.resumption.domain.AppPlan;
 import com.xunmei.core.resumption.dto.DistributeDto;
 import com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto;
 import com.xunmei.core.resumption.vo.appPlan.AppPlanVo;
+import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleItemVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleRequestVo;
 
@@ -19,7 +20,7 @@ public interface AppPlanService extends IService<AppPlan> {
      *
      * @return
      */
-    Page<AppPlan> selectPage(CoreResumptionPlanPageDto info);
+    Page<ResumptionPlanPageVo> selectPage(CoreResumptionPlanPageDto info);
 
     List<Long> selectItemIdsByPlanId(Long id);
 

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

@@ -1,5 +1,6 @@
 package com.xunmei.core.resumption.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -14,6 +15,7 @@ import com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto;
 import com.xunmei.core.resumption.mapper.*;
 import com.xunmei.core.resumption.service.AppPlanService;
 import com.xunmei.core.resumption.vo.appPlan.AppPlanVo;
+import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleItemVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleRequestVo;
 import com.xunmei.system.api.RemoteOrgService;
@@ -69,9 +71,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     RedisTemplate redisTemplate;
 
     @Override
-    public Page<AppPlan> selectPage(CoreResumptionPlanPageDto info) {
+    public Page<ResumptionPlanPageVo> selectPage(CoreResumptionPlanPageDto info) {
         //获取选择机构id
-        Long orgid = info.getOrgId();
+//        Long orgid = info.getOrgId();
         //下穿计算
 //        if (info.isCheckSub()) {
 //            List<Long> ids = orgService.selectCheckSubOrgIdList(info.getOrgId(), SecurityConstants.INNER);
@@ -80,23 +82,25 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 //
 //        }
         //获取前段对应的数据库页数
-        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());
+
+        Page<ResumptionPlanPageVo> result = info.getPageDto();
+        result = baseMapper.selectPage(result, info);
+        info.setParentId(result.getRecords().stream().map(r -> r.getId()).collect(Collectors.toList()));
+        List<ResumptionPlanPageVo> allChildren = new ArrayList<>();
+        if (CollectionUtil.isNotEmpty(info.getParentId())) {
+            allChildren = baseMapper.selectChildren(info);
+        }
+        Long order = ((info.getPageNum() - 1) * info.getPageSize()) + 1;
+        for (ResumptionPlanPageVo r : result.getRecords()) {
+            r.setIndex(order++);
+            Long childOrder = 1L;
+            List<ResumptionPlanPageVo> children = allChildren.stream().filter(c -> ObjectUtil.equal(c.getParentId(), r.getId())).collect(Collectors.toList());
+            for (ResumptionPlanPageVo child : children) {
+                child.setIndex(childOrder++);
+            }
+            r.setChildren(children);
+        }
+
         return result;
     }
 
@@ -106,9 +110,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
      * @param treeList
      * @return
      */
-    public static List<AppPlan> recursionDept(List<AppPlan> treeList,Long orgid) {
-        List<AppPlan> trees = new ArrayList<>();
-        for (AppPlan tree : treeList) {
+    public static List<ResumptionPlanPageVo> recursionDept(List<ResumptionPlanPageVo> treeList, Long orgid) {
+        List<ResumptionPlanPageVo> trees = new ArrayList<>();
+        for (ResumptionPlanPageVo tree : treeList) {
             // 找出父节点
             if (-1 == tree.getParentId()) {
                 // 调用递归方法填充子节点列表
@@ -125,8 +129,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
      * @param treeList 所有的List
      * @return
      */
-    public static AppPlan findChildren(AppPlan tree, List<AppPlan> treeList) {
-        for (AppPlan node : treeList) {
+    public static ResumptionPlanPageVo findChildren(ResumptionPlanPageVo tree, List<ResumptionPlanPageVo> treeList) {
+        for (ResumptionPlanPageVo node : treeList) {
             if (tree.getId().equals(node.getParentId())) {
                 if (tree.getChildren() == null) {
                     tree.setChildren(new ArrayList<>());

+ 129 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/vo/appPlan/ResumptionPlanPageVo.java

@@ -0,0 +1,129 @@
+package com.xunmei.core.resumption.vo.appPlan;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.xunmei.core.resumption.domain.AppPlan;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class ResumptionPlanPageVo {
+
+    @TableId(type = IdType.AUTO)
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    private Long index;
+
+    private Integer orgType;
+    /**
+     * 主键
+     */
+
+    /**
+     * 计划名称
+     */
+
+    private String planName;
+
+    /**
+     * 计划类型 0:履职计划,1,安全检查,2教育培训
+     */
+    private Integer planType;
+
+    /**
+     * 计划周期:每小时,每日,每周,每月,每季度,每半年,每年
+     */
+    private Integer planCycle;
+
+    /**
+     * 执行时刻:全天,营业前,营业期间,营业终
+     */
+    private Integer planExec;
+
+    /**
+     * 执行机构类型
+     */
+    private Integer execOrgType;
+
+    /**
+     * 执行类型:0:机构类型,1:具体机构
+     */
+    private Integer execType;
+
+
+    /**
+     * 计划状态:0:启用,1禁用
+     */
+
+    private Integer planStatus;
+
+    /**
+     * 休息时间不履职
+     */
+    private Integer notResumptionOnRest;
+
+    /**
+     * 计划创建机构名称
+     */
+    private String planCreateOrgName;
+
+    /**
+     * 计划创建机构id
+     */
+    private String planCreateOrgId;
+
+    /**
+     * 计划所属机构名称
+     */
+    private String planOfOrgName;
+
+    /**
+     * 计划所属机构id
+     */
+    private String planOfOrgId;
+
+    /**
+     * 计划执行次数
+     */
+    private String count;
+
+    /**
+     * 计划是否下发
+     */
+    private String distributeStatus;
+
+    /**
+     * 计划下发默认状态
+     */
+    private String distributePlanStatus;
+
+    /**
+     * 计划父id(下发机构独有)
+     */
+    private Long parentId;
+
+    /**
+     * 计划机构列表
+     */
+    private String orgNames;
+
+    /**
+     * 角色集合
+     */
+    private String roleNames;
+
+
+    @TableField(exist = false)
+    private String orgId;
+
+
+    private List<ResumptionPlanPageVo> children;
+}

+ 103 - 31
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppPlanMapper.xml

@@ -10,29 +10,29 @@
         ,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">
+    <resultMap id="appPlans" type="com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo">
         <id column="id" property="id"/>
         <result column="plan_name" property="planName"/>
         <result column="plan_type" property="planType"/>
         <result column="plan_cycle" property="planCycle"/>
         <result column="plan_exec" property="planExec"/>
         <result column="exec_org_type" property="execOrgType"/>
-        <result column="check_org_type" property="checkOrgType"/>
-        <result column="check_type" property="checkType"/>
+        <!--        <result column="check_type" property="checkType"/>-->
         <result column="exec_type" property="execType"/>
         <result column="plan_status" property="planStatus"/>
         <result column="plan_status" property="planStatus"/>
-        <result column="description" property="description"/>
-        <result column="create_time" property="createTime"/>
-        <result column="modified_name" property="modifiedName"/>
-        <result column="update_time" property="updateTime"/>
-        <result column="modified_by" property="modifiedBy"/>
+        <!--        <result column="description" property="description"/>-->
+        <!--        <result column="create_time" property="createTime"/>-->
+        <!--        <result column="modified_name" property="modifiedName"/>-->
+        <!--        <result column="update_time" property="updateTime"/>-->
+        <!--        <result column="modified_by" property="modifiedBy"/>-->
         <result column="roleNames" property="roleNames"/>
         <result column="orgNames" property="orgNames"/>
     </resultMap>
 
 
-    <select id="selectPage" parameterType="com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto" resultMap="appPlans">
+    <select id="selectPage" parameterType="com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto"
+            resultMap="appPlans">
         SELECT
         a.*,
         d.roleNames,
@@ -83,9 +83,13 @@
             <if test="info.orgType != null">
                 and a.exec_org_type = #{info.orgType}
             </if>
-            <if test="info.orgId != null">
+            <if test="info.checkSub==false">
                 and a.plan_of_org_id = #{info.orgId}
             </if>
+            <if test="info.checkSub==true">
+                and a.plan_of_org_id in (select id from sys_org where path like concat( (select path from sys_org where
+                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=")">
@@ -93,29 +97,98 @@
                 </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-->
-<!--                (select id from sys_org-->
-<!--                where path like concat((select path from sys_org where id=#{info.orgId}),'%')-->
-<!--                )-->
+            <!--            <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-->
+            <!--                (select id from sys_org-->
+            <!--                where path like concat((select path from sys_org where id=#{info.orgId}),'%')-->
+            <!--                )-->
+            <!--            </if>-->
+<!--            and a.id in (-->
+<!--            select if(plan_of_org_id=plan_create_org_id,id,parent_id ) as id from core_resumption_plan-->
+<!--            where 1=1-->
+<!--            <if test="info.checkSub==false">-->
+<!--                and plan_of_org_id=#{info.orgId}-->
 <!--            </if>-->
-            and a.id in (
-                select if(parent_id=-1,id,parent_id ) as id from core_resumption_plan
-                where 1=1
-                <if test="info.checkSub==false">
-                    and plan_of_org_id=#{info.orgId}
-                </if>
-                <if test="info.checkSub=true">
-                    and plan_of_org_id in (select id from sys_org
-                                            where path like concat((select path from sys_org where id=#{info.orgId}),'%'))
-                </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}
+<!--            <if test="info.checkSub==true">-->
+<!--                and plan_of_org_id in (select id from sys_org-->
+<!--                where path like concat((select path from sys_org where id=#{info.orgId}),'%'))-->
+<!--            </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="selectChildren" parameterType="com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto"
+            resultMap="appPlans">
+        SELECT
+        a.*,
+        d.roleNames,
+        b.orgId,
+        b.orgNames,
+        o.name as plan_of_org_name,
+        g.name as plan_create_org_name
+        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.checkSub==true">-->
+            <!--                and a.plan_of_org_id in (select id from sys_org where path like concat( (select path from sys_org where-->
+            <!--                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>
+            and a.parent_id in
+            <foreach collection="info.parentId" item="id" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
         </where>
     </select>
     <select id="selectItemPage" parameterType="com.xunmei.core.resumption.vo.appPlan.RuleItemVo"
@@ -325,6 +398,5 @@
                 </foreach>
             </if>
         </where>
-
     </select>
 </mapper>