1:更改首页流量统计的sql
2:更改topic数据的获取方式 3:修改sql中where错误 4:修改表结构sql
This commit is contained in:
@@ -161,8 +161,10 @@ CREATE TABLE `ui_code_protocol_type_dic` (
|
|||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`protocol_type` varchar(255) DEFAULT '',
|
`protocol_type` varchar(255) DEFAULT '',
|
||||||
`view_code` varchar(255) DEFAULT NULL,
|
`view_code` varchar(255) DEFAULT NULL,
|
||||||
|
`service_id` int(11) DEFAULT NULL,
|
||||||
|
`remarks` varchar(255) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/code_protocol_type_dic';
|
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/code_protocol_type_dic';
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE `ui_code_service_type_dic` (
|
CREATE TABLE `ui_code_service_type_dic` (
|
||||||
|
|||||||
@@ -32,8 +32,17 @@
|
|||||||
</select>
|
</select>
|
||||||
<!-- 根据最近时间条获取带宽,进出口流量 -->
|
<!-- 根据最近时间条获取带宽,进出口流量 -->
|
||||||
<select id="getNetFlowPortInfoNew" resultType="java.util.HashMap">
|
<select id="getNetFlowPortInfoNew" resultType="java.util.HashMap">
|
||||||
SELECT IFNULL(SUM(c2s_byte_len),0) AS inoctets ,IFNULL(SUM(s2c_byte_len),0) AS outoctets FROM traffic_trans_statistic
|
SELECT SUM(total_traffic.inoctets) AS inoctets ,SUM(total_traffic.outoctets) AS outoctets FROM (
|
||||||
WHERE stat_time > DATE_SUB(#{statTime}, INTERVAL 1 HOUR)
|
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
|
||||||
|
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=1
|
||||||
|
UNION ALL
|
||||||
|
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
|
||||||
|
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=2
|
||||||
|
) total_traffic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<!-- 获取近五分钟的带宽根据ip46,协议 tcp,udp变化 -->
|
<!-- 获取近五分钟的带宽根据ip46,协议 tcp,udp变化 -->
|
||||||
<select id="getBandwidthTrans" resultMap="BandwidthResultMap">
|
<select id="getBandwidthTrans" resultMap="BandwidthResultMap">
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ public interface TrafficHttpStatisticDao {
|
|||||||
List<Map> getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime);
|
List<Map> getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime);
|
||||||
Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime);
|
Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId,@Param("statTime") Date statTime);
|
||||||
|
|
||||||
List<Map> getDomainByTopicList(@Param("statTime") Date statTime);
|
List<Map> getDomainByTopicList(@Param("statTime") Date statTime,@Param("endTime")Date endTime);
|
||||||
|
|
||||||
|
List<Map> getUiWebsiteDomainTopicList( );
|
||||||
|
|
||||||
List<Map> getDomainByTopicId(@Param("topicId")Object TopicId,@Param("statTime")Date statTime);
|
List<Map> getDomainByTopicId( @Param("statTime")Date statTime ,@Param("endTime")Date endTime);
|
||||||
}
|
}
|
||||||
@@ -1,87 +1,106 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.nis.web.dao.dashboard.TrafficHttpStatisticDao">
|
<mapper
|
||||||
<resultMap id="BaseResultMap" type="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
namespace="com.nis.web.dao.dashboard.TrafficHttpStatisticDao">
|
||||||
<id column="stat_id" jdbcType="INTEGER" property="statId" />
|
<resultMap id="BaseResultMap"
|
||||||
<result column="link_num" jdbcType="INTEGER" property="linkNum" />
|
type="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||||
<result column="web_id" jdbcType="INTEGER" property="webId" />
|
<id column="stat_id" jdbcType="INTEGER" property="statId" />
|
||||||
<result column="c2s_pkt_num" jdbcType="BIGINT" property="c2sPktNum" />
|
<result column="link_num" jdbcType="INTEGER" property="linkNum" />
|
||||||
<result column="s2c_pkt_num" jdbcType="BIGINT" property="s2cPktNum" />
|
<result column="web_id" jdbcType="INTEGER" property="webId" />
|
||||||
<result column="c2s_byte_len" jdbcType="BIGINT" property="c2sByteLen" />
|
<result column="c2s_pkt_num" jdbcType="BIGINT"
|
||||||
<result column="s2c_byte_len" jdbcType="BIGINT" property="s2cByteLen" />
|
property="c2sPktNum" />
|
||||||
<result column="stat_time" jdbcType="TIMESTAMP" property="statTime" />
|
<result column="s2c_pkt_num" jdbcType="BIGINT"
|
||||||
</resultMap>
|
property="s2cPktNum" />
|
||||||
<sql id="Base_Column_List">
|
<result column="c2s_byte_len" jdbcType="BIGINT"
|
||||||
stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len,
|
property="c2sByteLen" />
|
||||||
stat_time
|
<result column="s2c_byte_len" jdbcType="BIGINT"
|
||||||
</sql>
|
property="s2cByteLen" />
|
||||||
<!-- 获取最近时间并且有效 -->
|
<result column="stat_time" jdbcType="TIMESTAMP"
|
||||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
property="statTime" />
|
||||||
SELECT stat_time statTime FROM traffic_http_statistic order by stat_time desc limit 1
|
</resultMap>
|
||||||
</select>
|
<sql id="Base_Column_List">
|
||||||
<!-- 根据服务网站将域名分类 网站列表-->
|
stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len,
|
||||||
<select id="getDomainByWebsiteList" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
s2c_byte_len,
|
||||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( website_service_id, 268435455 ) websiteServiceId
|
stat_time
|
||||||
FROM TRAFFIC_HTTP_STATISTIC t
|
</sql>
|
||||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
<!-- 获取最近时间并且有效 -->
|
||||||
where t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
<select id="getMaxStatTime"
|
||||||
GROUP BY u.website_service_id ORDER BY count desc limit 0,10
|
resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||||
</select>
|
SELECT stat_time statTime FROM traffic_http_statistic order by stat_time
|
||||||
<!-- 根据主题将域名分类 主题列表 最近五分钟top10-->
|
desc limit 1
|
||||||
<select id="getDomainByTopicList" resultType="java.util.HashMap">
|
</select>
|
||||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( topic_id, 268435455 ) topicId
|
<!-- 根据服务网站将域名分类 网站列表 -->
|
||||||
FROM TRAFFIC_HTTP_STATISTIC t
|
<select id="getDomainByWebsiteList"
|
||||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
|
||||||
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( website_service_id,
|
||||||
GROUP BY u.topic_id ORDER BY count desc limit 0,10
|
268435455 ) websiteServiceId
|
||||||
|
FROM TRAFFIC_HTTP_STATISTIC t
|
||||||
</select>
|
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
||||||
<!--获取上个时间段该网站站域名流量的数据量 -->
|
where t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||||
<select id="preWebsiteListCount" resultType="java.lang.Long">
|
GROUP BY u.website_service_id ORDER BY count desc limit 0,10
|
||||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t
|
</select>
|
||||||
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
|
||||||
WHERE u.website_service_id=#{websiteServiceId}
|
<!-- 根据主题将域名分类 主题列表 最近五分钟top10 -->
|
||||||
and stat_time < DATE_SUB(#{statTime},INTERVAL 1 hour)
|
<select id="getDomainByTopicList" resultType="java.util.HashMap">
|
||||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 2 hour)
|
SELECT
|
||||||
</select>
|
IFNULL(topic_id, 268435455) topicId,
|
||||||
|
id
|
||||||
<!--获取网站列表列表 -->
|
FROM
|
||||||
<!-- <select id="websiteList" resultMap="BaseResultMap">
|
ui_website_domain_topic u
|
||||||
SELECT web_id webId, (SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count FROM traffic_http_statistic
|
GROUP BY
|
||||||
WHERE web_id !=0 and stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM traffic_http_statistic),INTERVAL 5 MINUTE)
|
u.topic_id,
|
||||||
GROUP BY web_id ORDER BY count DESC limit 0,10
|
id
|
||||||
</select> -->
|
</select>
|
||||||
<!-- 根据网站分组获取子域名 -->
|
|
||||||
<select id="getDomainByWebsiteServiceId" resultType="java.util.HashMap">
|
<!--获取上个时间段该网站站域名流量的数据量 -->
|
||||||
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
|
<select id="preWebsiteListCount" resultType="java.lang.Long">
|
||||||
FROM traffic_http_statistic t
|
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t
|
||||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id
|
||||||
where u.website_service_id=#{websiteServiceId}
|
WHERE u.website_service_id=#{websiteServiceId}
|
||||||
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
and stat_time < DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||||
GROUP BY t.web_id ORDER BY count desc limit 0,10
|
and stat_time > DATE_SUB(#{statTime},INTERVAL 2 hour)
|
||||||
</select>
|
</select>
|
||||||
<!-- 根据主题分组获取子域名 -->
|
|
||||||
<select id="getDomainByTopicId" resultType="java.util.HashMap">
|
<!--获取网站列表列表 -->
|
||||||
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
|
<!-- <select id="websiteList" resultMap="BaseResultMap"> SELECT web_id webId,
|
||||||
FROM traffic_http_statistic t
|
(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)+SUM(c2s_byte_len)+SUM(s2c_byte_len)) count
|
||||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
FROM traffic_http_statistic WHERE web_id !=0 and stat_time >= DATE_SUB((SELECT
|
||||||
where u.topic_id=#{topicId}
|
MAX(stat_time) FROM traffic_http_statistic),INTERVAL 5 MINUTE) GROUP BY web_id
|
||||||
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
ORDER BY count DESC limit 0,10 </select> -->
|
||||||
GROUP BY t.web_id ORDER BY count desc limit 0,10
|
<!-- 根据网站分组获取子域名 -->
|
||||||
</select>
|
<select id="getDomainByWebsiteServiceId"
|
||||||
|
resultType="java.util.HashMap">
|
||||||
<!-- 指定网站下的TOP10之外为others -->
|
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count
|
||||||
<select id="websiteDomainOthers" resultType="java.util.HashMap">
|
FROM traffic_http_statistic t
|
||||||
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t
|
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
||||||
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
where u.website_service_id=#{websiteServiceId}
|
||||||
where u.website_service_id=#{websiteServiceId}
|
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||||
|
GROUP BY t.web_id ORDER BY count desc limit 0,10
|
||||||
|
</select>
|
||||||
|
<!-- 根据主题分组获取子域名 -->
|
||||||
|
<select id="getDomainByTopicId" resultType="java.util.HashMap">
|
||||||
|
select web_id webId,sum(c2s_byte_len + s2c_byte_len) count from
|
||||||
|
traffic_http_statistic t where
|
||||||
|
<![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} group by t.web_id ]]>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 指定网站下的TOP10之外为others -->
|
||||||
|
<select id="websiteDomainOthers" resultType="java.util.HashMap">
|
||||||
|
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM
|
||||||
|
traffic_http_statistic t
|
||||||
|
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id
|
||||||
|
where u.website_service_id=#{websiteServiceId}
|
||||||
|
|
||||||
<if test="webIdList!=null and webIdList.size()>0">
|
<if test="webIdList!=null and webIdList.size()>0">
|
||||||
and t.web_id not in
|
and t.web_id not in
|
||||||
<foreach collection="webIdList" item="singleType" index="index" open="(" close=")" separator=",">
|
<foreach collection="webIdList" item="singleType"
|
||||||
#{singleType}
|
index="index" open="(" close=")" separator=",">
|
||||||
</foreach>
|
#{singleType}
|
||||||
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
and stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
and stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
</sql>
|
</sql>
|
||||||
<!-- 获取最近时间 -->
|
<!-- 获取最近时间 -->
|
||||||
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficProtocolStatistic">
|
<select id="getMaxStatTime" resultType="com.nis.domain.restful.dashboard.TrafficProtocolStatistic">
|
||||||
SELECT stat_time statTime FROM traffic_protocol_statistic WHERE order by stat_time desc limit 1
|
SELECT stat_time statTime FROM traffic_protocol_statistic order by stat_time desc limit 1
|
||||||
</select>
|
</select>
|
||||||
<select id="protocolChart" resultType="java.util.HashMap">
|
<select id="protocolChart" resultType="java.util.HashMap">
|
||||||
SELECT proto_type protoType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_protocol_statistic WHERE
|
SELECT proto_type protoType, SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_protocol_statistic WHERE
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
package com.nis.web.service;
|
package com.nis.web.service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -12,142 +18,170 @@ import com.nis.util.StringUtils;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Service基类
|
* Service基类
|
||||||
|
*
|
||||||
* @author ThinkGem
|
* @author ThinkGem
|
||||||
* @version 2014-05-16
|
* @version 2014-05-16
|
||||||
*/
|
*/
|
||||||
public abstract class BaseService {
|
public abstract class BaseService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志对象
|
* 日志对象
|
||||||
*/
|
*/
|
||||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据范围过滤
|
* 数据范围过滤
|
||||||
* @param user 当前用户对象,通过“entity.getCurrentUser()”获取
|
*
|
||||||
|
* @param user 当前用户对象,通过“entity.getCurrentUser()”获取
|
||||||
* @param officeAlias 机构表别名,多个用“,”逗号隔开。
|
* @param officeAlias 机构表别名,多个用“,”逗号隔开。
|
||||||
* @param userAlias 用户表别名,多个用“,”逗号隔开,传递空,忽略此参数
|
* @param userAlias 用户表别名,多个用“,”逗号隔开,传递空,忽略此参数
|
||||||
* @return 标准连接条件对象
|
* @return 标准连接条件对象
|
||||||
*/
|
*/
|
||||||
public static String dataScopeFilter(SysUser user, String officeAlias, String userAlias) {
|
public static String dataScopeFilter(SysUser user, String officeAlias, String userAlias) {
|
||||||
|
|
||||||
|
|
||||||
StringBuilder sqlString = new StringBuilder();
|
StringBuilder sqlString = new StringBuilder();
|
||||||
|
|
||||||
// 进行权限过滤,多个角色权限范围之间为或者关系。
|
// 进行权限过滤,多个角色权限范围之间为或者关系。
|
||||||
List<Integer> dataScope = Lists.newArrayList();
|
List<Integer> dataScope = Lists.newArrayList();
|
||||||
|
|
||||||
if (StringUtils.isBlank(user.getLoginId())){
|
if (StringUtils.isBlank(user.getLoginId())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 超级管理员,跳过权限过滤
|
// 超级管理员,跳过权限过滤
|
||||||
if (user.isAdmin()){
|
if (user.isAdmin()) {
|
||||||
boolean isDataScopeAll = isContainsDataScopeAll(user.getUserRoleList());
|
boolean isDataScopeAll = isContainsDataScopeAll(user.getUserRoleList());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (SysRole r : user.getUserRoleList()) {
|
for (SysRole r : user.getUserRoleList()) {
|
||||||
for (String oa : StringUtils.split(officeAlias, ",")){
|
for (String oa : StringUtils.split(officeAlias, ",")) {
|
||||||
if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(oa)){
|
if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(oa)) {
|
||||||
|
|
||||||
sqlString.append(createScopeSql(r.getDataScope(),oa,user));
|
sqlString.append(createScopeSql(r.getDataScope(), oa, user));
|
||||||
dataScope.add(r.getDataScope());
|
dataScope.add(r.getDataScope());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果没有全部数据权限,并设置了用户别名,则当前权限为本人;如果未设置别名,当前无权限为已植入权限
|
// 如果没有全部数据权限,并设置了用户别名,则当前权限为本人;如果未设置别名,当前无权限为已植入权限
|
||||||
if (!isDataScopeAll){
|
if (!isDataScopeAll) {
|
||||||
if (StringUtils.isNotBlank(userAlias)){
|
if (StringUtils.isNotBlank(userAlias)) {
|
||||||
for (String ua : StringUtils.split(userAlias, ",")){
|
for (String ua : StringUtils.split(userAlias, ",")) {
|
||||||
sqlString.append(" OR " + ua + ".id = '" + user.getId() + "'");
|
sqlString.append(" OR " + ua + ".id = '" + user.getId() + "'");
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
for (String oa : StringUtils.split(officeAlias, ",")){
|
for (String oa : StringUtils.split(officeAlias, ",")) {
|
||||||
//sqlString.append(" OR " + oa + ".id = " + user.getOffice().getId());
|
// sqlString.append(" OR " + oa + ".id = " + user.getOffice().getId());
|
||||||
sqlString.append(" OR " + oa + ".id IS NULL");
|
sqlString.append(" OR " + oa + ".id IS NULL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
// 如果包含全部权限,则去掉之前添加的所有条件,并跳出循环。
|
// 如果包含全部权限,则去掉之前添加的所有条件,并跳出循环。
|
||||||
sqlString = new StringBuilder();
|
sqlString = new StringBuilder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(sqlString.toString())){
|
if (StringUtils.isNotBlank(sqlString.toString())) {
|
||||||
return " AND (" + sqlString.substring(4) + ")";
|
return " AND (" + sqlString.substring(4) + ")";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试数据是否包含全集
|
* 测试数据是否包含全集
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static boolean isContainsDataScopeAll(List<SysRole> roleList) {
|
private static boolean isContainsDataScopeAll(List<SysRole> roleList) {
|
||||||
boolean isDataScopeAll = false;
|
boolean isDataScopeAll = false;
|
||||||
|
|
||||||
for(SysRole role : roleList) {
|
for (SysRole role : roleList) {
|
||||||
if(SysRole.DATA_SCOPE_ALL.equals(role.getDataScope())){
|
if (SysRole.DATA_SCOPE_ALL.equals(role.getDataScope())) {
|
||||||
isDataScopeAll = true;
|
isDataScopeAll = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return isDataScopeAll;
|
return isDataScopeAll;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤机构信息
|
||||||
|
*
|
||||||
|
* @param dataScope 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;4:所在部门及以下数据;5:所在部门数据;6:所在单位及以下数据;7:所在单位数据)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String createScopeSql(int dataScope, String officeAlias, SysUser user) {
|
||||||
|
StringBuilder scopeSql = new StringBuilder(1024);
|
||||||
|
|
||||||
|
if (SysRole.DATA_SCOPE_COMPANY_AND_CHILD.equals(dataScope)) {
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId());
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getCompany().getParentIds()
|
||||||
|
+ user.getCompany().getId() + ",%'");
|
||||||
|
} else if (SysRole.DATA_SCOPE_COMPANY.equals(dataScope)) {
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId());
|
||||||
|
// 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门)
|
||||||
|
scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getCompany().getId() + "' AND "
|
||||||
|
+ officeAlias + ".type>1)");
|
||||||
|
} else if (SysRole.DATA_SCOPE_OFFICE_AND_CHILD.equals(dataScope)) {
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId());
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getOffice().getParentIds()
|
||||||
|
+ user.getOffice().getId() + ",%'");
|
||||||
|
} else if (SysRole.DATA_SCOPE_OFFICE.equals(dataScope)) {
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId());
|
||||||
|
} else if (SysRole.DATA_SCOPE_ENTITY_AND_CHILD.equals(dataScope)) {
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId());
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getEntity().getParentIds()
|
||||||
|
+ user.getEntity().getId() + ",%'");
|
||||||
|
|
||||||
|
} else if (SysRole.DATA_SCOPE_ENTITY.equals(dataScope)) {
|
||||||
|
scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId());
|
||||||
|
// 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门)
|
||||||
|
scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getEntity().getId() + "' AND " + officeAlias
|
||||||
|
+ ".type>1)");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return scopeSql.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取前几个小时的数据
|
||||||
|
*
|
||||||
|
* @param ihour
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected Date getBeforeByHourTime(int ihour) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - ihour);
|
||||||
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过滤机构信息
|
* 根据count降序排列获取top10的count对应的view
|
||||||
* @param dataScope 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;4:所在部门及以下数据;5:所在部门数据;6:所在单位及以下数据;7:所在单位数据)
|
*
|
||||||
* @return
|
* @param set 所有的count
|
||||||
|
* @param countAndViewMap key是count,val是viewmap
|
||||||
*/
|
*/
|
||||||
private static String createScopeSql(int dataScope,String officeAlias,SysUser user) {
|
protected List<Map> getTop10Data(Set<Long> set, Map<Long, List<Map>> countAndViewMap) {
|
||||||
StringBuilder scopeSql = new StringBuilder(1024);
|
List<Map> topicList = new ArrayList<Map>();
|
||||||
|
Long[] countArr = new Long[set.size()];
|
||||||
if (SysRole.DATA_SCOPE_COMPANY_AND_CHILD.equals(dataScope)){
|
set.toArray(countArr);
|
||||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId());
|
Arrays.sort(countArr);
|
||||||
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getCompany().getParentIds() + user.getCompany().getId() + ",%'");
|
for (int i = countArr.length - 1; i >= 0; i--) {
|
||||||
|
List<Map> list = countAndViewMap.get(countArr[i]);
|
||||||
|
boolean exit = false;
|
||||||
|
for (Map map : list) {
|
||||||
|
topicList.add(map);
|
||||||
|
if (topicList.size() == 10) {
|
||||||
|
exit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (SysRole.DATA_SCOPE_COMPANY.equals(dataScope)){
|
return topicList;
|
||||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId());
|
|
||||||
// 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门)
|
|
||||||
scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getCompany().getId() + "' AND " + officeAlias + ".type>1)");
|
|
||||||
}
|
|
||||||
else if (SysRole.DATA_SCOPE_OFFICE_AND_CHILD.equals(dataScope)){
|
|
||||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId());
|
|
||||||
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getOffice().getParentIds() + user.getOffice().getId() + ",%'");
|
|
||||||
}
|
|
||||||
else if (SysRole.DATA_SCOPE_OFFICE.equals(dataScope)){
|
|
||||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId());
|
|
||||||
}
|
|
||||||
else if (SysRole.DATA_SCOPE_ENTITY_AND_CHILD.equals(dataScope)){
|
|
||||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId());
|
|
||||||
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getEntity().getParentIds() + user.getEntity().getId() + ",%'");
|
|
||||||
|
|
||||||
} else if (SysRole.DATA_SCOPE_ENTITY.equals(dataScope)){
|
|
||||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId());
|
|
||||||
// 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门)
|
|
||||||
scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getEntity().getId() + "' AND " + officeAlias + ".type>1)");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return scopeSql.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ import com.zdjizhi.utils.StringUtil;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DashboardService extends BaseService{
|
public class DashboardService extends BaseService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public TrafficIpActiveStatisticDao trafficIpActiveStatisticDao;
|
public TrafficIpActiveStatisticDao trafficIpActiveStatisticDao;
|
||||||
@@ -29,29 +30,28 @@ public class DashboardService extends BaseService{
|
|||||||
public NtcTotalReportDao ntcTotalReportDao;
|
public NtcTotalReportDao ntcTotalReportDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
public TrafficPortActiveStatisticDao trafficPortActiveStatisticDao;
|
public TrafficPortActiveStatisticDao trafficPortActiveStatisticDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流量统计 数据显示
|
* 流量统计 数据显示 info:先查询最近时间,根据时间条件查询数据 效率提高
|
||||||
* info:先查询最近时间,根据时间条件查询数据 效率提高
|
|
||||||
*/
|
*/
|
||||||
public List<Map> getTotalReportList(){
|
public List<Map> getTotalReportList() {
|
||||||
List<Map> totalReportList =new ArrayList<Map>();
|
List<Map> totalReportList = new ArrayList<Map>();
|
||||||
List<Map> newData = new ArrayList<Map>();
|
List<Map> newData = new ArrayList<Map>();
|
||||||
// 流量统计阻断丢弃回流等数据显示最近时间
|
// 流量统计阻断丢弃回流等数据显示最近时间
|
||||||
NtcTotalReport maxReportTime = ntcTotalReportDao.getMaxReportTime();
|
NtcTotalReport maxReportTime = ntcTotalReportDao.getMaxReportTime();
|
||||||
if(maxReportTime!=null&&maxReportTime.getReportTime()!=null) {
|
if (maxReportTime != null && maxReportTime.getReportTime() != null) {
|
||||||
Date reportTime = maxReportTime.getReportTime();
|
Date reportTime = maxReportTime.getReportTime();
|
||||||
totalReportList = ntcTotalReportDao.getTotalReportList(reportTime);// 返回阻断,监测等結果
|
totalReportList = ntcTotalReportDao.getTotalReportList(reportTime);// 返回阻断,监测等結果
|
||||||
}
|
}
|
||||||
Map maxRecvtTime = ntcTotalReportDao.getMaxStatTime();
|
Map maxRecvtTime = ntcTotalReportDao.getMaxStatTime();
|
||||||
if(maxRecvtTime!=null && maxRecvtTime.get("statTime")!=null) {
|
if (maxRecvtTime != null && maxRecvtTime.get("statTime") != null) {
|
||||||
Date recvTime = (Date) maxRecvtTime.get("statTime");
|
Date recvTime = (Date) maxRecvtTime.get("statTime");
|
||||||
newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime);
|
newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime);
|
||||||
}
|
}
|
||||||
// 统计带宽的流入流出 单位 五分钟 的 byte
|
// 统计带宽的流入流出 单位 五分钟 的 byte
|
||||||
if(StringUtil.isNotEmpty(newData)){
|
if (StringUtil.isNotEmpty(newData)) {
|
||||||
Double inoctets = Double.parseDouble(newData.get(0).get("inoctets").toString()) ;
|
Double inoctets = Double.parseDouble(newData.get(0).get("inoctets").toString());
|
||||||
Double outoctets = Double.parseDouble(newData.get(0).get("outoctets").toString()) ;
|
Double outoctets = Double.parseDouble(newData.get(0).get("outoctets").toString());
|
||||||
|
|
||||||
if (StringUtil.isEmpty(totalReportList)) {
|
if (StringUtil.isEmpty(totalReportList)) {
|
||||||
Map valueMap = Maps.newHashMap();
|
Map valueMap = Maps.newHashMap();
|
||||||
@@ -65,131 +65,135 @@ public class DashboardService extends BaseService{
|
|||||||
}
|
}
|
||||||
return totalReportList;
|
return totalReportList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ip46,协议tcp,udp查询带宽
|
* 根据ip46,协议tcp,udp查询带宽
|
||||||
|
*
|
||||||
* @param addrType
|
* @param addrType
|
||||||
* @param transType
|
* @param transType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<HashMap> getBandwidthTrans(String addrType,Integer transType) {
|
public List<HashMap> getBandwidthTrans(String addrType, Integer transType) {
|
||||||
ArrayList<HashMap> listMap=new ArrayList<HashMap>();
|
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
List<TrafficTransStatistic> bandwidthList = new ArrayList<TrafficTransStatistic>();
|
List<TrafficTransStatistic> bandwidthList = new ArrayList<TrafficTransStatistic>();
|
||||||
Map maxStatTime = ntcTotalReportDao.getMaxStatTime();
|
Map maxStatTime = ntcTotalReportDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null && maxStatTime.get("statTime")!=null) {
|
if (maxStatTime != null && maxStatTime.get("statTime") != null) {
|
||||||
Date stat = (Date) maxStatTime.get("statTime");
|
Date stat = (Date) maxStatTime.get("statTime");
|
||||||
HashMap m = new HashMap();
|
HashMap m = new HashMap();
|
||||||
bandwidthList=ntcTotalReportDao.getBandwidthTrans(stat, addrType, transType);
|
bandwidthList = ntcTotalReportDao.getBandwidthTrans(stat, addrType, transType);
|
||||||
List timeList = new ArrayList();
|
List timeList = new ArrayList();
|
||||||
List linkList = new ArrayList();
|
List linkList = new ArrayList();
|
||||||
List gbpsList = new ArrayList();
|
List gbpsList = new ArrayList();
|
||||||
List ppsList = new ArrayList();
|
List ppsList = new ArrayList();
|
||||||
if(bandwidthList!=null&&bandwidthList.size()>0) {
|
if (bandwidthList != null && bandwidthList.size() > 0) {
|
||||||
for (TrafficTransStatistic tt : bandwidthList) {
|
for (TrafficTransStatistic tt : bandwidthList) {
|
||||||
if(tt.getTime()!=null) {
|
if (tt.getTime() != null) {
|
||||||
timeList.add(tt.getTime());
|
timeList.add(tt.getTime());
|
||||||
if(tt.getLinkNum()!=null) {
|
if (tt.getLinkNum() != null) {
|
||||||
linkList.add(tt.getLinkNum());
|
linkList.add(tt.getLinkNum());
|
||||||
}
|
}
|
||||||
if(tt.getPps()!=null) {
|
if (tt.getPps() != null) {
|
||||||
ppsList.add(tt.getPps());
|
ppsList.add(tt.getPps());
|
||||||
}
|
}
|
||||||
if(tt.getGbps()!=null) {
|
if (tt.getGbps() != null) {
|
||||||
gbpsList.add(tt.getGbps());
|
gbpsList.add(tt.getGbps());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.put("linkNum",linkList);
|
m.put("linkNum", linkList);
|
||||||
m.put("gbps",gbpsList);
|
m.put("gbps", gbpsList);
|
||||||
m.put("pps",ppsList);
|
m.put("pps", ppsList);
|
||||||
m.put("statTime",timeList);
|
m.put("statTime", timeList);
|
||||||
listMap.add(m);
|
listMap.add(m);
|
||||||
}
|
}
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据service 动作查询近五分钟变化趋势
|
* 根据service 动作查询近五分钟变化趋势 entrance 默认为1,2
|
||||||
* entrance 默认为1,2
|
|
||||||
*/
|
*/
|
||||||
public List<HashMap> getActionTrans(String serviceType) {
|
public List<HashMap> getActionTrans(String serviceType) {
|
||||||
String sql ="";
|
String sql = "";
|
||||||
String sqlBlock="((service>=16 and service<=40) or (service>=258 and service<=273) or (service=576))"; //阻断
|
String sqlBlock = "((service>=16 and service<=40) or (service>=258 and service<=273) or (service=576))"; // 阻断
|
||||||
String sqlMonitor="((service>=128 and service<=152) or (service>=384 and service<=513) or (service=592) or (service>=848 and service<=1030) or (service=1152))"; //监测
|
String sqlMonitor = "((service>=128 and service<=152) or (service>=384 and service<=513) or (service=592) or (service>=848 and service<=1030) or (service=1152))"; // 监测
|
||||||
// 区分动作
|
// 区分动作
|
||||||
if(StringUtils.isNotBlank(serviceType)) {
|
if (StringUtils.isNotBlank(serviceType)) {
|
||||||
if(serviceType.equalsIgnoreCase("block")) {
|
if (serviceType.equalsIgnoreCase("block")) {
|
||||||
sql=sqlBlock;
|
sql = sqlBlock;
|
||||||
}
|
}
|
||||||
if(serviceType.equalsIgnoreCase("monitor")) {
|
if (serviceType.equalsIgnoreCase("monitor")) {
|
||||||
sql=sqlMonitor;
|
sql = sqlMonitor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<HashMap> listMap=new ArrayList<HashMap>();
|
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
List<NtcEntranceReport> entrance1 = new ArrayList<NtcEntranceReport>();
|
List<NtcEntranceReport> entrance1 = new ArrayList<NtcEntranceReport>();
|
||||||
List<NtcEntranceReport> entrance2 = new ArrayList<NtcEntranceReport>();
|
List<NtcEntranceReport> entrance2 = new ArrayList<NtcEntranceReport>();
|
||||||
Map maxReportTime = ntcTotalReportDao.getEntranceMaxReportTime();
|
Map maxReportTime = ntcTotalReportDao.getEntranceMaxReportTime();
|
||||||
if(maxReportTime!=null && maxReportTime.get("reportTime")!=null) {
|
if (maxReportTime != null && maxReportTime.get("reportTime") != null) {
|
||||||
Date reportTime = (Date) maxReportTime.get("reportTime");
|
Date reportTime = (Date) maxReportTime.get("reportTime");
|
||||||
HashMap m1 = new HashMap();
|
HashMap m1 = new HashMap();
|
||||||
HashMap m2 = new HashMap();
|
HashMap m2 = new HashMap();
|
||||||
entrance1=ntcTotalReportDao.getActionTrans(reportTime, 1, sql);
|
entrance1 = ntcTotalReportDao.getActionTrans(reportTime, 1, sql);
|
||||||
entrance2=ntcTotalReportDao.getActionTrans(reportTime, 2, sql);
|
entrance2 = ntcTotalReportDao.getActionTrans(reportTime, 2, sql);
|
||||||
List timeList = new ArrayList();
|
List timeList = new ArrayList();
|
||||||
List sumList1 = new ArrayList();
|
List sumList1 = new ArrayList();
|
||||||
List sumList2 = new ArrayList();
|
List sumList2 = new ArrayList();
|
||||||
// entrance 为1的趋势
|
// entrance 为1的趋势
|
||||||
if(entrance1!=null&&entrance1.size()>0) {
|
if (entrance1 != null && entrance1.size() > 0) {
|
||||||
for (NtcEntranceReport tt : entrance1) {
|
for (NtcEntranceReport tt : entrance1) {
|
||||||
if(tt.getTime()!=null&&tt.getSum()!=null) {
|
if (tt.getTime() != null && tt.getSum() != null) {
|
||||||
timeList.add(tt.getTime());
|
timeList.add(tt.getTime());
|
||||||
sumList1.add(tt.getSum());
|
sumList1.add(tt.getSum());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// entrance 为2的趋势
|
// entrance 为2的趋势
|
||||||
if(entrance2!=null&&entrance2.size()>0) {
|
if (entrance2 != null && entrance2.size() > 0) {
|
||||||
for (NtcEntranceReport tt : entrance2) {
|
for (NtcEntranceReport tt : entrance2) {
|
||||||
if(tt.getTime()!=null&&tt.getSum()!=null) {
|
if (tt.getTime() != null && tt.getSum() != null) {
|
||||||
// timeList.add(tt.getTime());
|
// timeList.add(tt.getTime());
|
||||||
sumList2.add(tt.getSum());
|
sumList2.add(tt.getSum());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m1.put("count",sumList1);//[{time:[],link:[],link2:[]}]
|
m1.put("count", sumList1);// [{time:[],link:[],link2:[]}]
|
||||||
m1.put("statTime",timeList);
|
m1.put("statTime", timeList);
|
||||||
m1.put("entranceId",1);
|
m1.put("entranceId", 1);
|
||||||
m2.put("count",sumList2);//[{link1:[],time:[],entrance:"1"},]
|
m2.put("count", sumList2);// [{link1:[],time:[],entrance:"1"},]
|
||||||
m2.put("statTime",timeList);
|
m2.put("statTime", timeList);
|
||||||
m2.put("entranceId",2);
|
m2.put("entranceId", 2);
|
||||||
listMap.add(m1);
|
listMap.add(m1);
|
||||||
listMap.add(m2);
|
listMap.add(m2);
|
||||||
}
|
}
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最近活跃端口时间五分钟数据
|
* 最近活跃端口时间五分钟数据
|
||||||
|
*
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
public List<Map> getPortActiveList(){
|
public List<Map> getPortActiveList() {
|
||||||
List<Map> list = new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
TrafficPortActiveStatistic maxStatTime = trafficPortActiveStatisticDao.getMaxStatTime();
|
TrafficPortActiveStatistic maxStatTime = trafficPortActiveStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
List<TrafficPortActiveStatistic> portActiveList = trafficPortActiveStatisticDao.getPortActiveList(statTime);
|
List<TrafficPortActiveStatistic> portActiveList = trafficPortActiveStatisticDao.getPortActiveList(statTime);
|
||||||
//上个时间五分钟数据
|
// 上个时间五分钟数据
|
||||||
if(portActiveList!=null&&portActiveList.size()>0) {
|
if (portActiveList != null && portActiveList.size() > 0) {
|
||||||
for (TrafficPortActiveStatistic port : portActiveList) {
|
for (TrafficPortActiveStatistic port : portActiveList) {
|
||||||
if(port.getPort()!=null) {
|
if (port.getPort() != null) {
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("port", port.getPort());
|
map.put("port", port.getPort());
|
||||||
map.put("sum", port.getSum());
|
map.put("sum", port.getSum());
|
||||||
TrafficPortActiveStatistic portActiveOld = trafficPortActiveStatisticDao.getPortActiveOld(port.getPort(),statTime);
|
TrafficPortActiveStatistic portActiveOld = trafficPortActiveStatisticDao
|
||||||
if(portActiveOld!=null&&portActiveOld.getSum()!=null){
|
.getPortActiveOld(port.getPort(), statTime);
|
||||||
map.put("preSum",portActiveOld.getSum());
|
if (portActiveOld != null && portActiveOld.getSum() != null) {
|
||||||
}else{
|
map.put("preSum", portActiveOld.getSum());
|
||||||
map.put("preSum",0);
|
} else {
|
||||||
|
map.put("preSum", 0);
|
||||||
}
|
}
|
||||||
list.add(map);
|
list.add(map);
|
||||||
}
|
}
|
||||||
@@ -198,83 +202,87 @@ public class DashboardService extends BaseService{
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活跃IP最近五分钟数据TOP10
|
* 活跃IP最近五分钟数据TOP10
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<HashMap> ipActiveFiveMinute(){
|
public List<HashMap> ipActiveFiveMinute() {
|
||||||
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
||||||
ArrayList<HashMap> listMap=new ArrayList<HashMap>();
|
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
// 查询最近五分钟TOP10
|
// 查询最近五分钟TOP10
|
||||||
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
||||||
if(list!=null&&list.size()>0) {
|
if (list != null && list.size() > 0) {
|
||||||
for (LinkedHashMap map : list) {
|
for (LinkedHashMap map : list) {
|
||||||
HashMap m = new HashMap();
|
HashMap m = new HashMap();
|
||||||
if(map.get("ipAddr")!=null) {
|
if (map.get("ipAddr") != null) {
|
||||||
String ipAddr = (String) map.get("ipAddr");
|
String ipAddr = (String) map.get("ipAddr");
|
||||||
m.put("ipAddr", ipAddr);
|
m.put("ipAddr", ipAddr);
|
||||||
// 根据五分钟TOP10IP,查询TOP10中每个IP最近一小时的变化
|
// 根据五分钟TOP10IP,查询TOP10中每个IP最近一小时的变化
|
||||||
ArrayList<TrafficIpActiveStatistic> ipList = trafficIpActiveStatisticDao.ipActiveFiveMinute(ipAddr,statTime);
|
ArrayList<TrafficIpActiveStatistic> ipList = trafficIpActiveStatisticDao
|
||||||
|
.ipActiveFiveMinute(ipAddr, statTime);
|
||||||
List linkList = new ArrayList();
|
List linkList = new ArrayList();
|
||||||
List timeList = new ArrayList();
|
List timeList = new ArrayList();
|
||||||
if(ipList!=null&&ipList.size()>0) {
|
if (ipList != null && ipList.size() > 0) {
|
||||||
for (TrafficIpActiveStatistic ip : ipList) {
|
for (TrafficIpActiveStatistic ip : ipList) {
|
||||||
if(ip.getLinkNum()!=null&&ip.getTime()!=null) {
|
if (ip.getLinkNum() != null && ip.getTime() != null) {
|
||||||
linkList.add(ip.getLinkNum());
|
linkList.add(ip.getLinkNum());
|
||||||
timeList.add(ip.getTime());
|
timeList.add(ip.getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.put("linkNum",linkList);
|
m.put("linkNum", linkList);
|
||||||
m.put("statTime",timeList);
|
m.put("statTime", timeList);
|
||||||
listMap.add(m);
|
listMap.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据活跃IP最近五分钟TOP10,查询近1小时最大值
|
* 根据活跃IP最近五分钟TOP10,查询近1小时最大值
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<HashMap> ipActiveOneHour(){
|
public List<HashMap> ipActiveOneHour() {
|
||||||
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
||||||
ArrayList<HashMap> listMap=new ArrayList<HashMap>();
|
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
||||||
if(list!=null&&list.size()>0) {
|
if (list != null && list.size() > 0) {
|
||||||
for (LinkedHashMap map : list) {
|
for (LinkedHashMap map : list) {
|
||||||
if(map.get("ipAddr")!=null) {
|
if (map.get("ipAddr") != null) {
|
||||||
String ipAddr = (String) map.get("ipAddr");
|
String ipAddr = (String) map.get("ipAddr");
|
||||||
ArrayList<HashMap> iplList = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr,statTime);
|
ArrayList<HashMap> iplList = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr, statTime);
|
||||||
listMap.add(iplList.get(0));
|
listMap.add(iplList.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public List<LinkedHashMap> ipActiveChart(){
|
public List<LinkedHashMap> ipActiveChart() {
|
||||||
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
||||||
ArrayList<LinkedHashMap> list = new ArrayList<>();
|
ArrayList<LinkedHashMap> list = new ArrayList<>();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
||||||
if(list!=null&&list.size()>0) {
|
if (list != null && list.size() > 0) {
|
||||||
for (LinkedHashMap map : list) {
|
for (LinkedHashMap map : list) {
|
||||||
if(map.get("ipAddr")!=null) {
|
if (map.get("ipAddr") != null) {
|
||||||
Map m = new LinkedHashMap();
|
Map m = new LinkedHashMap();
|
||||||
map.put("pktNum",0);
|
map.put("pktNum", 0);
|
||||||
map.put("byteLen",0);
|
map.put("byteLen", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,19 +292,20 @@ public class DashboardService extends BaseService{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 协议统计
|
* 协议统计
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Map> protocolChart() {
|
public List<Map> protocolChart() {
|
||||||
TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime();
|
TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime();
|
||||||
List<Map> list=new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
list = trafficProtocolStatisticDao.protocolChart(statTime);
|
list = trafficProtocolStatisticDao.protocolChart(statTime);
|
||||||
//当不查询包,字节时 设为0
|
// 当不查询包,字节时 设为0
|
||||||
if(list!=null&&list.size()>0) {
|
if (list != null && list.size() > 0) {
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("pktNum",0);
|
map.put("pktNum", 0);
|
||||||
map.put("byteLen",0);
|
map.put("byteLen", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@@ -304,97 +313,103 @@ public class DashboardService extends BaseService{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 协议统计报表
|
* 协议统计报表
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Map> getProtocolList(String startTime,String endTime){
|
public List<Map> getProtocolList(String startTime, String endTime) {
|
||||||
TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime();
|
TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime();
|
||||||
List<Map> list=new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
list = trafficProtocolStatisticDao.getProtocolList(statTime,startTime,endTime);
|
list = trafficProtocolStatisticDao.getProtocolList(statTime, startTime, endTime);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* app应用top10 图
|
* app应用top10 图
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Map> appChart() {
|
public List<Map> appChart() {
|
||||||
List<Map> list=new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime();
|
TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
list = trafficAppStatisticDao.appChart(statTime);
|
list = trafficAppStatisticDao.appChart(statTime);
|
||||||
//当不查询包,字节时 设为0
|
// 当不查询包,字节时 设为0
|
||||||
if(list!=null&&list.size()>0) {
|
if (list != null && list.size() > 0) {
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("pktNum",0);
|
map.put("pktNum", 0);
|
||||||
map.put("byteLen",0);
|
map.put("byteLen", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App统计报表
|
* App统计报表
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Map> getAppList(String startTime,String endTime){
|
public List<Map> getAppList(String startTime, String endTime) {
|
||||||
TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime();
|
TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime();
|
||||||
List<Map> list=new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
list = trafficAppStatisticDao.getAppList(statTime,startTime,endTime);
|
list = trafficAppStatisticDao.getAppList(statTime, startTime, endTime);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 操作系统列表 排名TOP10
|
// 操作系统列表 排名TOP10
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public List<Map> systemList(){
|
public List<Map> systemList() {
|
||||||
List<Map> result = new ArrayList<Map>();
|
List<Map> result = new ArrayList<Map>();
|
||||||
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null) {
|
if (maxStatTime != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
List<TrafficUaStatistic> list = trafficUaStatisticDao.systemList(statTime);
|
List<TrafficUaStatistic> list = trafficUaStatisticDao.systemList(statTime);
|
||||||
Long preCount=0l;
|
Long preCount = 0l;
|
||||||
for (TrafficUaStatistic ua : list) {
|
for (TrafficUaStatistic ua : list) {
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("osType",ua.getOsType());
|
map.put("osType", ua.getOsType());
|
||||||
map.put("count",ua.getCount());
|
map.put("count", ua.getCount());
|
||||||
map.put("pktNum",0);
|
map.put("pktNum", 0);
|
||||||
map.put("byteLen",0);
|
map.put("byteLen", 0);
|
||||||
preCount = trafficUaStatisticDao.preSystemListCount(ua.getOsType(),statTime);//上个时段的量 用于与现在对比
|
preCount = trafficUaStatisticDao.preSystemListCount(ua.getOsType(), statTime);// 上个时段的量 用于与现在对比
|
||||||
if(preCount!=null){
|
if (preCount != null) {
|
||||||
map.put("preCount",preCount);
|
map.put("preCount", preCount);
|
||||||
}else{
|
} else {
|
||||||
map.put("preCount",0);
|
map.put("preCount", 0);
|
||||||
}
|
|
||||||
result.add(map);
|
|
||||||
}
|
}
|
||||||
|
result.add(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<Map> getBrowserBySystem(Integer osType ){
|
|
||||||
|
public List<Map> getBrowserBySystem(Integer osType) {
|
||||||
List<Map> list = new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null) {
|
if (maxStatTime != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
list = trafficUaStatisticDao.getBrowserBySystem(osType,statTime);
|
list = trafficUaStatisticDao.getBrowserBySystem(osType, statTime);
|
||||||
List bsType = new ArrayList();
|
List bsType = new ArrayList();
|
||||||
//查新固定操系统下的除了TOP10以外的others
|
// 查新固定操系统下的除了TOP10以外的others
|
||||||
if(list!=null&& list.size()>0){
|
if (list != null && list.size() > 0) {
|
||||||
for (Map map : list) {
|
for (Map map : list) {
|
||||||
bsType.add(map.get("bsType"));
|
bsType.add(map.get("bsType"));
|
||||||
}
|
}
|
||||||
if(list.size()>10) {
|
if (list.size() > 10) {
|
||||||
Map others = new HashMap();
|
Map others = new HashMap();
|
||||||
others = trafficUaStatisticDao.systemOthers(bsType,osType,statTime);
|
others = trafficUaStatisticDao.systemOthers(bsType, osType, statTime);
|
||||||
if(others!=null&&others.size()>0){
|
if (others != null && others.size() > 0) {
|
||||||
others.put("bsType", "-1");
|
others.put("bsType", "-1");
|
||||||
list.add(others);
|
list.add(others);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -402,132 +417,74 @@ public class DashboardService extends BaseService{
|
|||||||
public List<Map> browserList() {
|
public List<Map> browserList() {
|
||||||
List<Map> result = new ArrayList<Map>();
|
List<Map> result = new ArrayList<Map>();
|
||||||
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null) {
|
if (maxStatTime != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
List<TrafficUaStatistic> list = trafficUaStatisticDao.browserList(statTime);
|
List<TrafficUaStatistic> list = trafficUaStatisticDao.browserList(statTime);
|
||||||
Long preCount=0l;
|
Long preCount = 0l;
|
||||||
if(list!=null&&list.size()>0){
|
if (list != null && list.size() > 0) {
|
||||||
for (TrafficUaStatistic ua : list) {
|
for (TrafficUaStatistic ua : list) {
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("bsType",ua.getBsType());
|
map.put("bsType", ua.getBsType());
|
||||||
map.put("count",ua.getCount());
|
map.put("count", ua.getCount());
|
||||||
map.put("pktNum",0);
|
map.put("pktNum", 0);
|
||||||
map.put("byteLen",0);
|
map.put("byteLen", 0);
|
||||||
preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType(),statTime);//上个时段的量 用于与现在对比
|
preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType(), statTime);// 上个时段的量 用于与现在对比
|
||||||
if(preCount!=null){
|
if (preCount != null) {
|
||||||
map.put("preCount",preCount);
|
map.put("preCount", preCount);
|
||||||
}else{
|
} else {
|
||||||
map.put("preCount",0);
|
map.put("preCount", 0);
|
||||||
}
|
|
||||||
result.add(map);
|
|
||||||
}
|
}
|
||||||
|
result.add(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<Map> getSystemBybrowser(Integer bsType ){
|
|
||||||
|
public List<Map> getSystemBybrowser(Integer bsType) {
|
||||||
List<Map> list = new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null) {
|
if (maxStatTime != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
list = trafficUaStatisticDao.getSystemBybrowser(bsType,statTime);
|
list = trafficUaStatisticDao.getSystemBybrowser(bsType, statTime);
|
||||||
List osType = new ArrayList();
|
List osType = new ArrayList();
|
||||||
//查询固定操系统下的除了TOP10以外的others
|
// 查询固定操系统下的除了TOP10以外的others
|
||||||
if(list!=null&& list.size()>0){
|
if (list != null && list.size() > 0) {
|
||||||
for (Map map : list) {
|
for (Map map : list) {
|
||||||
osType.add(map.get("osType"));
|
osType.add(map.get("osType"));
|
||||||
}
|
}
|
||||||
if(list.size()>10) {
|
if (list.size() > 10) {
|
||||||
Map others = new HashMap();
|
Map others = new HashMap();
|
||||||
others = trafficUaStatisticDao.browserOthers(osType,bsType,statTime);
|
others = trafficUaStatisticDao.browserOthers(osType, bsType, statTime);
|
||||||
if(others!=null&&others.size()>0){
|
if (others != null && others.size() > 0) {
|
||||||
others.put("osType", "-1");
|
others.put("osType", "-1");
|
||||||
list.add(others);
|
list.add(others);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map> websiteList() {
|
public List<Map> websiteList() {
|
||||||
List<Map> result = new ArrayList<Map>();
|
List<Map> result = new ArrayList<Map>();
|
||||||
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null) {
|
if (maxStatTime != null) {
|
||||||
List<TrafficHttpStatistic> list = trafficHttpStatisticDao.websiteList(maxStatTime.getStatTime());
|
List<TrafficHttpStatistic> list = trafficHttpStatisticDao.websiteList(maxStatTime.getStatTime());
|
||||||
Long preCount=0l;
|
Long preCount = 0l;
|
||||||
if(list!=null&&list.size()>0){
|
if (list != null && list.size() > 0) {
|
||||||
for (TrafficHttpStatistic website : list) {
|
for (TrafficHttpStatistic website : list) {
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("webId",website.getWebId());
|
map.put("webId", website.getWebId());
|
||||||
map.put("count",website.getCount());
|
map.put("count", website.getCount());
|
||||||
map.put("pktNum",0);
|
map.put("pktNum", 0);
|
||||||
map.put("byteLen",0);
|
map.put("byteLen", 0);
|
||||||
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId(),maxStatTime.getStatTime());//上个时段的量 用于与现在对比
|
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId(),
|
||||||
if(preCount!=null){
|
maxStatTime.getStatTime());// 上个时段的量 用于与现在对比
|
||||||
map.put("preCount",preCount);
|
if (preCount != null) {
|
||||||
}else{
|
map.put("preCount", preCount);
|
||||||
map.put("preCount",0);
|
} else {
|
||||||
}
|
map.put("preCount", 0);
|
||||||
result.add(map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 根据网站服务查询子域名
|
|
||||||
* @param websiteServiceId
|
|
||||||
* @return list
|
|
||||||
*/
|
|
||||||
public List<Map> getDomainByWebsiteServiceId(Integer websiteServiceId ){
|
|
||||||
List<Map> list = new ArrayList<Map>();
|
|
||||||
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
|
||||||
if(maxStatTime!=null) {
|
|
||||||
Date statTime = maxStatTime.getStatTime();
|
|
||||||
list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId,statTime);
|
|
||||||
List webIdList = new ArrayList();
|
|
||||||
//查询固定网站下的域名除了TOP10以外的others域名
|
|
||||||
if(list!=null&& list.size()>0){
|
|
||||||
for (Map map : list) {
|
|
||||||
webIdList.add(map.get("webId"));
|
|
||||||
}
|
|
||||||
if(list.size()>10) {
|
|
||||||
Map others = new HashMap();
|
|
||||||
others = trafficHttpStatisticDao.websiteDomainOthers(webIdList,websiteServiceId,statTime);
|
|
||||||
if(others!=null&&others.size()>0){
|
|
||||||
others.put("webId", "-1");
|
|
||||||
list.add(others);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
获取网站列表
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<Map> getDomainByWebsiteList(){
|
|
||||||
List<Map> result = new ArrayList<Map>();
|
|
||||||
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
|
||||||
if(maxStatTime!=null) {
|
|
||||||
Date statTime = maxStatTime.getStatTime();
|
|
||||||
List<TrafficHttpStatistic> websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime);
|
|
||||||
if(websiteList!=null&&websiteList.size()>0){
|
|
||||||
Long preCount=0l;
|
|
||||||
for (TrafficHttpStatistic website : websiteList) {
|
|
||||||
Map map = new HashMap();
|
|
||||||
map.put("websiteServiceId",website.getWesiteServiceId());
|
|
||||||
map.put("count",website.getCount());
|
|
||||||
map.put("pktNum",0);
|
|
||||||
map.put("byteLen",0);
|
|
||||||
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWesiteServiceId(),statTime);//上个时段的量 用于与现在对比
|
|
||||||
if(preCount!=null){
|
|
||||||
map.put("preCount",preCount);
|
|
||||||
}else{
|
|
||||||
map.put("preCount",0);
|
|
||||||
}
|
}
|
||||||
result.add(map);
|
result.add(map);
|
||||||
}
|
}
|
||||||
@@ -535,27 +492,130 @@ public class DashboardService extends BaseService{
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*主题网站分类,域名
|
* 根据网站服务查询子域名
|
||||||
*
|
*
|
||||||
* **/
|
* @param websiteServiceId
|
||||||
public List<Map> getTopicAndDomainList(){
|
* @return list
|
||||||
List<Map> topicList = new ArrayList<Map>();
|
*/
|
||||||
|
public List<Map> getDomainByWebsiteServiceId(Integer websiteServiceId) {
|
||||||
|
List<Map> list = new ArrayList<Map>();
|
||||||
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
||||||
if(maxStatTime!=null) {
|
if (maxStatTime != null) {
|
||||||
Date statTime = maxStatTime.getStatTime();
|
Date statTime = maxStatTime.getStatTime();
|
||||||
//按照主题分类 获得主题
|
list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId, statTime);
|
||||||
topicList = trafficHttpStatisticDao.getDomainByTopicList(statTime);
|
List webIdList = new ArrayList();
|
||||||
if(topicList!=null&&topicList.size()>0){
|
// 查询固定网站下的域名除了TOP10以外的others域名
|
||||||
for (Map m : topicList) {
|
if (list != null && list.size() > 0) {
|
||||||
List<Map> domainList= new ArrayList<Map>();
|
for (Map map : list) {
|
||||||
if(m!=null&&m.get("topicId")!=null){
|
webIdList.add(map.get("webId"));
|
||||||
domainList = trafficHttpStatisticDao.getDomainByTopicId(m.get("topicId"),statTime);
|
}
|
||||||
m.put("domainData", domainList);
|
if (list.size() > 10) {
|
||||||
|
Map others = new HashMap();
|
||||||
|
others = trafficHttpStatisticDao.websiteDomainOthers(webIdList, websiteServiceId, statTime);
|
||||||
|
if (others != null && others.size() > 0) {
|
||||||
|
others.put("webId", "-1");
|
||||||
|
list.add(others);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return topicList;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<Map> getDomainByWebsiteList() {
|
||||||
|
List<Map> result = new ArrayList<Map>();
|
||||||
|
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
||||||
|
if (maxStatTime != null) {
|
||||||
|
Date statTime = maxStatTime.getStatTime();
|
||||||
|
List<TrafficHttpStatistic> websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime);
|
||||||
|
if (websiteList != null && websiteList.size() > 0) {
|
||||||
|
Long preCount = 0l;
|
||||||
|
for (TrafficHttpStatistic website : websiteList) {
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("websiteServiceId", website.getWesiteServiceId());
|
||||||
|
map.put("count", website.getCount());
|
||||||
|
map.put("pktNum", 0);
|
||||||
|
map.put("byteLen", 0);
|
||||||
|
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWesiteServiceId(), statTime);// 上个时段的量
|
||||||
|
// 用于与现在对比
|
||||||
|
if (preCount != null) {
|
||||||
|
map.put("preCount", preCount);
|
||||||
|
} else {
|
||||||
|
map.put("preCount", 0);
|
||||||
|
}
|
||||||
|
result.add(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题网站分类,域名
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public List<Map> getTopicAndDomainList() {
|
||||||
|
|
||||||
|
Date startTime = getBeforeByHourTime(1);// 获取上一个小时
|
||||||
|
Map<String, List<String>> topicIdAndIdMap = new HashMap<>();// 存储topicid和id的对应关系,一个topicid有多个id
|
||||||
|
List<Map> topicIdAndIdList = trafficHttpStatisticDao.getDomainByTopicList(startTime, new Date());// 获取最近一个小时topicId和id的对应关系,group
|
||||||
|
for (Map map : topicIdAndIdList) {
|
||||||
|
Object topicIdObj = map.get("topicId");
|
||||||
|
Object idObj = map.get("id");
|
||||||
|
if (topicIdObj != null && idObj != null) {
|
||||||
|
if (topicIdAndIdMap.containsKey(String.valueOf(topicIdObj))) {
|
||||||
|
topicIdAndIdMap.get(String.valueOf(topicIdObj)).add(String.valueOf(idObj));
|
||||||
|
} else {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add(String.valueOf(idObj));
|
||||||
|
topicIdAndIdMap.put(String.valueOf(topicIdObj), list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> set = new HashSet<>();
|
||||||
|
Map<Long, List<Map>> countAndViewMap = new HashMap<>();// 存储count和map的对应关系,后面根据count过滤,获取top10的count
|
||||||
|
List<Map> webIdAndCountList = trafficHttpStatisticDao.getDomainByTopicId(startTime, new Date());// 获取最近一小时的webid和count的关系
|
||||||
|
for (String topicId : topicIdAndIdMap.keySet()) {// 遍历上面获取的topicid和id的对应关系,拼接json
|
||||||
|
Map viewMap = new HashMap<>();
|
||||||
|
viewMap.put("topicId", topicId);
|
||||||
|
List<Map> list = new ArrayList<>();
|
||||||
|
long count = 0l;// 记录当前topicid所有的count
|
||||||
|
List<String> idList = topicIdAndIdMap.get(topicId);// 根据topicid获取对应的id
|
||||||
|
for (String id : idList) {
|
||||||
|
for (Map webIdAndCountMap : webIdAndCountList) {// 遍历webid和count
|
||||||
|
String webId = String.valueOf(webIdAndCountMap.get("webId"));
|
||||||
|
if (webId != null && webId.equals(id)) {// 如果webid和id相等则获取count数据并统计
|
||||||
|
String countStr = String.valueOf(webIdAndCountMap.get("count"));
|
||||||
|
if (countStr != null) {
|
||||||
|
count += Long.parseLong(countStr);// 将count累加
|
||||||
|
list.add(webIdAndCountMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewMap.put("count", count);
|
||||||
|
viewMap.put("domainData", list);
|
||||||
|
if (countAndViewMap.containsKey(count)) {// 将每个count和对应的viewmap放到map中,count可能相同所以value是list
|
||||||
|
countAndViewMap.get(count).add(viewMap);
|
||||||
|
} else {
|
||||||
|
List<Map> listMap = new ArrayList<>();
|
||||||
|
listMap.add(viewMap);
|
||||||
|
countAndViewMap.put(count, listMap);
|
||||||
|
}
|
||||||
|
set.add(count);
|
||||||
|
}
|
||||||
|
return getTop10Data(set, countAndViewMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user