diff options
| author | wangwei <[email protected]> | 2019-01-10 19:32:16 +0800 |
|---|---|---|
| committer | wangwei <[email protected]> | 2019-01-10 19:32:16 +0800 |
| commit | 64eb016fa0fa12314a61eceec3294cc6f1a7ea1d (patch) | |
| tree | e24f62315d75f4c1c48f92b3dc43d64561edeabf | |
| parent | acf2aff5ccfda32f7c979fb8d2323acd84521764 (diff) | |
https监控接口 替换为 网站统计接口
5 files changed, 60 insertions, 7 deletions
diff --git a/src/main/java/com/nis/galaxy/template/ForEventsInterface.java b/src/main/java/com/nis/galaxy/template/ForEventsInterface.java index 644f4dc..a98e753 100644 --- a/src/main/java/com/nis/galaxy/template/ForEventsInterface.java +++ b/src/main/java/com/nis/galaxy/template/ForEventsInterface.java @@ -500,7 +500,7 @@ public class ForEventsInterface { } /** - * HTTPS监控TOP10 + * 网站统计__暂时先用https监控的tag标签 */ @Scheduled(cron = "${1h.scheduled.cron.plan}") @SchedulerLock(name = "https.monitor", lockAtLeastForString = "PT20M", lockAtMostForString = "PT40M") @@ -508,13 +508,12 @@ public class ForEventsInterface { if (!Boolean.parseBoolean(scheduledEventsEnable)) { return; } - String logMark = "HTTPS监控TOP10"; + String logMark = "网站统计_暂时用https监控tag标签"; Date end = DateUtil.getFormatHour(new Date()); Date start = DateUtil.getSomeHour(end, -1); List contentValue = null; - String type = "HttpsMonitor"; try { - contentValue = eventsService.getTypeMonitorReject(start, end, type); + contentValue = eventsService.getFocusWebsite(start, end, logMark); } catch (Exception e) { logger.error(logMark + "\t查询异常\trestTemplate", e); } diff --git a/src/main/java/com/nis/galaxy/web/dao/EventsDao.java b/src/main/java/com/nis/galaxy/web/dao/EventsDao.java index 40c0794..fa5a6cd 100644 --- a/src/main/java/com/nis/galaxy/web/dao/EventsDao.java +++ b/src/main/java/com/nis/galaxy/web/dao/EventsDao.java @@ -62,4 +62,8 @@ public interface EventsDao { List<EventsPortInfo> getPortInfo(@Param("push") Date push, @Param("start") Date start, @Param("end") Date end); Date getPortInfoLastTime(@Param("end") Date end); + + List<EventsSpecificWebsites> getFocusWebsite(@Param("push") Date push, @Param("start") Date start, @Param("end") Date end); + + Date getFocusWebsiteLastTime(@Param("end")Date end); } diff --git a/src/main/java/com/nis/galaxy/web/service/EventsService.java b/src/main/java/com/nis/galaxy/web/service/EventsService.java index 15c2e89..e22fac4 100644 --- a/src/main/java/com/nis/galaxy/web/service/EventsService.java +++ b/src/main/java/com/nis/galaxy/web/service/EventsService.java @@ -61,8 +61,14 @@ public interface EventsService { List<EventsSpecificWebsites> getSpecificWebsites(Date push,String logMark); - - List<EventsSpecificWebsites> getFocusWebsite(String start, String end); + /** + * 网站统计 + * @param start + * @param end + * @param logMark + * @return + */ + List<EventsSpecificWebsites> getFocusWebsite(Date start, Date end,String logMark); /** diff --git a/src/main/java/com/nis/galaxy/web/service/impl/EventsServiceImpl.java b/src/main/java/com/nis/galaxy/web/service/impl/EventsServiceImpl.java index 4062e29..d5fb963 100644 --- a/src/main/java/com/nis/galaxy/web/service/impl/EventsServiceImpl.java +++ b/src/main/java/com/nis/galaxy/web/service/impl/EventsServiceImpl.java @@ -306,6 +306,41 @@ public class EventsServiceImpl implements EventsService { } /** + * 网站统计 + * @param start + * @param end + * @param logMark + * @return + */ + @Override + public List<EventsSpecificWebsites> getFocusWebsite(Date start, Date end,String logMark) { + long timeMillisStart = System.currentTimeMillis(); + List<EventsSpecificWebsites> list = new ArrayList<>(); + try { + list = eventsDao.getFocusWebsite(start,start,end); + } catch (Exception e) { + logger.error(logMark + "\t查询异常\tserviceImpl", e); + } + if (ListUtils.isEmptyList(list) && ConfigUtil.recentData) { + logger.warn("{}\t{}至{}\t期间无数据\t查询最近数据", logMark, start, end); + try { + Date startLastTime = eventsDao.getFocusWebsiteLastTime(end); + if (startLastTime != null) { + startLastTime = DateUtil.getFormatHour(startLastTime); + Date endLastTime = DateUtil.getSomeHour(startLastTime, 1); + list = eventsDao.getFocusWebsite(start,startLastTime, endLastTime); + } else { + logger.warn(logMark + "\t无数据"); + } + } catch (Exception e) { + logger.error(logMark + "\t最近数据\t查询异常\tserviceImpl", e); + } + } + logger.info("{}耗时\t{}", logMark, (System.currentTimeMillis() - timeMillisStart)); + return list; + } + + /** * 事件监测 * * @param logMark diff --git a/src/main/resources/mybatis/mapper/EventsMapper.xml b/src/main/resources/mybatis/mapper/EventsMapper.xml index 0b84ec7..640f17c 100644 --- a/src/main/resources/mybatis/mapper/EventsMapper.xml +++ b/src/main/resources/mybatis/mapper/EventsMapper.xml @@ -119,7 +119,7 @@ <select id="getFocusWebsite" resultType="com.nis.galaxy.domain.EventsSpecificWebsites"> <![CDATA[ - SELECT #{end} AS time,t.website AS name,COALESCE(SUM(s.link_sum),0) AS num + SELECT #{push} AS time,t.website AS name,COALESCE(SUM(s.link_sum),0) AS num FROM (SELECT t.id,w.website FROM ui_website_domain_topic t LEFT JOIN (SELECT item_code webid,item_value website @@ -391,6 +391,15 @@ LIMIT 1 ]]> </select> + <select id="getFocusWebsiteLastTime" resultType="java.util.Date"> + <![CDATA[ + SELECT stat_time + FROM TRAFFIC_HTTP_STATISTIC + WHERE stat_time < #{end} + ORDER BY stat_time DESC + LIMIT 1 + ]]> + </select> <!--时间:端口信息--> <select id="getPortInfoLastTime" resultType="java.util.Date"> </select> |
