|
|
@@ -342,10 +342,82 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
if (sysOrg1.getType() == 3) {
|
|
|
tMonitoringRetrievalPlan.setCreateType(1);
|
|
|
tMonitoringRetrievalPlan.setIsDistribute("1");
|
|
|
-
|
|
|
+ SysOrg sysOrg = new SysOrg();
|
|
|
+ sysOrg.setPath(sysOrg1.getPath());
|
|
|
+ sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
+ List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
+ List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = new ArrayList<>();
|
|
|
+ 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("1")) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ if ((tMonitoringRetrievalPlan.getImmediately().equals("1") || tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString())) && CollectionUtils.isNotEmpty(tMonitoringRetrievalPlans)) {
|
|
|
+ try {
|
|
|
+ iCoreMonitoringRetrievalTaskService.noCycleTask(tMonitoringRetrievalPlans);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("下发任务异常,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
- tMonitoringRetrievalPlan.setCreateType(ZERO);
|
|
|
- tMonitoringRetrievalPlan.setIsDistribute(ZERO.toString());
|
|
|
+ if (tMonitoringRetrievalPlan.getCreateType() == null) {
|
|
|
+ tMonitoringRetrievalPlan.setCreateType(ZERO);
|
|
|
+ }
|
|
|
+ if (tMonitoringRetrievalPlan.getIsDistribute() == null) {
|
|
|
+ tMonitoringRetrievalPlan.setIsDistribute(ZERO.toString());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return tMonitoringRetrievalPlanMapper.insert(tMonitoringRetrievalPlan);
|
|
|
}
|
|
|
@@ -362,34 +434,23 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
if (CollectionUtils.isNotEmpty(coreMonitoringRetrievalTasks)) {
|
|
|
throw new ServiceException("下发任务已做完,不能修改");
|
|
|
}
|
|
|
- iCoreMonitoringRetrievalTaskService.updateDeleteTaskByPlanId(tMonitoringRetrievalPlan.getId(), 1);
|
|
|
+ // iCoreMonitoringRetrievalTaskService.updateDeleteTaskByPlanId(tMonitoringRetrievalPlan.getId(), 1);
|
|
|
+ iCoreMonitoringRetrievalTaskService.deleteTaskByPlanId(tMonitoringRetrievalPlan.getId());
|
|
|
tMonitoringRetrievalPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
tMonitoringRetrievalPlan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
TMonitoringRetrievalPlan plan = baseMapper.selectById(tMonitoringRetrievalPlan.getId());
|
|
|
-/* if (plan.getPlanStatus() != tMonitoringRetrievalPlan.getPlanStatus()) {
|
|
|
- if (tMonitoringRetrievalPlan.getPlanStatus() == 1) {
|
|
|
- //删除任务
|
|
|
- iCoreMonitoringRetrievalTaskService.updateDeleteTaskByPlanId(tMonitoringRetrievalPlan.getId(), 1);
|
|
|
- //禁用子任务
|
|
|
- if (null == plan.getParentId()) {
|
|
|
- baseMapper.updatePlanStatus(1, tMonitoringRetrievalPlan.getId());
|
|
|
- }
|
|
|
- } else {
|
|
|
- //还原任务
|
|
|
- iCoreMonitoringRetrievalTaskService.updateDeleteTaskByPlanId(tMonitoringRetrievalPlan.getId(), 0);
|
|
|
- if (null == plan.getParentId()) {
|
|
|
- baseMapper.updatePlanStatus(0, tMonitoringRetrievalPlan.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
- /* if (tMonitoringRetrievalPlan.getOrgType().equals("1")) {
|
|
|
- tMonitoringRetrievalPlan.setCreateType(ZERO);
|
|
|
- } else {
|
|
|
- tMonitoringRetrievalPlan.setCreateType(1);
|
|
|
- }*/
|
|
|
plan.setIsDistribute("0");
|
|
|
- return tMonitoringRetrievalPlanMapper.updateById(plan);
|
|
|
+ int i = tMonitoringRetrievalPlanMapper.updateById(plan);
|
|
|
+ try {
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("parent_id", plan.getId());
|
|
|
+ baseMapper.delete(queryWrapper);
|
|
|
+ distribute(plan.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
/**
|