|
|
@@ -9,7 +9,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
+import com.xunmei.common.core.domain.DateRange;
|
|
|
import com.xunmei.common.core.domain.retrieval.domain.CoreMonitoringRetrievalTask;
|
|
|
+import com.xunmei.common.core.enums.CycleCommonEnum;
|
|
|
import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.util.BeanHelper;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
@@ -128,10 +130,16 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
TMonitoringRetrievalPlan plan = tMonitoringRetrievalPlanMapper.selectById(id);
|
|
|
BeanUtils.copyProperties(plan, tMonitoringRetrievalPlanVO);
|
|
|
boolean isEdit = false;
|
|
|
+ boolean isComplete = false;
|
|
|
if (plan.getParentId() != null) {
|
|
|
isEdit = true;
|
|
|
}
|
|
|
tMonitoringRetrievalPlanVO.setIsEdit(isEdit);
|
|
|
+ List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectComplete(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(coreMonitoringRetrievalTasks) && plan.getParentId() == null) {
|
|
|
+ isComplete = true;
|
|
|
+ }
|
|
|
+ tMonitoringRetrievalPlanVO.setIsComplete(isComplete);
|
|
|
return tMonitoringRetrievalPlanVO;
|
|
|
}
|
|
|
|
|
|
@@ -197,7 +205,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tm.setEndTime(time);
|
|
|
tMonitoringRetrievalPlans.add(tm);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
SysOrg sysOrg = new SysOrg();
|
|
|
sysOrg.setPath(tm.getOrgPath());
|
|
|
sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
@@ -305,6 +313,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
cal.add(Calendar.DATE, amount);
|
|
|
Date time = cal.getTime();
|
|
|
tMonitoringRetrievalPlan1.setEndTime(time);
|
|
|
+ // List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans1 = tMonitoringRetrievalPlans(l.getPath(), l.getType(), tMonitoringRetrievalPlan1);
|
|
|
}
|
|
|
tMonitoringRetrievalPlans.add(tMonitoringRetrievalPlan1);
|
|
|
} else {
|
|
|
@@ -446,8 +455,74 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans(String path, Integer type, TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
|
|
|
+ List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = new ArrayList<>();
|
|
|
+ SysOrg sysOrg = new SysOrg();
|
|
|
+ sysOrg.setPath(path);
|
|
|
+ sysOrg.setType(Integer.valueOf(type));
|
|
|
+ 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.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 "1":
|
|
|
+ amount = 1;
|
|
|
+ break;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(new Date());
|
|
|
+ cal.add(Calendar.DATE, amount);
|
|
|
+ Date time = cal.getTime();
|
|
|
+ plan.setEndTime(time);
|
|
|
+ }
|
|
|
+ tMonitoringRetrievalPlans.add(plan);
|
|
|
+ }
|
|
|
+ return tMonitoringRetrievalPlans;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int withdraw(Long id) {
|
|
|
+ DateRange startAndEnd;
|
|
|
TMonitoringRetrievalPlan plan = baseMapper.selectById(id);
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq(PARENT_ID, id);
|
|
|
@@ -457,15 +532,33 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tMonitoringRetrievalPlan.setPlanStatus(2);
|
|
|
tMonitoringRetrievalPlan.setIsDistribute("0");
|
|
|
baseMapper.updateById(tMonitoringRetrievalPlan);
|
|
|
- iCoreMonitoringRetrievalTaskService.deleteTaskByPlanId(tMonitoringRetrievalPlan.getId());
|
|
|
+ //删除所有的任务,现在删除本周期的任务
|
|
|
if (plan.getPlanCycle().equals("0")) {
|
|
|
+ iCoreMonitoringRetrievalTaskService.deleteAllTaskByPlanId(tMonitoringRetrievalPlan.getId());
|
|
|
+ //如果无周期删除计划
|
|
|
baseMapper.deleteById(tMonitoringRetrievalPlan.getId());
|
|
|
}
|
|
|
}
|
|
|
+ if (!plan.getPlanCycle().equals("0")) {
|
|
|
+ switch (plan.getPlanCycle()) {
|
|
|
+ //天
|
|
|
+ case "1":
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ iCoreMonitoringRetrievalTaskService.deleteDayTaskByPlanId(plan.getId(), plan.getPlanCycle(), localDate);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ startAndEnd = DateUtils.getStartAndEnd(new Date(), Integer.valueOf(plan.getPlanCycle()) + 1);
|
|
|
+ iCoreMonitoringRetrievalTaskService.deleteDayTaskByTime(plan.getId(), plan.getPlanCycle(), startAndEnd.getStartTime(), startAndEnd.getEndTime());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
plan.setPlanStatus(2);
|
|
|
plan.setIsDistribute("0");
|
|
|
- iCoreMonitoringRetrievalTaskService.deleteTaskByPlanId(id);
|
|
|
+ if (!plan.getPlanCycle().equals("0")) {
|
|
|
+ startAndEnd = DateUtils.getStartAndEnd(new Date(), Integer.valueOf(plan.getPlanCycle()) + 1);
|
|
|
+ iCoreMonitoringRetrievalTaskService.deleteDayTaskByTimeAndPlanId(id, plan.getPlanCycle(), startAndEnd.getStartTime(), startAndEnd.getEndTime());
|
|
|
+ }
|
|
|
return baseMapper.updateById(plan);
|
|
|
}
|
|
|
|
|
|
@@ -625,98 +718,99 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
@Override
|
|
|
public int updateTMonitoringRetrievalPlan(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectComplete(tMonitoringRetrievalPlan.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(coreMonitoringRetrievalTasks)) {
|
|
|
- throw new ServiceException("下发任务已做完,不能修改");
|
|
|
- }
|
|
|
- // iCoreMonitoringRetrievalTaskService.updateDeleteTaskByPlanId(tMonitoringRetrievalPlan.getId(), 1);
|
|
|
- iCoreMonitoringRetrievalTaskService.deleteTaskByPlanId(tMonitoringRetrievalPlan.getId());
|
|
|
+ //如果计划下面的任务都是没完成就删除所有任务,有完成就只修改
|
|
|
tMonitoringRetrievalPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
tMonitoringRetrievalPlan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
TMonitoringRetrievalPlan plan = baseMapper.selectById(tMonitoringRetrievalPlan.getId());
|
|
|
BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
plan.setIsDistribute("0");
|
|
|
int i = tMonitoringRetrievalPlanMapper.updateById(plan);
|
|
|
- try {
|
|
|
- QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
- queryWrapper.eq("parent_id", plan.getId());
|
|
|
- baseMapper.delete(queryWrapper);
|
|
|
- SysOrg sysOrg1 = remoteOrgService.selectSysOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);
|
|
|
- List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = new ArrayList<>();
|
|
|
- if (sysOrg1.getType() == 1) {
|
|
|
- distribute(plan.getId());
|
|
|
- } else {
|
|
|
- SysOrg sysOrg = new SysOrg();
|
|
|
- sysOrg.setPath(plan.getOrgPath());
|
|
|
- sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
- List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
- for (SysOrg s : sysOrgs) {
|
|
|
- TMonitoringRetrievalPlan plan1 = new TMonitoringRetrievalPlan();
|
|
|
- BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan1);
|
|
|
- plan1.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
- plan1.setOrgId(s.getId());
|
|
|
- plan1.setOrgName(s.getShortName());
|
|
|
- plan1.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
- plan1.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
- plan1.setOrgPath(s.getPath());
|
|
|
- plan1.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
- plan1.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
- plan1.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
- plan1.setPlanStatus(ZERO);
|
|
|
- plan1.setCreateBy(SecurityUtils.getUsername());
|
|
|
- plan1.setUpdateTime(DateUtils.getNowDate());
|
|
|
- plan1.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- plan1.setCreateTime(DateUtils.getNowDate());
|
|
|
- plan1.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
- plan1.setCreateType(1);
|
|
|
- plan1.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
- plan1.setIsDistribute("1");
|
|
|
- if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
- tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
- plan1.setStartTime(new Date());
|
|
|
- int amount = 0;
|
|
|
- LocalDate lastDayOfMonth;
|
|
|
- switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
- case "1":
|
|
|
- amount = 1;
|
|
|
- break;
|
|
|
- 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;
|
|
|
+ if (CollectionUtils.isEmpty(coreMonitoringRetrievalTasks)) {
|
|
|
+ iCoreMonitoringRetrievalTaskService.deleteTaskByPlanId(tMonitoringRetrievalPlan.getId());
|
|
|
+ try {
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("parent_id", plan.getId());
|
|
|
+ baseMapper.delete(queryWrapper);
|
|
|
+ SysOrg sysOrg1 = remoteOrgService.selectSysOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);
|
|
|
+ List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = new ArrayList<>();
|
|
|
+ if (sysOrg1.getType() == 1) {
|
|
|
+ distribute(plan.getId());
|
|
|
+ } else {
|
|
|
+ SysOrg sysOrg = new SysOrg();
|
|
|
+ sysOrg.setPath(plan.getOrgPath());
|
|
|
+ sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
+ List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
+ for (SysOrg s : sysOrgs) {
|
|
|
+ TMonitoringRetrievalPlan plan1 = new TMonitoringRetrievalPlan();
|
|
|
+ BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan1);
|
|
|
+ plan1.setPlanName(tMonitoringRetrievalPlan.getPlanName());
|
|
|
+ plan1.setOrgId(s.getId());
|
|
|
+ plan1.setOrgName(s.getShortName());
|
|
|
+ plan1.setRoleId(tMonitoringRetrievalPlan.getRoleId());
|
|
|
+ plan1.setRoleName(tMonitoringRetrievalPlan.getRoleName());
|
|
|
+ plan1.setOrgPath(s.getPath());
|
|
|
+ plan1.setOrgType(tMonitoringRetrievalPlan.getOrgType());
|
|
|
+ plan1.setPlanCycle(tMonitoringRetrievalPlan.getPlanCycle());
|
|
|
+ plan1.setPlanFrequency(tMonitoringRetrievalPlan.getPlanFrequency());
|
|
|
+ plan1.setPlanStatus(ZERO);
|
|
|
+ plan1.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ plan1.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ plan1.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ plan1.setCreateTime(DateUtils.getNowDate());
|
|
|
+ plan1.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
+ plan1.setCreateType(1);
|
|
|
+ plan1.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
+ plan1.setIsDistribute("1");
|
|
|
+ if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+ tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE)) {
|
|
|
+ plan1.setStartTime(new Date());
|
|
|
+ int amount = 0;
|
|
|
+ LocalDate lastDayOfMonth;
|
|
|
+ switch (tMonitoringRetrievalPlan.getPlanCycle()) {
|
|
|
+ case "1":
|
|
|
+ amount = 1;
|
|
|
+ break;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(new Date());
|
|
|
+ cal.add(Calendar.DATE, amount);
|
|
|
+ Date time = cal.getTime();
|
|
|
+ plan1.setEndTime(time);
|
|
|
}
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(new Date());
|
|
|
- cal.add(Calendar.DATE, amount);
|
|
|
- Date time = cal.getTime();
|
|
|
- plan1.setEndTime(time);
|
|
|
+ tMonitoringRetrievalPlans.add(plan1);
|
|
|
}
|
|
|
- tMonitoringRetrievalPlans.add(plan1);
|
|
|
- }
|
|
|
- if ((tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE) || tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString())) && CollectionUtils.isNotEmpty(tMonitoringRetrievalPlans)) {
|
|
|
- try {
|
|
|
- iCoreMonitoringRetrievalTaskService.noCycleTask(tMonitoringRetrievalPlans);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new ServiceException("下发任务异常,请联系管理员");
|
|
|
+ if ((tMonitoringRetrievalPlan.getImmediately().equals(Boolean.TRUE) || tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString())) && CollectionUtils.isNotEmpty(tMonitoringRetrievalPlans)) {
|
|
|
+ try {
|
|
|
+ iCoreMonitoringRetrievalTaskService.noCycleTask(tMonitoringRetrievalPlans);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("下发任务异常,请联系管理员");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
- e.getMessage();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
@@ -736,18 +830,10 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
TMonitoringRetrievalPlan monitoringRetrievalPlan = tMonitoringRetrievalPlanMapper.selectById(id);
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectComplete(id);
|
|
|
if (CollectionUtils.isNotEmpty(coreMonitoringRetrievalTasks)) {
|
|
|
- throw new ServiceException("下发任务已做完,不能删除");
|
|
|
+ throw new ServiceException("计划有已完成或者已逾期的任务,不能被删除。");
|
|
|
}
|
|
|
- //如果是下发的任务
|
|
|
- /* if (monitoringRetrievalPlan.getParentId() != null) {
|
|
|
- //不能删除
|
|
|
- throw new ServiceException("子任务,不能删除");
|
|
|
- } else {*/
|
|
|
- // if (monitoringRetrievalPlan.getCreateType() == 0) {
|
|
|
i = tMonitoringRetrievalPlanMapper.updatePlan(monitoringRetrievalPlan);
|
|
|
iCoreMonitoringRetrievalTaskService.deleteWaitTaskByPlanId(id);
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
return i;
|
|
|
}
|