|
|
@@ -4,20 +4,27 @@ package com.xunmei.core.access.service.impl;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
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.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
+import com.xunmei.common.core.constant.CacheConstants;
|
|
|
import com.xunmei.common.core.constant.DictConstants;
|
|
|
import com.xunmei.common.core.constant.ErrorMsgConstants;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.registerbook.domain.CoreRegisterBookPdf;
|
|
|
import com.xunmei.common.core.domain.retrieval.domain.CoreMonitoringRetrievalTask;
|
|
|
import com.xunmei.common.core.enums.OrgTypeEnum;
|
|
|
+import com.xunmei.common.core.enums.PlanStatus;
|
|
|
import com.xunmei.common.core.enums.RegisterBookType;
|
|
|
+import com.xunmei.common.core.enums.drill.DrillPlanStatus;
|
|
|
import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.exception.SystemException;
|
|
|
import com.xunmei.common.core.thread.ThreadPoolConfig;
|
|
|
+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.web.page.TableDataInfo;
|
|
|
@@ -43,6 +50,7 @@ import com.xunmei.system.api.*;
|
|
|
import com.xunmei.system.api.domain.*;
|
|
|
import com.xunmei.system.api.enums.BusinessPlanType;
|
|
|
import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
+import com.xunmei.system.api.vo.SysOrgVO;
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -59,13 +67,12 @@ import java.io.File;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static java.util.stream.Collectors.toList;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 监控调阅计划Service业务层处理
|
|
|
@@ -112,6 +119,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
@Autowired
|
|
|
private RemoteDictDataService dictDataService;
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo selectPage(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
|
|
|
//未删除
|
|
|
@@ -596,7 +604,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
|
|
|
final CompletableFuture<List<TMonitoringRetrievalPlan>> planListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- return getNeedCreateTaskPlans(loginUserOrg, publishPlan);
|
|
|
+ return getNeedCreateTaskPlans(loginUserOrg, publishPlan);
|
|
|
}, threadPoolTaskExecutor);
|
|
|
|
|
|
planListFuture.thenAcceptAsync((result) -> {
|
|
|
@@ -613,8 +621,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
- private List<TMonitoringRetrievalPlan> getNeedCreateTaskPlans(SysOrg loginUserOrg,TMonitoringRetrievalPlan publishPlan)
|
|
|
- {
|
|
|
+ private List<TMonitoringRetrievalPlan> getNeedCreateTaskPlans(SysOrg loginUserOrg, TMonitoringRetrievalPlan publishPlan) {
|
|
|
List<TMonitoringRetrievalPlan> tempPlans = new ArrayList<>();
|
|
|
SysOrg publishPlanOrg = remoteOrgService.selectSysOrgById(publishPlan.getOrgId(), SecurityConstants.INNER);
|
|
|
//如果登录当前是省联社 办事处
|
|
|
@@ -630,7 +637,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tm.setPlanStatus(1);
|
|
|
tm.setIsDistribute("1");
|
|
|
baseMapper.updateById(tm);
|
|
|
- setPlanStartEndTime(publishPlan,tm);
|
|
|
+ setPlanStartEndTime(publishPlan, tm);
|
|
|
tempPlans.add(tm);
|
|
|
// if (publishPlan.getOrgType().equals("3")) {
|
|
|
// setPlanStartEndTime(publishPlan,tm);
|
|
|
@@ -649,8 +656,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
// 计划机构类型 是 省联社或者办事处及行社以下的机构类型 才创建子计划
|
|
|
if (!checkOrgType(Integer.parseInt(publishPlan.getOrgType()))) {
|
|
|
// 查询当前计划的具体执行机构
|
|
|
@@ -658,18 +664,17 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
List<Long> planExecOrgIds = planExecOrgList.stream().map(x -> x.getOrgId()).collect(Collectors.toList());
|
|
|
// 根据机构类型和具体调阅机构 获取需创建子计划的机构
|
|
|
- List<SysOrg> subPlanOrglist =getPlanOrgListByOrgTypeAndExecOrgs(planExecOrgIds,Integer.parseInt(publishPlan.getOrgType()), publishPlanOrg.getPath());
|
|
|
+ List<SysOrg> subPlanOrglist = getPlanOrgListByOrgTypeAndExecOrgs(planExecOrgIds, Integer.parseInt(publishPlan.getOrgType()), publishPlanOrg.getPath());
|
|
|
|
|
|
- List<SysOrg> execOrglist=new ArrayList<>();
|
|
|
- if(ObjectUtil.isNotEmpty(planExecOrgList))
|
|
|
- {
|
|
|
- execOrglist= RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
- remoteOrgService.selectOrgByIdList(planExecOrgList.stream().map(x->x.getOrgId()).collect(Collectors.toList()), SecurityConstants.INNER),
|
|
|
+ List<SysOrg> execOrglist = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(planExecOrgList)) {
|
|
|
+ execOrglist = RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
+ remoteOrgService.selectOrgByIdList(planExecOrgList.stream().map(x -> x.getOrgId()).collect(Collectors.toList()), SecurityConstants.INNER),
|
|
|
ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
}
|
|
|
|
|
|
- List<TMonitoringRetrievalPlan> needAddSubPlans=new ArrayList<>();
|
|
|
- List<TMonitoringRetrievalPlanToExecOrg> needAddSubPlanExecOrgList=new ArrayList<>();
|
|
|
+ List<TMonitoringRetrievalPlan> needAddSubPlans = new ArrayList<>();
|
|
|
+ List<TMonitoringRetrievalPlanToExecOrg> needAddSubPlanExecOrgList = new ArrayList<>();
|
|
|
for (SysOrg subPlanOrg : subPlanOrglist) {
|
|
|
TMonitoringRetrievalPlan tMonitoringRetrievalPlan1 = new TMonitoringRetrievalPlan();
|
|
|
BeanUtils.copyProperties(publishPlan, tMonitoringRetrievalPlan1);
|
|
|
@@ -684,8 +689,8 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tMonitoringRetrievalPlan1.setOrgName(publishPlanOrg.getShortName());
|
|
|
// insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan1);
|
|
|
needAddSubPlans.add(tMonitoringRetrievalPlan1);
|
|
|
- if(ObjectUtil.isNotEmpty(planExecOrgList)){
|
|
|
- execOrglist.stream().filter(x -> x.getPath().contains(subPlanOrg.getPath())).forEach(x->{
|
|
|
+ if (ObjectUtil.isNotEmpty(planExecOrgList)) {
|
|
|
+ execOrglist.stream().filter(x -> x.getPath().contains(subPlanOrg.getPath())).forEach(x -> {
|
|
|
TMonitoringRetrievalPlanToExecOrg tempExecOrg = new TMonitoringRetrievalPlanToExecOrg();
|
|
|
tempExecOrg.setOrgId(x.getId());
|
|
|
tempExecOrg.setPlanId(tMonitoringRetrievalPlan1.getId());
|
|
|
@@ -694,22 +699,20 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
}
|
|
|
}
|
|
|
//保存子计划和子计划具体执行机构
|
|
|
- if(ObjectUtil.isNotEmpty(needAddSubPlans))
|
|
|
- {
|
|
|
+ if (ObjectUtil.isNotEmpty(needAddSubPlans)) {
|
|
|
this.saveBatch(needAddSubPlans);
|
|
|
itMonitoringRetrievalPlanToExecOrgService.saveBatch(needAddSubPlanExecOrgList);
|
|
|
- needAddSubPlans.stream().forEach(plan->{
|
|
|
- setPlanStartEndTime(plan,plan);
|
|
|
+ needAddSubPlans.stream().forEach(plan -> {
|
|
|
+ setPlanStartEndTime(plan, plan);
|
|
|
});
|
|
|
tempPlans.addAll(needAddSubPlans);
|
|
|
}
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
publishPlan.setCreateType(1);
|
|
|
publishPlan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
publishPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
baseMapper.updateById(publishPlan);
|
|
|
- setPlanStartEndTime(publishPlan,publishPlan);
|
|
|
+ setPlanStartEndTime(publishPlan, publishPlan);
|
|
|
tempPlans.add(publishPlan);
|
|
|
}
|
|
|
// if (publishPlan.getOrgType().equals("3")) {
|
|
|
@@ -733,12 +736,11 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
publishPlan.setCreateType(1);
|
|
|
publishPlan.setIsDistribute("1");
|
|
|
baseMapper.updateById(publishPlan);
|
|
|
- setPlanStartEndTime(publishPlan,publishPlan);
|
|
|
+ setPlanStartEndTime(publishPlan, publishPlan);
|
|
|
tempPlans.add(publishPlan);
|
|
|
// SysOrg sysOrg = new SysOrg();
|
|
|
// sysOrg.setPath(loginUserOrg.getPath());
|
|
|
@@ -752,22 +754,20 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
return tempPlans;
|
|
|
}
|
|
|
|
|
|
- private List<TMonitoringRetrievalPlan> buildSubPlans(TMonitoringRetrievalPlan parentPlan,List<Long> parentPlanExecOrgIds, SysOrg parentPlanOrg)
|
|
|
- {
|
|
|
+ private List<TMonitoringRetrievalPlan> buildSubPlans(TMonitoringRetrievalPlan parentPlan, List<Long> parentPlanExecOrgIds, SysOrg parentPlanOrg) {
|
|
|
List<TMonitoringRetrievalPlan> subPlans = new ArrayList<>();
|
|
|
// 根据机构类型和具体调阅机构 获取需创建子计划的机构
|
|
|
- List<SysOrg> hsOrglist =getPlanOrgListByOrgTypeAndExecOrgs(parentPlanExecOrgIds,3,parentPlanOrg.getPath());
|
|
|
+ List<SysOrg> hsOrglist = getPlanOrgListByOrgTypeAndExecOrgs(parentPlanExecOrgIds, 3, parentPlanOrg.getPath());
|
|
|
|
|
|
- List<SysOrg> execOrglist=new ArrayList<>();
|
|
|
- if(ObjectUtil.isNotEmpty(parentPlanExecOrgIds))
|
|
|
- {
|
|
|
- execOrglist= RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
+ List<SysOrg> execOrglist = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(parentPlanExecOrgIds)) {
|
|
|
+ execOrglist = RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
remoteOrgService.selectOrgByIdList(parentPlanExecOrgIds, SecurityConstants.INNER),
|
|
|
ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
}
|
|
|
|
|
|
- List<TMonitoringRetrievalPlan> needAddSubPlans=new ArrayList<>();
|
|
|
- List<TMonitoringRetrievalPlanToExecOrg> needAddSubPlanExecOrgList=new ArrayList<>();
|
|
|
+ List<TMonitoringRetrievalPlan> needAddSubPlans = new ArrayList<>();
|
|
|
+ List<TMonitoringRetrievalPlanToExecOrg> needAddSubPlanExecOrgList = new ArrayList<>();
|
|
|
for (SysOrg l : hsOrglist) {
|
|
|
TMonitoringRetrievalPlan tMonitoringRetrievalPlan1 = new TMonitoringRetrievalPlan();
|
|
|
BeanUtils.copyProperties(parentPlan, tMonitoringRetrievalPlan1);
|
|
|
@@ -783,8 +783,8 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tMonitoringRetrievalPlan1.setOrgName(parentPlanOrg.getShortName());
|
|
|
// insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan1);
|
|
|
needAddSubPlans.add(tMonitoringRetrievalPlan1);
|
|
|
- if(ObjectUtil.isNotEmpty(parentPlanExecOrgIds)){
|
|
|
- execOrglist.stream().filter(x -> x.getPath().contains(l.getPath())).forEach(x->{
|
|
|
+ if (ObjectUtil.isNotEmpty(parentPlanExecOrgIds)) {
|
|
|
+ execOrglist.stream().filter(x -> x.getPath().contains(l.getPath())).forEach(x -> {
|
|
|
TMonitoringRetrievalPlanToExecOrg tempExecOrg = new TMonitoringRetrievalPlanToExecOrg();
|
|
|
tempExecOrg.setOrgId(x.getId());
|
|
|
tempExecOrg.setPlanId(tMonitoringRetrievalPlan1.getId());
|
|
|
@@ -798,34 +798,31 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
parentPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
baseMapper.updateById(parentPlan);
|
|
|
|
|
|
- setPlanStartEndTime(parentPlan,tMonitoringRetrievalPlan1);
|
|
|
+ setPlanStartEndTime(parentPlan, tMonitoringRetrievalPlan1);
|
|
|
subPlans.add(tMonitoringRetrievalPlan1);
|
|
|
} else {
|
|
|
- List<SysOrg> sysOrgs=getExecOrgList(parentPlanExecOrgIds,Integer.valueOf(parentPlan.getOrgType()),l.getPath());
|
|
|
+ List<SysOrg> sysOrgs = getExecOrgList(parentPlanExecOrgIds, Integer.valueOf(parentPlan.getOrgType()), l.getPath());
|
|
|
for (SysOrg s : sysOrgs) {
|
|
|
- TMonitoringRetrievalPlan plan = createTempPlan(parentPlan,tMonitoringRetrievalPlan1.getId(),s);
|
|
|
+ TMonitoringRetrievalPlan plan = createTempPlan(parentPlan, tMonitoringRetrievalPlan1.getId(), s);
|
|
|
subPlans.add(plan);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return subPlans;
|
|
|
+ return subPlans;
|
|
|
}
|
|
|
|
|
|
- private List<TMonitoringRetrievalPlanToExecOrg> buildPlanExecOrgs(List<TMonitoringRetrievalPlan> plans , List<SysOrg> execOrglist)
|
|
|
- {
|
|
|
- if(ObjectUtil.isEmpty(plans))
|
|
|
- {
|
|
|
+ private List<TMonitoringRetrievalPlanToExecOrg> buildPlanExecOrgs(List<TMonitoringRetrievalPlan> plans, List<SysOrg> execOrglist) {
|
|
|
+ if (ObjectUtil.isEmpty(plans)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtil.isEmpty(execOrglist))
|
|
|
- {
|
|
|
+ if (ObjectUtil.isEmpty(execOrglist)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- List<TMonitoringRetrievalPlanToExecOrg> result=new ArrayList<>();
|
|
|
+ List<TMonitoringRetrievalPlanToExecOrg> result = new ArrayList<>();
|
|
|
|
|
|
- plans.stream().forEach(x->{
|
|
|
- execOrglist.stream().filter(eOrg -> eOrg.getPath().contains(x.getOrgPath())).forEach(y->{
|
|
|
+ plans.stream().forEach(x -> {
|
|
|
+ execOrglist.stream().filter(eOrg -> eOrg.getPath().contains(x.getOrgPath())).forEach(y -> {
|
|
|
TMonitoringRetrievalPlanToExecOrg tempExecOrg = new TMonitoringRetrievalPlanToExecOrg();
|
|
|
tempExecOrg.setOrgId(y.getId());
|
|
|
tempExecOrg.setPlanId(x.getId());
|
|
|
@@ -848,18 +845,17 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据机构类型和具体调阅机构 获取需创建计划的行社机构
|
|
|
+ * 根据机构类型和具体调阅机构 获取需创建计划的行社机构
|
|
|
+ *
|
|
|
* @param execOrgIds
|
|
|
* @param orgType
|
|
|
* @param belongOrgPath
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<SysOrg> getPlanOrgListByOrgTypeAndExecOrgs(List<Long> execOrgIds,Integer orgType, String belongOrgPath) {
|
|
|
- if(ObjectUtil.isNotEmpty(execOrgIds))
|
|
|
- {
|
|
|
+ public List<SysOrg> getPlanOrgListByOrgTypeAndExecOrgs(List<Long> execOrgIds, Integer orgType, String belongOrgPath) {
|
|
|
+ if (ObjectUtil.isNotEmpty(execOrgIds)) {
|
|
|
//省联社/办事处/行社
|
|
|
- if(checkOrgType(orgType))
|
|
|
- {
|
|
|
+ if (checkOrgType(orgType)) {
|
|
|
return RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
remoteOrgService.selectOrgByIdList(execOrgIds, SecurityConstants.INNER),
|
|
|
ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
@@ -868,19 +864,15 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
else {
|
|
|
return RemoteCallHandlerExecutor.executeRemoteCall(() -> remoteOrgService.selectParentHs(execOrgIds, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
//省联社/办事处/行社
|
|
|
- if(checkOrgType(orgType))
|
|
|
- {
|
|
|
+ if (checkOrgType(orgType)) {
|
|
|
SysOrg org = new SysOrg();
|
|
|
org.setType(orgType);
|
|
|
org.setPath(belongOrgPath);
|
|
|
//查询符合的机构,需求是先把行社加入
|
|
|
return remoteOrgService.listByParentIdAndType(org, SecurityConstants.INNER);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
SysOrg org = new SysOrg();
|
|
|
org.setType(3);
|
|
|
org.setPath(belongOrgPath);
|
|
|
@@ -901,8 +893,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
}
|
|
|
|
|
|
// 准备生成任务需要的临时计划
|
|
|
- private TMonitoringRetrievalPlan createTempPlan(TMonitoringRetrievalPlan tMonitoringRetrievalPlan,Long planId,SysOrg org)
|
|
|
- {
|
|
|
+ private TMonitoringRetrievalPlan createTempPlan(TMonitoringRetrievalPlan tMonitoringRetrievalPlan, Long planId, SysOrg org) {
|
|
|
TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
@@ -959,12 +950,11 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
// Date time = cal.getTime();
|
|
|
// plan.setEndTime(time);
|
|
|
// }
|
|
|
- setPlanStartEndTime(tMonitoringRetrievalPlan,plan);
|
|
|
+ setPlanStartEndTime(tMonitoringRetrievalPlan, plan);
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
- private void setPlanStartEndTime(TMonitoringRetrievalPlan tMonitoringRetrievalPlan,TMonitoringRetrievalPlan tempPlan)
|
|
|
- {
|
|
|
+ private void setPlanStartEndTime(TMonitoringRetrievalPlan tMonitoringRetrievalPlan, TMonitoringRetrievalPlan tempPlan) {
|
|
|
if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
tempPlan.setStartTime(new Date());
|
|
|
@@ -1001,19 +991,18 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void checkPlanIsCreatingTask(Long planId,String msg)
|
|
|
- {
|
|
|
- String redisKey="Monitoring_Creating_Task" + planId;
|
|
|
+ private void checkPlanIsCreatingTask(Long planId, String msg) {
|
|
|
+ String redisKey = "Monitoring_Creating_Task" + planId;
|
|
|
//仅当hashKey不存在时才设置
|
|
|
Boolean hasKey = RedisUtils.hasKey(redisKey);
|
|
|
if (hasKey) {
|
|
|
- throw new ServiceException("该任务正在生成中,现在不能被"+msg+",请稍后再试。");
|
|
|
+ throw new ServiceException("该任务正在生成中,现在不能被" + msg + ",请稍后再试。");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int withdraw(Long id) {
|
|
|
- checkPlanIsCreatingTask(id,"撤回");
|
|
|
+ checkPlanIsCreatingTask(id, "撤回");
|
|
|
TMonitoringRetrievalPlan plan = baseMapper.selectById(id);
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq(PARENT_ID, id);
|
|
|
@@ -1225,16 +1214,17 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
if (ObjectUtil.equal(tMonitoringRetrievalPlanDto.getPlanCycle(), 0) && ObjectUtil.hasEmpty(tMonitoringRetrievalPlanDto.getStartTime(), tMonitoringRetrievalPlanDto.getEndTime())) {
|
|
|
throw new RuntimeException("当计划为无周期的时候,请填入开始时间和结束时间!");
|
|
|
}
|
|
|
- TMonitoringRetrievalPlan tMonitoringRetrievalPlan =new TMonitoringRetrievalPlan();
|
|
|
+ TMonitoringRetrievalPlan tMonitoringRetrievalPlan = new TMonitoringRetrievalPlan();
|
|
|
BeanUtils.copyProperties(tMonitoringRetrievalPlanDto, tMonitoringRetrievalPlan);
|
|
|
- int result= insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan);
|
|
|
+ int result = insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan);
|
|
|
batchSavePlanToExecOrg(tMonitoringRetrievalPlanDto.getPlanExecOrgIdList(), tMonitoringRetrievalPlan.getId());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public void batchSavePlanToExecOrg(List<Long> orgIdList, Long planId) {
|
|
|
- if(ObjectUtil.isEmpty(orgIdList))
|
|
|
- { return;}
|
|
|
+ if (ObjectUtil.isEmpty(orgIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
List<TMonitoringRetrievalPlanToExecOrg> planOrgList = new ArrayList();
|
|
|
for (Long orgId : orgIdList) {
|
|
|
TMonitoringRetrievalPlanToExecOrg org = new TMonitoringRetrievalPlanToExecOrg();
|
|
|
@@ -1363,34 +1353,31 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public int updateTMonitoringRetrievalPlan(TMonitoringRetrievalPlanDto tMonitoringRetrievalPlanDto) throws ParseException {
|
|
|
- Integer result=1;
|
|
|
+ Integer result = 1;
|
|
|
try {
|
|
|
- TMonitoringRetrievalPlan newPlan =new TMonitoringRetrievalPlan();
|
|
|
+ TMonitoringRetrievalPlan newPlan = new TMonitoringRetrievalPlan();
|
|
|
BeanUtils.copyProperties(tMonitoringRetrievalPlanDto, newPlan);
|
|
|
|
|
|
boolean isComplete = getIsComplete(newPlan.getId());
|
|
|
TMonitoringRetrievalPlan oldPlan = baseMapper.selectById(newPlan.getId());
|
|
|
|
|
|
- if(!ObjectUtil.equal(newPlan.getRoleId(),oldPlan.getRoleId()))
|
|
|
- {
|
|
|
+ if (!ObjectUtil.equal(newPlan.getRoleId(), oldPlan.getRoleId())) {
|
|
|
SysRole sysRole = remoteRoleService.getRoleById(newPlan.getRoleId(), SecurityConstants.INNER);
|
|
|
newPlan.setRoleName(sysRole.getRoleName());
|
|
|
}
|
|
|
BeanUtils.copyProperties(newPlan, oldPlan);
|
|
|
|
|
|
// 草稿状态 下的计划不存在任务和子计划 直接修改
|
|
|
- if(oldPlan.getPlanStatus()==0)
|
|
|
- {
|
|
|
+ if (oldPlan.getPlanStatus() == 0) {
|
|
|
// 先删除具体调阅机构,再重新新增具体调阅机构
|
|
|
tMonitoringRetrievalPlanToExecOrgMapper.deleteByMap(MapUtil.of("plan_id", oldPlan.getId()));
|
|
|
batchSavePlanToExecOrg(tMonitoringRetrievalPlanDto.getPlanExecOrgIdList(), oldPlan.getId());
|
|
|
return tMonitoringRetrievalPlanMapper.updateById(oldPlan);
|
|
|
}
|
|
|
// 使用中,
|
|
|
- else if(oldPlan.getPlanStatus()==1)
|
|
|
- {
|
|
|
+ else if (oldPlan.getPlanStatus() == 1) {
|
|
|
// 但是任务都未完成,修改计划和所有子计划, 删除现有任务,根据是否立即生效 判断是否立即生成任务
|
|
|
- if(!isComplete){
|
|
|
+ if (!isComplete) {
|
|
|
|
|
|
tMonitoringRetrievalPlanToExecOrgMapper.deleteByMap(MapUtil.of("plan_id", oldPlan.getId()));
|
|
|
batchSavePlanToExecOrg(tMonitoringRetrievalPlanDto.getPlanExecOrgIdList(), oldPlan.getId());
|
|
|
@@ -1401,42 +1388,36 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tMonitoringRetrievalPlanMapper.delete(queryWrapper);
|
|
|
|
|
|
// 编辑的非行社创建计划,需处理子计划
|
|
|
- if(oldPlan.getOrgType()!="3")
|
|
|
- {
|
|
|
+ if (oldPlan.getOrgType() != "3") {
|
|
|
iCoreMonitoringRetrievalTaskService.updateComplete(!isComplete, newPlan, oldPlan);
|
|
|
}
|
|
|
return result;
|
|
|
- }
|
|
|
- else // 任务中存在已完成的任务,只能修改任务名称
|
|
|
+ } else // 任务中存在已完成的任务,只能修改任务名称
|
|
|
{
|
|
|
tMonitoringRetrievalPlanMapper.updateById(oldPlan);
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq(PARENT_ID, oldPlan.getId());
|
|
|
List<TMonitoringRetrievalPlan> subPlanList = tMonitoringRetrievalPlanMapper.selectList(queryWrapper);
|
|
|
- if(ObjectUtil.isNotEmpty(subPlanList))
|
|
|
- {
|
|
|
- subPlanList.forEach(x->x.setPlanName(oldPlan.getPlanName()));
|
|
|
+ if (ObjectUtil.isNotEmpty(subPlanList)) {
|
|
|
+ subPlanList.forEach(x -> x.setPlanName(oldPlan.getPlanName()));
|
|
|
this.saveOrUpdateBatch(subPlanList);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
// 停用状态 肯定存在已完成的任务, 只能修改任务名称
|
|
|
- else if(oldPlan.getPlanStatus()==2)
|
|
|
- {
|
|
|
+ else if (oldPlan.getPlanStatus() == 2) {
|
|
|
tMonitoringRetrievalPlanMapper.updateById(oldPlan);
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq(PARENT_ID, oldPlan.getId());
|
|
|
List<TMonitoringRetrievalPlan> subPlanList = tMonitoringRetrievalPlanMapper.selectList(queryWrapper);
|
|
|
- if(ObjectUtil.isNotEmpty(subPlanList))
|
|
|
- {
|
|
|
- subPlanList.forEach(x->x.setPlanName(oldPlan.getPlanName()));
|
|
|
+ if (ObjectUtil.isNotEmpty(subPlanList)) {
|
|
|
+ subPlanList.forEach(x -> x.setPlanName(oldPlan.getPlanName()));
|
|
|
this.saveOrUpdateBatch(subPlanList);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.getMessage();
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -1444,7 +1425,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
}
|
|
|
|
|
|
// 根据计划Id清除计划下的所有任务
|
|
|
- private void clearTaskByPlanId(Long id){
|
|
|
+ private void clearTaskByPlanId(Long id) {
|
|
|
TMonitoringRetrievalPlan plan = baseMapper.selectById(id);
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq(PARENT_ID, id);
|
|
|
@@ -1454,8 +1435,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
planIds = list1.stream().map(TMonitoringRetrievalPlan::getId).collect(Collectors.toList());
|
|
|
coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(planIds);
|
|
|
- }
|
|
|
- else if (plan.getPlanCycle().equals("0")) {
|
|
|
+ } else if (plan.getPlanCycle().equals("0")) {
|
|
|
planIds.add(id);
|
|
|
coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(planIds);
|
|
|
}
|
|
|
@@ -1476,7 +1456,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
public int deleteTMonitoringRetrievalPlanByIds(Long[] ids) {
|
|
|
int i = 0;
|
|
|
for (Long id : ids) {
|
|
|
- checkPlanIsCreatingTask(id,"删除");
|
|
|
+ checkPlanIsCreatingTask(id, "删除");
|
|
|
|
|
|
TMonitoringRetrievalPlan tMonitoringRetrievalPlan = new TMonitoringRetrievalPlan();
|
|
|
tMonitoringRetrievalPlan.setIsDeleted(2L);
|
|
|
@@ -1602,8 +1582,8 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
List<SysDictData> sysDictData = dictDataService.selectAllDictByeTypeFormDB(DictConstants.CORE_REGISTRATION_PROJECT, SecurityConstants.INNER);
|
|
|
for (AccessDataVo vo : accessDataVos) {
|
|
|
vo.setProject(DictUtils.getDictLabel(DictConstants.CORE_REGISTRATION_PROJECT, Integer.parseInt(vo.getProject())));
|
|
|
- if (ObjectUtil.isEmpty(vo.getProject())){
|
|
|
- sysDictData.stream().filter(d->d.getDictValue().equals(vo.getProject())).findFirst().ifPresent(d->vo.setProject(d.getDictLabel()));
|
|
|
+ if (ObjectUtil.isEmpty(vo.getProject())) {
|
|
|
+ sysDictData.stream().filter(d -> d.getDictValue().equals(vo.getProject())).findFirst().ifPresent(d -> vo.setProject(d.getDictLabel()));
|
|
|
}
|
|
|
}
|
|
|
accessPdf.setDataVos(accessDataVos);
|
|
|
@@ -1634,11 +1614,145 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
@Override
|
|
|
public void compensate(CompensateDto compensateDto) {
|
|
|
+ TMonitoringRetrievalPlan retrievalPlan = getById(compensateDto.getPlanId());
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(retrievalPlan)) {
|
|
|
+ throw new ServiceException("计划不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.notEqual(retrievalPlan.getPlanStatus(), PlanStatus.USING.getCode())) {
|
|
|
+ throw new ServiceException("计划尚未下发或已停用");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.equal(retrievalPlan.getIsDeleted(), "1")) {
|
|
|
+ throw new ServiceException("计划状态异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysOrgVO> orgCacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
+ //推断计划 创建任务
|
|
|
+ deducePlanAndBuildTask(retrievalPlan, compensateDto.getOrgIdList(), orgCacheList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static final Set<OrgTypeEnum> INVALID_ORG_TYPES = Sets.newHashSet(OrgTypeEnum.SHEGN_LIAN_SHE, OrgTypeEnum.BAN_SHI_CHU, OrgTypeEnum.DIQU_HANG_SHE);
|
|
|
|
|
|
+ private void deducePlanAndBuildTask(TMonitoringRetrievalPlan retrievalPlan, List<Long> orgIdList, List<SysOrgVO> orgCacheList) {
|
|
|
+ List<SysOrgVO> orgList = orgCacheList.stream().filter(org -> orgIdList.contains(org.getId())).collect(toList());
|
|
|
+ if (orgList.isEmpty()) {
|
|
|
+ throw new ServiceException("未查询到orgIdList中指定的机构信息");
|
|
|
+ }
|
|
|
+ List<Long> idList = orgList.stream().map(SysOrgVO::getId).collect(toList());
|
|
|
+ List<Integer> typeList = orgList.stream().map(SysOrgVO::getType).distinct().collect(toList());
|
|
|
+ if (typeList.size() > 1) {
|
|
|
+ throw new ServiceException("orgIdList中指定的机构信息存在多种机构类型");
|
|
|
+ }
|
|
|
+
|
|
|
+ OrgTypeEnum orgTypeEnum = OrgTypeEnum.getOrgTypeEnum(typeList.get(0));
|
|
|
+
|
|
|
+ // 省联社创建的计划
|
|
|
+ if (checkIsTopOrgCreatePlan(retrievalPlan, orgCacheList)) {
|
|
|
+ List<TMonitoringRetrievalPlan> allHsPlanList = getHsPlanList(retrievalPlan);
|
|
|
+ if (ObjectUtil.isEmpty(allHsPlanList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> map = getHsOrg(orgCacheList, orgList, orgTypeEnum);
|
|
|
+ List<Long> hsPlanIdList = allHsPlanList.stream().map(TMonitoringRetrievalPlan::getId).collect(toList());
|
|
|
+ List<Long> hsOrgIdList = ((List<SysOrgVO>) map.get("list")).stream().map(SysOrgVO::getId).collect(toList());
|
|
|
+ if (ObjectUtil.hasEmpty(hsPlanIdList, hsOrgIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<TMonitoringRetrievalPlan> reallyPlanList = findReallyPlanIdList(hsPlanIdList, hsOrgIdList);
|
|
|
+ boolean underHsOrgType = (boolean) map.get("underHsOrgType");
|
|
|
+ create(reallyPlanList, underHsOrgType ? idList : null);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 行社自建计划
|
|
|
+ if (INVALID_ORG_TYPES.contains(orgTypeEnum)) {
|
|
|
+ throw new ServiceException("orgIdList中传递机构信息错误!与计划信息不匹配");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TMonitoringRetrievalPlan> plans = Lists.newArrayList(retrievalPlan);
|
|
|
+ if (OrgTypeEnum.HANG_SHE.equals(orgTypeEnum)) {
|
|
|
+ create(plans, null);
|
|
|
+ } else {
|
|
|
+ //其实这里如果真是传入了行社以下的机构,那么大概率这里的reallyPlanIdList 计划id也只会有一个元素
|
|
|
+ create(plans, idList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void create(List<TMonitoringRetrievalPlan> planList, List<Long> idList) {
|
|
|
+ run(() -> coreMonitoringRetrievalTaskBuilderService.createAndSaveTask(planList, LocalDate.now(), idList), threadPoolTaskExecutor);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<TMonitoringRetrievalPlan> findReallyPlanIdList(List<Long> planIdList, List<Long> orgIdList) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<TMonitoringRetrievalPlan> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(TMonitoringRetrievalPlan::getId, planIdList);
|
|
|
+ wrapper.in(TMonitoringRetrievalPlan::getOrgId, orgIdList);
|
|
|
+ return baseMapper.selectList(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean checkIsTopOrgCreatePlan(TMonitoringRetrievalPlan retrievalPlan, List<SysOrgVO> orgCacheList) {
|
|
|
+ Long orgId = retrievalPlan.getOrgId();
|
|
|
+ SysOrgVO org = orgCacheList.stream().filter(o -> o.getId().equals(orgId)).findFirst().orElse(null);
|
|
|
+ if (org == null) {
|
|
|
+ throw new ServiceException("未查询到计划所属机构信息");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.equal(org.getType(), OrgTypeEnum.SHEGN_LIAN_SHE.getCode())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.equal(org.getType(), OrgTypeEnum.HANG_SHE.getCode())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ throw new ServiceException("当前仅支持省联社/行社所创建的计划!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<TMonitoringRetrievalPlan> getHsPlanList(TMonitoringRetrievalPlan drillPlan) {
|
|
|
+ LambdaQueryWrapper<TMonitoringRetrievalPlan> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TMonitoringRetrievalPlan::getPlanStatus, DrillPlanStatus.USING.getCode());
|
|
|
+ wrapper.eq(TMonitoringRetrievalPlan::getIsDeleted, 0L);
|
|
|
+ wrapper.eq(TMonitoringRetrievalPlan::getParentId, drillPlan.getId());
|
|
|
+ return baseMapper.selectList(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> getHsOrg(List<SysOrgVO> orgCacheList, List<SysOrgVO> needBuildTaskOrgList, OrgTypeEnum needBuildTaskOrgTypeEnum) {
|
|
|
+ List<SysOrgVO> list = new ArrayList<>();
|
|
|
+ boolean underHsOrgType = false;
|
|
|
+ switch (needBuildTaskOrgTypeEnum) {
|
|
|
+ //如果是省联社/办事处/地区行社 那么找到下级的行社
|
|
|
+ case SHEGN_LIAN_SHE:
|
|
|
+ case BAN_SHI_CHU:
|
|
|
+ case DIQU_HANG_SHE:
|
|
|
+ for (SysOrgVO sysOrgVO : needBuildTaskOrgList) {
|
|
|
+ String path = sysOrgVO.getPath();
|
|
|
+ List<SysOrgVO> collect = orgCacheList
|
|
|
+ .stream()
|
|
|
+ .filter(org -> ObjectUtil.isAllNotEmpty(org.getPath(), org.getType()))
|
|
|
+ .filter(org -> org.getPath().contains(path))
|
|
|
+ .filter(org -> org.getType().equals(OrgTypeEnum.HANG_SHE.getCode()))
|
|
|
+ .collect(toList());
|
|
|
+ list.addAll(collect);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case HANG_SHE: //如果传进来的就是行社 那么直接返回
|
|
|
+ list = needBuildTaskOrgList;
|
|
|
+ break;
|
|
|
+ default: //如果是行社以下机构类型,那么找到上级的行社机构返回
|
|
|
+ List<Long> ids = needBuildTaskOrgList.stream().map(SysOrgVO::getId).collect(toList());
|
|
|
+ List<SysOrg> sysOrgs = remoteOrgService.selectParentHs(ids, SecurityConstants.INNER);
|
|
|
+ list = BeanHelper.copyProperties(sysOrgs, SysOrgVO.class);
|
|
|
+ underHsOrgType = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("list", list);
|
|
|
+ map.put("underHsOrgType", underHsOrgType);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void run(Runnable runnable, ThreadPoolTaskExecutor threadPoolTaskExecutor) {
|
|
|
-
|
|
|
+ CompletableFuture.runAsync(runnable, threadPoolTaskExecutor);
|
|
|
}
|
|
|
}
|