解决重点保障事件、事件监测、事件封堵 分页参数bug
This commit is contained in:
@@ -3,9 +3,13 @@ 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.domain.Page;
|
||||
import com.nis.util.JsonDateSerializer;
|
||||
import com.wordnik.swagger.annotations.ApiModel;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -53,6 +57,7 @@ public class EventKeyProtection {
|
||||
private String searchTaskStartTime;
|
||||
private String searchTaskEndTime;
|
||||
private List<Long> taskIdList;
|
||||
protected Page<T> page;
|
||||
|
||||
@JsonIgnore
|
||||
public List<Long> getTaskIdList() {
|
||||
@@ -165,6 +170,20 @@ public class EventKeyProtection {
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
public Page<T> getPage() {
|
||||
if (page == null) {
|
||||
page = new Page<T>();
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<T> setPage(Page<T> page) {
|
||||
this.page = page;
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventKeyProtection{" +
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.nis.domain.restful;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import org.apache.commons.httpclient.util.DateUtil;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@@ -10,6 +11,9 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.nis.util.JsonDateSerializer;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
/**
|
||||
* @author GouGe
|
||||
@@ -51,6 +55,7 @@ public class EventMonitorOrBlock {
|
||||
private String searchTaskEndTime;
|
||||
private int reportType;
|
||||
private List<Long> taskIdList;
|
||||
protected Page<T> page;
|
||||
|
||||
@JsonIgnore
|
||||
public List<Long> getTaskIdList() {
|
||||
@@ -180,6 +185,20 @@ public class EventMonitorOrBlock {
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
public Page<T> getPage() {
|
||||
if (page == null) {
|
||||
page = new Page<T>();
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<T> setPage(Page<T> page) {
|
||||
this.page = page;
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventMonitorOrBlock{" +
|
||||
|
||||
@@ -39,13 +39,20 @@ public class EventInfoController extends BaseRestController {
|
||||
|
||||
@RequestMapping(value = "/ntcEventKeyProtection", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "重点保障事件总览", httpMethod = "GET", notes = "获取重点保障事件信息", response = Map.class)
|
||||
public Map<String, ?> getEventKeyProtection(EventKeyProtection eventKeyProtection, HttpServletRequest request, HttpServletResponse response) {
|
||||
public Map<String, ?> getEventKeyProtection(Page page, EventKeyProtection eventKeyProtection, HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
|
||||
|
||||
Page<EventKeyProtection> eventKeyProtectionPage = null;
|
||||
Page<?> reportPage = null;
|
||||
try {
|
||||
eventKeyProtectionPage = eventService.getEventsKeyProtection(eventKeyProtection);
|
||||
String orderBy = "";
|
||||
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
|
||||
orderBy = Page.getOrderBySql(EventKeyProtection.class.getSimpleName(), page.getOrderBy());
|
||||
} else {
|
||||
orderBy = "report_time";
|
||||
}
|
||||
page.setOrderBy(orderBy);
|
||||
reportPage = eventService.getEventsKeyProtection(
|
||||
new Page<EventKeyProtection>(request, response, EventKeyProtection.class), eventKeyProtection);
|
||||
} catch (Exception e) {
|
||||
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
e.printStackTrace();
|
||||
@@ -58,40 +65,47 @@ public class EventInfoController extends BaseRestController {
|
||||
}
|
||||
}
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取重点保障事件信息成功",
|
||||
eventKeyProtectionPage, 0);
|
||||
reportPage, 0);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ntcEventsMonitorOrBlock", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "事件监测、封堵", httpMethod = "GET", notes = "获取事件监测、封堵信息", response = Map.class)
|
||||
public Map<String, ?> getEventsMonitorOrBlock(EventMonitorOrBlock eventMonitorOrBlock, HttpServletRequest request, HttpServletResponse response) {
|
||||
public Map<String, ?> getEventsMonitorOrBlock(Page page,EventMonitorOrBlock eventMonitorOrBlock, HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
|
||||
|
||||
Page<?> reportPage = null;
|
||||
int typeId = eventMonitorOrBlock.getReportType();
|
||||
String logMark = null;
|
||||
if(typeId == 1){
|
||||
logMark = "事件封堵";
|
||||
}else if(typeId == 2){
|
||||
logMark = "事件监测";
|
||||
}else{
|
||||
logMark = "事件类型未定义、默认查询事件封堵";
|
||||
eventMonitorOrBlock.setReportType(1);
|
||||
if (typeId == 1) {
|
||||
logMark = "事件封堵";
|
||||
} else if (typeId == 2) {
|
||||
logMark = "事件监测";
|
||||
} else {
|
||||
logMark = "事件类型未定义、默认查询事件封堵";
|
||||
eventMonitorOrBlock.setReportType(1);
|
||||
}
|
||||
Page<EventMonitorOrBlock> eventMonitorPage = null;
|
||||
try {
|
||||
eventMonitorPage = eventService.getEventsMonitorOrBlock(eventMonitorOrBlock,logMark);
|
||||
String orderBy = "";
|
||||
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
|
||||
orderBy = Page.getOrderBySql(EventKeyProtection.class.getSimpleName(), page.getOrderBy());
|
||||
} else {
|
||||
orderBy = "report_time";
|
||||
}
|
||||
page.setOrderBy(orderBy);
|
||||
reportPage = eventService.getEventsMonitorOrBlock(new Page<EventKeyProtection>(request, response, EventMonitorOrBlock.class), 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());
|
||||
"获取" + logMark + "信息失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
} else {
|
||||
throw ((RestServiceException) e);
|
||||
}
|
||||
}
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取"+logMark+"信息成功",
|
||||
eventMonitorPage, 0);
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取" + logMark + "信息成功",
|
||||
reportPage, 0);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
AND task_name like concat(concat('%',#{taskName}),'%')
|
||||
</if>
|
||||
</where>
|
||||
order by reportTime desc;
|
||||
order by reportTime desc
|
||||
</select>
|
||||
<select id="getEventsMonitorOrBlock" resultType="com.nis.domain.restful.EventMonitorOrBlock"
|
||||
useCache="false" flushCache="true">
|
||||
@@ -76,6 +76,6 @@
|
||||
AND task_name like concat(concat('%',#{taskName}),'%')
|
||||
</if>
|
||||
</where>
|
||||
order by reportTime desc;
|
||||
order by reportTime desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -35,9 +35,8 @@ public class EventService {
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public Page<EventKeyProtection> getEventsKeyProtection(EventKeyProtection eventKeyProtection) throws ParseException {
|
||||
public Page<EventKeyProtection> getEventsKeyProtection(Page page, 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();
|
||||
@@ -84,9 +83,10 @@ public class EventService {
|
||||
logger.info("获取重点保障事件API请求参数为空,默认查询起始时间" + startTemp + "至今数据");
|
||||
}
|
||||
try {
|
||||
eventKeyProtection.setPage(page);
|
||||
list = eventServiceDao.getEventsKeyProtection(eventKeyProtection);
|
||||
} catch (Exception ex) {
|
||||
logger.error("重点保障事件查询异常,{}", ex);
|
||||
logger.error("重点保障事件查询异常", ex);
|
||||
}
|
||||
page.setList(list);
|
||||
return page;
|
||||
@@ -98,9 +98,8 @@ public class EventService {
|
||||
* @param eventMonitorOrBlock
|
||||
* @return
|
||||
*/
|
||||
public Page<EventMonitorOrBlock> getEventsMonitorOrBlock(EventMonitorOrBlock eventMonitorOrBlock, String logMark) {
|
||||
public Page<EventMonitorOrBlock> getEventsMonitorOrBlock(Page page,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();
|
||||
@@ -133,7 +132,7 @@ public class EventService {
|
||||
+ "},{"
|
||||
+ ((null == taskName && !"".equals(taskName)) ? "无" + countParamEmpty++ : taskName)
|
||||
+ "},{"
|
||||
+ ((null == taskIds && !"".equals(taskIds)) ? "无" + countParamEmpty++ : taskIds)+ "}");
|
||||
+ ((null == taskIds && !"".equals(taskIds)) ? "无" + countParamEmpty++ : taskIds) + "}");
|
||||
} catch (Exception ex) {
|
||||
logger.error("时间参数处理转换异常", ex);
|
||||
String rangeNhourOfTime = CalendarUtils.getRangeOfhour(DateUtils.getDateTime());
|
||||
@@ -154,6 +153,7 @@ public class EventService {
|
||||
logger.info("获取" + logMark + "API请求参数为空,默认查询起始时间" + startTemp + "到现在的数据");
|
||||
}
|
||||
try {
|
||||
eventMonitorOrBlock.setPage(page);
|
||||
list = eventServiceDao.getEventsMonitorOrBlock(eventMonitorOrBlock);
|
||||
} catch (Exception ex) {
|
||||
logger.error(logMark + "查询异常", ex);
|
||||
|
||||
Reference in New Issue
Block a user