1:修改网站流量统计中不查询link_num和pktcount的值

This commit is contained in:
renkaige
2018-12-17 16:28:43 +06:00
parent 38c662f87c
commit 092d1ed317
3 changed files with 10 additions and 15 deletions

View File

@@ -24,6 +24,7 @@ public interface TrafficHttpStatisticDao {
@Param("endTime") Date endTime);
List<Map> getDomainByTopicList(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
List<Map> getHttpStatisticNoLinkAndPkt(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
List<Map> getTrafficHttpStatistic(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
List getIdByWebSiteId(@Param("websiteId") Integer websiteId);
}

View File

@@ -59,13 +59,19 @@
</select>
<!--获取上个时间段该网站站域名流量的数据量 -->
<select id="getHttpStatisticNoLinkAndPkt" resultType="java.util.HashMap">
select web_id webId,
SUM(c2s_byte_len + s2c_byte_len) byteCount from
traffic_http_statistic t where
<![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} group by t.web_id ]]>
</select>
<select id="getTrafficHttpStatistic" resultType="java.util.HashMap">
select web_id webId,
SUM(c2s_byte_len + s2c_byte_len) byteCount,
sum(c2s_pkt_num + s2c_pkt_num) pktCount,
link_num linkNum from
traffic_http_statistic t where
<![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} group by t.web_id,link_num order by byteCount]]>
<![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} group by t.web_id,link_num]]>
</select>

View File

@@ -852,14 +852,12 @@ public class DashboardService extends BaseService {
Set<Long> set = new HashSet<>();
Map<Long, List<Map>> countAndViewMap = new HashMap<>();// 存储count和map的对应关系,后面根据count过滤,获取top10的count
List<Map> webIdAndCountList = trafficHttpStatisticDao.getTrafficHttpStatistic(beginDate, endDate);// 获取最近一小时的webid和count的关系
List<Map> prevWebIdAndCountList = trafficHttpStatisticDao.getTrafficHttpStatistic(getBeforeByHourTime(2),
List<Map> webIdAndCountList = trafficHttpStatisticDao.getHttpStatisticNoLinkAndPkt(beginDate, endDate);// 获取最近一小时的webid和count的关系
List<Map> prevWebIdAndCountList = trafficHttpStatisticDao.getHttpStatisticNoLinkAndPkt(getBeforeByHourTime(2),
beginDate);// 获取最近一小时的webid和count的关系
for (String websiteServiceId : websiteIdAndIdMap.keySet()) {// 遍历上面获取的websiteServiceId和id的对应关系,拼接json
Map viewMap = new HashMap<>();
long count = 0l;// 记录当前websiteServiceId所有的count
long linkNum = 0l;//
long packets = 0l;//
long prevCount = 0l;// 记录当前websiteServiceId所有的count
List<String> idList = websiteIdAndIdMap.get(websiteServiceId);// 根据websiteServiceId获取对应的id
for (String id : idList) {
@@ -867,17 +865,9 @@ public class DashboardService extends BaseService {
String webId = String.valueOf(webIdAndCountMap.get("webId"));
if (webId != null && webId.equals(id)) {// 如果webid和id相等则获取count数据并统计
String countStr = String.valueOf(webIdAndCountMap.get("byteCount"));
String linkNumStr = String.valueOf(webIdAndCountMap.get("linkNum"));
String packetsStr = String.valueOf(webIdAndCountMap.get("pktCount"));
if (countStr != null) {
count += Long.parseLong(countStr);// 将count累加
}
if (linkNumStr != null) {
linkNum += Long.parseLong(linkNumStr);// 将count累加
}
if (packetsStr != null) {
packets += Long.parseLong(packetsStr);// 将count累加
}
}
}
for (Map webIdAndCountMap : prevWebIdAndCountList) {// 遍历webid和count
@@ -893,8 +883,6 @@ public class DashboardService extends BaseService {
}
viewMap.put("websiteServiceId", websiteServiceId);
viewMap.put("count", count);
viewMap.put("linkNum", linkNum);
viewMap.put("packets", packets);
viewMap.put("pktNum", 0);
viewMap.put("byteLen", 0);
viewMap.put("preCount", prevCount);