1、报表统计接口添加按月统计功能 ;

2、将开始时间和结束时间默认值获取方法改为按时间类型,默认为分钟(最近5分钟);
3、0x403	APP字节特征添加APP_SUBSCRIBE_ID域表
This commit is contained in:
zhangdongxu
2018-08-28 17:05:01 +08:00
parent 03b576fa4f
commit d038e3ee1f
7 changed files with 138 additions and 85 deletions

View File

@@ -178,50 +178,22 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
}
/**
*
*
* @Title: getLocalTime
* @Description: (各种业务查询的时间条件默认值)
* @param @param startTime
* @param @param endTime
* @param @param 本地存储时间长度(小时)
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
* @Description: 按类型获取默认时间
* @author (zdx)
* @date 2018年8月28日 下午4:53:40
* @param startTime
* @param endTime
* @param localLen
* @param type
* @return
* @throws Exception
*/
public static Map<String, String> getLocalTime(String startTime,String endTime,Long localLen,String type)throws Exception {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd");
Map<String, String> timeMap=new HashMap<String, String>();
Date date=new Date();
//日报表默认查询前一天的数据
if("daily".equals(type) && startTime == null && endTime == null){
Calendar cal=Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
timeMap.put("startTime", sdf.format(cal.getTime()));
timeMap.put("endTime", sdf.format(sdf.parse(sdf2.format(cal.getTime())+" 23:59:59")));
logger.info("日报默认开始时间条件:"+sdf.format(cal.getTime()));
logger.info("日报默认结束时间条件:"+sdf.format(sdf.parse(sdf2.format(cal.getTime())+" 23:59:59")));
return timeMap;
if (StringUtil.isEmpty(type)) {
type = "minute";
}
//月报表默认查询前一天的数据
if("month".equals(type) && startTime == null && endTime == null){
Calendar cal=Calendar.getInstance();
cal.add(Calendar.MONTH, date.getMonth()-2);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
timeMap.put("startTime", sdf.format(cal.getTime()));
timeMap.put("endTime", sdf.format(date));
logger.info("月报默认开始时间条件:"+sdf.format(cal.getTime()));
logger.info("月报默认结束时间条件:"+sdf.format(date));
return timeMap;
}
//实时报表统计默认查询最近5分钟
if("minute".equals(type) && startTime == null && endTime == null){
Calendar cal=Calendar.getInstance();
@@ -234,23 +206,30 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
timeMap.put("startTime", sdf.format(cal.getTime()));
logger.info("实时报表统计默认开始时间条件:"+timeMap.get("startTime"));
logger.info("默认结束时间条件:"+timeMap.get("endTime"));
return timeMap;
}
if(startTime == null && endTime == null && localLen != null){
}else if("hour".equals(type) && startTime == null && endTime == null){//小时报表默认查询最近一小时的数据
Calendar cal=Calendar.getInstance();
cal.add(Calendar.HOUR, -localLen.intValue());
timeMap.put("endTime", sdf.format(cal.getTime()));
cal.add(Calendar.HOUR_OF_DAY, -1);
timeMap.put("startTime", sdf.format(cal.getTime()));
timeMap.put("endTime", sdf.format(date));
logger.info("默认开始时间条件:"+sdf.format(cal.getTime()));
logger.info("默认结束时间条件:"+sdf.format(date));
return timeMap;
}else {
timeMap.put("startTime", startTime);
timeMap.put("endTime", endTime);
logger.info("开始时间条件:"+startTime);
logger.info("结束时间条件:"+endTime);
return timeMap;
logger.info("小时报默认开始时间条件:"+timeMap.get("startTime"));
logger.info("小时报默认结束时间条件:"+timeMap.get("endTime"));
}else if("daily".equals(type) && startTime == null && endTime == null){//日报表默认查询最近一天的数据
Calendar cal=Calendar.getInstance();
timeMap.put("endTime", sdf.format(cal.getTime()));
cal.add(Calendar.DAY_OF_YEAR, -1);
timeMap.put("startTime", sdf.format(cal.getTime()));
logger.info("日报默认开始时间条件:"+timeMap.get("startTime"));
logger.info("日报默认结束时间条件:"+timeMap.get("endTime"));
}else if("month".equals(type) && startTime == null && endTime == null){//月报表默认查询最近一月的数据
Calendar cal=Calendar.getInstance();
timeMap.put("endTime", sdf.format(cal.getTime()));
cal.add(Calendar.MONTH,-1);
timeMap.put("startTime", sdf.format(cal.getTime()));
logger.info("月报默认开始时间条件:"+timeMap.get("startTime"));
logger.info("月报默认结束时间条件:"+timeMap.get("endTime"));
}
return timeMap;
}
/**

View File

@@ -25,6 +25,7 @@ import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.HiveJDBCByDruid;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.HiveSqlService;
@@ -168,11 +169,12 @@ public class LogController extends BaseRestController {
* @throws Exception
*/
public void resetTime(LogEntity<?> entity) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(),
entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "log");
entity.setSearchFoundStartTime(map.get("startTime"));
entity.setSearchFoundEndTime(map.get("endTime"));
if (StringUtil.isEmpty(entity.getSearchFoundStartTime())&&StringUtil.isEmpty(entity.getSearchFoundEndTime())) {
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(),
entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "minute");
entity.setSearchFoundStartTime(map.get("startTime"));
entity.setSearchFoundEndTime(map.get("endTime"));
}
}
/**

View File

@@ -1,6 +1,5 @@
package com.nis.web.controller.restful;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -35,6 +34,7 @@ import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.HiveJDBCByDruid;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.HiveSqlService;
@@ -708,11 +708,12 @@ public class MmLogSearchController extends BaseRestController {
* @throws Exception
*/
public void resetTime(LogEntity<?> entity) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(),
entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "log");
entity.setSearchFoundStartTime(map.get("startTime"));
entity.setSearchFoundEndTime(map.get("endTime"));
if (StringUtil.isEmpty(entity.getSearchFoundStartTime())&&StringUtil.isEmpty(entity.getSearchFoundEndTime())) {
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(),
entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "minute");
entity.setSearchFoundStartTime(map.get("startTime"));
entity.setSearchFoundEndTime(map.get("endTime"));
}
}
/**

View File

@@ -1,6 +1,5 @@
package com.nis.web.controller.restful;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -38,6 +37,7 @@ import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.HiveJDBCByDruid;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.HiveSqlService;
@@ -975,11 +975,12 @@ public class NtcLogSearchController extends BaseRestController {
* @throws Exception
*/
public void resetTime(LogEntity<?> entity) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(),
entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "log");
entity.setSearchFoundStartTime(map.get("startTime"));
entity.setSearchFoundEndTime(map.get("endTime"));
if (StringUtil.isEmpty(entity.getSearchFoundStartTime())&&StringUtil.isEmpty(entity.getSearchFoundEndTime())) {
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(),
entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "minute");
entity.setSearchFoundStartTime(map.get("startTime"));
entity.setSearchFoundEndTime(map.get("endTime"));
}
}
/**

View File

@@ -25,6 +25,7 @@ import com.nis.domain.restful.NtcTagReport;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.ServicesRequestLogService;
@@ -62,7 +63,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> ntcPzReportPage = null;
try {
resetReportTime(ntcPzReport);
resetReportTime(ntcPzReport,true);
//验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcPzReport, NtcPzReport.class, page);
//验证serachCfgId
@@ -100,7 +101,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> reportPage = null;
try {
resetReportTime(ntcServiceReport);
resetReportTime(ntcServiceReport,false);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcServiceReport, NtcServiceReport.class, page);
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
@@ -137,7 +138,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> reportPage = null;
try {
resetReportTime(ntcTagReport);
resetReportTime(ntcTagReport,false);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcTagReport, NtcTagReport.class, page);
//验证serachTag
ntcReportService.checkNumericCondition(saveLogThread,start,ntcTagReport.getSearchTag(),"searchTag");
@@ -173,7 +174,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> reportPage = null;
try {
resetReportTime(ntcAttrTypeReport);
resetReportTime(ntcAttrTypeReport,false);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcAttrTypeReport, NtcAttrTypeReport.class, page);
//验证searchAttrType
ntcReportService.checkNumericCondition(saveLogThread,start,ntcAttrTypeReport.getSearchAttrType(),"searchAttrType");
@@ -210,7 +211,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> reportPage = null;
try {
resetReportTime(ntcLwhhReport);
resetReportTime(ntcLwhhReport,false);
//验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcLwhhReport, NtcLwhhReport.class, page);
//验证serachCfgId
@@ -248,7 +249,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> reportPage = null;
try {
resetReportTime(ntcSrcipDomesticReport);
resetReportTime(ntcSrcipDomesticReport,false);
//验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcSrcipDomesticReport, NtcSrcipDomesticReport.class, page);
String orderBy = "";
@@ -287,7 +288,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> reportPage = null;
try {
resetReportTime(ntcDestipCountryReport);
resetReportTime(ntcDestipCountryReport,false);
// 验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcDestipCountryReport,
NtcDestipCountryReport.class, page);
@@ -325,7 +326,7 @@ public class SingleDimensionReport extends BaseRestController {
Page<?> reportPage = null;
try {
resetReportTime(ntcEntranceReport);
resetReportTime(ntcEntranceReport,false);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcEntranceReport, NtcEntranceReport.class,
page);
// 验证searchEntrance
@@ -361,11 +362,32 @@ public class SingleDimensionReport extends BaseRestController {
* @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"));
public void resetReportTime(NtcReportEntity<?> entity,Boolean isTotal) throws Exception {
if (StringUtil.isEmpty(entity.getSearchReportStartTime())&&StringUtil.isEmpty(entity.getSearchReportEndTime())) {
String dateType = "minute"; //默认为分钟
if (!isTotal){
if (entity.getSearchBusinessType().equals("2")) {
dateType = "hour";
}else if (entity.getSearchBusinessType().equals("3")) {
dateType = "daily";
}else if (entity.getSearchBusinessType().equals("4")) {
dateType = "month";
}
}else{
if (entity.getSearchBusinessType().equals("3")) {
dateType = "hour";
}else if (entity.getSearchBusinessType().equals("4")) {
dateType = "daily";
}else if (entity.getSearchBusinessType().equals("5")) {
dateType = "month";
}
}
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchReportStartTime(),
entity.getSearchReportEndTime(), Constants.PZ_REPORT_TIME, dateType);
entity.setSearchReportStartTime(map.get("startTime"));
entity.setSearchReportEndTime(map.get("endTime"));
}
}
}

View File

@@ -75,6 +75,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_PZ_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 5 ">
NTC_PZ_STAT_MONTH
</when>
<otherwise>
NTC_PZ_REPORT
</otherwise>
@@ -112,6 +115,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_PZ_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 5 ">
NTC_PZ_STAT_MONTH
</when>
<otherwise>
NTC_PZ_REPORT
</otherwise>
@@ -143,6 +149,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_SERVICE_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_SERVICE_STAT_MONTH
</when>
<otherwise>
NTC_SERVICE_REPORT
</otherwise>
@@ -169,6 +178,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_SERVICE_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_SERVICE_STAT_MONTH
</when>
<otherwise>
NTC_SERVICE_REPORT
</otherwise>
@@ -202,6 +214,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_TAG_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_TAG_STAT_MONTH
</when>
<otherwise>
NTC_TAG_REPORT
</otherwise>
@@ -230,6 +245,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_TAG_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_TAG_STAT_MONTH
</when>
<otherwise>
NTC_TAG_REPORT
</otherwise>
@@ -263,6 +281,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_ATTR_TYPE_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_ATTR_TYPE_STAT_MONTH
</when>
<otherwise>
NTC_ATTR_TYPE_REPORT
</otherwise>
@@ -292,6 +313,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_ATTR_TYPE_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_ATTR_TYPE_STAT_MONTH
</when>
<otherwise>
NTC_ATTR_TYPE_REPORT
</otherwise>
@@ -324,6 +348,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_LWHH_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_LWHH_STAT_MONTH
</when>
<otherwise>
NTC_LWHH_REPORT
</otherwise>
@@ -352,6 +379,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_LWHH_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_LWHH_STAT_MONTH
</when>
<otherwise>
NTC_LWHH_REPORT
</otherwise>
@@ -383,6 +413,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_SRCIP_DOMESTIC_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_SRCIP_DOMESTIC_STAT_MONTH
</when>
<otherwise>
NTC_SRCIP_DOMESTIC_REPORT
</otherwise>
@@ -408,6 +441,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_SRCIP_DOMESTIC_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_SRCIP_DOMESTIC_STAT_MONTH
</when>
<otherwise>
NTC_SRCIP_DOMESTIC_REPORT
</otherwise>
@@ -440,6 +476,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_DESTIP_COUNTRY_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_DESTIP_COUNTRY_STAT_MONTH
</when>
<otherwise>
NTC_DESTIP_COUNTRY_REPORT
</otherwise>
@@ -465,6 +504,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_DESTIP_COUNTRY_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_DESTIP_COUNTRY_STAT_MONTH
</when>
<otherwise>
NTC_DESTIP_COUNTRY_REPORT
</otherwise>
@@ -497,6 +539,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_ENTRANCE_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_ENTRANCE_STAT_MONTH
</when>
<otherwise>
NTC_ENTRANCE_REPORT
</otherwise>
@@ -526,6 +571,9 @@
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
NTC_ENTRANCE_STAT_DAILY
</when>
<when test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 4 ">
NTC_ENTRANCE_STAT_MONTH
</when>
<otherwise>
NTC_ENTRANCE_REPORT
</otherwise>