2018-12-25 18:22:33 +08:00
|
|
|
package com.nis.web.service.restful;
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
import com.nis.domain.restful.EventKeyProtection;
|
|
|
|
|
import com.nis.domain.restful.EventMonitorOrBlock;
|
|
|
|
|
import com.nis.util.CalendarUtils;
|
|
|
|
|
import com.nis.util.DateUtils;
|
|
|
|
|
import com.nis.web.dao.EventServiceDao;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
2018-12-26 15:26:32 +08:00
|
|
|
import java.util.Arrays;
|
2018-12-25 18:22:33 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author GouGe
|
|
|
|
|
* @data 2018/12/24 15:30
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class EventService {
|
|
|
|
|
@Autowired
|
|
|
|
|
EventServiceDao eventServiceDao;
|
|
|
|
|
|
|
|
|
|
protected final Logger logger = Logger.getLogger(SystemHomePageService.class);
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重点保障事件
|
|
|
|
|
*
|
|
|
|
|
* @param eventKeyProtection
|
|
|
|
|
* @return
|
|
|
|
|
* @throws ParseException
|
|
|
|
|
*/
|
|
|
|
|
public Page<EventKeyProtection> getEventsKeyProtection(EventKeyProtection eventKeyProtection) throws ParseException {
|
|
|
|
|
List<EventKeyProtection> list = new ArrayList();
|
|
|
|
|
Page<EventKeyProtection> page = new Page<>();
|
|
|
|
|
String searchReportStartTime = eventKeyProtection.getSearchReportStartTime();
|
|
|
|
|
String searchReportEndTime = eventKeyProtection.getSearchReportEndTime();
|
|
|
|
|
String searchTaskStartTime = eventKeyProtection.getSearchTaskStartTime();
|
|
|
|
|
String searchTaskEndTime = eventKeyProtection.getSearchTaskEndTime();
|
|
|
|
|
String taskName = eventKeyProtection.getTaskName();
|
2018-12-26 15:26:32 +08:00
|
|
|
String taskIds = eventKeyProtection.getTaskIds();
|
|
|
|
|
List<Long> longList = new ArrayList<>();
|
|
|
|
|
if (taskIds != null) {
|
|
|
|
|
String[] strarr = taskIds.split(",");
|
|
|
|
|
List<String> strings = Arrays.asList(strarr);
|
|
|
|
|
for (String str : strings) {
|
|
|
|
|
Long i = Long.parseLong(str);
|
|
|
|
|
longList.add(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eventKeyProtection.setTaskIdList(longList);
|
2018-12-25 18:22:33 +08:00
|
|
|
int countParamEmpty = 0;
|
2018-12-26 15:26:32 +08:00
|
|
|
try {
|
|
|
|
|
logger.info("开始获取重点保障事件信息,参数为{"
|
|
|
|
|
+ ((null == searchReportStartTime && !"".equals(searchReportStartTime)) ? "无" + countParamEmpty++ : format.parse(searchReportStartTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == searchReportEndTime && !"".equals(searchReportEndTime)) ? "无" + countParamEmpty++ : format.parse(searchReportEndTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == searchTaskStartTime && !"".equals(searchTaskStartTime)) ? "无" + countParamEmpty++ : format.parse(searchTaskStartTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == searchTaskEndTime && !"".equals(searchTaskEndTime)) ? "无" + countParamEmpty++ : format.parse(searchTaskEndTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == taskName && !"".equals(taskName)) ? "无" + countParamEmpty++ : taskName)
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == taskIds && !"".equals(taskIds)) ? "无" + countParamEmpty++ : taskIds) + "}");
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error("时间参数处理转换异常,{}", ex);
|
|
|
|
|
String rangeOfday = CalendarUtils.getRangeOfday(DateUtils.getDateTime());
|
|
|
|
|
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeOfday, -24 * 30);
|
|
|
|
|
eventKeyProtection = new EventKeyProtection();
|
|
|
|
|
eventKeyProtection.setSearchReportStartTime(startTemp);
|
|
|
|
|
logger.info("获取重点保障事件API请求参数转换异常,默认查询起始时间" + startTemp + "至今数据");
|
2018-12-25 18:22:33 +08:00
|
|
|
}
|
2018-12-26 15:26:32 +08:00
|
|
|
if (countParamEmpty == 6) {
|
|
|
|
|
String rangeOfday = CalendarUtils.getRangeOfday(DateUtils.getDateTime());
|
|
|
|
|
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeOfday, -24 * 30);
|
2018-12-25 18:22:33 +08:00
|
|
|
eventKeyProtection = new EventKeyProtection();
|
|
|
|
|
eventKeyProtection.setSearchReportStartTime(startTemp);
|
2018-12-26 15:26:32 +08:00
|
|
|
logger.info("获取重点保障事件API请求参数为空,默认查询起始时间" + startTemp + "至今数据");
|
2018-12-25 18:22:33 +08:00
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
list = eventServiceDao.getEventsKeyProtection(eventKeyProtection);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error("重点保障事件查询异常,{}", ex);
|
|
|
|
|
}
|
|
|
|
|
page.setList(list);
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 事件监测、封堵
|
|
|
|
|
*
|
|
|
|
|
* @param eventMonitorOrBlock
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2018-12-26 15:26:32 +08:00
|
|
|
public Page<EventMonitorOrBlock> getEventsMonitorOrBlock(EventMonitorOrBlock eventMonitorOrBlock, String logMark) {
|
2018-12-25 18:22:33 +08:00
|
|
|
List<EventMonitorOrBlock> list = new ArrayList();
|
|
|
|
|
Page<EventMonitorOrBlock> page = new Page<>();
|
|
|
|
|
String searchReportStartTime = eventMonitorOrBlock.getSearchReportStartTime();
|
|
|
|
|
String searchReportEndTime = eventMonitorOrBlock.getSearchReportEndTime();
|
|
|
|
|
String searchTaskStartTime = eventMonitorOrBlock.getSearchTaskStartTime();
|
|
|
|
|
String searchTaskEndTime = eventMonitorOrBlock.getSearchTaskEndTime();
|
|
|
|
|
String taskName = eventMonitorOrBlock.getTaskName();
|
2018-12-26 15:26:32 +08:00
|
|
|
String taskIds = eventMonitorOrBlock.getTaskIds();
|
|
|
|
|
List<Long> longList = new ArrayList<>();
|
|
|
|
|
if (taskIds != null) {
|
|
|
|
|
String[] strarr = taskIds.split(",");
|
|
|
|
|
List<String> strings = Arrays.asList(strarr);
|
|
|
|
|
for (String str : strings) {
|
|
|
|
|
Long i = Long.parseLong(str);
|
|
|
|
|
longList.add(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eventMonitorOrBlock.setTaskIdList(longList);
|
2018-12-25 18:22:33 +08:00
|
|
|
int countParamEmpty = 0;
|
|
|
|
|
if (taskName != null) {
|
|
|
|
|
eventMonitorOrBlock.setTaskName(taskName.trim());
|
|
|
|
|
}
|
2018-12-26 15:26:32 +08:00
|
|
|
try {
|
|
|
|
|
logger.info("开始获取" + logMark + ",参数为{"
|
|
|
|
|
+ ((null == searchReportStartTime && !"".equals(searchReportStartTime)) ? "无" + countParamEmpty++ : format.parse(searchReportStartTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == searchReportEndTime && !"".equals(searchReportEndTime)) ? "无" + countParamEmpty++ : format.parse(searchReportEndTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == searchTaskStartTime && !"".equals(searchTaskStartTime)) ? "无" + countParamEmpty++ : format.parse(searchTaskStartTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == searchTaskEndTime && !"".equals(searchTaskEndTime)) ? "无" + countParamEmpty++ : format.parse(searchTaskEndTime))
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == taskName && !"".equals(taskName)) ? "无" + countParamEmpty++ : taskName)
|
|
|
|
|
+ "},{"
|
|
|
|
|
+ ((null == taskIds && !"".equals(taskIds)) ? "无" + countParamEmpty++ : taskIds)+ "}");
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error("时间参数处理转换异常", ex);
|
|
|
|
|
String rangeNhourOfTime = CalendarUtils.getRangeOfhour(DateUtils.getDateTime());
|
|
|
|
|
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeNhourOfTime, -24);
|
|
|
|
|
int typeId = eventMonitorOrBlock.getReportType();
|
|
|
|
|
eventMonitorOrBlock = new EventMonitorOrBlock();
|
|
|
|
|
eventMonitorOrBlock.setSearchReportStartTime(startTemp);
|
|
|
|
|
eventMonitorOrBlock.setReportType(typeId);
|
|
|
|
|
logger.info("获取" + logMark + "API请求参数转换异常,默认查询起始时间" + startTemp + "到现在的数据");
|
2018-12-25 18:22:33 +08:00
|
|
|
}
|
2018-12-26 15:26:32 +08:00
|
|
|
if (countParamEmpty == 6) {
|
|
|
|
|
String rangeNhourOfTime = CalendarUtils.getRangeOfhour(DateUtils.getDateTime());
|
|
|
|
|
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeNhourOfTime, -24);
|
|
|
|
|
int typeId = eventMonitorOrBlock.getReportType();
|
|
|
|
|
eventMonitorOrBlock = new EventMonitorOrBlock();
|
|
|
|
|
eventMonitorOrBlock.setSearchReportStartTime(startTemp);
|
|
|
|
|
eventMonitorOrBlock.setReportType(typeId);
|
|
|
|
|
logger.info("获取" + logMark + "API请求参数为空,默认查询起始时间" + startTemp + "到现在的数据");
|
2018-12-25 18:22:33 +08:00
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
list = eventServiceDao.getEventsMonitorOrBlock(eventMonitorOrBlock);
|
|
|
|
|
} catch (Exception ex) {
|
2018-12-26 15:26:32 +08:00
|
|
|
logger.error(logMark + "查询异常", ex);
|
2018-12-25 18:22:33 +08:00
|
|
|
}
|
|
|
|
|
page.setList(list);
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
}
|