|
|
@@ -113,8 +113,9 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
//获取数据
|
|
|
|
|
|
page = tMonitoringRetrievalPlanMapper.selectPageList(page, tMonitoringRetrievalPlan);
|
|
|
- page.getRecords().forEach(p->{
|
|
|
- boolean isComplete = this.getIsComplete(p.getId());p.setIsComplete(isComplete);
|
|
|
+ page.getRecords().forEach(p -> {
|
|
|
+ boolean isComplete = this.getIsComplete(p.getId());
|
|
|
+ p.setIsComplete(isComplete);
|
|
|
});
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
@@ -136,25 +137,29 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
TMonitoringRetrievalPlan plan1 = tMonitoringRetrievalPlanMapper.selectById(plan.getParentId());
|
|
|
tMonitoringRetrievalPlanVO.setParentFrequency(plan1.getPlanFrequency());
|
|
|
}
|
|
|
- QueryWrapper queryWrapper=new QueryWrapper();
|
|
|
- queryWrapper.eq("is_deleted",0);
|
|
|
- queryWrapper.eq("parent_id",id);
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("is_deleted", 0);
|
|
|
+ queryWrapper.eq("parent_id", id);
|
|
|
List<TMonitoringRetrievalPlan> list = tMonitoringRetrievalPlanMapper.selectList(queryWrapper);
|
|
|
list.add(plan);
|
|
|
List<Long> collect = list.stream().map(TMonitoringRetrievalPlan::getId).collect(Collectors.toList());
|
|
|
boolean isEdit = false;
|
|
|
- boolean isComplete = false;
|
|
|
+ boolean isComplete = true;
|
|
|
if (plan.getParentId() != null) {
|
|
|
isEdit = true;
|
|
|
}
|
|
|
tMonitoringRetrievalPlanVO.setIsEdit(isEdit);
|
|
|
- List<String>status=new ArrayList<>();
|
|
|
+ List<String> status = new ArrayList<>();
|
|
|
status.add("2");
|
|
|
- status.add("3");
|
|
|
+ // status.add("3");
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(collect, status);
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(coreMonitoringRetrievalTasks) && plan.getParentId() == null) {
|
|
|
- isComplete = true;
|
|
|
+ if (CollectionUtils.isNotEmpty(coreMonitoringRetrievalTasks)) {
|
|
|
+ isComplete = false;
|
|
|
+ }
|
|
|
+ if (plan.getPlanStatus()==0){
|
|
|
+ isEdit=false;
|
|
|
+ isComplete=false;
|
|
|
}
|
|
|
tMonitoringRetrievalPlanVO.setIsComplete(isComplete);
|
|
|
return tMonitoringRetrievalPlanVO;
|
|
|
@@ -162,7 +167,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public int distribute(Long id,Boolean immediateEffect) throws ParseException {
|
|
|
+ public int distribute(Long id, Boolean immediateEffect) throws ParseException {
|
|
|
//查询
|
|
|
TMonitoringRetrievalPlan tMonitoringRetrievalPlan = tMonitoringRetrievalPlanMapper.selectById(id);
|
|
|
tMonitoringRetrievalPlan.setImmediately(immediateEffect);
|
|
|
@@ -495,51 +500,64 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
@Override
|
|
|
public int withdraw(Long id) {
|
|
|
+
|
|
|
TMonitoringRetrievalPlan plan = baseMapper.selectById(id);
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq(PARENT_ID, id);
|
|
|
List<TMonitoringRetrievalPlan> list1 = tMonitoringRetrievalPlanMapper.selectList(queryWrapper);
|
|
|
List<Long> collect = new ArrayList<>();
|
|
|
+ plan.setPlanStatus(2);
|
|
|
+ plan.setIsDistribute("0");
|
|
|
//如果有子计划
|
|
|
if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
collect = list1.stream().map(TMonitoringRetrievalPlan::getId).collect(Collectors.toList());
|
|
|
- List<String>status=new ArrayList<>();
|
|
|
+ List<String> status = new ArrayList<>();
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(collect, null);
|
|
|
status.add("0");
|
|
|
status.add("1");
|
|
|
status.add("3");
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks1 = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(collect, status);
|
|
|
- Boolean isComplete=false;
|
|
|
- if (coreMonitoringRetrievalTasks.size()==coreMonitoringRetrievalTasks1.size()){
|
|
|
- isComplete=true;
|
|
|
+ Boolean isComplete = false;
|
|
|
+ if (coreMonitoringRetrievalTasks.size() == coreMonitoringRetrievalTasks1.size()) {
|
|
|
+ isComplete = true;
|
|
|
}
|
|
|
- //无周期删除所有任务
|
|
|
- if (plan.getPlanCycle().equals("0")) {
|
|
|
+ //如果全是未完成,删除任务删除子计划
|
|
|
+ if (isComplete) {
|
|
|
+ plan.setPlanStatus(0);
|
|
|
coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(collect);
|
|
|
}
|
|
|
- for (TMonitoringRetrievalPlan tMonitoringRetrievalPlan : list1) {
|
|
|
- tMonitoringRetrievalPlan.setPlanStatus(2);
|
|
|
- tMonitoringRetrievalPlan.setIsDistribute("0");
|
|
|
- baseMapper.updateById(tMonitoringRetrievalPlan);
|
|
|
- //删除所有的任务,现在删除本周期的任务
|
|
|
- if (plan.getPlanCycle().equals("0")) {
|
|
|
- //如果无周期删除计划
|
|
|
- baseMapper.deleteById(tMonitoringRetrievalPlan.getId());
|
|
|
+ //无周期删除所有任务
|
|
|
+ /* if (plan.getPlanCycle().equals("0")) {
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(collect);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ for (TMonitoringRetrievalPlan tMonitoringRetrievalPlan : list1) {
|
|
|
+ if (!isComplete){
|
|
|
+ tMonitoringRetrievalPlan.setPlanStatus(2);
|
|
|
+ }
|
|
|
+ tMonitoringRetrievalPlan.setIsDistribute("0");
|
|
|
+ baseMapper.updateById(tMonitoringRetrievalPlan);
|
|
|
+ //如果是无周期和全是未完成,删除计划
|
|
|
+ if (plan.getPlanCycle().equals("0")||isComplete) {
|
|
|
+ baseMapper.deleteById(tMonitoringRetrievalPlan.getId());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
if (!plan.getPlanCycle().equals("0")) {
|
|
|
switch (plan.getPlanCycle()) {
|
|
|
//天
|
|
|
case "1":
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
- if (isComplete){
|
|
|
+ //不存在已完成,有已完成不删
|
|
|
+ if (isComplete) {
|
|
|
coreMonitoringRetrievalTaskBuilderService.deleteDayTaskByPlanId(plan.getId(), plan.getPlanCycle(), null);
|
|
|
+ plan.setPlanStatus(0);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
- // startAndEnd = DateUtils.getStartAndEnd(new Date(), Integer.valueOf(plan.getPlanCycle()) + 1);
|
|
|
- if (isComplete){
|
|
|
- coreMonitoringRetrievalTaskBuilderService.deleteDayTaskByTime(plan.getId(), plan.getPlanCycle(),null,null);
|
|
|
+ if (isComplete) {
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteDayTaskByTime(plan.getId(), plan.getPlanCycle(), null, null);
|
|
|
+ plan.setPlanStatus(0);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -548,20 +566,19 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
collect.add(id);
|
|
|
coreMonitoringRetrievalTaskBuilderService.deleteAllTaskByPlanIds(collect);
|
|
|
}
|
|
|
- plan.setPlanStatus(2);
|
|
|
- plan.setIsDistribute("0");
|
|
|
- List<String>status=new ArrayList<>();
|
|
|
- List<Long>ids=new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> status = new ArrayList<>();
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
ids.add(id);
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(ids, null);
|
|
|
status.add("0");
|
|
|
status.add("1");
|
|
|
status.add("3");
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks1 = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(ids, status);
|
|
|
- if (!plan.getPlanCycle().equals("0")) {
|
|
|
- // startAndEnd = DateUtils.getStartAndEnd(new Date(), Integer.valueOf(plan.getPlanCycle()) + 1);
|
|
|
- if (coreMonitoringRetrievalTasks.size()==coreMonitoringRetrievalTasks1.size()){
|
|
|
- coreMonitoringRetrievalTaskBuilderService.deleteDayTaskByTimeAndPlanId(id, plan.getPlanCycle(),null,null);
|
|
|
+ //原来只是非无周期,现在所有
|
|
|
+ if (plan.getPlanCycle().equals("0")) {
|
|
|
+ if (coreMonitoringRetrievalTasks.size() == coreMonitoringRetrievalTasks1.size()) {
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteDayTaskByTimeAndPlanId(id, plan.getPlanCycle(), null, null);
|
|
|
}
|
|
|
}
|
|
|
plan.setImmediately(false);
|
|
|
@@ -577,29 +594,29 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
List<TMonitoringRetrievalPlan> list1 = tMonitoringRetrievalPlanMapper.selectList(queryWrapper);
|
|
|
List<Long> collect = new ArrayList<>();
|
|
|
//如果有子计划
|
|
|
- Boolean isComplete=false;
|
|
|
+ Boolean isComplete = false;
|
|
|
if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
collect = list1.stream().map(TMonitoringRetrievalPlan::getId).collect(Collectors.toList());
|
|
|
- List<String>status=new ArrayList<>();
|
|
|
+ List<String> status = new ArrayList<>();
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(collect, null);
|
|
|
status.add("0");
|
|
|
status.add("1");
|
|
|
status.add("3");
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks1 = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(collect, status);
|
|
|
- if (coreMonitoringRetrievalTasks.size()==coreMonitoringRetrievalTasks1.size()){
|
|
|
- isComplete=true;
|
|
|
+ if (coreMonitoringRetrievalTasks.size() == coreMonitoringRetrievalTasks1.size()) {
|
|
|
+ isComplete = true;
|
|
|
}
|
|
|
- }else {
|
|
|
- List<String>status=new ArrayList<>();
|
|
|
- List<Long>ids=new ArrayList<>();
|
|
|
+ } else {
|
|
|
+ List<String> status = new ArrayList<>();
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
ids.add(id);
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(ids, null);
|
|
|
status.add("0");
|
|
|
status.add("1");
|
|
|
status.add("3");
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks1 = iCoreMonitoringRetrievalTaskService.selectAllTaskByPlanId(ids, status);
|
|
|
- if (coreMonitoringRetrievalTasks.size()==coreMonitoringRetrievalTasks1.size()){
|
|
|
- isComplete=true;
|
|
|
+ if (coreMonitoringRetrievalTasks.size() == coreMonitoringRetrievalTasks1.size()) {
|
|
|
+ isComplete = true;
|
|
|
}
|
|
|
}
|
|
|
return isComplete;
|
|
|
@@ -688,8 +705,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
public int updateTMonitoringRetrievalPlan(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
|
|
|
List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectComplete(tMonitoringRetrievalPlan.getId());
|
|
|
//如果计划下面的任务都是没完成就删除所有任务,有完成就只修改
|
|
|
-// tMonitoringRetrievalPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
-// tMonitoringRetrievalPlan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+//
|
|
|
TMonitoringRetrievalPlan plan = baseMapper.selectById(tMonitoringRetrievalPlan.getId());
|
|
|
BeanUtils.copyProperties(tMonitoringRetrievalPlan, plan);
|
|
|
SysRole sysRole = remoteRoleService.getRoleById(tMonitoringRetrievalPlan.getRoleId(), SecurityConstants.INNER);
|
|
|
@@ -704,7 +720,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
SysOrg sysOrg1 = remoteOrgService.selectSysOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);
|
|
|
List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = new ArrayList<>();
|
|
|
if (sysOrg1.getType() == 1 && plan.getIsDistribute().equals("1")) {
|
|
|
- distribute(plan.getId(),false);
|
|
|
+ distribute(plan.getId(), true);
|
|
|
} else {
|
|
|
SysOrg sysOrg = new SysOrg();
|
|
|
sysOrg.setPath(plan.getOrgPath());
|
|
|
@@ -797,15 +813,24 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tMonitoringRetrievalPlan.setIsDeleted(2L);
|
|
|
tMonitoringRetrievalPlan.setId(id);
|
|
|
TMonitoringRetrievalPlan monitoringRetrievalPlan = tMonitoringRetrievalPlanMapper.selectById(id);
|
|
|
- List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectComplete(id);
|
|
|
+
|
|
|
+ /* List<CoreMonitoringRetrievalTask> coreMonitoringRetrievalTasks = iCoreMonitoringRetrievalTaskService.selectComplete(id);
|
|
|
if (CollectionUtils.isNotEmpty(coreMonitoringRetrievalTasks)) {
|
|
|
throw new ServiceException("计划有已完成或者已逾期的任务,不能被删除。");
|
|
|
- }
|
|
|
+ }*/
|
|
|
i = tMonitoringRetrievalPlanMapper.updatePlan(monitoringRetrievalPlan);
|
|
|
if (i < 1) {
|
|
|
return i;
|
|
|
}
|
|
|
- coreMonitoringRetrievalTaskBuilderService.deleteWaitTaskByPlanId(id);
|
|
|
+ if ("1".equals(monitoringRetrievalPlan.getPlanCycle())) {
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteTaskByToday(id, currentDate.toString());
|
|
|
+ } else {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(new Date());
|
|
|
+ coreMonitoringRetrievalTaskBuilderService.deleteTaskByStartTime(id, format);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return i;
|
|
|
}
|