1、根据库表结构设计调整回调类配置入库字段顺序;
2、APP阻断、APP监测和APP DOMAIN特征发现分发到阀门添加额外字段; 3、实现配置日志总量统计接口功能
This commit is contained in:
@@ -1,67 +1,16 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.util.JsonDateSerializer;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class NtcPzReport implements Serializable{
|
||||
public class NtcPzReport extends NtcReportEntity<NtcPzReport>{
|
||||
|
||||
private static final long serialVersionUID = 987165268916441272L;
|
||||
@ApiModelProperty(value="配置ID", required=true)
|
||||
protected Long cfgId;
|
||||
@ApiModelProperty(value="业务类型", required=true)
|
||||
protected Integer service;
|
||||
@ApiModelProperty(value="日志数量", required=true)
|
||||
protected Long sum;
|
||||
@ApiModelProperty(value="统计时间", required=true)
|
||||
protected Date reportTime;
|
||||
|
||||
/**
|
||||
* 业务类型:1:配置命中总量业务 2:配置报表业务
|
||||
*/
|
||||
protected String searchBusinessType = "1";
|
||||
protected String searchReportStartTime;
|
||||
protected String searchReportEndTime;
|
||||
protected Long searchReportStartTimeCluster;
|
||||
protected Long searchReportEndTimeCluster;
|
||||
protected String searchService;
|
||||
protected String searchCfgId;
|
||||
|
||||
protected Page<NtcPzReport> page;
|
||||
|
||||
/**
|
||||
* 自定义SQL(SQL标识,SQL内容)
|
||||
*/
|
||||
protected Map<String, String> sqlMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public NtcPzReport() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cfgId
|
||||
* @param service
|
||||
*/
|
||||
public NtcPzReport(Long cfgId, Long sum) {
|
||||
super();
|
||||
this.cfgId = cfgId;
|
||||
this.sum = sum;
|
||||
}
|
||||
|
||||
|
||||
public Long getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
@@ -70,78 +19,6 @@ public class NtcPzReport implements Serializable{
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
|
||||
public Integer getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(Integer service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public Long getSum() {
|
||||
return sum;
|
||||
}
|
||||
|
||||
public void setSum(Long sum) {
|
||||
this.sum = sum;
|
||||
}
|
||||
|
||||
@JsonSerialize(using=JsonDateSerializer.class)
|
||||
public Date getReportTime() {
|
||||
return reportTime;
|
||||
}
|
||||
|
||||
public void setReportTime(Date reportTime) {
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchBusinessType() {
|
||||
return searchBusinessType;
|
||||
}
|
||||
|
||||
public void setSearchBusinessType(String searchBusinessType) {
|
||||
this.searchBusinessType = searchBusinessType;
|
||||
}
|
||||
@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 Long getSearchReportStartTimeCluster() {
|
||||
return searchReportStartTimeCluster;
|
||||
}
|
||||
|
||||
public void setSearchReportStartTimeCluster(Long searchReportStartTimeCluster) {
|
||||
this.searchReportStartTimeCluster = searchReportStartTimeCluster;
|
||||
}
|
||||
@JsonIgnore
|
||||
public Long getSearchReportEndTimeCluster() {
|
||||
return searchReportEndTimeCluster;
|
||||
}
|
||||
|
||||
public void setSearchReportEndTimeCluster(Long searchReportEndTimeCluster) {
|
||||
this.searchReportEndTimeCluster = searchReportEndTimeCluster;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchService() {
|
||||
return searchService;
|
||||
}
|
||||
|
||||
public void setSearchService(String searchService) {
|
||||
this.searchService = searchService;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchCfgId() {
|
||||
return searchCfgId;
|
||||
@@ -150,31 +27,4 @@ public class NtcPzReport implements Serializable{
|
||||
public void setSearchCfgId(String searchCfgId) {
|
||||
this.searchCfgId = searchCfgId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
public Page<NtcPzReport> getPage() {
|
||||
if (page == null){
|
||||
page = new Page<NtcPzReport>();
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<NtcPzReport> setPage(Page<NtcPzReport> page) {
|
||||
this.page = page;
|
||||
return page;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
public Map<String, String> getSqlMap() {
|
||||
if (sqlMap == null){
|
||||
sqlMap = Maps.newHashMap();
|
||||
}
|
||||
return sqlMap;
|
||||
}
|
||||
|
||||
public void setSqlMap(Map<String, String> sqlMap) {
|
||||
this.sqlMap = sqlMap;
|
||||
}
|
||||
}
|
||||
|
||||
160
src/main/java/com/nis/domain/restful/NtcReportEntity.java
Normal file
160
src/main/java/com/nis/domain/restful/NtcReportEntity.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.util.JsonDateSerializer;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public abstract class NtcReportEntity<T> implements Serializable{
|
||||
|
||||
@ApiModelProperty(value="业务类型", required=true)
|
||||
protected Integer service;
|
||||
@ApiModelProperty(value="日志数量", required=true)
|
||||
protected Long sum;
|
||||
@ApiModelProperty(value="统计时间", required=true)
|
||||
protected Date reportTime;
|
||||
|
||||
/**
|
||||
* 业务类型:1:配置命中总量业务 2:配置报表业务
|
||||
*/
|
||||
protected String searchBusinessType = "1";
|
||||
protected String searchReportStartTime;
|
||||
protected String searchReportEndTime;
|
||||
protected Long searchReportStartTimeCluster;
|
||||
protected Long searchReportEndTimeCluster;
|
||||
protected String searchService;
|
||||
|
||||
protected Page<T> page;
|
||||
|
||||
/**
|
||||
* 自定义SQL(SQL标识,SQL内容)
|
||||
*/
|
||||
protected Map<String, String> sqlMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public NtcReportEntity() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cfgId
|
||||
* @param service
|
||||
*/
|
||||
public NtcReportEntity(Long cfgId, Long sum) {
|
||||
super();
|
||||
this.sum = sum;
|
||||
}
|
||||
|
||||
public Integer getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(Integer service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public Long getSum() {
|
||||
return sum;
|
||||
}
|
||||
|
||||
public void setSum(Long sum) {
|
||||
this.sum = sum;
|
||||
}
|
||||
|
||||
@JsonSerialize(using=JsonDateSerializer.class)
|
||||
public Date getReportTime() {
|
||||
return reportTime;
|
||||
}
|
||||
|
||||
public void setReportTime(Date reportTime) {
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchBusinessType() {
|
||||
return searchBusinessType;
|
||||
}
|
||||
|
||||
public void setSearchBusinessType(String searchBusinessType) {
|
||||
this.searchBusinessType = searchBusinessType;
|
||||
}
|
||||
@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 Long getSearchReportStartTimeCluster() {
|
||||
return searchReportStartTimeCluster;
|
||||
}
|
||||
|
||||
public void setSearchReportStartTimeCluster(Long searchReportStartTimeCluster) {
|
||||
this.searchReportStartTimeCluster = searchReportStartTimeCluster;
|
||||
}
|
||||
@JsonIgnore
|
||||
public Long getSearchReportEndTimeCluster() {
|
||||
return searchReportEndTimeCluster;
|
||||
}
|
||||
|
||||
public void setSearchReportEndTimeCluster(Long searchReportEndTimeCluster) {
|
||||
this.searchReportEndTimeCluster = searchReportEndTimeCluster;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchService() {
|
||||
return searchService;
|
||||
}
|
||||
|
||||
public void setSearchService(String searchService) {
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
public Map<String, String> getSqlMap() {
|
||||
if (sqlMap == null){
|
||||
sqlMap = Maps.newHashMap();
|
||||
}
|
||||
return sqlMap;
|
||||
}
|
||||
|
||||
public void setSqlMap(Map<String, String> sqlMap) {
|
||||
this.sqlMap = sqlMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -157,6 +157,10 @@ public final class Constants {
|
||||
*/
|
||||
public static final Long REPORT_LOCAL_TIME = Configurations.getLongProperty("reportLocalTime", 1);
|
||||
|
||||
/**
|
||||
* 实时报表统计默认时间,单位分钟
|
||||
*/
|
||||
public static final Long PZ_REPORT_TIME = Configurations.getLongProperty("pzReportTime", 5);
|
||||
/**
|
||||
* 日志是否从hive中查询
|
||||
*/
|
||||
|
||||
@@ -222,6 +222,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
return timeMap;
|
||||
}
|
||||
|
||||
//实时报表统计,默认查询最近5分钟
|
||||
if("minute".equals(type) && startTime == null && endTime == null){
|
||||
Calendar cal=Calendar.getInstance();
|
||||
timeMap.put("startTime", sdf.format(cal.getTime()));
|
||||
if(localLen != null){
|
||||
cal.add(Calendar.MINUTE, -localLen.intValue());
|
||||
}else{
|
||||
cal.add(Calendar.MINUTE, -5);
|
||||
}
|
||||
timeMap.put("endTime", sdf.format(cal.getTime()));
|
||||
logger.info("实时报表统计默认开始时间条件:"+timeMap.get("startTime"));
|
||||
logger.info("默认结束时间条件:"+timeMap.get("endTime"));
|
||||
return timeMap;
|
||||
}
|
||||
if(startTime == null && endTime == null && localLen != null){
|
||||
Calendar cal=Calendar.getInstance();
|
||||
cal.add(Calendar.HOUR, -localLen.intValue());
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.nis.domain.restful.NtcMailLog;
|
||||
import com.nis.domain.restful.NtcOpenvpnLog;
|
||||
import com.nis.domain.restful.NtcPptpLog;
|
||||
import com.nis.domain.restful.NtcPzReport;
|
||||
import com.nis.domain.restful.NtcReportEntity;
|
||||
import com.nis.domain.restful.NtcSshLog;
|
||||
import com.nis.domain.restful.NtcSslLog;
|
||||
import com.nis.restful.RestServiceException;
|
||||
@@ -43,6 +44,7 @@ import com.nis.web.service.HiveSqlService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.service.restful.LogTestService;
|
||||
import com.nis.web.service.restful.NtcReportService;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -63,6 +65,9 @@ public class LogController extends BaseRestController {
|
||||
public LogTestService testService;
|
||||
@Autowired
|
||||
protected ServicesRequestLogService servicesRequestLogService;
|
||||
|
||||
@Autowired
|
||||
protected NtcReportService ntcReportService;
|
||||
|
||||
@RequestMapping(value = "/ntcIpLogs", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "IP地址日志查询", httpMethod = "GET", notes = "对应配置为IP地址管理,存储动作为阻断与监测的命中日志。对日志功能IP地址提供数据基础查询服务")
|
||||
@@ -842,28 +847,60 @@ public class LogController extends BaseRestController {
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "DDos日志检索成功",
|
||||
ntcDdosLogPage, 0);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ntcPzReport", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "配置日志总量统计", httpMethod = "GET", notes = "配置命中日志数量实时统计报表,对外提供多种数据表现形式,具体可应用于界面配置命中总量业务、配置报表业务等")
|
||||
public Map<String, ?> ntcPzReport(Page page, NtcPzReport ntcPzReport, Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
|
||||
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
|
||||
request, null);
|
||||
|
||||
Page<?> ntcPzReportPage = null;
|
||||
try {
|
||||
ntcPzReportPage = testService.findNtcPzReport(new Page<NtcPzReport>(request, response, NtcPzReport.class),
|
||||
resetReportTime(ntcPzReport);
|
||||
//验证实时报表
|
||||
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcPzReport, NtcDdosLog.class, page);
|
||||
//验证serachCfgId
|
||||
ntcReportService.checkNumericCondition(saveLogThread,start,ntcPzReport.getSearchCfgId(),"searchCfgId");
|
||||
String orderBy = "";
|
||||
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
|
||||
orderBy = Page.getOrderBySql(NtcPzReport.class.getSimpleName(), page.getOrderBy());
|
||||
} else {
|
||||
orderBy = "report_time";
|
||||
}
|
||||
page.setOrderBy(orderBy);
|
||||
ntcPzReportPage = ntcReportService.findNtcPzReport(new Page<NtcPzReport>(request, response, NtcPzReport.class),
|
||||
ntcPzReport);
|
||||
} catch (Exception e) {
|
||||
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
if (!(e instanceof RestServiceException)) {
|
||||
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "配置日志总量统计失败");
|
||||
}
|
||||
throw ((RestServiceException) e);
|
||||
}
|
||||
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "配置总量统计成功",
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "配置日志总量统计成功",
|
||||
ntcPzReportPage, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @author (zdx)
|
||||
* @date 2018年7月12日 上午11:01:30
|
||||
* @param entity
|
||||
* @throws Exception
|
||||
*/
|
||||
public void resetReportTime(NtcReportEntity<?> entity) throws Exception {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchReportStartTime(),
|
||||
entity.getSearchReportEndTime(), Constants.PZ_REPORT_TIME, "minute");
|
||||
entity.setSearchReportStartTime(map.get("startTime"));
|
||||
entity.setSearchReportEndTime(map.get("endTime"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
20
src/main/java/com/nis/web/dao/NtcReportDao.java
Normal file
20
src/main/java/com/nis/web/dao/NtcReportDao.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.nis.web.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.nis.domain.DfReportEntity;
|
||||
import com.nis.domain.restful.NtcPzReport;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName:NtcReportDao
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zdx)
|
||||
* @date 2018年7月11日 下午5:47:55
|
||||
* @version V1.0
|
||||
*/
|
||||
@MyBatisDao
|
||||
public interface NtcReportDao extends CrudDao {
|
||||
List<NtcPzReport> findNtcPzReport(NtcPzReport pz);
|
||||
|
||||
}
|
||||
60
src/main/java/com/nis/web/dao/NtcReportDao.xml
Normal file
60
src/main/java/com/nis/web/dao/NtcReportDao.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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.NtcReportDao">
|
||||
<resultMap id="NtcPzReportMap" type="com.nis.domain.restful.NtcPzReport">
|
||||
<result column="CFG_ID" jdbcType="BIGINT" property="cfgId" />
|
||||
<result column="SERVICE" jdbcType="INTEGER" property="service" />
|
||||
<result column="SUM" jdbcType="BIGINT" property="sum" />
|
||||
<result column="REPORT_TIME" jdbcType="TIMESTAMP" property="reportTime" />
|
||||
</resultMap>
|
||||
<sql id="commonPorperty">
|
||||
SERVICE,SUM,REPORT_TIME
|
||||
</sql>
|
||||
|
||||
<select id="findNtcPzReport" parameterType="com.nis.domain.restful.NtcPzReport"
|
||||
resultMap="NtcPzReportMap">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="page !=null and page.fields != null and page.fields != ''">
|
||||
${page.fields}
|
||||
</when>
|
||||
<otherwise>
|
||||
CFG_ID,
|
||||
<include refid="commonPorperty" />
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM (SELECT CFG_ID, SERVICE, SUM(SUM) SUM ,REPORT_TIME
|
||||
FROM NTC_PZ_REPORT
|
||||
<where>
|
||||
<if test="searchCfgId != null and searchCfgId !=''">
|
||||
<![CDATA[AND CFG_ID in (#{searchCfgId})]]>
|
||||
</if>
|
||||
<if test="searchService != null and searchService !=''">
|
||||
<![CDATA[AND SERVICE in #{searchService}]]>
|
||||
</if>
|
||||
<if test="searchReportStartTime != null and searchReportStartTime !=''">
|
||||
<![CDATA[AND REPORT_TIME >= STR_TO_DATE(#{searchReportStartTime},'%Y-%m-%d %H:%i:%s')]]>
|
||||
</if>
|
||||
<if test="searchReportEndTime != null and searchReportEndTime !=''">
|
||||
<![CDATA[AND REPORT_TIME < STR_TO_DATE(#{searchReportEndTime},'%Y-%m-%d %H:%i:%s')]]>
|
||||
</if>
|
||||
</where>
|
||||
|
||||
<if test="searchBusinessType != null and searchBusinessType ==1">
|
||||
GROUP BY CFG_ID,SERVICE
|
||||
)
|
||||
</if>
|
||||
<if test="searchBusinessType != null and searchBusinessType ==2">
|
||||
GROUP BY CFG_ID,SERVICE,REPORT_TIME
|
||||
)
|
||||
</if>
|
||||
NTC_PZ_REPORT
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -22,6 +22,7 @@ import com.nis.domain.DfReportEntity;
|
||||
import com.nis.domain.LogEntity;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.StatLogEntity;
|
||||
import com.nis.domain.restful.NtcReportEntity;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
@@ -240,7 +241,105 @@ public abstract class BaseLogService {
|
||||
logger.info("请求参数校验结束----" + System.currentTimeMillis());
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @Description:
|
||||
* @author (zdx)
|
||||
* @date 2018年7月12日 上午11:43:32
|
||||
* @param thread
|
||||
* @param start
|
||||
* @param entity
|
||||
* @param clazz
|
||||
* @param page
|
||||
*/
|
||||
public void queryReportConditionCheck(SaveRequestLogThread thread, long start, NtcReportEntity<?> entity, Class clazz,
|
||||
Page page) {
|
||||
logger.info("实时报表统计查询参数校验开始----" + System.currentTimeMillis());
|
||||
if (!StringUtil.isBlank(entity.getSearchBusinessType())&&!StringUtil.isNumeric(entity.getSearchBusinessType())) {
|
||||
logger.error(RestBusinessCode.param_formate_error.getErrorReason()+",searchBusinessType参数格式错误");
|
||||
thread.setExceptionInfo("searchBusinessType参数格式错误");
|
||||
throw new RestServiceException(thread,
|
||||
System.currentTimeMillis() - start,
|
||||
"searchBusinessType参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
//searchService
|
||||
checkNumericCondition(thread, start, entity.getSearchService(), "searchService");
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchReportStartTime())) {
|
||||
sdf.parse(entity.getSearchReportStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportStartTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchReportEndTime())) {
|
||||
sdf.parse(entity.getSearchReportEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportEndTime参数错误");
|
||||
}
|
||||
if (!StringUtil.isBlank(entity.getSearchBusinessType())&&!StringUtil.isNumeric(entity.getSearchBusinessType())) {
|
||||
logger.error(RestBusinessCode.param_formate_error.getErrorReason()+",searchBusinessType参数格式错误");
|
||||
thread.setExceptionInfo("searchBusinessType参数格式错误");
|
||||
throw new RestServiceException(thread,
|
||||
System.currentTimeMillis() - start,
|
||||
"searchBusinessType参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
|
||||
logger.info("实时报表统计查询参数校验结束----" + System.currentTimeMillis());
|
||||
|
||||
}
|
||||
/**
|
||||
* @Description:用于验证数值类型格式,多个值以","分隔
|
||||
* @author (zdx)
|
||||
* @date 2018年7月12日 下午12:47:35
|
||||
* @param thread
|
||||
* @param start
|
||||
* @param condition
|
||||
* @param condName
|
||||
*/
|
||||
public void checkNumericCondition(SaveRequestLogThread thread, long start,String condition,String condName) {
|
||||
if (!StringUtil.isEmpty(condition)){
|
||||
Boolean flag = false;
|
||||
if (condition.contains(",")) {
|
||||
String services[] =condition.split(",");
|
||||
for (String service : services) {
|
||||
if(!StringUtil.isNumeric(service)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else if(!StringUtil.isNumeric(condition)) {
|
||||
flag = true;
|
||||
}
|
||||
if (flag) {
|
||||
logger.error(RestBusinessCode.param_formate_error.getErrorReason()+","+condName+"参数格式错误");
|
||||
thread.setExceptionInfo(condName+"参数格式错误");
|
||||
throw new RestServiceException(thread,
|
||||
System.currentTimeMillis() - start,
|
||||
condName+"参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* wx 报表查询条件检查
|
||||
*
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.NtcPzReport;
|
||||
import com.nis.web.dao.NtcReportDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zdx)
|
||||
* @date 2018年7月10日 上午9:47:39
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class NtcReportService extends BaseLogService {
|
||||
|
||||
@Autowired
|
||||
protected NtcReportDao dao;
|
||||
|
||||
public Page<?> findNtcPzReport(Page<NtcPzReport> page, NtcPzReport entity)
|
||||
throws Exception {
|
||||
page.setList(dao.findNtcPzReport(entity));
|
||||
if ("1".equals(entity.getSearchBusinessType())) {
|
||||
Page<Map> pageTotal = new Page<Map>();
|
||||
pageTotal.setPageNo(page.getPageNo());
|
||||
pageTotal.setPageSize(page.getPageSize());
|
||||
List<Map> restList = new ArrayList<Map>();
|
||||
List<NtcPzReport> list = page.getList();
|
||||
for (NtcPzReport ntcPzReport : list) {
|
||||
Map<String, Long> restMap = new HashMap<String, Long>();
|
||||
restMap.put("cfgId", ntcPzReport.getCfgId());
|
||||
restMap.put("sum", ntcPzReport.getSum());
|
||||
restList.add(restMap);
|
||||
}
|
||||
pageTotal.setCount(restList.size());
|
||||
pageTotal.setList(restList);
|
||||
return pageTotal;
|
||||
} else if ("2".equals(entity.getSearchBusinessType())) {
|
||||
return page;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user