|
|
@@ -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;
|