diff options
| author | wangwei <[email protected]> | 2018-09-11 16:24:25 +0800 |
|---|---|---|
| committer | wangwei <[email protected]> | 2018-09-11 16:24:25 +0800 |
| commit | 0d4d344cdbbfb000e6bde9dfbfa07f9ac5fe167e (patch) | |
| tree | cb44b6430cfa3203c4c10568dbbbc79af1bcd8cd | |
| parent | 713e2c96ea9d036feb7b1985d0cb85b13d2188ab (diff) | |
添加功能:查询不到数据时,最多向前查询3阶段,若没有推null,反之推查询结果。
14 files changed, 518 insertions, 411 deletions
diff --git a/src/main/java/com/nis/galaxy/util/DateUtils.java b/src/main/java/com/nis/galaxy/util/DateUtils.java index c12f330..12400ef 100644 --- a/src/main/java/com/nis/galaxy/util/DateUtils.java +++ b/src/main/java/com/nis/galaxy/util/DateUtils.java @@ -41,11 +41,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * @return */ public static String getBeforeTimeOf5min30s() { - //GregorianCalendar gc = new GregorianCalendar(); - //gc.add(Calendar.MINUTE, -5); - //gc.add(Calendar.SECOND, -30); - //return DateUtils.formatDateTime(gc.getTime()); - return "2018-01-01 00:00:00"; + GregorianCalendar gc = new GregorianCalendar(); + gc.add(Calendar.MINUTE, -5); + gc.add(Calendar.SECOND, -30); + return DateUtils.formatDateTime(gc.getTime()); + //return "2018-01-01 00:00:00"; } @@ -55,11 +55,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * @return */ public static String getBeforeTimeOf1h30s() { - //GregorianCalendar gc = new GregorianCalendar(); - //gc.add(Calendar.HOUR, -1); - //gc.add(Calendar.SECOND, -30); - //return DateUtils.formatDateTime(gc.getTime()); - return "2018-01-01 00:00:00"; + GregorianCalendar gc = new GregorianCalendar(); + gc.add(Calendar.HOUR, -1); + gc.add(Calendar.SECOND, -30); + return DateUtils.formatDateTime(gc.getTime()); + //return "2018-01-01 00:00:00"; } /** @@ -68,11 +68,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * @return */ public static String getBeforeTimeOf24h30s() { - //GregorianCalendar gc = new GregorianCalendar(); - //gc.add(Calendar.DATE, -1); - //gc.add(Calendar.SECOND, -30); - //return DateUtils.formatDateTime(gc.getTime()); - return "2018-01-01 00:00:00"; + GregorianCalendar gc = new GregorianCalendar(); + gc.add(Calendar.DATE, -1); + gc.add(Calendar.SECOND, -30); + return DateUtils.formatDateTime(gc.getTime()); + // return "2018-01-01 00:00:00"; } /** @@ -82,12 +82,12 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * @return */ public static String getAfter5min(String time) { - //Date date = DateUtils.parseDate(time); - //GregorianCalendar gc = new GregorianCalendar(); - //gc.setTime(date); - //gc.add(Calendar.MINUTE, 5); - //return DateUtils.formatDateTime(gc.getTime()); - return "2018-12-01 00:00:00"; + Date date = DateUtils.parseDate(time); + GregorianCalendar gc = new GregorianCalendar(); + gc.setTime(date); + gc.add(Calendar.MINUTE, 5); + return DateUtils.formatDateTime(gc.getTime()); + //return "2018-12-01 00:00:00"; } /** * 获取距离time时间minute分钟的时间,之前需加符号-、之后为正+ @@ -110,12 +110,12 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * @return */ public static String getAfter24h(String time) { - //Date date = DateUtils.parseDate(time); - //GregorianCalendar gc = new GregorianCalendar(); - //gc.setTime(date); - //gc.add(Calendar.DATE, 1); - //return DateUtils.formatDateTime(gc.getTime()); - return "2018-12-01 00:00:00"; + Date date = DateUtils.parseDate(time); + GregorianCalendar gc = new GregorianCalendar(); + gc.setTime(date); + gc.add(Calendar.DATE, 1); + return DateUtils.formatDateTime(gc.getTime()); + //return "2018-12-01 00:00:00"; } /** @@ -125,12 +125,12 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * @return */ public static String getAfter1h(String time) { - // Date date = DateUtils.parseDate(time); - // GregorianCalendar gc = new GregorianCalendar(); - // gc.setTime(date); - // gc.add(Calendar.HOUR, 1); - // return DateUtils.formatDateTime(gc.getTime()); - return "2018-12-01 00:00:00"; + Date date = DateUtils.parseDate(time); + GregorianCalendar gc = new GregorianCalendar(); + gc.setTime(date); + gc.add(Calendar.HOUR, 1); + return DateUtils.formatDateTime(gc.getTime()); + // return "2018-12-01 00:00:00"; } diff --git a/src/main/java/com/nis/galaxy/web/controller/BlockingController.java b/src/main/java/com/nis/galaxy/web/controller/BlockingController.java index 97d06cb..96efac8 100644 --- a/src/main/java/com/nis/galaxy/web/controller/BlockingController.java +++ b/src/main/java/com/nis/galaxy/web/controller/BlockingController.java @@ -25,7 +25,8 @@ public class BlockingController { @RequestMapping(value = "/getAllBlockInformation/{start}",method = RequestMethod.GET) public List<NtcTypeCount> getAllBlockInformation(@PathVariable("start") String start){ String end = DateUtils.getAfter5min(start); - return blockingService.getAllBlockInformation(start,end); + int times = 1; + return blockingService.getAllBlockInformation(start,end,times); } /** @@ -35,7 +36,8 @@ public class BlockingController { @RequestMapping(value = "/getDisBlockInformation/{start}",method = RequestMethod.GET) public List<NtcDisReport> getDisBlockInformation(@PathVariable("start") String start){ String end = DateUtils.getAfter5min(start); - return blockingService.getDisBlockInformation(start,end); + int times=1; + return blockingService.getDisBlockInformation(start,end,times); } @@ -46,7 +48,8 @@ public class BlockingController { @RequestMapping(value = "/getDNSDeceiveInformation/{start}",method = RequestMethod.GET) public List<NtcEntranceReport> getDNSDeceiveInformation(@PathVariable("start") String start){ String end = DateUtils.getAfter5min(start); - return blockingService.getDNSDeceiveInformation(start,end); + int times =1; + return blockingService.getDNSDeceiveInformation(start,end,times); } /** @@ -56,7 +59,8 @@ public class BlockingController { @RequestMapping(value = "/get24hAllBlockEachProtocol/{start}",method = RequestMethod.GET) public List<TimeTypeCount > get24hAllBlockEachProtocol(@PathVariable("start")String start){ String end = DateUtils.getAfter5min(start); - return blockingService.get24hAllBlockEachProtocol(start,end); + int times =1; + return blockingService.get24hAllBlockEachProtocol(start,end,times); }/** /** * 24h全国热力图 5min @@ -65,7 +69,8 @@ public class BlockingController { @RequestMapping(value = "/getAllHotStatistis/{start}",method = RequestMethod.GET) public List<HotStatistic > getAllHotStatistis(@PathVariable("start") String start){ String end = DateUtils.getAfter5min(start); - return blockingService.getAllHotStatistis(start,end); + int times =1; + return blockingService.getAllHotStatistis(start,end,times); } @@ -82,7 +87,8 @@ public class BlockingController { @RequestMapping(value = "/getDisBlockMap/{start}", method = RequestMethod.GET) public List<AreaCount> getDisBlockMap(@PathVariable("start") String start) { String end = DateUtils.getAfter5min(start); - List<AreaCount> disBlockMap = blockingService.getDisBlockMap(start, end); + int times= 1; + List<AreaCount> disBlockMap = blockingService.getDisBlockMap(start, end,times); return disBlockMap; } /** diff --git a/src/main/java/com/nis/galaxy/web/controller/BlockingTopNController.java b/src/main/java/com/nis/galaxy/web/controller/BlockingTopNController.java index 465738a..907a403 100644 --- a/src/main/java/com/nis/galaxy/web/controller/BlockingTopNController.java +++ b/src/main/java/com/nis/galaxy/web/controller/BlockingTopNController.java @@ -25,7 +25,8 @@ public class BlockingTopNController { @RequestMapping(value = "/getBlockTop10URLOf1h/{start}",method = RequestMethod.GET) public List<NtcRejectUrlStatistic> getBlockTop10URLOf1h(@PathVariable("start") String start){ String end = DateUtils.getAfter1h(start); - return blockingTopNService.getBlockTop10URLOf1h(start,end); + int times =1; + return blockingTopNService.getBlockTop10URLOf1h(start,end,times); } /** @@ -35,7 +36,8 @@ public class BlockingTopNController { @RequestMapping(value = "/getBlockTop10WebsiteOf1h/{start}",method = RequestMethod.GET) public List<NtcRejectWebsiteStatistic> getBlockTop10WebsiteOf1h(@PathVariable("start") String start){ String end = DateUtils.getAfter1h(start); - return blockingTopNService.getBlockTop10WebsiteOf1h(start,end); + int times =1; + return blockingTopNService.getBlockTop10WebsiteOf1h(start,end,times); } /** @@ -45,7 +47,8 @@ public class BlockingTopNController { @RequestMapping(value = "/getBlockTop10Tag24h/{start}",method = RequestMethod.GET) public List<NtcTagReport> getBlockTop10Tag24h(@PathVariable("start") String start){ String end = DateUtils.getAfter1h(start); - return blockingTopNService.getBlockTop10Tag24h(start,end); + int times =1; + return blockingTopNService.getBlockTop10Tag24h(start,end,times); } /** * 5min内封堵标签TOP10 * @return @@ -53,7 +56,8 @@ public class BlockingTopNController { @RequestMapping(value = "/getBlockTop10Tag5m/{start}",method = RequestMethod.GET) public List<NtcTagReport> getBlockTop10Tag5m(@PathVariable("start") String start){ String end = DateUtils.getAfter5min(start); - return blockingTopNService.getBlockTop10Tag5m(start,end); + int times =1; + return blockingTopNService.getBlockTop10Tag5m(start,end,times); } /** @@ -63,7 +67,8 @@ public class BlockingTopNController { @RequestMapping(value = "/getAreaBlockTop10ProtocolOf24h/{start}",method = RequestMethod.GET) public List<AreaBlockProtocol> getAreaBlockTop10ProtocolOf24(@PathVariable("start") String start){ String end = DateUtils.getAfter24h(start); - return blockingTopNService.getAreaBlockTop10ProtocolOf24(start,end); + int times =1; + return blockingTopNService.getAreaBlockTop10ProtocolOf24(start,end,times); } /** @@ -73,7 +78,8 @@ public class BlockingTopNController { @RequestMapping(value = "/getBlockTop10URLOf5m/{start}",method = RequestMethod.GET) public List<NtcUrlIpCount> getBlockTop10URLOf5m(@PathVariable("start")String start){ String end = DateUtils.getAfter5min(start); - return blockingTopNService.getBlockTop10URLOf5m(start,end); + int times =1; + return blockingTopNService.getBlockTop10URLOf5m(start,end,times); } /** * 5分钟内全国阻断website TOP10 @@ -82,8 +88,7 @@ public class BlockingTopNController { @RequestMapping(value = "/getBlockTop10WebsiteOf5m/{start}",method = RequestMethod.GET) public List<NtcUrlIpCount> getBlockTop10WebsiteOf5m(@PathVariable("start") String start){ String end = DateUtils.getAfter5min(start); - return blockingTopNService.getBlockTop10WebsiteOf5m(start,end); + int times=1; + return blockingTopNService.getBlockTop10WebsiteOf5m(start,end,times); } - - } diff --git a/src/main/java/com/nis/galaxy/web/controller/NetflowController.java b/src/main/java/com/nis/galaxy/web/controller/NetflowController.java index 4f8a645..4e5e75e 100644 --- a/src/main/java/com/nis/galaxy/web/controller/NetflowController.java +++ b/src/main/java/com/nis/galaxy/web/controller/NetflowController.java @@ -29,7 +29,8 @@ public class NetflowController { @RequestMapping(value = "/getNetflowStatistic5m/{start}", method = RequestMethod.GET) public List<TimeTypeCount> getNetflowStatistic5m(@PathVariable("start") String start) { String end = DateUtils.getAfter5min(start); - return netflowService.getNetflowStatistic5m(start,end); + int times =1; + return netflowService.getNetflowStatistic5m(start,end,times); } /** @@ -40,7 +41,8 @@ public class NetflowController { @RequestMapping(value = "/getProtocolStatisticOf1h/{start}", method = RequestMethod.GET) public List<NetflowProtocol> getProtocolStatisticOf1h(@PathVariable("start") String start) { String end = DateUtils.getAfter5min(start); - return netflowService.getProtocolStatisticOf1h(start,end); + int times =1; + return netflowService.getProtocolStatisticOf1h(start,end,times); } /** * 5分钟内活跃IP信息 @@ -48,7 +50,8 @@ public class NetflowController { @RequestMapping(value = "/getIpActiveInfoOf5min/{start}", method = RequestMethod.GET) public List<IpActiveInfo> getIpActiveInfoOf5min(@PathVariable("start") String start) { String end = DateUtils.getAfter5min(start); - return netflowService.getIpActiveInfoOf5min(start,end); + int times =1; + return netflowService.getIpActiveInfoOf5min(start,end,times); } } diff --git a/src/main/java/com/nis/galaxy/web/controller/NetflowTopNController.java b/src/main/java/com/nis/galaxy/web/controller/NetflowTopNController.java index 6af2e58..b4e2591 100644 --- a/src/main/java/com/nis/galaxy/web/controller/NetflowTopNController.java +++ b/src/main/java/com/nis/galaxy/web/controller/NetflowTopNController.java @@ -19,6 +19,7 @@ public class NetflowTopNController { @RequestMapping(value = "/getIpActiveStatisticOf5m/{start}") public List<IpActiveInt> get(@PathVariable("start") String start){ String end = DateUtils.getAfter5min(start); - return netflowTopNService.getIpActiveStatisticOf5m(start,end); + int times =1; + return netflowTopNService.getIpActiveStatisticOf5m(start,end,times); } } diff --git a/src/main/java/com/nis/galaxy/web/service/BlockingService.java b/src/main/java/com/nis/galaxy/web/service/BlockingService.java index 1b6b712..fa78009 100644 --- a/src/main/java/com/nis/galaxy/web/service/BlockingService.java +++ b/src/main/java/com/nis/galaxy/web/service/BlockingService.java @@ -10,19 +10,19 @@ import org.springframework.ui.ModelMap; public interface BlockingService { - List getAllBlockInformation(String start,String end); + List getAllBlockInformation(String start,String end,int times); - List<NtcEntranceReport> getDNSDeceiveInformation(String start,String end); + List<NtcEntranceReport> getDNSDeceiveInformation(String start,String end,int times); - List<TimeTypeCount > get24hAllBlockEachProtocol(String start,String end); + List<TimeTypeCount > get24hAllBlockEachProtocol(String start,String end,int times); - List<NtcDisReport> getDisBlockInformation(String start,String end); + List<NtcDisReport> getDisBlockInformation(String start,String end,int times); - List<HotStatistic> getAllHotStatistis(String start,String end); + List<HotStatistic> getAllHotStatistis(String start,String end,int times); List<PointMap> getPointMapOf10s(); - List<AreaCount> getDisBlockMap(String start,String end); + List<AreaCount> getDisBlockMap(String start,String end,int times); List<CfgTypeCount> getAllCfgInfo(); } diff --git a/src/main/java/com/nis/galaxy/web/service/BlockingTopNService.java b/src/main/java/com/nis/galaxy/web/service/BlockingTopNService.java index de5eb36..2d9b7db 100644 --- a/src/main/java/com/nis/galaxy/web/service/BlockingTopNService.java +++ b/src/main/java/com/nis/galaxy/web/service/BlockingTopNService.java @@ -5,17 +5,17 @@ import com.nis.galaxy.domain.*; import java.util.List; public interface BlockingTopNService { - List<NtcRejectUrlStatistic> getBlockTop10URLOf1h( String start,String end); + List<NtcRejectUrlStatistic> getBlockTop10URLOf1h( String start,String end,int times); - List<NtcRejectWebsiteStatistic> getBlockTop10WebsiteOf1h(String start,String end); + List<NtcRejectWebsiteStatistic> getBlockTop10WebsiteOf1h(String start,String end,int times); - List<NtcTagReport> getBlockTop10Tag24h(String start,String end); + List<NtcTagReport> getBlockTop10Tag24h(String start,String end,int times); - List<AreaBlockProtocol> getAreaBlockTop10ProtocolOf24(String start, String end); + List<AreaBlockProtocol> getAreaBlockTop10ProtocolOf24(String start, String end,int times); - List<NtcUrlIpCount> getBlockTop10URLOf5m(String start,String end); + List<NtcUrlIpCount> getBlockTop10URLOf5m(String start,String end,int times); - List<NtcUrlIpCount> getBlockTop10WebsiteOf5m(String start,String end); + List<NtcUrlIpCount> getBlockTop10WebsiteOf5m(String start,String end,int times); - List<NtcTagReport> getBlockTop10Tag5m(String start,String end); + List<NtcTagReport> getBlockTop10Tag5m(String start,String end,int times); } diff --git a/src/main/java/com/nis/galaxy/web/service/NetflowService.java b/src/main/java/com/nis/galaxy/web/service/NetflowService.java index cb4eb43..620dc66 100644 --- a/src/main/java/com/nis/galaxy/web/service/NetflowService.java +++ b/src/main/java/com/nis/galaxy/web/service/NetflowService.java @@ -8,9 +8,9 @@ import com.nis.galaxy.domain.TimeTypeCount; import java.util.List; public interface NetflowService { - List<TimeTypeCount> getNetflowStatistic5m(String start,String end); + List<TimeTypeCount> getNetflowStatistic5m(String start,String end,int times); - List<NetflowProtocol> getProtocolStatisticOf1h(String start,String end); + List<NetflowProtocol> getProtocolStatisticOf1h(String start,String end,int times); - List<IpActiveInfo> getIpActiveInfoOf5min(String start,String end); + List<IpActiveInfo> getIpActiveInfoOf5min(String start,String end,int times); } diff --git a/src/main/java/com/nis/galaxy/web/service/NetflowTopNService.java b/src/main/java/com/nis/galaxy/web/service/NetflowTopNService.java index 5a33d1a..9c4bba3 100644 --- a/src/main/java/com/nis/galaxy/web/service/NetflowTopNService.java +++ b/src/main/java/com/nis/galaxy/web/service/NetflowTopNService.java @@ -5,5 +5,5 @@ import com.nis.galaxy.domain.IpActiveInt; import java.util.List; public interface NetflowTopNService { - List<IpActiveInt> getIpActiveStatisticOf5m(String start,String end); + List<IpActiveInt> getIpActiveStatisticOf5m(String start,String end,int times); } diff --git a/src/main/java/com/nis/galaxy/web/service/impl/BlockingServiceImp.java b/src/main/java/com/nis/galaxy/web/service/impl/BlockingServiceImp.java index 0e33371..28f1bfb 100644 --- a/src/main/java/com/nis/galaxy/web/service/impl/BlockingServiceImp.java +++ b/src/main/java/com/nis/galaxy/web/service/impl/BlockingServiceImp.java @@ -34,6 +34,8 @@ public class BlockingServiceImp implements BlockingService { private int a = 16, b = 65; private int c = 256, d = 266; private int e = 512, f = 576; + //最大查询次数 + private int max = 3; //局点表 @@ -48,12 +50,13 @@ public class BlockingServiceImp implements BlockingService { } /** - * 整体封堵数量 5min/条、粒度5min + * 封堵信息整体显示 5min/条、粒度5min * * @return */ @Override - public List getAllBlockInformation(String start, String end) { + public List getAllBlockInformation(String start, String end, int times) { + List<NtcTypeCount> result = new CopyOnWriteArrayList<>(); List<NtcTotalReport> list = null; try { list = blockingDao.getAllBlockInformation(start, end); @@ -63,42 +66,50 @@ public class BlockingServiceImp implements BlockingService { } //若插叙信息为空则继续查前一阶段的数据 if (list == null || list.size() == 0) { - getAllBlockInformation(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5)); - } - NtcTotalReport listParams = list.get(0); - List<NtcTypeCount> listNtcTypeCount = new CopyOnWriteArrayList<>(); - if (languageChose == 2) { - listNtcTypeCount.add(new NtcTypeCount("CONTROL NUMBER", listParams.getRejectNum())); - listNtcTypeCount.add(new NtcTypeCount("MONITOR NUMBER", listParams.getMonitorNum())); - listNtcTypeCount.add(new NtcTypeCount("NETWORK WATERFLOW", (listParams.getS2cByteLen() + listParams.getC2sByteLen()))); - listNtcTypeCount.add(new NtcTypeCount("UP BPS", listParams.getC2sByteLen())); - listNtcTypeCount.add(new NtcTypeCount("DOWN BPS", listParams.getS2cByteLen())); - listNtcTypeCount.add(new NtcTypeCount("NEW CONNECTION NUMBER", listParams.getNewUniConnNum())); - listNtcTypeCount.add(new NtcTypeCount("ACTIVE CONNECTIONS", listParams.getLiveConnNum())); - listNtcTypeCount.add(new NtcTypeCount("DISCARD CONNECTIONS", listParams.getDropConnNum())); - listNtcTypeCount.add(new NtcTypeCount("REFLUX LINK NUMBER", listParams.getLoopConnNum())); + //连续查询次数不大于max + if (times >= max) { + return null; + } + return getAllBlockInformation(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - if (languageChose == 1) { - listNtcTypeCount.add(new NtcTypeCount("管控数量", listParams.getRejectNum())); - listNtcTypeCount.add(new NtcTypeCount("监测数量", listParams.getMonitorNum())); - listNtcTypeCount.add(new NtcTypeCount("网络流量数量", (listParams.getS2cByteLen() + listParams.getC2sByteLen()))); - listNtcTypeCount.add(new NtcTypeCount("上行数量", listParams.getC2sByteLen())); - listNtcTypeCount.add(new NtcTypeCount("下行数量", listParams.getS2cByteLen())); - listNtcTypeCount.add(new NtcTypeCount("新建连接数", listParams.getNewUniConnNum())); - listNtcTypeCount.add(new NtcTypeCount("活跃连接数", listParams.getLiveConnNum())); - listNtcTypeCount.add(new NtcTypeCount("丢弃连接数", listParams.getDropConnNum())); - listNtcTypeCount.add(new NtcTypeCount("回流链接数", listParams.getLoopConnNum())); + if (list != null && list.size() != 0) { + NtcTotalReport listParams = list.get(0); + if (languageChose == 2) { + result.add(new NtcTypeCount("CONTROL NUMBER", listParams.getRejectNum())); + result.add(new NtcTypeCount("MONITOR NUMBER", listParams.getMonitorNum())); + result.add(new NtcTypeCount("NETWORK WATERFLOW", (listParams.getS2cByteLen() + listParams.getC2sByteLen()))); + result.add(new NtcTypeCount("UP BPS", listParams.getC2sByteLen())); + result.add(new NtcTypeCount("DOWN BPS", listParams.getS2cByteLen())); + result.add(new NtcTypeCount("NEW CONNECTION NUMBER", listParams.getNewUniConnNum())); + result.add(new NtcTypeCount("ACTIVE CONNECTIONS", listParams.getLiveConnNum())); + result.add(new NtcTypeCount("DISCARD CONNECTIONS", listParams.getDropConnNum())); + result.add(new NtcTypeCount("REFLUX LINK NUMBER", listParams.getLoopConnNum())); + } + if (languageChose == 1) { + result.add(new NtcTypeCount("管控数量", listParams.getRejectNum())); + result.add(new NtcTypeCount("监测数量", listParams.getMonitorNum())); + result.add(new NtcTypeCount("网络流量数量", (listParams.getS2cByteLen() + listParams.getC2sByteLen()))); + result.add(new NtcTypeCount("上行数量", listParams.getC2sByteLen())); + result.add(new NtcTypeCount("下行数量", listParams.getS2cByteLen())); + result.add(new NtcTypeCount("新建连接数", listParams.getNewUniConnNum())); + result.add(new NtcTypeCount("活跃连接数", listParams.getLiveConnNum())); + result.add(new NtcTypeCount("丢弃连接数", listParams.getDropConnNum())); + result.add(new NtcTypeCount("回流链接数", listParams.getLoopConnNum())); + } } - return listNtcTypeCount; + return result; } + /** * DNS欺骗信息显示 5min/条、粒度5min * * @return */ @Override - public List<NtcEntranceReport> getDNSDeceiveInformation(String start, String end) { + public List<NtcEntranceReport> getDNSDeceiveInformation(String start, String end, int times) { + List<NtcEntranceReport> result = new ArrayList<>(); + HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); List<NtcEntranceReport> list = null; try { list = blockingDao.getDNSDeceiveInformationOnly(start, end); @@ -107,26 +118,30 @@ public class BlockingServiceImp implements BlockingService { logger.info("DNS欺骗信息显示\t查询异常\tserviceImpl"); } //如果此次没有查询到数据查上一个5min的数据 - if (list==null || list.size() == 0) { - getDNSDeceiveInformation(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5)); + if (list == null || list.size() == 0) { + //连续查询次数不大于max + if (times >= max) { + return null; + } + return getDNSDeceiveInformation(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); - List<NtcEntranceReport> result = new ArrayList<>(); - for (NtcEntranceReport ntcEntranceReport : list) { - UiSysDictInfo uiSysDictInfo = listDictUiSys.get(ntcEntranceReport.getType()); - if (uiSysDictInfo != null) { - if (languageChose == 2) { - //获取英文字段 - ntcEntranceReport.setType(uiSysDictInfo.getItemValue()); - result.add(ntcEntranceReport); - } else if (languageChose == 1) { - //中文 - ntcEntranceReport.setType(uiSysDictInfo.getItemDesc()); - result.add(ntcEntranceReport); - } else { - //俄文 - ntcEntranceReport.setType(uiSysDictInfo.getItemValue()); - result.add(ntcEntranceReport); + if (list != null && list.size() != 0) { + for (NtcEntranceReport ntcEntranceReport : list) { + UiSysDictInfo uiSysDictInfo = listDictUiSys.get(ntcEntranceReport.getType()); + if (uiSysDictInfo != null) { + if (languageChose == 2) { + //获取英文字段 + ntcEntranceReport.setType(uiSysDictInfo.getItemValue()); + result.add(ntcEntranceReport); + } else if (languageChose == 1) { + //中文 + ntcEntranceReport.setType(uiSysDictInfo.getItemDesc()); + result.add(ntcEntranceReport); + } else { + //俄文 + ntcEntranceReport.setType(uiSysDictInfo.getItemValue()); + result.add(ntcEntranceReport); + } } } } @@ -141,7 +156,8 @@ public class BlockingServiceImp implements BlockingService { * @return */ @Override - public List<TimeTypeCount> get24hAllBlockEachProtocol(String start, String end) { + public List<TimeTypeCount> get24hAllBlockEachProtocol(String start, String end, int times) { + ArrayList<TimeTypeCount> result = new ArrayList<>(); List<TimeTypeCount> list = null; try { list = blockingDao.get24hAllBlockEachProtocolOnly(start, end); @@ -150,29 +166,34 @@ public class BlockingServiceImp implements BlockingService { logger.info("24小时全国范围阻断协议信息\t查询异常\tserviceImpl"); } //若查询结果为空,查询上时间段的数据 - if (list==null || list.size() == 0) { - get24hAllBlockEachProtocol(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5)); + if (list == null || list.size() == 0) { + //连续查询次数不大于max + if (times >= max) { + return null; + } + return get24hAllBlockEachProtocol(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - HashMap<String, NtcServiceDict> listNtcService = listNtcService(); - ArrayList<TimeTypeCount> result = new ArrayList<>(); - for (TimeTypeCount timeTypeCount : list) { - String type = timeTypeCount.getType(); - if (type != null) { - //每条具体对象的字典字段 - NtcServiceDict ntcServiceDict = listNtcService.get(type); - if (ntcServiceDict != null) { - if (languageChose == 2) { - //获取英文字段 - timeTypeCount.setType(ntcServiceDict.getServiceNameEn()); - result.add(timeTypeCount); - } else if (languageChose == 1) { - //中文 - timeTypeCount.setType(ntcServiceDict.getServiceNameZh()); - result.add(timeTypeCount); - } else { - //俄文 - timeTypeCount.setType(ntcServiceDict.getServiceNameRu()); - result.add(timeTypeCount); + if (list != null && list.size() != 0) { + HashMap<String, NtcServiceDict> listNtcService = listNtcService(); + for (TimeTypeCount timeTypeCount : list) { + String type = timeTypeCount.getType(); + if (type != null) { + //每条具体对象的字典字段 + NtcServiceDict ntcServiceDict = listNtcService.get(type); + if (ntcServiceDict != null) { + if (languageChose == 2) { + //获取英文字段 + timeTypeCount.setType(ntcServiceDict.getServiceNameEn()); + result.add(timeTypeCount); + } else if (languageChose == 1) { + //中文 + timeTypeCount.setType(ntcServiceDict.getServiceNameZh()); + result.add(timeTypeCount); + } else { + //俄文 + timeTypeCount.setType(ntcServiceDict.getServiceNameRu()); + result.add(timeTypeCount); + } } } } @@ -188,7 +209,8 @@ public class BlockingServiceImp implements BlockingService { * @return */ @Override - public List<NtcDisReport> getDisBlockInformation(String start, String end) { + public List<NtcDisReport> getDisBlockInformation(String start, String end, int times) { + List<NtcDisReport> result = new ArrayList<>(); List<NtcDisReport> list1 = null; List<NtcDisReport> list2 = null; List<NtcDisReport> list3 = null; @@ -205,38 +227,43 @@ public class BlockingServiceImp implements BlockingService { list.addAll(list2); list.addAll(list3); //若查询结果为空,查询上时间段的数据 - if (list==null|| list.size() == 0) { - getDisBlockInformation(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5)); + if (list == null || list.size() == 0) { + //连续查询次数不大于max + if (times >= max) { + return null; + } + return getDisBlockInformation(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - List<NtcDisReport> result = new ArrayList<>(); - //业务表 - HashMap<String, NtcServiceDict> listNtcService = listNtcService(); - //局点表 - HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); - for (NtcDisReport ntcDisReport : list) { - //从字典表中拿出该对象映射的相关字段 - UiSysDictInfo uiSysDictInfo = listDictUiSys.get(ntcDisReport.getArea()); - if (uiSysDictInfo != null) { - //item_type=1表示地域 - if (uiSysDictInfo != null && uiSysDictInfo.getItemType() == 1) { - //从业务表中拿出该对象的相关字段 - NtcServiceDict ntcServiceDict = listNtcService.get(ntcDisReport.getType()); - if (ntcServiceDict != null) { - if (languageChose == 2) { - //设置type和area为英文名称字段 - ntcDisReport.setArea(uiSysDictInfo.getItemValue()); - ntcDisReport.setType(ntcServiceDict.getServiceNameEn()); - result.add(ntcDisReport); - } else if (languageChose == 1) { - //中文 - ntcDisReport.setArea(uiSysDictInfo.getItemDesc()); - ntcDisReport.setType(ntcServiceDict.getServiceNameZh()); - result.add(ntcDisReport); - } else { - //俄文 - ntcDisReport.setArea(uiSysDictInfo.getItemValue()); - ntcDisReport.setType(ntcServiceDict.getServiceNameRu()); - result.add(ntcDisReport); + if (list != null && list.size() != 0) { + //业务表 + HashMap<String, NtcServiceDict> listNtcService = listNtcService(); + //局点表 + HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); + for (NtcDisReport ntcDisReport : list) { + //从字典表中拿出该对象映射的相关字段 + UiSysDictInfo uiSysDictInfo = listDictUiSys.get(ntcDisReport.getArea()); + if (uiSysDictInfo != null) { + //item_type=1表示地域 + if (uiSysDictInfo != null && uiSysDictInfo.getItemType() == 1) { + //从业务表中拿出该对象的相关字段 + NtcServiceDict ntcServiceDict = listNtcService.get(ntcDisReport.getType()); + if (ntcServiceDict != null) { + if (languageChose == 2) { + //设置type和area为英文名称字段 + ntcDisReport.setArea(uiSysDictInfo.getItemValue()); + ntcDisReport.setType(ntcServiceDict.getServiceNameEn()); + result.add(ntcDisReport); + } else if (languageChose == 1) { + //中文 + ntcDisReport.setArea(uiSysDictInfo.getItemDesc()); + ntcDisReport.setType(ntcServiceDict.getServiceNameZh()); + result.add(ntcDisReport); + } else { + //俄文 + ntcDisReport.setArea(uiSysDictInfo.getItemValue()); + ntcDisReport.setType(ntcServiceDict.getServiceNameRu()); + result.add(ntcDisReport); + } } } } @@ -251,7 +278,8 @@ public class BlockingServiceImp implements BlockingService { * @return */ @Override - public List<HotStatistic> getAllHotStatistis(String start, String end) { + public List<HotStatistic> getAllHotStatistis(String start, String end, int times) { + ArrayList<HotStatistic> result = new ArrayList<>(); List<HotStatistic> list = null; try { list = blockingDao.getAllHotStatistisOnly(start, end); @@ -260,46 +288,50 @@ public class BlockingServiceImp implements BlockingService { logger.info("24小时内全国热力图"); } //如果此次没有查询到数据查上一个5min的数据 - if (list==null || list.size() == 0) { - getAllHotStatistis(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5)); + if (list == null || list.size() == 0) { + //连续查询次数不大于max + if (times >= max) { + return null; + } + getAllHotStatistis(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - HashMap<String, NtcServiceDict> listNtcService = listNtcService(); - HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); - ArrayList<HotStatistic> result = new ArrayList<>(); - for (HotStatistic hotStatistic : list) { - String area = hotStatistic.getArea(); - String type = hotStatistic.getType(); - if (area != null && type != null) { - //获得该对象对应的字典字段 - NtcServiceDict ntcServiceDict = listNtcService.get(type); - UiSysDictInfo uiSysDictInfo = listDictUiSys.get(area); - if (uiSysDictInfo != null && ntcServiceDict != null) { - //item=2是运营商 - int itemType = uiSysDictInfo.getItemType(); - if (itemType == 2) { - if (languageChose == 2) { - //英文 - hotStatistic.setArea(uiSysDictInfo.getItemValue()); - hotStatistic.setType(ntcServiceDict.getServiceNameEn()); - result.add(hotStatistic); + if (list != null && list.size() != 0) { + HashMap<String, NtcServiceDict> listNtcService = listNtcService(); + HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); + for (HotStatistic hotStatistic : list) { + String area = hotStatistic.getArea(); + String type = hotStatistic.getType(); + if (area != null && type != null) { + //获得该对象对应的字典字段 + NtcServiceDict ntcServiceDict = listNtcService.get(type); + UiSysDictInfo uiSysDictInfo = listDictUiSys.get(area); + if (uiSysDictInfo != null && ntcServiceDict != null) { + //item=2是运营商 + int itemType = uiSysDictInfo.getItemType(); + if (itemType == 2) { + if (languageChose == 2) { + //英文 + hotStatistic.setArea(uiSysDictInfo.getItemValue()); + hotStatistic.setType(ntcServiceDict.getServiceNameEn()); + result.add(hotStatistic); - } else if (languageChose == 1) { - //中文 - hotStatistic.setArea(uiSysDictInfo.getItemDesc()); - hotStatistic.setType(ntcServiceDict.getServiceNameZh()); - result.add(hotStatistic); - } else { - //俄文 - hotStatistic.setArea(uiSysDictInfo.getItemValue()); - hotStatistic.setType(ntcServiceDict.getServiceNameRu()); - result.add(hotStatistic); + } else if (languageChose == 1) { + //中文 + hotStatistic.setArea(uiSysDictInfo.getItemDesc()); + hotStatistic.setType(ntcServiceDict.getServiceNameZh()); + result.add(hotStatistic); + } else { + //俄文 + hotStatistic.setArea(uiSysDictInfo.getItemValue()); + hotStatistic.setType(ntcServiceDict.getServiceNameRu()); + result.add(hotStatistic); + } } } } } } return result; - } /** @@ -309,6 +341,7 @@ public class BlockingServiceImp implements BlockingService { */ @Override public List<PointMap> getPointMapOf10s() { + List<PointMap> result = new ArrayList<>(); List<PointMap> list = null; try { list = blockingDao.getPointMapOf10sOnly(); @@ -316,7 +349,6 @@ public class BlockingServiceImp implements BlockingService { e.printStackTrace(); logger.info("实时打点图\t查询异常\tserviceImpl"); } - List<PointMap> result = new ArrayList<>(); HashMap<String, NtcServiceDict> listNtcService = listNtcService(); for (PointMap pointMap : list) { String type = pointMap.getType(); @@ -350,7 +382,8 @@ public class BlockingServiceImp implements BlockingService { * @return */ @Override - public List<AreaCount> getDisBlockMap(String start, String end) { + public List<AreaCount> getDisBlockMap(String start, String end, int times) { + List<AreaCount> result = new ArrayList<>(); List<AreaCount> list1 = null; List<AreaCount> list2 = null; List<AreaCount> list3 = null; @@ -367,34 +400,38 @@ public class BlockingServiceImp implements BlockingService { list.addAll(list2); list.addAll(list3); //如果此次没有查询到数据查上一个5min的数据 - if (list==null || list.size() == 0) { - getDisBlockMap(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5)); + if (list == null || list.size() == 0) { + //连续查询次数不大于max + if (times >= max) { + return null; + } + return getDisBlockMap(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - List<AreaCount> result = new ArrayList<>(); - //局点表 - HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); - for (AreaCount areaCount : list) { - //查对应的局点表 - UiSysDictInfo uiSysDictInfo = listDictUiSys.get(areaCount.getArea()); - if (uiSysDictInfo != null) { - //1表示地域 - if (uiSysDictInfo.getItemType() == 1) { - if (languageChose == 2) { - //英文 - areaCount.setArea(uiSysDictInfo.getItemValue()); - result.add(areaCount); - } else if (languageChose == 1) { - //中文 - areaCount.setArea(uiSysDictInfo.getItemDesc()); - result.add(areaCount); - } else { - //俄文 - areaCount.setArea(uiSysDictInfo.getItemValue()); + if (list != null && list.size() != 0) { + //局点表 + HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); + for (AreaCount areaCount : list) { + //查对应的局点表 + UiSysDictInfo uiSysDictInfo = listDictUiSys.get(areaCount.getArea()); + if (uiSysDictInfo != null) { + //1表示地域 + if (uiSysDictInfo.getItemType() == 1) { + if (languageChose == 2) { + //英文 + areaCount.setArea(uiSysDictInfo.getItemValue()); + result.add(areaCount); + } else if (languageChose == 1) { + //中文 + areaCount.setArea(uiSysDictInfo.getItemDesc()); + result.add(areaCount); + } else { + //俄文 + areaCount.setArea(uiSysDictInfo.getItemValue()); + } } } } } - return result; } @@ -405,6 +442,7 @@ public class BlockingServiceImp implements BlockingService { */ @Override public List<CfgTypeCount> getAllCfgInfo() { + List<CfgTypeCount> result = new ArrayList<>(); List<CfgTypeCount> list = null; try { list = blockingDao.getAllCfgInfoOnly(); @@ -413,7 +451,6 @@ public class BlockingServiceImp implements BlockingService { logger.info("全国协议配置信息\t查询异常\tserviceImpl"); } HashMap<String, NtcServiceDict> listNtcService = listNtcService(); - List<CfgTypeCount> result = new ArrayList<>(); for (CfgTypeCount cfgTypeCount : list) { NtcServiceDict ntcServiceDict = listNtcService.get(cfgTypeCount.getType()); if (ntcServiceDict != null) { diff --git a/src/main/java/com/nis/galaxy/web/service/impl/BlockingTopNServiceImpl.java b/src/main/java/com/nis/galaxy/web/service/impl/BlockingTopNServiceImpl.java index a8e4928..ffa5719 100644 --- a/src/main/java/com/nis/galaxy/web/service/impl/BlockingTopNServiceImpl.java +++ b/src/main/java/com/nis/galaxy/web/service/impl/BlockingTopNServiceImpl.java @@ -27,7 +27,8 @@ public class BlockingTopNServiceImpl implements BlockingTopNService { MyLoad myLoad; @Value("${Language.Chose}") private int languageChose; - + //最大查询次数 + private int max = 3; //局点表 public HashMap<String, UiSysDictInfo> listDictUiSys() { @@ -46,80 +47,93 @@ public class BlockingTopNServiceImpl implements BlockingTopNService { /** * 1小时内全国阻断URLTOP10 + * * @param start * @param end * @return */ @Override - public List<NtcRejectUrlStatistic> getBlockTop10URLOf1h(String start, String end) { + public List<NtcRejectUrlStatistic> getBlockTop10URLOf1h(String start, String end, int times) { List<NtcRejectUrlStatistic> result = null; - try{ - result = blockingTopNDao.getBlockTop10URLOf1h(start, end); - }catch (Exception e){ + try { + result = blockingTopNDao.getBlockTop10URLOf1h(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("1小时内全国阻断URLTOP10\t查询异常\tserviceImpl"); } //如果此次没有查询到数据查上一个1h的数据 - if(result==null || result.size()==0){ - getBlockTop10URLOf1h(DateUtils.getBeforeNminOfTime(start,-60),DateUtils.getBeforeNminOfTime(end,-60)); + if (result == null || result.size() == 0) { + if (times >= max) { + return null; + } + return getBlockTop10URLOf1h(DateUtils.getBeforeNminOfTime(start, -60), DateUtils.getBeforeNminOfTime(end, -60), ++times); } return result; } /** * 1小时内全国阻断网站TOP10 + * * @param start * @param end * @return */ @Override - public List<NtcRejectWebsiteStatistic> getBlockTop10WebsiteOf1h(String start, String end) { + public List<NtcRejectWebsiteStatistic> getBlockTop10WebsiteOf1h(String start, String end, int times) { List<NtcRejectWebsiteStatistic> result = null; - try{ - result = blockingTopNDao.getBlockTop10WebsiteOf1h(start, end); - }catch (Exception e){ + try { + result = blockingTopNDao.getBlockTop10WebsiteOf1h(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("1小时内全国阻断网站TOP10\t查询异常\tserviceImpl"); } //如果此次没有查询到数据查上一个1h的数据 - if(result==null || result.size()==0){ - getBlockTop10WebsiteOf1h(DateUtils.getBeforeNminOfTime(start,-60),DateUtils.getBeforeNminOfTime(end,-60)); + if (result == null || result.size() == 0) { + if (times >= max) { + return null; + } + return getBlockTop10WebsiteOf1h(DateUtils.getBeforeNminOfTime(start, -60), DateUtils.getBeforeNminOfTime(end, -60), ++times); } return result; } + /** * 24小时内封堵标签TOP10 * * @return */ @Override - public List<NtcTagReport> getBlockTop10Tag24h(String start, String end) { - List<NtcTagReport> list =null; - try{ - list = blockingTopNDao.getBlockTop10Tag24hOnly(start, end); - }catch (Exception e){ + public List<NtcTagReport> getBlockTop10Tag24h(String start, String end, int times) { + List<NtcTagReport> result = new ArrayList<>(); + HashMap<String, UiTagDicInfo> listUiTagDicInfo = listUiTagDicInfo(); + List<NtcTagReport> list = null; + try { + list = blockingTopNDao.getBlockTop10Tag24hOnly(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("24小时内封堵标签TOP10\t查询异常\tserviceImpl"); } //如果此次没有查询到数据查上一个1h的数据 - if(list==null || list.size()==0){ - getBlockTop10Tag24h(DateUtils.getBeforeNminOfTime(start,-60),DateUtils.getBeforeNminOfTime(end,-60)); + if (list == null || list.size() == 0) { + if (times >= max) { + return null; + } + return getBlockTop10Tag24h(DateUtils.getBeforeNminOfTime(start, -60), DateUtils.getBeforeNminOfTime(end, -60), ++times); } - List<NtcTagReport> result = new ArrayList<>(); - HashMap<String, UiTagDicInfo> listUiTagDicInfo = listUiTagDicInfo(); - for (NtcTagReport ntcTagReport : list) { - String type = ntcTagReport.getType(); - UiTagDicInfo uiTagDicInfo = listUiTagDicInfo.get(type); - if (type != null && uiTagDicInfo != null) { - int itemType = uiTagDicInfo.getItemType(); - if (itemType == 3) { - //取字典表中的字段值 - ntcTagReport.setType(uiTagDicInfo.getItemValue()); - result.add(ntcTagReport); + if (list != null && list.size() != 0) { + for (NtcTagReport ntcTagReport : list) { + String type = ntcTagReport.getType(); + UiTagDicInfo uiTagDicInfo = listUiTagDicInfo.get(type); + if (type != null && uiTagDicInfo != null) { + int itemType = uiTagDicInfo.getItemType(); + if (itemType == 3) { + //取字典表中的字段值 + ntcTagReport.setType(uiTagDicInfo.getItemValue()); + result.add(ntcTagReport); + } } } } - return result; } @@ -131,52 +145,57 @@ public class BlockingTopNServiceImpl implements BlockingTopNService { * @return */ @Override - public List<AreaBlockProtocol> getAreaBlockTop10ProtocolOf24(String start, String end) { + public List<AreaBlockProtocol> getAreaBlockTop10ProtocolOf24(String start, String end, int times) { HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); HashMap<String, NtcServiceDict> listNtcService = listNtcService(); ArrayList<AreaBlockProtocol> result = new ArrayList<>(); //查询日报表 List<AreaBlockProtocol> list = null; - try{ - list = blockingTopNDao.getAreaBlockTop10ProtocolOf24hDayOnly(start, end); - if (list == null) { - //查分钟报 - list = blockingTopNDao.getAreaBlockTop10ProtocolOf24hOnly(start, end); - } - }catch (Exception e){ + try { + list = blockingTopNDao.getAreaBlockTop10ProtocolOf24hDayOnly(start, end); + if (list == null) { + //查分钟报 + list = blockingTopNDao.getAreaBlockTop10ProtocolOf24hOnly(start, end); + } + } catch (Exception e) { e.printStackTrace(); logger.info("24小时区域阻断协议TOP10\t查询异常\tserviceImpl"); } //查询数据为空则查询上一天数据 - if(list==null || list.size()==0){ - getAreaBlockTop10ProtocolOf24(DateUtils.getBeforeNminOfTime(start,-60*24),DateUtils.getBeforeNminOfTime(end,-60*24)); + if (list == null || list.size() == 0) { + if (times >= max) { + return null; + } + return getAreaBlockTop10ProtocolOf24(DateUtils.getBeforeNminOfTime(start, -60 * 24), DateUtils.getBeforeNminOfTime(end, -60 * 24), ++times); } - //映射 - for (AreaBlockProtocol areaBlockProtocol : list) { - String type = areaBlockProtocol.getType(); - String area = areaBlockProtocol.getArea(); - if (type != null && area != null) { - NtcServiceDict ntcServiceDict = listNtcService.get(type); - UiSysDictInfo uiSysDictInfo = listDictUiSys.get(area); - if (ntcServiceDict != null && uiSysDictInfo != null) { - //获取itemType=1位地域 - int itemType = uiSysDictInfo.getItemType(); - if (itemType == 1) { - if (languageChose == 2) { - //设置英文字段 - areaBlockProtocol.setType(ntcServiceDict.getServiceNameEn()); - areaBlockProtocol.setArea(uiSysDictInfo.getItemValue()); - result.add(areaBlockProtocol); - } else if (languageChose == 1) { - //中文 - areaBlockProtocol.setType(ntcServiceDict.getServiceNameZh()); - areaBlockProtocol.setArea(uiSysDictInfo.getItemDesc()); - result.add(areaBlockProtocol); - } else { - //俄文 - areaBlockProtocol.setType(ntcServiceDict.getServiceNameRu()); - areaBlockProtocol.setArea(uiSysDictInfo.getItemValue()); - result.add(areaBlockProtocol); + if (list != null && list.size() != 0) { + //映射 + for (AreaBlockProtocol areaBlockProtocol : list) { + String type = areaBlockProtocol.getType(); + String area = areaBlockProtocol.getArea(); + if (type != null && area != null) { + NtcServiceDict ntcServiceDict = listNtcService.get(type); + UiSysDictInfo uiSysDictInfo = listDictUiSys.get(area); + if (ntcServiceDict != null && uiSysDictInfo != null) { + //获取itemType=1位地域 + int itemType = uiSysDictInfo.getItemType(); + if (itemType == 1) { + if (languageChose == 2) { + //设置英文字段 + areaBlockProtocol.setType(ntcServiceDict.getServiceNameEn()); + areaBlockProtocol.setArea(uiSysDictInfo.getItemValue()); + result.add(areaBlockProtocol); + } else if (languageChose == 1) { + //中文 + areaBlockProtocol.setType(ntcServiceDict.getServiceNameZh()); + areaBlockProtocol.setArea(uiSysDictInfo.getItemDesc()); + result.add(areaBlockProtocol); + } else { + //俄文 + areaBlockProtocol.setType(ntcServiceDict.getServiceNameRu()); + areaBlockProtocol.setArea(uiSysDictInfo.getItemValue()); + result.add(areaBlockProtocol); + } } } } @@ -188,45 +207,53 @@ public class BlockingTopNServiceImpl implements BlockingTopNService { /** * 5分钟内全国阻断URLTOP10 + * * @param start * @param end * @return */ @Override - public List<NtcUrlIpCount> getBlockTop10URLOf5m(String start, String end) { - List<NtcUrlIpCount> result =null; - try{ - result = blockingTopNDao.getBlockTop10URLOf5m(start, end); + public List<NtcUrlIpCount> getBlockTop10URLOf5m(String start, String end, int times) { + List<NtcUrlIpCount> result = null; + try { + result = blockingTopNDao.getBlockTop10URLOf5m(start, end); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); logger.info("5分钟内全国阻断URLTOP10\t查询异常\tserviceImpl"); } //查询不到时,继续向前一段时间 - if(result==null || result.size()==0){ - return getBlockTop10URLOf5m(DateUtils.getBeforeNminOfTime(start,-5),DateUtils.getBeforeNminOfTime(end,-5)); + if (result == null || result.size() == 0) { + if (times >= max) { + return null; + } + return getBlockTop10URLOf5m(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } return result; } /** * 5分钟内全国阻断website + * * @param start * @param end * @return */ @Override - public List<NtcUrlIpCount> getBlockTop10WebsiteOf5m(String start, String end) { - List<NtcUrlIpCount> result =null; - try{ - result = blockingTopNDao.getBlockTop10WebsiteOf5m(start, end); - }catch (Exception e){ + public List<NtcUrlIpCount> getBlockTop10WebsiteOf5m(String start, String end, int times) { + List<NtcUrlIpCount> result = null; + try { + result = blockingTopNDao.getBlockTop10WebsiteOf5m(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("5分钟内全国阻断website\t查询异常\tserviceImpl"); } //查询不到时,继续向前一段时间 - if(result==null || result.size()==0){ - return getBlockTop10WebsiteOf5m(DateUtils.getBeforeNminOfTime(start,-5),DateUtils.getBeforeNminOfTime(end,-5)); + if (result == null || result.size() == 0) { + if (times >= max) { + return null; + } + return getBlockTop10WebsiteOf5m(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } return result; } @@ -239,30 +266,35 @@ public class BlockingTopNServiceImpl implements BlockingTopNService { * @return */ @Override - public List<NtcTagReport> getBlockTop10Tag5m(String start, String end) { + public List<NtcTagReport> getBlockTop10Tag5m(String start, String end, int times) { + List<NtcTagReport> result = new ArrayList<>(); + HashMap<String, UiTagDicInfo> listUiTagDicInfo = listUiTagDicInfo(); List<NtcTagReport> list = null; - try{ - list = blockingTopNDao.getBlockTop10Tag5mOnly(start, end); - }catch (Exception e){ + try { + list = blockingTopNDao.getBlockTop10Tag5mOnly(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("5分钟内全国阻断标签TOP10\t查询异常\tserviceImpl"); } //查询不到继续向前一段时间 - if(list==null || list.size()==0){ - return getBlockTop10Tag5m(DateUtils.getBeforeNminOfTime(start,-5),DateUtils.getBeforeNminOfTime(end,-5)); + if (list == null || list.size() == 0) { + if (times >= max) { + return null; + } + return getBlockTop10Tag5m(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - HashMap<String, UiTagDicInfo> listUiTagDicInfo =listUiTagDicInfo(); - List<NtcTagReport> result = new ArrayList<>(); - for (NtcTagReport ntcTagReport : list) { - String type = ntcTagReport.getType(); - if (type != null && listUiTagDicInfo != null) { - UiTagDicInfo uiTagDicInfo = listUiTagDicInfo.get(type); - if (uiTagDicInfo != null) { - int itemType = uiTagDicInfo.getItemType(); - //条件是属性item=3的 - if (itemType == 3) { - ntcTagReport.setType(uiTagDicInfo.getItemValue()); - result.add(ntcTagReport); + if (list != null && list.size() != 0) { + for (NtcTagReport ntcTagReport : list) { + String type = ntcTagReport.getType(); + if (type != null && listUiTagDicInfo != null) { + UiTagDicInfo uiTagDicInfo = listUiTagDicInfo.get(type); + if (uiTagDicInfo != null) { + int itemType = uiTagDicInfo.getItemType(); + //条件是属性item=3的 + if (itemType == 3) { + ntcTagReport.setType(uiTagDicInfo.getItemValue()); + result.add(ntcTagReport); + } } } } diff --git a/src/main/java/com/nis/galaxy/web/service/impl/NetflowServiceImpl.java b/src/main/java/com/nis/galaxy/web/service/impl/NetflowServiceImpl.java index 6dde531..4eb2ad3 100644 --- a/src/main/java/com/nis/galaxy/web/service/impl/NetflowServiceImpl.java +++ b/src/main/java/com/nis/galaxy/web/service/impl/NetflowServiceImpl.java @@ -32,6 +32,8 @@ public class NetflowServiceImpl implements NetflowService { @Value("${Language.Chose}") private int languageChose; + private int max = 3; + //协议表 public HashMap<String, String> listProtocolDict() { return myLoad.listProtocolDict; @@ -50,27 +52,33 @@ public class NetflowServiceImpl implements NetflowService { * @return */ @Override - public List<TimeTypeCount> getNetflowStatistic5m(String start, String end) { - List<TimeTypeCount> list =null; - try{ - list = netflowDao.getNetflowStatistic5mOnly(start, end); - }catch (Exception e){ + public List<TimeTypeCount> getNetflowStatistic5m(String start, String end, int times) { + List<TimeTypeCount> result = new ArrayList<>(); + HashMap<String, String> listProtocolDict = listProtocolDict(); + List<TimeTypeCount> list = null; + try { + list = netflowDao.getNetflowStatistic5mOnly(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("5分钟内网络流量统计\t查询异常\tserviceImpl"); } - if(list==null || list.size()==0){ - getNetflowStatistic5m(DateUtils.getBeforeNminOfTime(start,-5),DateUtils.getBeforeNminOfTime(end,-5)); + if (list == null || list.size() == 0) { + if (times >= max) { + return null; + } + return getNetflowStatistic5m(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - List<TimeTypeCount> result = new ArrayList<>(); - HashMap<String, String> listProtocolDict = listProtocolDict(); - for (TimeTypeCount timeTypeCount : list) { - String type = timeTypeCount.getType(); - if (type != null && listProtocolDict != null) { - String s = listProtocolDict.get(type); - if (s != null) { - //协议类型字典表 - timeTypeCount.setType(s); - result.add(timeTypeCount); + if (list != null && list.size() != 0) { + + for (TimeTypeCount timeTypeCount : list) { + String type = timeTypeCount.getType(); + if (type != null && listProtocolDict != null) { + String s = listProtocolDict.get(type); + if (s != null) { + //协议类型字典表 + timeTypeCount.setType(s); + result.add(timeTypeCount); + } } } } @@ -85,25 +93,29 @@ public class NetflowServiceImpl implements NetflowService { * @return */ @Override - public List<NetflowProtocol> getProtocolStatisticOf1h(String start, String end) { + public List<NetflowProtocol> getProtocolStatisticOf1h(String start, String end,int times) { + List<NetflowProtocol> result = new ArrayList<>(); + HashMap<String, String> listProtocolDict = listProtocolDict(); List<NetflowProtocol> list = null; - try{ - list = netflowDao.getProtocolStatisticOf1hOnly(start, end); - }catch (Exception e){ + try { + list = netflowDao.getProtocolStatisticOf1hOnly(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("1小时内网络协议统计\t查询异常\tserviceImpl"); } - if(list==null || list.size()==0){ - getProtocolStatisticOf1h(DateUtils.getBeforeNminOfTime(start,-5),DateUtils.getBeforeNminOfTime(end,-5)); + if (list == null || list.size() == 0) { + if(times>=max){ + return getProtocolStatisticOf1h(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5),++times); + } } - HashMap<String, String> listProtocolDict = listProtocolDict(); - List<NetflowProtocol> result = new ArrayList<>(); - for (NetflowProtocol netflowProtocol : list) { - String type = netflowProtocol.getType(); - if (type != null && listProtocolDict != null) { - //与协议类型的字典对应 - netflowProtocol.setType(listProtocolDict.get(type)); - result.add(netflowProtocol); + if(list!=null && list.size()!=0){ + for (NetflowProtocol netflowProtocol : list) { + String type = netflowProtocol.getType(); + if (type != null && listProtocolDict != null) { + //与协议类型的字典对应 + netflowProtocol.setType(listProtocolDict.get(type)); + result.add(netflowProtocol); + } } } return result; @@ -117,36 +129,41 @@ public class NetflowServiceImpl implements NetflowService { * @return */ @Override - public List<IpActiveInfo> getIpActiveInfoOf5min(String start, String end) { + public List<IpActiveInfo> getIpActiveInfoOf5min(String start, String end,int times) { + List<IpActiveInfo> result = new ArrayList<>(); + HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); List<IpActiveInfo> list = null; - try{ - list = netflowDao.getIpActiveInfoOf5minOnly(start, end); + try { + list = netflowDao.getIpActiveInfoOf5minOnly(start, end); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); logger.info("5分钟内活跃IP信息\t查询异常\tserviceImpl"); } - if(list==null || list.size()==0){ - getIpActiveInfoOf5min(DateUtils.getBeforeNminOfTime(start,-5),DateUtils.getBeforeNminOfTime(end,-5)); + if (list == null || list.size() == 0) { + if(times>=max){ + return null; + } + return getIpActiveInfoOf5min(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5),++times); } - List<IpActiveInfo> result = new ArrayList<>(); - HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); - for (IpActiveInfo ipActiveInfo : list) { - String area = ipActiveInfo.getArea(); - if (area != null && listDictUiSys != null) { - UiSysDictInfo dict = listDictUiSys.get(area); - //item_type=1表示地域 - if (dict != null && dict.getItemType()==1) { - if (languageChose == 2) { - //英文 - ipActiveInfo.setArea(dict.getItemValue()); - result.add(ipActiveInfo); - }else if(languageChose==1){ - ipActiveInfo.setArea(dict.getItemDesc()); - result.add(ipActiveInfo); - }else { - ipActiveInfo.setArea(dict.getItemValue()); - result.add(ipActiveInfo); + if(list !=null && list.size()!=0){ + for (IpActiveInfo ipActiveInfo : list) { + String area = ipActiveInfo.getArea(); + if (area != null && listDictUiSys != null) { + UiSysDictInfo dict = listDictUiSys.get(area); + //item_type=1表示地域 + if (dict != null && dict.getItemType() == 1) { + if (languageChose == 2) { + //英文 + ipActiveInfo.setArea(dict.getItemValue()); + result.add(ipActiveInfo); + } else if (languageChose == 1) { + ipActiveInfo.setArea(dict.getItemDesc()); + result.add(ipActiveInfo); + } else { + ipActiveInfo.setArea(dict.getItemValue()); + result.add(ipActiveInfo); + } } } } diff --git a/src/main/java/com/nis/galaxy/web/service/impl/NetflowTopNServiceImpl.java b/src/main/java/com/nis/galaxy/web/service/impl/NetflowTopNServiceImpl.java index 34eab97..b909c8a 100644 --- a/src/main/java/com/nis/galaxy/web/service/impl/NetflowTopNServiceImpl.java +++ b/src/main/java/com/nis/galaxy/web/service/impl/NetflowTopNServiceImpl.java @@ -27,8 +27,7 @@ public class NetflowTopNServiceImpl implements NetflowTopNService { MyLoad myLoad; @Value("${Language.Chose}") private int languageChose; - - + private int max = 3; //局点表 public HashMap<String, UiSysDictInfo> listDictUiSys() { @@ -37,42 +36,49 @@ public class NetflowTopNServiceImpl implements NetflowTopNService { /** * 5分钟内活跃IP流量TOP10 + * * @param start * @param end * @return */ @Override - public List<IpActiveInt> getIpActiveStatisticOf5m(String start,String end) { + public List<IpActiveInt> getIpActiveStatisticOf5m(String start, String end, int times) { + List<IpActiveInt> result = new ArrayList<>(); + HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); List<IpActiveInt> list = null; - try{ - list = netflowTopNDao.getIpActiveStatisticOf5mOnly(start, end); - }catch (Exception e){ + try { + list = netflowTopNDao.getIpActiveStatisticOf5mOnly(start, end); + } catch (Exception e) { e.printStackTrace(); logger.info("5分钟内活跃IP流量TOP10\t查询异常\tserviceImpl"); } - if(list==null || list.size()==0){ - getIpActiveStatisticOf5m(DateUtils.getBeforeNminOfTime(start,-5),DateUtils.getBeforeNminOfTime(end,-5)); + if (list == null || list.size() == 0) { + if (times >= max) { + return null; + } + getIpActiveStatisticOf5m(DateUtils.getBeforeNminOfTime(start, -5), DateUtils.getBeforeNminOfTime(end, -5), ++times); } - List<IpActiveInt> result = new ArrayList<>(); - HashMap<String, UiSysDictInfo> listDictUiSys = listDictUiSys(); - for (IpActiveInt ipActiveInt : list) { - String area = ipActiveInt.getArea(); - if(area!=null && listDictUiSys!=null){ - UiSysDictInfo dict = listDictUiSys.get(area); - if(dict!=null && dict.getItemType()==1){ - if(languageChose==2){ - ipActiveInt.setArea(dict.getItemValue()); - result.add(ipActiveInt); - }else if(languageChose==1){ - ipActiveInt.setArea(dict.getItemDesc()); - result.add(ipActiveInt); - }else{ - ipActiveInt.setArea(dict.getItemDesc()); - result.add(ipActiveInt); + if (list != null && list.size() != 0) { + for (IpActiveInt ipActiveInt : list) { + String area = ipActiveInt.getArea(); + if (area != null && listDictUiSys != null) { + UiSysDictInfo dict = listDictUiSys.get(area); + if (dict != null && dict.getItemType() == 1) { + if (languageChose == 2) { + ipActiveInt.setArea(dict.getItemValue()); + result.add(ipActiveInt); + } else if (languageChose == 1) { + ipActiveInt.setArea(dict.getItemDesc()); + result.add(ipActiveInt); + } else { + ipActiveInt.setArea(dict.getItemDesc()); + result.add(ipActiveInt); + } } } } + } return result; - } + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2d8c558..bab8704 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,7 +8,7 @@ spring: datasource: type: com.alibaba.druid.pool.DruidDataSource # 当前数据源操作类型 driver-class-name: org.mariadb.jdbc.Driver # mariadb驱动包 - url: jdbc:mariadb://192.168.10.204:3306/galaxy_ww # 数据库名称 + url: jdbc:mariadb://10.0.6.249:3306/galaxy # 数据库名称 username: ENC(L0d9FkUJX6BIaxPyy57bqQ==) password: ENC(0WPm6y8me4cavVjpk2BuBQ==) maxWait: 20000 |
