Переглянути джерело

修改调阅登记列表,增加删除按钮,新增树

luowei 2 роки тому
батько
коміт
edd746c2d7

+ 6 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/access/domain/TMonitoringRetrievalPlan.java

@@ -37,7 +37,12 @@ public class TMonitoringRetrievalPlan extends BaseEntity {
     @JsonSerialize(using = ToStringSerializer.class)
     @TableId(type = IdType.AUTO)
     private Long id;
-
+    @JsonSerialize(using = ToStringSerializer.class)
+    /**
+     * 上级id
+     */
+    @ApiModelProperty(value = "上级id")
+    private Long parentId;
     /**
      * 计划名称
      */

+ 70 - 9
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/access/service/impl/TMonitoringRetrievalPlanServiceImpl.java

@@ -1,24 +1,38 @@
 package com.xunmei.core.access.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.nacos.common.utils.CollectionUtils;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.constant.ErrorMsgConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlan;
+import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanPageVo;
+import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanRoleVo;
+import com.xunmei.common.core.domain.retrieval.domain.CoreMonitoringRetrievalTask;
+import com.xunmei.common.core.exception.ServiceException;
+import com.xunmei.common.core.util.BeanHelper;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.utils.StringUtils;
+import com.xunmei.common.core.vo.IdNameVo;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.core.access.domain.TMonitoringRetrievalPlan;
 import com.xunmei.core.access.mapper.TMonitoringRetrievalPlanMapper;
 import com.xunmei.core.access.service.ITMonitoringRetrievalPlanService;
+import com.xunmei.core.access.vo.TMonitoringRetrievalPlanVO;
 import com.xunmei.core.retrieval.service.ICoreMonitoringRetrievalTaskService;
+import com.xunmei.system.api.Eto.RoleConditionEto;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.RemoteRoleService;
 import com.xunmei.system.api.RemoteUserService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysRole;
 import com.xunmei.system.api.domain.SysUser;
+import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -26,6 +40,8 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
@@ -47,12 +63,14 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
     private RemoteOrgService remoteOrgService;
     @Autowired
     private RemoteRoleService remoteRoleService;
+    @Autowired
+    private RemoteOrgService orgService;
     @Lazy
     @Resource
     private ICoreMonitoringRetrievalTaskService iCoreMonitoringRetrievalTaskService;
 
     @Override
-    public TableDataInfo<TMonitoringRetrievalPlan> selectPage(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
+    public TableDataInfo selectPage(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
         //未删除
         tMonitoringRetrievalPlan.setIsDeleted(ZERO.longValue());
         Page<TMonitoringRetrievalPlan> page;
@@ -90,13 +108,29 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
         }
         query.orderByDesc("create_time");
         //获取数据
+        query.eq("create_type", 0);
         page = tMonitoringRetrievalPlanMapper.selectPage(page, query);
+        SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectTopOrg(SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+        List<TMonitoringRetrievalPlan> records = page.getRecords();
+        List<TMonitoringRetrievalPlanVO> tMonitoringRetrievalPlanVOS = BeanHelper.copyProperties(records, TMonitoringRetrievalPlanVO.class);
+        for (TMonitoringRetrievalPlanVO monitoringRetrievalPlan : tMonitoringRetrievalPlanVOS) {
+            dealData(monitoringRetrievalPlan, tMonitoringRetrievalPlanVOS, sysOrg.getId());
+        }
         //抓换为TableDataInfo适配前端
-        return TableDataInfo.build(page);
-
-
+        TableDataInfo<TMonitoringRetrievalPlanVO> tableDataInfo = new TableDataInfo();
+        tableDataInfo.setMsg("操作成功");
+        tableDataInfo.setCode(200);
+        tableDataInfo.setTotal(page.getTotal());
+        tableDataInfo.setRows(tMonitoringRetrievalPlanVOS);
+        return tableDataInfo;
     }
 
+    private void dealData(TMonitoringRetrievalPlanVO record, List<TMonitoringRetrievalPlanVO> records, Long orgId) {
+        record.setNo(records.indexOf(record) + 1);
+        List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = tMonitoringRetrievalPlanMapper.selectList(new LambdaQueryWrapper<TMonitoringRetrievalPlan>().eq(TMonitoringRetrievalPlan::getParentId, record.getId()));
+        List<TMonitoringRetrievalPlanVO> children = BeanHelper.copyProperties(tMonitoringRetrievalPlans, TMonitoringRetrievalPlanVO.class);
+        record.setChildren(children);
+    }
 
     /**
      * 查询监控调阅计划
@@ -115,7 +149,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
         TMonitoringRetrievalPlan tMonitoringRetrievalPlan = tMonitoringRetrievalPlanMapper.selectById(id);
         tMonitoringRetrievalPlan.setPlanStatus(ZERO);
         tMonitoringRetrievalPlanMapper.updateById(tMonitoringRetrievalPlan);
-        List<SysOrg> list = remoteOrgService.selectSysOrgByParentId(MINUS_ONE.longValue(), SecurityConstants.INNER);
+        List<SysOrg> list = remoteOrgService.selectSysOrgByParentId(tMonitoringRetrievalPlan.getOrgId(), SecurityConstants.INNER);
         Integer i = ZERO;
         List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = new ArrayList<>();
         for (SysOrg l : list) {
@@ -138,6 +172,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
             monitoringRetrievalPlan.setDescription(tMonitoringRetrievalPlan.getDescription());
             monitoringRetrievalPlan.setCreateType(1);
             monitoringRetrievalPlan.setId(IdWorker.getId());
+            monitoringRetrievalPlan.setParentId(tMonitoringRetrievalPlan.getId());
             i = tMonitoringRetrievalPlanMapper.insert(monitoringRetrievalPlan);
             tMonitoringRetrievalPlans.add(monitoringRetrievalPlan);
             if (i < ZERO) {
@@ -217,14 +252,40 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
      */
     @Override
     public int deleteTMonitoringRetrievalPlanByIds(Long[] ids) {
-        int i = ZERO;
+        int i = 0;
         for (Long id : ids) {
             TMonitoringRetrievalPlan tMonitoringRetrievalPlan = new TMonitoringRetrievalPlan();
             tMonitoringRetrievalPlan.setIsDeleted(2L);
             tMonitoringRetrievalPlan.setId(id);
-            i = tMonitoringRetrievalPlanMapper.updateTMonitoringRetrievalPlan(tMonitoringRetrievalPlan);
-            if (i < 1) {
-                return i;
+            TMonitoringRetrievalPlan monitoringRetrievalPlan = tMonitoringRetrievalPlanMapper.selectById(id);
+            //如果是下发的任务
+            if (monitoringRetrievalPlan.getParentId() != null) {
+                //不能删除
+                throw new ServiceException("子任务,不能删除");
+            } else {
+                if (monitoringRetrievalPlan.getCreateType() == 0) {
+                    QueryWrapper queryWrapper = new QueryWrapper();
+                    queryWrapper.eq("parent_id", monitoringRetrievalPlan.getId());
+                    List<TMonitoringRetrievalPlan> list = tMonitoringRetrievalPlanMapper.selectList(queryWrapper);
+                    list.add(monitoringRetrievalPlan);
+                    for (TMonitoringRetrievalPlan p : list) {
+                        CoreMonitoringRetrievalTask coreMonitoringRetrievalTask = new CoreMonitoringRetrievalTask();
+                        coreMonitoringRetrievalTask.setPlanId(p.getId());
+                        coreMonitoringRetrievalTask.setStatus("0");
+                        List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectCoreMonitoringRetrievalTaskList(coreMonitoringRetrievalTask);
+                        List<Long> collect = coreMonitoringRetrievalTasks.stream().map(CoreMonitoringRetrievalTask::getId).distinct().collect(Collectors.toList());
+                        if (CollectionUtils.isNotEmpty(collect)) {
+                            Long[] arr = new Long[collect.size()];
+                            collect.toArray(arr);
+                            iCoreMonitoringRetrievalTaskService.deleteCoreMonitoringRetrievalTaskByIds(arr);
+                        }
+                        p.setIsDeleted(2L);
+                        i = tMonitoringRetrievalPlanMapper.updateTMonitoringRetrievalPlan(p);
+                        if (i < 1) {
+                            return i;
+                        }
+                    }
+                }
             }
         }
         return i;

+ 18 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/access/vo/TMonitoringRetrievalPlanVO.java

@@ -0,0 +1,18 @@
+package com.xunmei.core.access.vo;
+
+import com.xunmei.core.access.domain.TMonitoringRetrievalPlan;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author :LuoWei
+ * @date : 2023/9/5
+ */
+@Data
+public class TMonitoringRetrievalPlanVO extends TMonitoringRetrievalPlan {
+    @ApiModelProperty(value = "序号")
+    private Integer no;
+    private List<TMonitoringRetrievalPlanVO> children;
+}

+ 2 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/retrieval/service/impl/CoreMonitoringRetrievalTaskServiceImpl.java

@@ -163,7 +163,8 @@ public class CoreMonitoringRetrievalTaskServiceImpl extends ServiceImpl<CoreMoni
      */
     @Override
     public List<CoreMonitoringRetrievalTask> selectCoreMonitoringRetrievalTaskList(CoreMonitoringRetrievalTask CoreMonitoringRetrievalTask) {
-        return coreMonitoringRetrievalTaskMapper.selectList(new QueryWrapper<>(CoreMonitoringRetrievalTask));
+       // return coreMonitoringRetrievalTaskMapper.selectList(new QueryWrapper<>(CoreMonitoringRetrievalTask));
+        return coreMonitoringRetrievalTaskMapper. selectCoreMonitoringRetrievalTaskList(CoreMonitoringRetrievalTask);
     }
 
     /**

+ 2 - 2
soc-modules/soc-modules-core/src/main/resources/mapper/access/TMonitoringRetrievalPlanMapper.xml

@@ -159,7 +159,7 @@
     </insert>
 
     <update id="updateTMonitoringRetrievalPlan" parameterType="com.xunmei.core.access.domain.TMonitoringRetrievalPlan">
-        update t_monitoring_retrieval_plan
+        update core_monitoring_retrieval_plan
         <trim prefix="SET" suffixOverrides=",">
                     <if test="planName != null">plan_name =
                         #{planName},
@@ -212,7 +212,7 @@
             <if test="endTime != null">end_time =
                 #{endTime},
             </if>
-            <if test="createType != null">createType =
+            <if test="createType != null">create_type =
                 #{createType},
             </if>
         </trim>

+ 4 - 0
soc-modules/soc-modules-core/src/main/resources/mapper/retrieval/CoreMonitoringRetrievalTaskMapper.xml

@@ -56,6 +56,10 @@
                         <if test="status != null ">
                             and status = #{status}
                         </if>
+                        <if test="planId !=null ">
+                            and plan_id=#{planId}
+                        </if>
+
         </where>
     </select>