1:核对阀门业务添加四个固定属性

2:修改网站流量的两个接口,改为用程序计算top10
This commit is contained in:
renkaige
2018-12-10 18:55:14 +06:00
parent 6553fd92ee
commit 174ae973c3
7 changed files with 213 additions and 123 deletions

View File

@@ -59,7 +59,7 @@ CREATE TABLE `ui_asn_ip_cfg` (
`user_region4` varchar(1024) DEFAULT '' COMMENT '预留自定义域4', `user_region4` varchar(1024) DEFAULT '' COMMENT '预留自定义域4',
`user_region5` varchar(1024) DEFAULT '' COMMENT '预留自定义域5', `user_region5` varchar(1024) DEFAULT '' COMMENT '预留自定义域5',
PRIMARY KEY (`cfg_id`) PRIMARY KEY (`cfg_id`)
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/asn_ip_cfg'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/asn_ip_cfg';
CREATE TABLE `ui_sys_dict_info` ( CREATE TABLE `ui_sys_dict_info` (
`sys_dict_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '字典ID', `sys_dict_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '字典ID',
@@ -77,7 +77,7 @@ CREATE TABLE `ui_sys_dict_info` (
`edit_time` datetime DEFAULT NULL COMMENT '修改时间', `edit_time` datetime DEFAULT NULL COMMENT '修改时间',
`is_initianlize` int(11) NOT NULL DEFAULT 0 COMMENT '是否是初始化数据1是0否', `is_initianlize` int(11) NOT NULL DEFAULT 0 COMMENT '是否是初始化数据1是0否',
PRIMARY KEY (`sys_dict_id`) PRIMARY KEY (`sys_dict_id`)
) ENGINE=FEDERATED AUTO_INCREMENT=448 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/sys_dict_info'; ) ENGINE=FEDERATED AUTO_INCREMENT=448 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/sys_dict_info';
CREATE TABLE `ui_code_app_dic` ( CREATE TABLE `ui_code_app_dic` (
@@ -92,7 +92,7 @@ CREATE TABLE `ui_sys_dict_info` (
`app_service` varchar(255) CHARACTER SET utf8mb4 DEFAULT '', `app_service` varchar(255) CHARACTER SET utf8mb4 DEFAULT '',
`lib` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'lib类别', `lib` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'lib类别',
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_app_dic'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/code_app_dic';
@@ -105,7 +105,7 @@ CREATE TABLE `ui_cfg_num_statistics` (
`compile_id` int(11) DEFAULT 0, `compile_id` int(11) DEFAULT 0,
`statistic_time` datetime DEFAULT NULL COMMENT '统计时间', `statistic_time` datetime DEFAULT NULL COMMENT '统计时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/cfg_num_statistics'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/cfg_num_statistics';
CREATE TABLE `ui_request_num_statistics` ( CREATE TABLE `ui_request_num_statistics` (
@@ -116,7 +116,7 @@ CREATE TABLE `ui_request_num_statistics` (
`statistic_time` datetime DEFAULT NULL COMMENT '统计时间', `statistic_time` datetime DEFAULT NULL COMMENT '统计时间',
`compile_id` int(11) DEFAULT 0, `compile_id` int(11) DEFAULT 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
)ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/request_num_statistics'; )ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/request_num_statistics';
CREATE TABLE `ui_sys_data_dictionary_item` ( CREATE TABLE `ui_sys_data_dictionary_item` (
@@ -129,14 +129,14 @@ CREATE TABLE `ui_sys_data_dictionary_item` (
`type` int(11) DEFAULT 1 COMMENT '该条记录页面是否可维护1可维护 0不可维护', `type` int(11) DEFAULT 1 COMMENT '该条记录页面是否可维护1可维护 0不可维护',
`dictionary_id` int(11) DEFAULT NULL COMMENT '关联数据字典外键', `dictionary_id` int(11) DEFAULT NULL COMMENT '关联数据字典外键',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
)ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/sys_data_dictionary_item'; )ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/sys_data_dictionary_item';
CREATE TABLE `ui_code_behavior_type_dic` ( CREATE TABLE `ui_code_behavior_type_dic` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`behavior_type` varchar(255) DEFAULT NULL, `behavior_type` varchar(255) DEFAULT NULL,
`view_code` varchar(255) DEFAULT NULL, `view_code` 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_behavior_type_dic'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/code_behavior_type_dic';
CREATE TABLE `ui_code_browser_type_dic` ( CREATE TABLE `ui_code_browser_type_dic` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -144,7 +144,7 @@ CREATE TABLE `ui_code_browser_type_dic` (
`view_code` varchar(255) DEFAULT NULL, `view_code` varchar(255) DEFAULT NULL,
`icon` varchar(255) DEFAULT NULL, `icon` 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_browser_type_dic'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/code_browser_type_dic';
CREATE TABLE `ui_code_os_type_dic` ( CREATE TABLE `ui_code_os_type_dic` (
@@ -153,7 +153,7 @@ CREATE TABLE `ui_code_os_type_dic` (
`view_code` varchar(255) DEFAULT NULL, `view_code` varchar(255) DEFAULT NULL,
`icon` varchar(255) DEFAULT NULL, `icon` 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_os_type_dic'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/code_os_type_dic';
@@ -172,7 +172,7 @@ CREATE TABLE `ui_code_service_type_dic` (
`service_type` varchar(255) DEFAULT '' COMMENT '业务类型', `service_type` varchar(255) DEFAULT '' COMMENT '业务类型',
`view_code` varchar(255) DEFAULT NULL COMMENT '界面编码', `view_code` varchar(255) DEFAULT NULL COMMENT '界面编码',
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_service_type_dic'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/code_service_type_dic';
CREATE TABLE `ui_code_web_service_dic` ( CREATE TABLE `ui_code_web_service_dic` (
@@ -182,7 +182,7 @@ CREATE TABLE `ui_code_web_service_dic` (
`view_code` varchar(255) DEFAULT '', `view_code` varchar(255) DEFAULT '',
`icon` varchar(255) DEFAULT '', `icon` varchar(255) DEFAULT '',
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_web_service_dic'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/code_web_service_dic';
@@ -201,7 +201,7 @@ CREATE TABLE `ui_service_dict_info` (
`editor_id` int(11) DEFAULT NULL COMMENT '修改人员取自sys_user.id', `editor_id` int(11) DEFAULT NULL COMMENT '修改人员取自sys_user.id',
`edit_time` datetime DEFAULT NULL COMMENT '修改时间', `edit_time` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`service_dict_id`) PRIMARY KEY (`service_dict_id`)
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/service_dict_info'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/service_dict_info';
CREATE TABLE `ui_request_info` ( CREATE TABLE `ui_request_info` (
@@ -222,7 +222,7 @@ CREATE TABLE `ui_service_dict_info` (
`task_id` bigint(20) DEFAULT NULL, `task_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `request_info_request_number` (`request_number`) USING BTREE UNIQUE KEY `request_info_request_number` (`request_number`) USING BTREE
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/request_info'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/request_info';
CREATE TABLE `ui_task_info` ( CREATE TABLE `ui_task_info` (
@@ -241,7 +241,7 @@ CREATE TABLE `ui_service_dict_info` (
`audit_time` date DEFAULT NULL, `audit_time` date DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `task_info_task_name` (`task_name`) USING BTREE UNIQUE KEY `task_info_task_name` (`task_name`) USING BTREE
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/task_info'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/task_info';
CREATE TABLE `ui_config_group_info` ( CREATE TABLE `ui_config_group_info` (
@@ -254,7 +254,7 @@ CREATE TABLE `ui_service_dict_info` (
`group_type` int(11) DEFAULT NULL COMMENT '1:协议2内容3区域 ,4 asn', `group_type` int(11) DEFAULT NULL COMMENT '1:协议2内容3区域 ,4 asn',
`compile_id` int(11) DEFAULT NULL, `compile_id` int(11) 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/config_group_info'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/config_group_info';
CREATE TABLE `ui_website_domain_topic` ( CREATE TABLE `ui_website_domain_topic` (
`id` bigint(20) NOT NULL AUTO_INCREMENT, `id` bigint(20) NOT NULL AUTO_INCREMENT,
@@ -267,7 +267,7 @@ CREATE TABLE `ui_service_dict_info` (
`desc` varchar(400) DEFAULT NULL COMMENT '描述信息', `desc` varchar(400) DEFAULT NULL COMMENT '描述信息',
`creator_id` int(11) DEFAULT NULL, `creator_id` int(11) 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/website_domain_topic'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/website_domain_topic';
@@ -307,4 +307,4 @@ CREATE TABLE `ui_http_url_cfg` (
`user_region4` varchar(1024) DEFAULT '' COMMENT '预留自定义域4', `user_region4` varchar(1024) DEFAULT '' COMMENT '预留自定义域4',
`user_region5` varchar(1024) DEFAULT '' COMMENT '预留自定义域5', `user_region5` varchar(1024) DEFAULT '' COMMENT '预留自定义域5',
PRIMARY KEY (`cfg_id`) PRIMARY KEY (`cfg_id`)
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@192.168.10.204:3306/gwall/http_url_cfg'; ) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/http_url_cfg';

View File

@@ -8,20 +8,26 @@ import org.apache.ibatis.annotations.Param;
import com.nis.domain.restful.dashboard.TrafficHttpStatistic; import com.nis.domain.restful.dashboard.TrafficHttpStatistic;
import com.nis.web.dao.MyBatisDao; import com.nis.web.dao.MyBatisDao;
@MyBatisDao @MyBatisDao
public interface TrafficHttpStatisticDao { public interface TrafficHttpStatisticDao {
TrafficHttpStatistic getMaxStatTime(); TrafficHttpStatistic getMaxStatTime();
List<TrafficHttpStatistic> websiteList(@Param("statTime")Date statTime);
//获取域名分类之后属于的网站
List<TrafficHttpStatistic> getDomainByWebsiteList(@Param("statTime")Date statTime);
Long preWebsiteListCount(@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);
List<Map> getDomainByTopicList(@Param("statTime") Date statTime,@Param("endTime")Date endTime); List<TrafficHttpStatistic> websiteList(@Param("statTime") Date statTime);
List<Map> getUiWebsiteDomainTopicList( );
List<Map> getDomainByTopicId( @Param("statTime")Date statTime ,@Param("endTime")Date endTime); // 获取域名分类之后属于的网站
List<Map> getDomainByWebsiteList(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
List<Map> preWebsiteListCount(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
List<Map> getDomainByWebsiteServiceId(@Param("webIdList") List webIdList,@Param("statTime") Date statTime, @Param("endTime") Date endTime);
Map websiteDomainOthers(@Param("webIdList") List webIdList, @Param("statTime") Date statTime,
@Param("endTime") Date endTime);
List<Map> getDomainByTopicList(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
List<Map> getDomainByTopicId(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
List getIdByWebSiteId(@Param("websiteId") Integer websiteId);
} }

View File

@@ -19,27 +19,33 @@
property="statTime" /> property="statTime" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num,
c2s_byte_len,
s2c_byte_len, s2c_byte_len,
stat_time stat_time
</sql> </sql>
<!-- 获取最近时间并且有效 --> <!-- 获取最近时间并且有效 -->
<select id="getMaxStatTime" <select id="getMaxStatTime"
resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic"> resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
SELECT stat_time statTime FROM traffic_http_statistic order by stat_time SELECT stat_time statTime FROM traffic_http_statistic order
by stat_time
desc limit 1 desc limit 1
</select> </select>
<!-- 根据服务网站将域名分类 网站列表 --> <!-- 根据服务网站将域名分类 网站列表 -->
<select id="getDomainByWebsiteList" <select id="getDomainByWebsiteList"
resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic"> resultType="java.util.HashMap">
SELECT SUM(c2s_byte_len+s2c_byte_len) count, IFNULL( website_service_id, SELECT
268435455 ) websiteServiceId IFNULL(
FROM TRAFFIC_HTTP_STATISTIC t website_service_id,
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id 268435455
where t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour) ) websiteServiceId,
GROUP BY u.website_service_id ORDER BY count desc limit 0,10 id
FROM
ui_website_domain_topic t group by website_service_id,id
</select> </select>
<!-- 根据主题将域名分类 主题列表 最近五分钟top10 --> <!-- 根据主题将域名分类 主题列表 最近五分钟top10 -->
<select id="getDomainByTopicList" resultType="java.util.HashMap"> <select id="getDomainByTopicList" resultType="java.util.HashMap">
SELECT SELECT
@@ -53,12 +59,11 @@
</select> </select>
<!--获取上个时间段该网站站域名流量的数据量 --> <!--获取上个时间段该网站站域名流量的数据量 -->
<select id="preWebsiteListCount" resultType="java.lang.Long"> <select id="preWebsiteListCount" resultType="java.util.HashMap">
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM traffic_http_statistic t select web_id webId, SUM(c2s_byte_len + s2c_byte_len) count from
LEFT JOIN ui_website_domain_topic u ON t.web_id = u.id traffic_http_statistic t where
WHERE u.website_service_id=#{websiteServiceId} <![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} group by t.web_id ]]>
and stat_time &lt; DATE_SUB(#{statTime},INTERVAL 1 hour)
and stat_time > DATE_SUB(#{statTime},INTERVAL 2 hour)
</select> </select>
<!--获取网站列表列表 --> <!--获取网站列表列表 -->
@@ -70,13 +75,29 @@
<!-- 根据网站分组获取子域名 --> <!-- 根据网站分组获取子域名 -->
<select id="getDomainByWebsiteServiceId" <select id="getDomainByWebsiteServiceId"
resultType="java.util.HashMap"> resultType="java.util.HashMap">
SELECT web_id webId,SUM(c2s_byte_len+s2c_byte_len) count SELECT
FROM traffic_http_statistic t web_id webId,
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id SUM(c2s_byte_len + s2c_byte_len) count
where u.website_service_id=#{websiteServiceId} FROM
and t.stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour) traffic_http_statistic t where
GROUP BY t.web_id ORDER BY count desc limit 0,10 <![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} ]]>
<if test="webIdList!=null and webIdList.size()>0">
and web_id in
<foreach collection="webIdList" item="singleType"
index="index" open="(" close=")" separator=",">
#{singleType}
</foreach>
</if>
group by t.web_id
</select> </select>
<select id="getIdByWebSiteId"
resultType="java.lang.String">
SELECT
distinct id FROM ui_website_domain_topic where website_service_id= #{websiteId}
</select>
<!-- 根据主题分组获取子域名 --> <!-- 根据主题分组获取子域名 -->
<select id="getDomainByTopicId" resultType="java.util.HashMap"> <select id="getDomainByTopicId" resultType="java.util.HashMap">
select web_id webId,sum(c2s_byte_len + s2c_byte_len) count from select web_id webId,sum(c2s_byte_len + s2c_byte_len) count from
@@ -91,9 +112,8 @@
<select id="websiteDomainOthers" resultType="java.util.HashMap"> <select id="websiteDomainOthers" resultType="java.util.HashMap">
SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM SELECT SUM(c2s_byte_len+s2c_byte_len) count FROM
traffic_http_statistic t traffic_http_statistic t
LEFT JOIN ui_website_domain_topic u ON t.web_id=u.id where
where u.website_service_id=#{websiteServiceId} <![CDATA[ stat_time>= #{statTime} and stat_time< #{endTime} ]]>
<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" <foreach collection="webIdList" item="singleType"
@@ -101,6 +121,6 @@
#{singleType} #{singleType}
</foreach> </foreach>
</if> </if>
and stat_time > DATE_SUB(#{statTime},INTERVAL 1 hour)
</select> </select>
</mapper> </mapper>

View File

@@ -466,32 +466,32 @@ public class DashboardService extends BaseService {
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(), // preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId(),
maxStatTime.getStatTime());// 上个时段的量 用于与现在对比 // maxStatTime.getStatTime());// 上个时段的量 用于与现在对比
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;
} // }
/** /**
* 根据网站服务查询子域名 * 根据网站服务查询子域名
@@ -500,28 +500,53 @@ public class DashboardService extends BaseService {
* @return list * @return list
*/ */
public List<Map> getDomainByWebsiteServiceId(Integer websiteServiceId) { public List<Map> getDomainByWebsiteServiceId(Integer websiteServiceId) {
List<Map> list = new ArrayList<Map>();
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime(); Date statTime = getBeforeByHourTime(1);// 获取上一个小时
if (maxStatTime != null) {
Date statTime = maxStatTime.getStatTime(); List idList = trafficHttpStatisticDao.getIdByWebSiteId(websiteServiceId);
list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId, statTime);
List webIdList = new ArrayList(); List<Map> matchList = trafficHttpStatisticDao.getDomainByWebsiteServiceId(idList, statTime, new Date());// 获取webid和count的对应关系,key是webid,val是count
// 查询固定网站下的域名除了TOP10以外的others域名 // 获取webid和count的对应关系,key是webid,val是count
if (list != null && list.size() > 0) { Set<Long> set = new HashSet<>();
for (Map map : list) { Map<Long, List<Map>> countMap = new HashMap();// 存储count和map的对应关系,后面根据count过滤,获取top10的count
webIdList.add(map.get("webId")); for (Map map : matchList) {
String countStr = String.valueOf(map.get("count"));
long count = Long.parseLong(countStr);
set.add(count);
if (countMap.containsKey(count)) {// 将每个count和对应的viewmap放到map中,count可能相同所以value是list
countMap.get(count).add(map);
} else {
List<Map> listMap = new ArrayList<>();
listMap.add(map);
countMap.put(count, listMap);
}
}
List<Map> top10Data = getTop10Data(set, countMap);
List<String> notTop10List = new ArrayList<>();// 获取不在top10中的webid,用来查询标记为orther
for (Map map : matchList) {
String webIdStr = String.valueOf(map.get("webId"));
boolean exist = false;
for (Map map1 : top10Data) {
String webIdStr1 = String.valueOf(map1.get("webId"));
if (webIdStr1 != null && webIdStr != null && webIdStr1.equals(webIdStr)) {
exist = true;
} }
if (list.size() > 10) { if (!exist) {
Map others = new HashMap(); notTop10List.add(webIdStr);
others = trafficHttpStatisticDao.websiteDomainOthers(webIdList, websiteServiceId, statTime);
if (others != null && others.size() > 0) {
others.put("webId", "-1");
list.add(others);
}
} }
} }
} }
return list;
// 查询固定网站下的域名除了TOP10以外的others域名
if (matchList != null && matchList.size() > 10) {
Map others = trafficHttpStatisticDao.websiteDomainOthers(notTop10List, statTime, new Date());
if (others != null && others.size() > 0) {
others.put("webId", "-1");
top10Data.add(others);
}
}
return top10Data;
} }
/** /**
@@ -531,31 +556,71 @@ public class DashboardService extends BaseService {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<Map> getDomainByWebsiteList() { public List<Map> getDomainByWebsiteList() {
List<Map> result = new ArrayList<Map>(); Date statTime = getBeforeByHourTime(1);// 获取上一个小时
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime(); Map<String, List<String>> websiteIdAndIdMap = new HashMap<>();// 存储websiteServiceId和id的对应关系,一个websiteServiceId有多个id
if (maxStatTime != null) { List<Map> websiteIdAndidList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime, new Date());// 获取website_service_id和id的对应关系,group
Date statTime = maxStatTime.getStatTime(); // by
List<TrafficHttpStatistic> websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime); // website_service_id,id
if (websiteList != null && websiteList.size() > 0) { for (Map map : websiteIdAndidList) {
Long preCount = 0l; Object websiteServiceIdObj = map.get("websiteServiceId");
for (TrafficHttpStatistic website : websiteList) { Object idObj = map.get("id");
Map map = new HashMap(); if (websiteServiceIdObj != null && idObj != null) {
map.put("websiteServiceId", website.getWesiteServiceId()); if (websiteIdAndIdMap.containsKey(String.valueOf(websiteServiceIdObj))) {
map.put("count", website.getCount()); websiteIdAndIdMap.get(String.valueOf(websiteServiceIdObj)).add(String.valueOf(idObj));
map.put("pktNum", 0); } else {
map.put("byteLen", 0); List<String> list = new ArrayList<>();
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWesiteServiceId(), statTime);// 上个时段的量 list.add(String.valueOf(idObj));
// 用于与现在对比 websiteIdAndIdMap.put(String.valueOf(websiteServiceIdObj), list);
if (preCount != null) {
map.put("preCount", preCount);
} else {
map.put("preCount", 0);
}
result.add(map);
} }
} }
} }
return result;
Set<Long> set = new HashSet<>();
Map<Long, List<Map>> countAndViewMap = new HashMap<>();// 存储count和map的对应关系,后面根据count过滤,获取top10的count
List<Map> webIdAndCountList = trafficHttpStatisticDao.preWebsiteListCount(statTime, new Date());// 获取最近一小时的webid和count的关系
List<Map> prevWebIdAndCountList = trafficHttpStatisticDao.preWebsiteListCount(getBeforeByHourTime(2), statTime);// 获取最近一小时的webid和count的关系
for (String websiteServiceId : websiteIdAndIdMap.keySet()) {// 遍历上面获取的websiteServiceId和id的对应关系,拼接json
Map viewMap = new HashMap<>();
long count = 0l;// 记录当前websiteServiceId所有的count
long prevCount = 0l;// 记录当前websiteServiceId所有的count
List<String> idList = websiteIdAndIdMap.get(websiteServiceId);// 根据websiteServiceId获取对应的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累加
}
}
}
for (Map webIdAndCountMap : prevWebIdAndCountList) {// 遍历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) {
prevCount += Long.parseLong(countStr);// 将count累加
}
}
}
}
viewMap.put("websiteServiceId", websiteServiceId);
viewMap.put("count", count);
viewMap.put("pktNum", 0);
viewMap.put("byteLen", 0);
viewMap.put("preCount", prevCount);
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);
} }
/** /**
@@ -616,6 +681,4 @@ public class DashboardService extends BaseService {
return getTop10Data(set, countAndViewMap); return getTop10Data(set, countAndViewMap);
} }
} }

View File

@@ -349,7 +349,7 @@ tapRedisDb=5
#0x205 基于PXY IP替换 517 #0x205 基于PXY IP替换 517
#0x402 APP DOMAIN特征发现 1026 #0x402 APP DOMAIN特征发现 1026
#0x404 APP IP特征 1028 #0x404 APP IP特征 1028
maat2Valve=33:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;512:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;513:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;514:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;515:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;517:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1026:strRegion|strStrRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1028:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;5:ipRegion@COMPILE_ID&USER_REGION&EFFECTIVE_RANGE maat2Valve=33:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;512:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;513:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;514:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;515:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;517:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1026:strRegion|strStrRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1028:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1040:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1056:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;5:ipRegion@COMPILE_ID&USER_REGION&EFFECTIVE_RANGE
##记录哪些service可以被分组复用(只有maat类配置可以被分组复用) ##记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
#业务ID:域类型1@表名,表名|域类型2@表名;业务ID:域类型1@表名,表名|域类型2@表名 #业务ID:域类型1@表名,表名|域类型2@表名;业务ID:域类型1@表名,表名|域类型2@表名

View File

@@ -29,6 +29,7 @@
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/> <t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
<t:field fieldType="String" srcName="effectiveRange" dstName="effective_range" isRequired="true"/> <t:field fieldType="String" srcName="effectiveRange" dstName="effective_range" isRequired="true"/>
<t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/> <t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/>
<t:field fieldType="String" srcName="userRegion" dstName="user_region" defaultVal="0"/>
</t:commonSource> </t:commonSource>
<!-- <!--
#0x05 DDOS流量丢弃 5=0:DDOS_PROTECT_TARGET_IP_CB #0x05 DDOS流量丢弃 5=0:DDOS_PROTECT_TARGET_IP_CB

View File

@@ -56,7 +56,7 @@
<p:maatType service="3;4;25;28;274"> <p:maatType service="3;4;25;28;274">
<p:expressions> <p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression> <p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
<p:valueExpression>[cfg_id];\t;0;\t;[addr_type];\t;[src_ip];\t;[mask_src_ip];\t;[src_port];\t;[mask_src_port];\t;[dst_ip];\t;[mask_dst_ip];\t;[dst_port];\t;[mask_dst_port];\t;[protocol];\t;[direction];\t;[is_valid];\t;[action];\t;[service];\t;[effective_range];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression> <p:valueExpression>[cfg_id];\t;0;\t;[addr_type];\t;[src_ip];\t;[mask_src_ip];\t;[src_port];\t;[mask_src_port];\t;[dst_ip];\t;[mask_dst_ip];\t;[dst_port];\t;[mask_dst_port];\t;[protocol];\t;[direction];\t;[is_valid];\t;[action];\t;[service];\t;[user_region];\t;[effective_range];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression>
</p:expressions> </p:expressions>
<p:sequences> <p:sequences>
<p:operation>1</p:operation> <p:operation>1</p:operation>