|
|
@@ -38,7 +38,12 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+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.stream.Collectors;
|
|
|
@@ -81,7 +86,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
}
|
|
|
//查询条件
|
|
|
String planName = tMonitoringRetrievalPlan.getPlanName();
|
|
|
- // tMonitoringRetrievalPlan.setPlanName(null);
|
|
|
+ // tMonitoringRetrievalPlan.setPlanName(null);
|
|
|
|
|
|
QueryWrapper<TMonitoringRetrievalPlan> query = new QueryWrapper<>(tMonitoringRetrievalPlan);
|
|
|
//下穿
|
|
|
@@ -107,18 +112,6 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
//获取数据
|
|
|
|
|
|
page = tMonitoringRetrievalPlanMapper.selectPageList(page, tMonitoringRetrievalPlan);
|
|
|
- /* List<TMonitoringRetrievalPlan> records = page.getRecords();
|
|
|
- List<TMonitoringRetrievalPlanVO>tMonitoringRetrievalPlanVOS = null;
|
|
|
- SysOrg sysOrg = remoteOrgService.selectSysOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);*/
|
|
|
- /* for (TMonitoringRetrievalPlan r:records){
|
|
|
- TMonitoringRetrievalPlanVO tMonitoringRetrievalPlanVO=new TMonitoringRetrievalPlanVO();
|
|
|
- BeanUtils.copyProperties(r,tMonitoringRetrievalPlanVO);
|
|
|
- if (r.getOrgId().equals(sysOrg.getId())||r.getParentId().equals(sysOrg.getId())){
|
|
|
- tMonitoringRetrievalPlanVO.setIsEdit(Boolean.TRUE);
|
|
|
- }
|
|
|
- tMonitoringRetrievalPlanVOS.add(tMonitoringRetrievalPlanVO);
|
|
|
- }*/
|
|
|
- // page.setRecords(tMonitoringRetrievalPlanVOS);
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
|
|
|
@@ -134,11 +127,8 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
TMonitoringRetrievalPlanVO tMonitoringRetrievalPlanVO = new TMonitoringRetrievalPlanVO();
|
|
|
TMonitoringRetrievalPlan plan = tMonitoringRetrievalPlanMapper.selectById(id);
|
|
|
BeanUtils.copyProperties(plan, tMonitoringRetrievalPlanVO);
|
|
|
- //1:
|
|
|
- SysOrg sysOrg = remoteOrgService.selectSysOrgById(plan.getOrgId(), SecurityConstants.INNER);
|
|
|
- SysOrg sysOrg1 = remoteOrgService.selectSysOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);
|
|
|
boolean isEdit = false;
|
|
|
- if (plan.getParentId()!=null) {
|
|
|
+ if (plan.getParentId() != null) {
|
|
|
isEdit = true;
|
|
|
}
|
|
|
tMonitoringRetrievalPlanVO.setIsEdit(isEdit);
|
|
|
@@ -147,7 +137,7 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public int distribute(Long id) {
|
|
|
+ public int distribute(Long id) throws ParseException {
|
|
|
//查询
|
|
|
TMonitoringRetrievalPlan tMonitoringRetrievalPlan = tMonitoringRetrievalPlanMapper.selectById(id);
|
|
|
tMonitoringRetrievalPlan.setIsDistribute("1");
|
|
|
@@ -211,14 +201,45 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
plan.setCreateTime(DateUtils.getNowDate());
|
|
|
plan.setDescription(tMonitoringRetrievalPlan.getDescription());
|
|
|
plan.setCreateType(1);
|
|
|
- plan.setId(tMonitoringRetrievalPlan.getId());
|
|
|
+ // plan.setId(tMonitoringRetrievalPlan.getId());
|
|
|
plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
plan.setIsDistribute("1");
|
|
|
- // i = tMonitoringRetrievalPlanMapper.insert(plan);
|
|
|
+ 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.getPlanCycle().equals(ZERO.toString()) && CollectionUtils.isNotEmpty(tMonitoringRetrievalPlans)) {
|
|
|
+ if ((tMonitoringRetrievalPlan.getImmediately().equals("1") || tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString())) && CollectionUtils.isNotEmpty(tMonitoringRetrievalPlans)) {
|
|
|
try {
|
|
|
iCoreMonitoringRetrievalTaskService.noCycleTask(tMonitoringRetrievalPlans);
|
|
|
} catch (Exception e) {
|
|
|
@@ -228,6 +249,26 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
+ private int getDayNum(int monthsToAdd) {
|
|
|
+ LocalDate lastDayOfMonth;
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ LocalDate nextMonthFirstDay = null;
|
|
|
+ nextMonthFirstDay = localDate.plusMonths(monthsToAdd).withDayOfMonth(1);
|
|
|
+ lastDayOfMonth = nextMonthFirstDay.minusDays(1);
|
|
|
+ int dayNum = 0;
|
|
|
+ try {
|
|
|
+ Date d1 = sdf.parse(lastDayOfMonth.toString());
|
|
|
+ Date d2 = sdf.parse(localDate.toString());
|
|
|
+ long date_interval = Math.abs(d1.getTime() - d2.getTime());//绝对值
|
|
|
+ long day = 1000 * 24 * 60 * 60;//1000*24*60*60毫秒是一天
|
|
|
+ dayNum = new Long(date_interval / day).intValue();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ }
|
|
|
+ return dayNum;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询监控调阅计划列表
|
|
|
*
|