|
|
@@ -1,17 +1,15 @@
|
|
|
package com.xunmei.core.access.service.impl;
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
+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.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.DateRange;
|
|
|
import com.xunmei.common.core.domain.registerbook.domain.CoreRegisterBookPdf;
|
|
|
import com.xunmei.common.core.domain.retrieval.domain.CoreMonitoringRetrievalTask;
|
|
|
import com.xunmei.common.core.enums.RegisterBookType;
|
|
|
@@ -19,35 +17,35 @@ import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.exception.SystemException;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.core.utils.StringUtils;
|
|
|
-
|
|
|
-import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.redis.utils.RedisUtils;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
-import com.xunmei.core.access.domain.CoreMonitoringTaskRegistration;
|
|
|
import com.xunmei.core.access.domain.TMonitoringRetrievalPlan;
|
|
|
+import com.xunmei.core.access.domain.TMonitoringRetrievalPlanToExecOrg;
|
|
|
+import com.xunmei.core.access.dto.TMonitoringRetrievalPlanDto;
|
|
|
import com.xunmei.core.access.mapper.TMonitoringRetrievalPlanMapper;
|
|
|
+import com.xunmei.core.access.mapper.TMonitoringRetrievalPlanToExecOrgMapper;
|
|
|
import com.xunmei.core.access.service.ITMonitoringRetrievalPlanService;
|
|
|
-
|
|
|
+import com.xunmei.core.access.service.ITMonitoringRetrievalPlanToExecOrgService;
|
|
|
import com.xunmei.core.access.vo.AccessPdfVO;
|
|
|
import com.xunmei.core.access.vo.TMonitoringRetrievalPlanVO;
|
|
|
import com.xunmei.core.registerbook.service.ICoreRegisterBookPdfService;
|
|
|
import com.xunmei.core.retrieval.mapper.CoreMonitoringRetrievalTaskMapper;
|
|
|
import com.xunmei.core.retrieval.service.ICoreMonitoringRetrievalTaskBuilderService;
|
|
|
import com.xunmei.core.retrieval.service.ICoreMonitoringRetrievalTaskService;
|
|
|
-
|
|
|
-import com.xunmei.core.safetyCheck.domain.CoreSafetyTask;
|
|
|
-import com.xunmei.core.safetyCheck.vo.regsiter.AppTaskRegisterPointVo;
|
|
|
+import com.xunmei.core.thread.ThreadPoolConfig;
|
|
|
import com.xunmei.system.api.RemoteFileService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.RemoteRoleService;
|
|
|
import com.xunmei.system.api.RemoteUserService;
|
|
|
import com.xunmei.system.api.domain.*;
|
|
|
-
|
|
|
+import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -56,10 +54,12 @@ import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -97,6 +97,16 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
@Autowired
|
|
|
private ICoreRegisterBookPdfService iCoreRegisterBookPdfService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ITMonitoringRetrievalPlanToExecOrgService itMonitoringRetrievalPlanToExecOrgService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TMonitoringRetrievalPlanToExecOrgMapper tMonitoringRetrievalPlanToExecOrgMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
|
|
|
+ private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo selectPage(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
|
|
|
//未删除
|
|
|
@@ -190,6 +200,9 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
}
|
|
|
tMonitoringRetrievalPlanVO.setIsHaveTask(haveTask);
|
|
|
tMonitoringRetrievalPlanVO.setIsComplete(isComplete);
|
|
|
+ final List<TMonitoringRetrievalPlanToExecOrg> execOrgList = tMonitoringRetrievalPlanToExecOrgMapper.selectByMap(MapUtil.of("plan_id", id));
|
|
|
+ final List<Long> execOrgIdList = execOrgList.stream().map(TMonitoringRetrievalPlanToExecOrg::getOrgId).collect(Collectors.toList());
|
|
|
+ tMonitoringRetrievalPlanVO.setPlanExecOrgIdList(ObjectUtil.isEmpty(execOrgIdList) ? null : execOrgIdList);
|
|
|
return tMonitoringRetrievalPlanVO;
|
|
|
}
|
|
|
|
|
|
@@ -204,6 +217,9 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tMonitoringRetrievalPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
tMonitoringRetrievalPlan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
tMonitoringRetrievalPlanMapper.updateById(tMonitoringRetrievalPlan);
|
|
|
+
|
|
|
+ final List<TMonitoringRetrievalPlanToExecOrg> planExecOrgList = tMonitoringRetrievalPlanToExecOrgMapper.selectByMap(MapUtil.of("plan_id", id));
|
|
|
+
|
|
|
Integer i = 1;
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq(PARENT_ID, id);
|
|
|
@@ -215,117 +231,122 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
//如果当前是省联社
|
|
|
if (nowUserOrg.getType() == 1) {
|
|
|
//如果顶级
|
|
|
- SysOrg org = new SysOrg();
|
|
|
- org.setType(3);
|
|
|
- org.setPath(topOrg.getPath());
|
|
|
if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
for (TMonitoringRetrievalPlan tm : list1) {
|
|
|
tm.setPlanStatus(1);
|
|
|
tm.setIsDistribute("1");
|
|
|
baseMapper.updateById(tm);
|
|
|
if (tMonitoringRetrievalPlan.getOrgType().equals("3")) {
|
|
|
- if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
- tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
- tm.setStartTime(new Date());
|
|
|
- int amount = 0;
|
|
|
- LocalDate lastDayOfMonth;
|
|
|
- switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
- case "2":
|
|
|
- amount = 7;
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
- amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- amount = getDayNum(3);
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- amount = getDayNum(6);
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- amount = getDayNum(12);
|
|
|
- break;
|
|
|
- default:
|
|
|
- amount = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(new Date());
|
|
|
- cal.add(Calendar.DATE, amount);
|
|
|
- Date time = cal.getTime();
|
|
|
- tm.setEndTime(time);
|
|
|
- tMonitoringRetrievalPlans.add(tm);
|
|
|
- }
|
|
|
+// if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+// tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+// tm.setStartTime(new Date());
|
|
|
+// int amount = 0;
|
|
|
+// LocalDate lastDayOfMonth;
|
|
|
+// switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+//
|
|
|
+// case "2":
|
|
|
+// amount = 7;
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// LocalDate currentDate = LocalDate.now();
|
|
|
+// lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
+// amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
+// break;
|
|
|
+// case "4":
|
|
|
+// amount = getDayNum(3);
|
|
|
+// break;
|
|
|
+// case "5":
|
|
|
+// amount = getDayNum(6);
|
|
|
+// break;
|
|
|
+// case "6":
|
|
|
+// amount = getDayNum(12);
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// amount = 1;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// Calendar cal = Calendar.getInstance();
|
|
|
+// cal.setTime(new Date());
|
|
|
+// cal.add(Calendar.DATE, amount);
|
|
|
+// Date time = cal.getTime();
|
|
|
+// tm.setEndTime(time);
|
|
|
+// }
|
|
|
+ setPlanStartEndTime(tMonitoringRetrievalPlan,tm);
|
|
|
+ tMonitoringRetrievalPlans.add(tm);
|
|
|
} else {
|
|
|
- SysOrg sysOrg = new SysOrg();
|
|
|
- sysOrg.setPath(tm.getOrgPath());
|
|
|
- sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
- List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
+// SysOrg sysOrg = new SysOrg();
|
|
|
+// sysOrg.setPath(tm.getOrgPath());
|
|
|
+// sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
+// List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
+ List<SysOrg> sysOrgs=getExecOrgList(planExecOrgList,Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()),tm.getOrgPath());
|
|
|
for (SysOrg s : sysOrgs) {
|
|
|
- TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
- BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
- plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
- plan.setOrgId(s.getId());
|
|
|
- plan.setOrganization(s.getShortName());
|
|
|
- plan.setOrgName(s.getShortName());
|
|
|
- plan.setOrganization(s.getShortName());
|
|
|
- plan.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
- plan.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
- plan.setOrgPath(s.getPath());
|
|
|
- plan.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
- plan.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
- plan.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
- plan.setPlanStatus(ZERO);
|
|
|
- plan.setCreateBy(SecurityUtils.getUsername());
|
|
|
- plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
- plan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- plan.setCreateTime(DateUtils.getNowDate());
|
|
|
- plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
- plan.setCreateType(1);
|
|
|
- plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
- plan.setIsDistribute("1");
|
|
|
- if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
- tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
- plan.setStartTime(new Date());
|
|
|
- int amount = 0;
|
|
|
- LocalDate lastDayOfMonth;
|
|
|
- switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
- case "2":
|
|
|
- amount = 7;
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
- amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- amount = getDayNum(3);
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- amount = getDayNum(6);
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- amount = getDayNum(12);
|
|
|
- break;
|
|
|
- default:
|
|
|
- amount = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(new Date());
|
|
|
- cal.add(Calendar.DATE, amount);
|
|
|
- Date time = cal.getTime();
|
|
|
- plan.setEndTime(time);
|
|
|
- }
|
|
|
+// TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
+// BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
+// plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
+// plan.setOrgId(s.getId());
|
|
|
+// plan.setOrganization(s.getShortName());
|
|
|
+// plan.setOrgName(s.getShortName());
|
|
|
+// plan.setOrganization(s.getShortName());
|
|
|
+// plan.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
+// plan.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
+// plan.setOrgPath(s.getPath());
|
|
|
+// plan.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
+// plan.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
+// plan.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
+// plan.setPlanStatus(ZERO);
|
|
|
+// plan.setCreateBy(SecurityUtils.getUsername());
|
|
|
+// plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+// plan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+// plan.setCreateTime(DateUtils.getNowDate());
|
|
|
+// plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
+// plan.setCreateType(1);
|
|
|
+// plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
+// plan.setIsDistribute("1");
|
|
|
+// if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+// tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+// plan.setStartTime(new Date());
|
|
|
+// int amount = 0;
|
|
|
+// LocalDate lastDayOfMonth;
|
|
|
+// switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+// case "2":
|
|
|
+// amount = 7;
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// LocalDate currentDate = LocalDate.now();
|
|
|
+// lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
+// amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
+// break;
|
|
|
+// case "4":
|
|
|
+// amount = getDayNum(3);
|
|
|
+// break;
|
|
|
+// case "5":
|
|
|
+// amount = getDayNum(6);
|
|
|
+// break;
|
|
|
+// case "6":
|
|
|
+// amount = getDayNum(12);
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// amount = 1;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// Calendar cal = Calendar.getInstance();
|
|
|
+// cal.setTime(new Date());
|
|
|
+// cal.add(Calendar.DATE, amount);
|
|
|
+// Date time = cal.getTime();
|
|
|
+// plan.setEndTime(time);
|
|
|
+// }
|
|
|
+ TMonitoringRetrievalPlan plan = createTempPlan(tMonitoringRetrievalPlan,tMonitoringRetrievalPlan.getId(),s);
|
|
|
tMonitoringRetrievalPlans.add(plan);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+// SysOrg org = new SysOrg();
|
|
|
+// org.setType(3);
|
|
|
+// org.setPath(topOrg.getPath());
|
|
|
//查询符合的机构,需求是先把行社加入
|
|
|
- List<SysOrg> list = remoteOrgService.listByParentIdAndType(org, SecurityConstants.INNER);
|
|
|
+// List<SysOrg> list = remoteOrgService.listByParentIdAndType(org, SecurityConstants.INNER);
|
|
|
+ List<SysOrg> list=getExecOrgList(planExecOrgList,3,topOrg.getPath());
|
|
|
for (SysOrg l : list) {
|
|
|
TMonitoringRetrievalPlan tMonitoringRetrievalPlan1 = new TMonitoringRetrievalPlan();
|
|
|
BeanUtils.copyProperties(tMonitoringRetrievalPlan, tMonitoringRetrievalPlan1);
|
|
|
@@ -340,109 +361,115 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
SysOrg sysOrg = remoteOrgService.selectSysOrgById(tMonitoringRetrievalPlan.getOrgId(), SecurityConstants.INNER);
|
|
|
tMonitoringRetrievalPlan1.setOrgName(sysOrg.getShortName());
|
|
|
i = insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan1);
|
|
|
+ if(ObjectUtil.isNotEmpty(planExecOrgList)){
|
|
|
+ batchSavePlanToExecOrg(planExecOrgList.stream().map(x->x.getOrgId()).collect(Collectors.toList()), tMonitoringRetrievalPlan1.getId());
|
|
|
+ }
|
|
|
}
|
|
|
if (tMonitoringRetrievalPlan.getOrgType().equals("3")) {
|
|
|
tMonitoringRetrievalPlan.setCreateType(1);
|
|
|
tMonitoringRetrievalPlan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
tMonitoringRetrievalPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
baseMapper.updateById(tMonitoringRetrievalPlan);
|
|
|
- if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
- tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
- tMonitoringRetrievalPlan1.setStartTime(new Date());
|
|
|
- int amount = 0;
|
|
|
- LocalDate lastDayOfMonth;
|
|
|
- switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
-
|
|
|
- case "2":
|
|
|
- amount = 7;
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
- amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- amount = getDayNum(3);
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- amount = getDayNum(6);
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- amount = getDayNum(12);
|
|
|
- break;
|
|
|
- default:
|
|
|
- amount = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(new Date());
|
|
|
- cal.add(Calendar.DATE, amount);
|
|
|
- Date time = cal.getTime();
|
|
|
- tMonitoringRetrievalPlan1.setEndTime(time);
|
|
|
- }
|
|
|
+// if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+// tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+// tMonitoringRetrievalPlan1.setStartTime(new Date());
|
|
|
+// int amount = 0;
|
|
|
+// LocalDate lastDayOfMonth;
|
|
|
+// switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+//
|
|
|
+// case "2":
|
|
|
+// amount = 7;
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// LocalDate currentDate = LocalDate.now();
|
|
|
+// lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
+// amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
+// break;
|
|
|
+// case "4":
|
|
|
+// amount = getDayNum(3);
|
|
|
+// break;
|
|
|
+// case "5":
|
|
|
+// amount = getDayNum(6);
|
|
|
+// break;
|
|
|
+// case "6":
|
|
|
+// amount = getDayNum(12);
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// amount = 1;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// Calendar cal = Calendar.getInstance();
|
|
|
+// cal.setTime(new Date());
|
|
|
+// cal.add(Calendar.DATE, amount);
|
|
|
+// Date time = cal.getTime();
|
|
|
+// tMonitoringRetrievalPlan1.setEndTime(time);
|
|
|
+// }
|
|
|
+ setPlanStartEndTime(tMonitoringRetrievalPlan,tMonitoringRetrievalPlan1);
|
|
|
tMonitoringRetrievalPlans.add(tMonitoringRetrievalPlan1);
|
|
|
} else {
|
|
|
- SysOrg sysOrg = new SysOrg();
|
|
|
- sysOrg.setPath(l.getPath());
|
|
|
- sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
- List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
+// SysOrg sysOrg = new SysOrg();
|
|
|
+// sysOrg.setPath(l.getPath());
|
|
|
+// sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
+// List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
+ List<SysOrg> sysOrgs=getExecOrgList(planExecOrgList,Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()),l.getPath());
|
|
|
for (SysOrg s : sysOrgs) {
|
|
|
- TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
- BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
- plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
- plan.setOrgId(s.getId());
|
|
|
- plan.setOrganization(s.getShortName());
|
|
|
- plan.setId(tMonitoringRetrievalPlan1.getId());
|
|
|
- plan.setOrgName(s.getShortName());
|
|
|
- plan.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
- plan.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
- plan.setOrgPath(s.getPath());
|
|
|
- plan.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
- plan.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
- plan.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
- plan.setPlanStatus(ZERO);
|
|
|
- plan.setCreateBy(SecurityUtils.getUsername());
|
|
|
- plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
- plan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- plan.setCreateTime(DateUtils.getNowDate());
|
|
|
- plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
- plan.setCreateType(1);
|
|
|
- plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
- plan.setIsDistribute("1");
|
|
|
- if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
- tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
- plan.setStartTime(new Date());
|
|
|
- int amount = 0;
|
|
|
- LocalDate lastDayOfMonth;
|
|
|
- switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
-
|
|
|
- case "2":
|
|
|
- amount = 7;
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
- amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- amount = getDayNum(3);
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- amount = getDayNum(6);
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- amount = getDayNum(12);
|
|
|
- break;
|
|
|
- default:
|
|
|
- amount = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(new Date());
|
|
|
- cal.add(Calendar.DATE, amount);
|
|
|
- Date time = cal.getTime();
|
|
|
- plan.setEndTime(time);
|
|
|
- }
|
|
|
+// TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
+// BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
+// plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
+// plan.setOrgId(s.getId());
|
|
|
+// plan.setOrganization(s.getShortName());
|
|
|
+// plan.setId(tMonitoringRetrievalPlan1.getId());
|
|
|
+// plan.setOrgName(s.getShortName());
|
|
|
+// plan.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
+// plan.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
+// plan.setOrgPath(s.getPath());
|
|
|
+// plan.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
+// plan.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
+// plan.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
+// plan.setPlanStatus(ZERO);
|
|
|
+// plan.setCreateBy(SecurityUtils.getUsername());
|
|
|
+// plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+// plan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+// plan.setCreateTime(DateUtils.getNowDate());
|
|
|
+// plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
+// plan.setCreateType(1);
|
|
|
+// plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
+// plan.setIsDistribute("1");
|
|
|
+// if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+// tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+// plan.setStartTime(new Date());
|
|
|
+// int amount = 0;
|
|
|
+// LocalDate lastDayOfMonth;
|
|
|
+// switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+//
|
|
|
+// case "2":
|
|
|
+// amount = 7;
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// LocalDate currentDate = LocalDate.now();
|
|
|
+// lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
+// amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
+// break;
|
|
|
+// case "4":
|
|
|
+// amount = getDayNum(3);
|
|
|
+// break;
|
|
|
+// case "5":
|
|
|
+// amount = getDayNum(6);
|
|
|
+// break;
|
|
|
+// case "6":
|
|
|
+// amount = getDayNum(12);
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// amount = 1;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// Calendar cal = Calendar.getInstance();
|
|
|
+// cal.setTime(new Date());
|
|
|
+// cal.add(Calendar.DATE, amount);
|
|
|
+// Date time = cal.getTime();
|
|
|
+// plan.setEndTime(time);
|
|
|
+// }
|
|
|
+ TMonitoringRetrievalPlan plan = createTempPlan(tMonitoringRetrievalPlan,tMonitoringRetrievalPlan1.getId(),s);
|
|
|
tMonitoringRetrievalPlans.add(plan);
|
|
|
}
|
|
|
}
|
|
|
@@ -457,61 +484,62 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
for (SysOrg s : sysOrgs) {
|
|
|
- TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
- BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
- plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
- plan.setOrgId(s.getId());
|
|
|
- plan.setOrganization(s.getShortName());
|
|
|
- plan.setOrgName(s.getShortName());
|
|
|
- plan.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
- plan.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
- plan.setOrgPath(s.getPath());
|
|
|
- plan.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
- plan.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
- plan.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
- plan.setPlanStatus(ZERO);
|
|
|
- plan.setCreateBy(SecurityUtils.getUsername());
|
|
|
- plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
- plan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- plan.setCreateTime(DateUtils.getNowDate());
|
|
|
- plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
- plan.setCreateType(1);
|
|
|
- plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
- plan.setIsDistribute("1");
|
|
|
- if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
- tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
- plan.setStartTime(new Date());
|
|
|
- int amount = 0;
|
|
|
- LocalDate lastDayOfMonth;
|
|
|
- switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
-
|
|
|
- case "2":
|
|
|
- amount = 7;
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
- amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- amount = getDayNum(3);
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- amount = getDayNum(6);
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- amount = getDayNum(12);
|
|
|
- break;
|
|
|
- default:
|
|
|
- amount = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(new Date());
|
|
|
- cal.add(Calendar.DATE, amount);
|
|
|
- Date time = cal.getTime();
|
|
|
- plan.setEndTime(time);
|
|
|
- }
|
|
|
+// TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
+// BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
+// plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
+// plan.setOrgId(s.getId());
|
|
|
+// plan.setOrganization(s.getShortName());
|
|
|
+// plan.setOrgName(s.getShortName());
|
|
|
+// plan.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
+// plan.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
+// plan.setOrgPath(s.getPath());
|
|
|
+// plan.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
+// plan.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
+// plan.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
+// plan.setPlanStatus(ZERO);
|
|
|
+// plan.setCreateBy(SecurityUtils.getUsername());
|
|
|
+// plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+// plan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+// plan.setCreateTime(DateUtils.getNowDate());
|
|
|
+// plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
+// plan.setCreateType(1);
|
|
|
+// plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
+// plan.setIsDistribute("1");
|
|
|
+// if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+// tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+// plan.setStartTime(new Date());
|
|
|
+// int amount = 0;
|
|
|
+// LocalDate lastDayOfMonth;
|
|
|
+// switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+//
|
|
|
+// case "2":
|
|
|
+// amount = 7;
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// LocalDate currentDate = LocalDate.now();
|
|
|
+// lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
+// amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
+// break;
|
|
|
+// case "4":
|
|
|
+// amount = getDayNum(3);
|
|
|
+// break;
|
|
|
+// case "5":
|
|
|
+// amount = getDayNum(6);
|
|
|
+// break;
|
|
|
+// case "6":
|
|
|
+// amount = getDayNum(12);
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// amount = 1;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// Calendar cal = Calendar.getInstance();
|
|
|
+// cal.setTime(new Date());
|
|
|
+// cal.add(Calendar.DATE, amount);
|
|
|
+// Date time = cal.getTime();
|
|
|
+// plan.setEndTime(time);
|
|
|
+// }
|
|
|
+ TMonitoringRetrievalPlan plan = createTempPlan(tMonitoringRetrievalPlan,tMonitoringRetrievalPlan.getId(),s);
|
|
|
tMonitoringRetrievalPlans.add(plan);
|
|
|
}
|
|
|
}
|
|
|
@@ -525,6 +553,120 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
+ private List<SysOrg> getExecOrgList(List<TMonitoringRetrievalPlanToExecOrg> planExecOrgList, Integer execOrgType, String belongOrgPath) {
|
|
|
+ if (ObjectUtil.isEmpty(planExecOrgList)) {
|
|
|
+ return RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
+ remoteOrgService.selectByOrgPathAndOrgType(belongOrgPath, execOrgType, SecurityConstants.INNER),
|
|
|
+ ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ } else {
|
|
|
+ List<Long> list = planExecOrgList.stream().map(TMonitoringRetrievalPlanToExecOrg::getOrgId).collect(Collectors.toList());
|
|
|
+ return RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
+ remoteOrgService.selectOrgByIdList(list, SecurityConstants.INNER),
|
|
|
+ ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 准备生成任务需要的临时计划
|
|
|
+ private TMonitoringRetrievalPlan createTempPlan(TMonitoringRetrievalPlan tMonitoringRetrievalPlan,Long planId,SysOrg org)
|
|
|
+ {
|
|
|
+ TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();
|
|
|
+ BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
+ plan.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
+ plan.setOrgId(org.getId());
|
|
|
+ plan.setOrganization(org.getShortName());
|
|
|
+ plan.setId(planId);
|
|
|
+ plan.setOrgName(org.getShortName());
|
|
|
+ plan.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
+ plan.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
+ plan.setOrgPath(org.getPath());
|
|
|
+ plan.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
+ plan.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
+ plan.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
+ plan.setPlanStatus(ZERO);
|
|
|
+ plan.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ plan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ plan.setCreateTime(DateUtils.getNowDate());
|
|
|
+ plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
+ plan.setCreateType(1);
|
|
|
+ plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
+ plan.setIsDistribute("1");
|
|
|
+// if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+// tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+// plan.setStartTime(new Date());
|
|
|
+// int amount = 0;
|
|
|
+// LocalDate lastDayOfMonth;
|
|
|
+// switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+//
|
|
|
+// case "2":
|
|
|
+// amount = 7;
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// LocalDate currentDate = LocalDate.now();
|
|
|
+// lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
+// amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
+// break;
|
|
|
+// case "4":
|
|
|
+// amount = getDayNum(3);
|
|
|
+// break;
|
|
|
+// case "5":
|
|
|
+// amount = getDayNum(6);
|
|
|
+// break;
|
|
|
+// case "6":
|
|
|
+// amount = getDayNum(12);
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// amount = 1;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// Calendar cal = Calendar.getInstance();
|
|
|
+// cal.setTime(new Date());
|
|
|
+// cal.add(Calendar.DATE, amount);
|
|
|
+// Date time = cal.getTime();
|
|
|
+// plan.setEndTime(time);
|
|
|
+// }
|
|
|
+ setPlanStartEndTime(tMonitoringRetrievalPlan,plan);
|
|
|
+ return plan;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPlanStartEndTime(TMonitoringRetrievalPlan tMonitoringRetrievalPlan,TMonitoringRetrievalPlan tempPlan)
|
|
|
+ {
|
|
|
+ if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+ tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+ tempPlan.setStartTime(new Date());
|
|
|
+ int amount = 0;
|
|
|
+ LocalDate lastDayOfMonth;
|
|
|
+ switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+
|
|
|
+ case "2":
|
|
|
+ amount = 7;
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
|
|
|
+ amount = lastDayOfMonth.getDayOfMonth() - currentDate.getDayOfMonth();
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ amount = getDayNum(3);
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ amount = getDayNum(6);
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ amount = getDayNum(12);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ amount = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(new Date());
|
|
|
+ cal.add(Calendar.DATE, amount);
|
|
|
+ Date time = cal.getTime();
|
|
|
+ tempPlan.setEndTime(time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void checkPlanIsCreatingTask(Long planId,String msg)
|
|
|
{
|
|
|
String redisKey="Monitoring_Creating_Task" + planId;
|
|
|
@@ -743,6 +885,31 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
return tMonitoringRetrievalPlanMapper.insert(tMonitoringRetrievalPlan);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int insertTMonitoringRetrievalPlan(TMonitoringRetrievalPlanDto tMonitoringRetrievalPlanDto) {
|
|
|
+ if (ObjectUtil.equal(tMonitoringRetrievalPlanDto.getPlanCycle(), 0) && ObjectUtil.hasEmpty(tMonitoringRetrievalPlanDto.getStartTime(), tMonitoringRetrievalPlanDto.getEndTime())) {
|
|
|
+ throw new RuntimeException("当计划为无周期的时候,请填入开始时间和结束时间!");
|
|
|
+ }
|
|
|
+ TMonitoringRetrievalPlan tMonitoringRetrievalPlan =new TMonitoringRetrievalPlan();
|
|
|
+ BeanUtils.copyProperties(tMonitoringRetrievalPlanDto, tMonitoringRetrievalPlan);
|
|
|
+ int result= insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan);
|
|
|
+ batchSavePlanToExecOrg(tMonitoringRetrievalPlanDto.getPlanExecOrgIdList(), tMonitoringRetrievalPlan.getId());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void batchSavePlanToExecOrg(List<Long> orgIdList, Long planId) {
|
|
|
+ List<TMonitoringRetrievalPlanToExecOrg> planOrgList = new ArrayList();
|
|
|
+ for (Long orgId : orgIdList) {
|
|
|
+ TMonitoringRetrievalPlanToExecOrg org = new TMonitoringRetrievalPlanToExecOrg();
|
|
|
+ org.setOrgId(orgId);
|
|
|
+ org.setPlanId(planId);
|
|
|
+ planOrgList.add(org);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(planOrgList)) {
|
|
|
+ itMonitoringRetrievalPlanToExecOrgService.saveBatch(planOrgList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Async
|
|
|
@Override
|
|
|
public void updateComplete(boolean isComplete, TMonitoringRetrievalPlan tMonitoringRetrievalPlan, TMonitoringRetrievalPlan plan) {
|
|
|
@@ -849,10 +1016,86 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
// SysRole sysRole = remoteRoleService.getRoleById(tMonitoringRetrievalPlan.getRoleId(), SecurityConstants.INNER);
|
|
|
// plan.setRoleName(sysRole.getRoleName());
|
|
|
int i = tMonitoringRetrievalPlanMapper.updateById(plan);
|
|
|
+
|
|
|
+
|
|
|
iCoreMonitoringRetrievalTaskService.updateComplete(isComplete, tMonitoringRetrievalPlan, plan);
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public int updateTMonitoringRetrievalPlan(TMonitoringRetrievalPlanDto tMonitoringRetrievalPlanDto) throws ParseException {
|
|
|
+ try {
|
|
|
+ TMonitoringRetrievalPlan tMonitoringRetrievalPlan =new TMonitoringRetrievalPlan();
|
|
|
+ BeanUtils.copyProperties(tMonitoringRetrievalPlanDto, tMonitoringRetrievalPlan);
|
|
|
+
|
|
|
+ boolean isComplete = getIsComplete(tMonitoringRetrievalPlanDto.getId());
|
|
|
+ TMonitoringRetrievalPlan plan = baseMapper.selectById(tMonitoringRetrievalPlanDto.getId());
|
|
|
+ BeanUtils.copyProperties(tMonitoringRetrievalPlanDto, plan);
|
|
|
+ int result =0;
|
|
|
+ // 存在已完成的任务,不能修改具体执行机构
|
|
|
+ if(isComplete){
|
|
|
+ result = tMonitoringRetrievalPlanMapper.updateById(plan);
|
|
|
+ iCoreMonitoringRetrievalTaskService.updateComplete(isComplete, tMonitoringRetrievalPlan, plan);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 草稿状态
|
|
|
+ if(plan.getPlanStatus()==0)
|
|
|
+ {
|
|
|
+ tMonitoringRetrievalPlanToExecOrgMapper.deleteByMap(MapUtil.of("plan_id", plan.getId()));
|
|
|
+ batchSavePlanToExecOrg(tMonitoringRetrievalPlanDto.getPlanExecOrgIdList(), plan.getId());
|
|
|
+ result = tMonitoringRetrievalPlanMapper.updateById(plan);
|
|
|
+ }
|
|
|
+ // 使用中, 但是任务都未完成, 删除现有任务,并重新生成任务
|
|
|
+ else if(plan.getPlanStatus()==1)
|
|
|
+ {
|
|
|
+ tMonitoringRetrievalPlanToExecOrgMapper.deleteByMap(MapUtil.of("plan_id", plan.getId()));
|
|
|
+ batchSavePlanToExecOrg(tMonitoringRetrievalPlanDto.getPlanExecOrgIdList(), plan.getId());
|
|
|
+ result =tMonitoringRetrievalPlanMapper.updateById(plan);
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+
|
|
|
+ try{
|
|
|
+ clearTaskByPlanId(plan.getId());
|
|
|
+ distribute(plan.getId(),true);
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ }
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据计划Id清除计划下的所有任务
|
|
|
+ private void clearTaskByPlanId(Long id){
|
|
|
+ TMonitoringRetrievalPlan plan = baseMapper.selectById(id);
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq(PARENT_ID, id);
|
|
|
+ List<TMonitoringRetrievalPlan> list1 = tMonitoringRetrievalPlanMapper.selectList(queryWrapper);
|
|
|
+ List<Long> planIds = new ArrayList<>();
|
|
|
+ // 不为空说明是一个有 子计划的省联社计划
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
+ planIds = list1.stream().map(TMonitoringRetrievalPlan::getId).collect(Collectors.toList());
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(planIds);
|
|
|
+ }
|
|
|
+ else if (plan.getPlanCycle().equals("0")) {
|
|
|
+ planIds.add(id);
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(planIds);
|
|
|
+ }
|
|
|
+ // 是一个行社计划
|
|
|
+ else if (CollectionUtils.isEmpty(list1)) {
|
|
|
+ planIds.add(id);
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(planIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批量删除监控调阅计划(逻辑删除
|
|
|
*
|