增加重点保障事件、事件封堵、监测接口
This commit is contained in:
168
src/main/java/com/nis/domain/restful/EventKeyProtection.java
Normal file
168
src/main/java/com/nis/domain/restful/EventKeyProtection.java
Normal file
@@ -0,0 +1,168 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.nis.util.JsonDateSerializer;
|
||||
import com.wordnik.swagger.annotations.ApiModel;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.httpclient.util.DateUtil;
|
||||
|
||||
/**
|
||||
* @author GouGe
|
||||
* @data 2018/12/24 15:35
|
||||
*/
|
||||
@ApiModel(value = "重点保障事件对象", description = "用来封装重点事件保障")
|
||||
public class EventKeyProtection {
|
||||
private static final long serialVersionUID = -3597060253861898787L;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "审核时间")
|
||||
private Date taskTime;
|
||||
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "统计时间")
|
||||
private Date reportTime;
|
||||
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "事件名称")
|
||||
private String taskName;
|
||||
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "事件ID")
|
||||
private long taskId;
|
||||
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "来函件数")
|
||||
private long letterNum;
|
||||
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "配置总数")
|
||||
private long configNum;
|
||||
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "监测数量")
|
||||
private long monitorNum;
|
||||
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "管控数量")
|
||||
private long controlNum;
|
||||
|
||||
private String searchReportStartTime;
|
||||
private String searchReportEndTime;
|
||||
private String searchTaskStartTime;
|
||||
private String searchTaskEndTime;
|
||||
|
||||
|
||||
@JsonSerialize(using = JsonDateSerializer.class)
|
||||
public Date getTaskTime() {
|
||||
return taskTime;
|
||||
}
|
||||
|
||||
public void setTaskTime(Date taskTime) {
|
||||
this.taskTime = taskTime;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
public long getLetterNum() {
|
||||
return letterNum;
|
||||
}
|
||||
|
||||
public void setLetterNum(long letterNum) {
|
||||
this.letterNum = letterNum;
|
||||
}
|
||||
|
||||
public long getConfigNum() {
|
||||
return configNum;
|
||||
}
|
||||
|
||||
public void setConfigNum(long configNum) {
|
||||
this.configNum = configNum;
|
||||
}
|
||||
|
||||
public long getMonitorNum() {
|
||||
return monitorNum;
|
||||
}
|
||||
|
||||
public void setMonitorNum(long monitorNum) {
|
||||
this.monitorNum = monitorNum;
|
||||
}
|
||||
|
||||
public long getControlNum() {
|
||||
return controlNum;
|
||||
}
|
||||
|
||||
public void setControlNum(long controlNum) {
|
||||
this.controlNum = controlNum;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchReportStartTime() {
|
||||
return searchReportStartTime;
|
||||
}
|
||||
|
||||
public void setSearchReportStartTime(String searchReportStartTime) {
|
||||
this.searchReportStartTime = searchReportStartTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchReportEndTime() {
|
||||
return searchReportEndTime;
|
||||
}
|
||||
|
||||
public void setSearchReportEndTime(String searchReportEndTime) {
|
||||
this.searchReportEndTime = searchReportEndTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchTaskStartTime() {
|
||||
return searchTaskStartTime;
|
||||
}
|
||||
|
||||
public void setSearchTaskStartTime(String searchTaskStartTime) {
|
||||
this.searchTaskStartTime = searchTaskStartTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchTaskEndTime() {
|
||||
return searchTaskEndTime;
|
||||
}
|
||||
|
||||
public void setSearchTaskEndTime(String searchTaskEndTime) {
|
||||
this.searchTaskEndTime = searchTaskEndTime;
|
||||
}
|
||||
|
||||
public long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
@JsonSerialize(using = JsonDateSerializer.class)
|
||||
public Date getReportTime() {
|
||||
return reportTime;
|
||||
}
|
||||
|
||||
public void setReportTime(Date reportTime) {
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventKeyProtection [taskTime=" + taskTime + ", reportTime=" + reportTime + ", taskName=" + taskName
|
||||
+ ", taskId=" + taskId + ", letterNum=" + letterNum + ", configNum=" + configNum + ", monitorNum="
|
||||
+ monitorNum + ", controlNum=" + controlNum + "]";
|
||||
}
|
||||
|
||||
}
|
||||
179
src/main/java/com/nis/domain/restful/EventMonitorOrBlock.java
Normal file
179
src/main/java/com/nis/domain/restful/EventMonitorOrBlock.java
Normal file
@@ -0,0 +1,179 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.httpclient.util.DateUtil;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.nis.util.JsonDateSerializer;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author GouGe
|
||||
* @data 2018/12/24 17:58
|
||||
*/
|
||||
public class EventMonitorOrBlock {
|
||||
private static final long serialVersionUID = -3597060253861898787L;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "审核时间")
|
||||
private Date taskTime;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "统计时间")
|
||||
private Date reportTime;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "事件名称")
|
||||
private String taskName;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "事件ID")
|
||||
private long taskId;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "ip数量")
|
||||
private long ipNum;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "http数量")
|
||||
private long httpNum;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "邮件数量")
|
||||
private long mailNum;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "视频次数")
|
||||
private long vedioNum;
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty(value = "代理次数")
|
||||
private long agentNum;
|
||||
|
||||
private String searchReportStartTime;
|
||||
private String searchReportEndTime;
|
||||
private String searchTaskStartTime;
|
||||
private String searchTaskEndTime;
|
||||
private int reportType;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public int getReportType() {
|
||||
return reportType;
|
||||
}
|
||||
|
||||
public void setReportType(int reportType) {
|
||||
this.reportType = reportType;
|
||||
}
|
||||
|
||||
@JsonSerialize(using = JsonDateSerializer.class)
|
||||
public Date getTaskTime() {
|
||||
return taskTime;
|
||||
}
|
||||
|
||||
public void setTaskTime(Date taskTime) {
|
||||
this.taskTime = taskTime;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
public long getIpNum() {
|
||||
return ipNum;
|
||||
}
|
||||
|
||||
public void setIpNum(long ipNum) {
|
||||
this.ipNum = ipNum;
|
||||
}
|
||||
|
||||
public long getHttpNum() {
|
||||
return httpNum;
|
||||
}
|
||||
|
||||
public void setHttpNum(long httpNum) {
|
||||
this.httpNum = httpNum;
|
||||
}
|
||||
|
||||
public long getMailNum() {
|
||||
return mailNum;
|
||||
}
|
||||
|
||||
public void setMailNum(long mailNum) {
|
||||
this.mailNum = mailNum;
|
||||
}
|
||||
|
||||
public long getVedioNum() {
|
||||
return vedioNum;
|
||||
}
|
||||
|
||||
public void setVedioNum(long vedioNum) {
|
||||
this.vedioNum = vedioNum;
|
||||
}
|
||||
|
||||
public long getAgentNum() {
|
||||
return agentNum;
|
||||
}
|
||||
|
||||
public void setAgentNum(long agentNum) {
|
||||
this.agentNum = agentNum;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchReportStartTime() {
|
||||
return searchReportStartTime;
|
||||
}
|
||||
|
||||
public void setSearchReportStartTime(String searchReportStartTime) {
|
||||
this.searchReportStartTime = searchReportStartTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchReportEndTime() {
|
||||
return searchReportEndTime;
|
||||
}
|
||||
|
||||
public void setSearchReportEndTime(String searchReportEndTime) {
|
||||
this.searchReportEndTime = searchReportEndTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchTaskStartTime() {
|
||||
return searchTaskStartTime;
|
||||
}
|
||||
|
||||
public void setSearchTaskStartTime(String searchTaskStartTime) {
|
||||
this.searchTaskStartTime = searchTaskStartTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchTaskEndTime() {
|
||||
return searchTaskEndTime;
|
||||
}
|
||||
|
||||
public void setSearchTaskEndTime(String searchTaskEndTime) {
|
||||
this.searchTaskEndTime = searchTaskEndTime;
|
||||
}
|
||||
|
||||
public long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
@JsonSerialize(using = JsonDateSerializer.class)
|
||||
public Date getReportTime() {
|
||||
return reportTime;
|
||||
}
|
||||
|
||||
public void setReportTime(Date reportTime) {
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventMonitorOrBlock [taskTime=" + taskTime + ", reportTime=" + reportTime + ", taskName=" + taskName
|
||||
+ ", taskId=" + taskId + ", ipNum=" + ipNum + ", httpNum=" + httpNum + ", mailNum=" + mailNum
|
||||
+ ", vedioNum=" + vedioNum + ", agentNum=" + agentNum + "]";
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* 常用日历操作辅助类
|
||||
@@ -169,4 +170,75 @@ public class CalendarUtils {
|
||||
// }
|
||||
// System.out.println(n);
|
||||
}
|
||||
/**
|
||||
* 获取time时间的前整点时间点
|
||||
* eg:2018-12-12 12:06:36 结果为:2018-12-12 00:00:00
|
||||
* 2018-12-12 00:59:36 结果为:2018-12-12 00:00:00
|
||||
*
|
||||
* @param time
|
||||
* @return 取前一个整天的时间, 如果返回为null检查输入的String类型时间格式
|
||||
*/
|
||||
public static String getRangeOfday(String time) {
|
||||
if (time == null || time.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
int length = time.length();
|
||||
int cut = 8;
|
||||
if (length <= cut) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
time = time.substring(0, length - cut);
|
||||
time = time.concat("00:00:00");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取距离time时间hour小时的时间,之前需加符号-、之后为正+
|
||||
*
|
||||
* @param time
|
||||
* @param hour
|
||||
* @return
|
||||
*/
|
||||
public static String getRangeNhourOfTime(String time, int hour) {
|
||||
if (time == null) {
|
||||
return "";
|
||||
}
|
||||
Date date = DateUtils.parseDate(time);
|
||||
GregorianCalendar gc = new GregorianCalendar();
|
||||
gc.setTime(date);
|
||||
gc.add(Calendar.HOUR, hour);
|
||||
return DateUtils.formatDateTime(gc.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取time时间的前整点时间点
|
||||
* eg:2018-12-12 12:06:36 结果为:2018-12-12 12:00:00
|
||||
* 2018-12-12 00:59:36 结果为:2018-12-12 00:00:00
|
||||
*
|
||||
* @param time
|
||||
* @return 取前一个整点的时间, 如果返回为null检查输入的String类型时间格式
|
||||
*/
|
||||
public static String getRangeOfhour(String time) {
|
||||
if (time == null || time.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
int length = time.length();
|
||||
int cut = 8;
|
||||
if (length <= cut) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
time = time.substring(0, length - 5);
|
||||
time = time.concat("00:00");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.nis.web.controller.restful;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.EventKeyProtection;
|
||||
import com.nis.domain.restful.EventMonitorOrBlock;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.controller.BaseRestController;
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import com.nis.web.service.restful.EventService;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GouGe
|
||||
* @data 2018/12/24 15:21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("${servicePath}")
|
||||
@Api(value = "EventInfoController", description = "事件封堵、监测、保障接口")
|
||||
@SuppressWarnings("all")
|
||||
public class EventInfoController extends BaseRestController {
|
||||
@Autowired
|
||||
ServicesRequestLogService servicesRequestLogService;
|
||||
|
||||
@Autowired
|
||||
EventService eventService;
|
||||
|
||||
@RequestMapping(value = "/log/v1/ntcEventKeyProtection", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "重点保障事件总览", httpMethod = "GET", notes = "获取重点保障事件信息", response = Map.class)
|
||||
public Map<String, ?> getEventKeyProtection(EventKeyProtection eventKeyProtection, HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
|
||||
|
||||
Page<EventKeyProtection> eventKeyProtectionPage = null;
|
||||
try {
|
||||
eventKeyProtectionPage = eventService.getEventsKeyProtection(eventKeyProtection);
|
||||
} catch (Exception e) {
|
||||
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
if (!(e instanceof RestServiceException)) {
|
||||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||||
"获取重点保障事件信息失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
} else {
|
||||
throw ((RestServiceException) e);
|
||||
}
|
||||
}
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取重点保障事件信息成功",
|
||||
eventKeyProtectionPage, 0);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/log/v1/ntcEventsMonitorOrBlock", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "事件监测、封堵", httpMethod = "GET", notes = "获取事件监测、封堵信息", response = Map.class)
|
||||
public Map<String, ?> getEventsMonitorOrBlock(EventMonitorOrBlock eventMonitorOrBlock, HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
|
||||
|
||||
int typeId = eventMonitorOrBlock.getReportType();
|
||||
String logMark = null;
|
||||
if(typeId == 1){
|
||||
logMark = "事件封堵";
|
||||
}else if(typeId == 2){
|
||||
logMark = "事件监测";
|
||||
}else{
|
||||
logMark = "事件类型未定义、默认查询事件封堵";
|
||||
eventMonitorOrBlock.setReportType(1);
|
||||
}
|
||||
Page<EventMonitorOrBlock> eventMonitorPage = null;
|
||||
try {
|
||||
eventMonitorPage = eventService.getEventsMonitorOrBlock(eventMonitorOrBlock,logMark);
|
||||
} catch (Exception e) {
|
||||
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
if (!(e instanceof RestServiceException)) {
|
||||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||||
"获取"+logMark+"信息失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
} else {
|
||||
throw ((RestServiceException) e);
|
||||
}
|
||||
}
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取"+logMark+"信息成功",
|
||||
eventMonitorPage, 0);
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/nis/web/dao/EventServiceDao.java
Normal file
19
src/main/java/com/nis/web/dao/EventServiceDao.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.nis.web.dao;
|
||||
|
||||
import com.nis.domain.restful.EventKeyProtection;
|
||||
import com.nis.domain.restful.EventMonitorOrBlock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author GouGe
|
||||
* @data 2018/12/24 17:00
|
||||
*/
|
||||
@MyBatisDao
|
||||
public interface EventServiceDao {
|
||||
|
||||
List<EventKeyProtection> getEventsKeyProtection(EventKeyProtection eventKeyProtection);
|
||||
|
||||
List<EventMonitorOrBlock> getEventsMonitorOrBlock(EventMonitorOrBlock eventMonitorOrBlock);
|
||||
|
||||
}
|
||||
75
src/main/java/com/nis/web/dao/EventServiceDao.xml
Normal file
75
src/main/java/com/nis/web/dao/EventServiceDao.xml
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nis.web.dao.EventServiceDao">
|
||||
<select id="getEventsKeyProtection" resultType="com.nis.domain.restful.EventKeyProtection"
|
||||
useCache="false" flushCache="true">
|
||||
|
||||
SELECT task_time as taskTime,
|
||||
report_time as reportTime,
|
||||
task_id as taskId,
|
||||
task_name as taskName,
|
||||
letter_num as letterNum,
|
||||
config_num as configNum,
|
||||
monitor_num as monitorTime,
|
||||
control_num as controlerNum
|
||||
FROM ntc_major_task_report
|
||||
<where>
|
||||
<if test="searchReportStartTime != null and searchReportStartTime !=''">
|
||||
<![CDATA[AND report_time >= #{searchReportStartTime}]]>
|
||||
</if>
|
||||
<if test="searchReportEndTime != null and searchReportEndTime !=''">
|
||||
<![CDATA[AND report_time < #{searchReportEndTime}]]>
|
||||
</if>
|
||||
<if test="searchTaskStartTime != null and searchTaskStartTime !=''">
|
||||
<![CDATA[AND task_time >= #{searchTaskStartTime}]]>
|
||||
</if>
|
||||
<if test="searchTaskEndTime != null and searchTaskEndTime !=''">
|
||||
<![CDATA[AND task_time < #{searchTaskEndTime}]]>
|
||||
</if>
|
||||
<if test="taskId != null and taskId !='' and taskId != 0">
|
||||
AND task_id = #{taskId}
|
||||
</if>
|
||||
<if test="taskName != null and taskName !=''">
|
||||
AND task_name like concat(concat('%',#{taskName}),'%')
|
||||
</if>
|
||||
</where>
|
||||
order by taskId asc;
|
||||
</select>
|
||||
<select id="getEventsMonitorOrBlock" resultType="com.nis.domain.restful.EventMonitorOrBlock"
|
||||
useCache="false" flushCache="true">
|
||||
SELECT task_time as taskTime,
|
||||
report_time as reportTime,
|
||||
task_id as taskId,
|
||||
task_name as taskName,
|
||||
ip_num as ipNum,
|
||||
http_num as httpNum,
|
||||
mail_num as mailNum,
|
||||
vedio_num as vedioNum,
|
||||
agent_num as agentNum
|
||||
FROM ntc_task_report
|
||||
<where>
|
||||
<if test="searchReportStartTime != null and searchReportStartTime !=''">
|
||||
<![CDATA[AND report_time >= #{searchReportStartTime}]]>
|
||||
</if>
|
||||
<if test="searchReportEndTime != null and searchReportEndTime !=''">
|
||||
<![CDATA[AND report_time < #{searchReportEndTime}]]>
|
||||
</if>
|
||||
<if test="searchTaskStartTime != null and searchTaskStartTime !=''">
|
||||
<![CDATA[AND task_time >= #{searchTaskStartTime}]]>
|
||||
</if>
|
||||
<if test="searchTaskEndTime != null and searchTaskEndTime !=''">
|
||||
<![CDATA[AND task_time < #{searchTaskEndTime}]]>
|
||||
</if>
|
||||
<if test="taskId != null and taskId !='' and taskId != 0">
|
||||
AND task_id = #{taskId}
|
||||
</if>
|
||||
<if test="reportType != null and reportType !=''">
|
||||
AND report_type = #{reportType}
|
||||
</if>
|
||||
<if test="taskName != null and taskName !=''">
|
||||
AND task_name like concat(concat('%',#{taskName}),'%')
|
||||
</if>
|
||||
</where>
|
||||
order by taskId asc;
|
||||
</select>
|
||||
</mapper>
|
||||
144
src/main/java/com/nis/web/service/restful/EventService.java
Normal file
144
src/main/java/com/nis/web/service/restful/EventService.java
Normal file
@@ -0,0 +1,144 @@
|
||||
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;
|
||||
import java.util.Date;
|
||||
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();
|
||||
long taskId = eventKeyProtection.getTaskId();
|
||||
int countParamEmpty = 0;
|
||||
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 == String.valueOf(taskId) && !"".equals(String.valueOf(taskId))) ? "无"+countParamEmpty++ : (long)taskId));
|
||||
}catch(Exception ex){
|
||||
logger.error("时间参数处理转换异常,{}", ex);
|
||||
String rangeOfday = CalendarUtils.getRangeOfday(DateUtils.getDateTime());
|
||||
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeOfday, -24);
|
||||
eventKeyProtection = new EventKeyProtection();
|
||||
eventKeyProtection.setSearchReportStartTime(startTemp);
|
||||
logger.info("获取重点保障事件API请求参数转换异常,默认查询昨天"+startTemp+"至今数据");
|
||||
}
|
||||
if(countParamEmpty == 6){
|
||||
String rangeOfday = CalendarUtils.getRangeOfday(DateUtils.getDateTime());
|
||||
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeOfday, -24);
|
||||
eventKeyProtection = new EventKeyProtection();
|
||||
eventKeyProtection.setSearchReportStartTime(startTemp);
|
||||
logger.info("获取重点保障事件API请求参数为空,默认查询昨天"+startTemp+"至今数据");
|
||||
}
|
||||
try {
|
||||
list = eventServiceDao.getEventsKeyProtection(eventKeyProtection);
|
||||
} catch (Exception ex) {
|
||||
logger.error("重点保障事件查询异常,{}", ex);
|
||||
}
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件监测、封堵
|
||||
*
|
||||
* @param eventMonitorOrBlock
|
||||
* @return
|
||||
*/
|
||||
public Page<EventMonitorOrBlock> getEventsMonitorOrBlock(EventMonitorOrBlock eventMonitorOrBlock,String logMark) {
|
||||
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();
|
||||
long taskId = eventMonitorOrBlock.getTaskId();
|
||||
int countParamEmpty = 0;
|
||||
if (taskName != null) {
|
||||
eventMonitorOrBlock.setTaskName(taskName.trim());
|
||||
}
|
||||
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 == String.valueOf(taskId) && !"".equals(String.valueOf(taskId))) ? "无"+countParamEmpty++ : (long)taskId));
|
||||
}catch(Exception ex){
|
||||
logger.error("时间参数处理转换异常,{}", ex);
|
||||
String rangeNhourOfTime = CalendarUtils.getRangeOfhour(DateUtils.getDateTime());
|
||||
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeNhourOfTime, -1);
|
||||
int typeId = eventMonitorOrBlock.getReportType();
|
||||
eventMonitorOrBlock = new EventMonitorOrBlock();
|
||||
eventMonitorOrBlock.setSearchReportStartTime(startTemp);
|
||||
eventMonitorOrBlock.setReportType(typeId);
|
||||
logger.info("获取"+logMark+"API请求参数转换异常,默认查询上一小时"+startTemp+"到现在的数据");
|
||||
}
|
||||
if(countParamEmpty==6){
|
||||
String rangeNhourOfTime = CalendarUtils.getRangeOfhour(DateUtils.getDateTime());
|
||||
String startTemp = CalendarUtils.getRangeNhourOfTime(rangeNhourOfTime, -1);
|
||||
int typeId = eventMonitorOrBlock.getReportType();
|
||||
eventMonitorOrBlock = new EventMonitorOrBlock();
|
||||
eventMonitorOrBlock.setSearchReportStartTime(startTemp);
|
||||
eventMonitorOrBlock.setReportType(typeId);
|
||||
logger.info("获取"+logMark+"API请求参数为空,默认查询上一小时"+startTemp+"到现在的数据");
|
||||
}
|
||||
try {
|
||||
list = eventServiceDao.getEventsMonitorOrBlock(eventMonitorOrBlock);
|
||||
} catch (Exception ex) {
|
||||
logger.error(logMark+"查询异常,{}", ex);
|
||||
}
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user