diff --git a/src/main/java/com/nis/util/DateUtils.java b/src/main/java/com/nis/util/DateUtils.java index 0c862e0..7b883ef 100644 --- a/src/main/java/com/nis/util/DateUtils.java +++ b/src/main/java/com/nis/util/DateUtils.java @@ -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 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 timeMap=new HashMap(); - 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; } /** diff --git a/src/main/java/com/nis/web/controller/restful/LogController.java b/src/main/java/com/nis/web/controller/restful/LogController.java index 8bf1386..a102590 100644 --- a/src/main/java/com/nis/web/controller/restful/LogController.java +++ b/src/main/java/com/nis/web/controller/restful/LogController.java @@ -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 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 map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(), + entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "minute"); + entity.setSearchFoundStartTime(map.get("startTime")); + entity.setSearchFoundEndTime(map.get("endTime")); + } } /** diff --git a/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java b/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java index 606cf01..376e539 100644 --- a/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java +++ b/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java @@ -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 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 map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(), + entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "minute"); + entity.setSearchFoundStartTime(map.get("startTime")); + entity.setSearchFoundEndTime(map.get("endTime")); + } } /** diff --git a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java index cca2a20..aeb2a63 100644 --- a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java +++ b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java @@ -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 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 map = DateUtils.getLocalTime(entity.getSearchFoundStartTime(), + entity.getSearchFoundEndTime(), Constants.LOG_LOCAL_TIME, "minute"); + entity.setSearchFoundStartTime(map.get("startTime")); + entity.setSearchFoundEndTime(map.get("endTime")); + } } /** diff --git a/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java b/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java index 7216965..0121453 100644 --- a/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java +++ b/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java @@ -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 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 map = DateUtils.getLocalTime(entity.getSearchReportStartTime(), + entity.getSearchReportEndTime(), Constants.PZ_REPORT_TIME, dateType); + entity.setSearchReportStartTime(map.get("startTime")); + entity.setSearchReportEndTime(map.get("endTime")); + } } + + } diff --git a/src/main/java/com/nis/web/dao/NtcReportDao.xml b/src/main/java/com/nis/web/dao/NtcReportDao.xml index 6c8faca..8ba705a 100644 --- a/src/main/java/com/nis/web/dao/NtcReportDao.xml +++ b/src/main/java/com/nis/web/dao/NtcReportDao.xml @@ -75,6 +75,9 @@ NTC_PZ_STAT_DAILY + + NTC_PZ_STAT_MONTH + NTC_PZ_REPORT @@ -112,6 +115,9 @@ NTC_PZ_STAT_DAILY + + NTC_PZ_STAT_MONTH + NTC_PZ_REPORT @@ -143,6 +149,9 @@ NTC_SERVICE_STAT_DAILY + + NTC_SERVICE_STAT_MONTH + NTC_SERVICE_REPORT @@ -169,6 +178,9 @@ NTC_SERVICE_STAT_DAILY + + NTC_SERVICE_STAT_MONTH + NTC_SERVICE_REPORT @@ -202,6 +214,9 @@ NTC_TAG_STAT_DAILY + + NTC_TAG_STAT_MONTH + NTC_TAG_REPORT @@ -230,6 +245,9 @@ NTC_TAG_STAT_DAILY + + NTC_TAG_STAT_MONTH + NTC_TAG_REPORT @@ -263,6 +281,9 @@ NTC_ATTR_TYPE_STAT_DAILY + + NTC_ATTR_TYPE_STAT_MONTH + NTC_ATTR_TYPE_REPORT @@ -292,6 +313,9 @@ NTC_ATTR_TYPE_STAT_DAILY + + NTC_ATTR_TYPE_STAT_MONTH + NTC_ATTR_TYPE_REPORT @@ -324,6 +348,9 @@ NTC_LWHH_STAT_DAILY + + NTC_LWHH_STAT_MONTH + NTC_LWHH_REPORT @@ -352,6 +379,9 @@ NTC_LWHH_STAT_DAILY + + NTC_LWHH_STAT_MONTH + NTC_LWHH_REPORT @@ -383,6 +413,9 @@ NTC_SRCIP_DOMESTIC_STAT_DAILY + + NTC_SRCIP_DOMESTIC_STAT_MONTH + NTC_SRCIP_DOMESTIC_REPORT @@ -408,6 +441,9 @@ NTC_SRCIP_DOMESTIC_STAT_DAILY + + NTC_SRCIP_DOMESTIC_STAT_MONTH + NTC_SRCIP_DOMESTIC_REPORT @@ -440,6 +476,9 @@ NTC_DESTIP_COUNTRY_STAT_DAILY + + NTC_DESTIP_COUNTRY_STAT_MONTH + NTC_DESTIP_COUNTRY_REPORT @@ -465,6 +504,9 @@ NTC_DESTIP_COUNTRY_STAT_DAILY + + NTC_DESTIP_COUNTRY_STAT_MONTH + NTC_DESTIP_COUNTRY_REPORT @@ -497,6 +539,9 @@ NTC_ENTRANCE_STAT_DAILY + + NTC_ENTRANCE_STAT_MONTH + NTC_ENTRANCE_REPORT @@ -526,6 +571,9 @@ NTC_ENTRANCE_STAT_DAILY + + NTC_ENTRANCE_STAT_MONTH + NTC_ENTRANCE_REPORT diff --git a/src/main/resources/applicationConfig-rule.properties b/src/main/resources/applicationConfig-rule.properties index 2ebd644..6f68276 100644 --- a/src/main/resources/applicationConfig-rule.properties +++ b/src/main/resources/applicationConfig-rule.properties @@ -176,7 +176,7 @@ service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16; #0x403 APP字节特征 1027=10:APP_COMPILE;11:APP_GROUP;14:APP_PKT_BIN,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE #0x404 APP IP特征 -1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP;18:NTC_IP_RANGE +1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP;14:APP_SUBSCRIBE_ID;18:NTC_IP_RANGE #0x405 SSL证书特征 1029=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_SSL_CERT;18:NTC_IP_RANGE #0x406 TCP Session特征