|
|
@@ -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");
|
|
|
@@ -166,59 +156,119 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
//如果顶级
|
|
|
List<TMonitoringRetrievalPlan> tMonitoringRetrievalPlans = new ArrayList<>();
|
|
|
Integer i = ZERO;
|
|
|
- if (topOrg.getType() == 1) {
|
|
|
- SysOrg org = new SysOrg();
|
|
|
- org.setType(3);
|
|
|
- org.setPath(topOrg.getPath());
|
|
|
- //查询符合的机构,需求是先把行社加入
|
|
|
- List<SysOrg> list = remoteOrgService.listByParentIdAndType(org, SecurityConstants.INNER);
|
|
|
- for (SysOrg l : list) {
|
|
|
- TMonitoringRetrievalPlan tMonitoringRetrievalPlan1 = new TMonitoringRetrievalPlan();
|
|
|
- BeanUtils.copyProperties(tMonitoringRetrievalPlan, tMonitoringRetrievalPlan1);
|
|
|
- tMonitoringRetrievalPlan1.setOrgId(l.getId());
|
|
|
- tMonitoringRetrievalPlan1.setOrgPath(l.getPath());
|
|
|
- tMonitoringRetrievalPlan1.setParentId(id);
|
|
|
- if (tMonitoringRetrievalPlan.getOrgType().equals("3")) {
|
|
|
- tMonitoringRetrievalPlan1.setIsDistribute("1");
|
|
|
+ SysOrg org = new SysOrg();
|
|
|
+ org.setType(3);
|
|
|
+ org.setPath(topOrg.getPath());
|
|
|
+ //查询符合的机构,需求是先把行社加入
|
|
|
+ List<SysOrg> list = remoteOrgService.listByParentIdAndType(org, SecurityConstants.INNER);
|
|
|
+ for (SysOrg l : list) {
|
|
|
+ TMonitoringRetrievalPlan tMonitoringRetrievalPlan1 = new TMonitoringRetrievalPlan();
|
|
|
+ BeanUtils.copyProperties(tMonitoringRetrievalPlan, tMonitoringRetrievalPlan1);
|
|
|
+ tMonitoringRetrievalPlan1.setOrgId(l.getId());
|
|
|
+ tMonitoringRetrievalPlan1.setOrgPath(l.getPath());
|
|
|
+ tMonitoringRetrievalPlan1.setParentId(id);
|
|
|
+ tMonitoringRetrievalPlan1.setIsDistribute("1");
|
|
|
+ tMonitoringRetrievalPlan1.setCreateType(1);
|
|
|
+ i = insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan1);
|
|
|
+ if (tMonitoringRetrievalPlan.getOrgType().equals("3")) {
|
|
|
+ if (!tMonitoringRetrievalPlan.getPlanCycle().equals(ZERO.toString()) &&
|
|
|
+ tMonitoringRetrievalPlan.getImmediately().equals("1")) {
|
|
|
+ tMonitoringRetrievalPlan1.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();
|
|
|
+ tMonitoringRetrievalPlan1.setEndTime(time);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
}
|
|
|
- tMonitoringRetrievalPlan1.setCreateType(1);
|
|
|
- i = insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- SysOrg sysOrg = new SysOrg();
|
|
|
- sysOrg.setPath(tMonitoringRetrievalPlan.getOrgPath());
|
|
|
- sysOrg.setType(Integer.valueOf(tMonitoringRetrievalPlan.getOrgType()));
|
|
|
- List<SysOrg> sysOrgs = remoteOrgService.listByParentIdAndType(sysOrg, SecurityConstants.INNER);
|
|
|
- tMonitoringRetrievalPlan.setIsDistribute("1");
|
|
|
- tMonitoringRetrievalPlan.setCreateType(1);
|
|
|
- tMonitoringRetrievalPlanMapper.updateById(tMonitoringRetrievalPlan);
|
|
|
- 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.setId(tMonitoringRetrievalPlan.getId());
|
|
|
- plan.setParentId(tMonitoringRetrievalPlan.getId());
|
|
|
- plan.setIsDistribute("1");
|
|
|
- // i = tMonitoringRetrievalPlanMapper.insert(plan);
|
|
|
- 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 +278,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;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询监控调阅计划列表
|
|
|
*
|
|
|
@@ -268,12 +338,15 @@ public class TMonitoringRetrievalPlanServiceImpl extends ServiceImpl<TMonitoring
|
|
|
tMonitoringRetrievalPlan.setId(id);
|
|
|
tMonitoringRetrievalPlan.setOrgPath(data.getPath());
|
|
|
SysOrg sysOrg1 = remoteOrgService.selectSysOrgById(sysUser.getOrgId(), SecurityConstants.INNER);
|
|
|
+ //如果是行社新增就没有下发的按钮
|
|
|
if (sysOrg1.getType() == 3) {
|
|
|
tMonitoringRetrievalPlan.setCreateType(1);
|
|
|
+ tMonitoringRetrievalPlan.setIsDistribute("1");
|
|
|
+
|
|
|
} else {
|
|
|
tMonitoringRetrievalPlan.setCreateType(ZERO);
|
|
|
+ tMonitoringRetrievalPlan.setIsDistribute(ZERO.toString());
|
|
|
}
|
|
|
- tMonitoringRetrievalPlan.setIsDistribute(ZERO.toString());
|
|
|
return tMonitoringRetrievalPlanMapper.insert(tMonitoringRetrievalPlan);
|
|
|
}
|
|
|
|