1:合并maat类配置删除接口
2:修改首页流量统计实体类中pps与gbps的数据类型,并修改从clickhouse中查询的sql
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
package com.nis.domain.restful.dashboard;
|
package com.nis.domain.restful.dashboard;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class TrafficTransStatistic {
|
public class TrafficTransStatistic implements Serializable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private Integer statId ;
|
private Integer statId ;
|
||||||
private String addrType ;
|
private String addrType ;
|
||||||
private Integer transType ;
|
private Integer transType ;
|
||||||
@@ -15,19 +20,19 @@ public class TrafficTransStatistic {
|
|||||||
private Date statTime ;
|
private Date statTime ;
|
||||||
|
|
||||||
private String time;
|
private String time;
|
||||||
private Long pps;
|
private String pps;
|
||||||
private Long gbps;
|
private String gbps;
|
||||||
|
|
||||||
public Long getPps() {
|
public String getPps() {
|
||||||
return pps;
|
return pps;
|
||||||
}
|
}
|
||||||
public void setPps(Long pps) {
|
public void setPps(String pps) {
|
||||||
this.pps = pps;
|
this.pps = pps;
|
||||||
}
|
}
|
||||||
public Long getGbps() {
|
public String getGbps() {
|
||||||
return gbps;
|
return gbps;
|
||||||
}
|
}
|
||||||
public void setGbps(Long gbps) {
|
public void setGbps(String gbps) {
|
||||||
this.gbps = gbps;
|
this.gbps = gbps;
|
||||||
}
|
}
|
||||||
public String getTime() {
|
public String getTime() {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class MaatTestController {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
try {
|
try {
|
||||||
if (!configRedisService.delMaatConfig(compileMap)) {
|
if (!configRedisService.delMaatConfig(compileMap,false)) {
|
||||||
FileUtils.addStrToFile(
|
FileUtils.addStrToFile(
|
||||||
sdf.format(new Date()) + "\t" + "error:删除业务类型" + serviceType + "下的maat配置" + configId + "失败\n",
|
sdf.format(new Date()) + "\t" + "error:删除业务类型" + serviceType + "下的maat配置" + configId + "失败\n",
|
||||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ import com.zdjizhi.utils.StringUtil;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("${servicePath}/ckLog/v1")
|
@RequestMapping("${servicePath}/log/v2")
|
||||||
@Api(value = "TrafficeReportController", description = "流量统计查询报表controller")
|
@Api(value = "TrafficeReportController", description = "流量统计查询报表controller")
|
||||||
public class TrafficeReportController extends BaseRestController {
|
public class TrafficeReportController extends BaseRestController {
|
||||||
|
|
||||||
|
|||||||
@@ -62,10 +62,6 @@ public interface TrafficReportDao extends CrudDao {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NtcTotalReport getMaxReportTime();
|
NtcTotalReport getMaxReportTime();
|
||||||
Map getMaxStatTime();
|
Map getMaxStatTime();
|
||||||
List<Map> getTotalReportList(@Param("reportTime") Date reportTime);
|
List<Map> getTotalReportList(@Param("reportTime") Date reportTime);
|
||||||
|
|||||||
@@ -170,11 +170,11 @@
|
|||||||
</if>
|
</if>
|
||||||
<if
|
<if
|
||||||
test="searchReportStartTime != null and searchReportStartTime !=''">
|
test="searchReportStartTime != null and searchReportStartTime !=''">
|
||||||
<![CDATA[AND REPORT_TIME > STR_TO_DATE(#{searchReportStartTime},'%Y-%m-%d %H:%i:%s')]]>
|
<![CDATA[AND REPORT_TIME >= STR_TO_DATE(#{searchReportStartTime},'%Y-%m-%d %H:%i:%s')]]>
|
||||||
</if>
|
</if>
|
||||||
<if
|
<if
|
||||||
test="searchReportEndTime != null and searchReportEndTime !=''">
|
test="searchReportEndTime != null and searchReportEndTime !=''">
|
||||||
<![CDATA[AND REPORT_TIME <= STR_TO_DATE(#{searchReportEndTime},'%Y-%m-%d %H:%i:%s')]]>
|
<![CDATA[AND REPORT_TIME < STR_TO_DATE(#{searchReportEndTime},'%Y-%m-%d %H:%i:%s')]]>
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
<choose>
|
<choose>
|
||||||
@@ -913,17 +913,19 @@
|
|||||||
|
|
||||||
|
|
||||||
<resultMap id="BandwidthResultMap" type="com.nis.domain.restful.dashboard.TrafficTransStatistic">
|
<resultMap id="BandwidthResultMap" type="com.nis.domain.restful.dashboard.TrafficTransStatistic">
|
||||||
<id column="stat_id" jdbcType="INTEGER" property="statId" />
|
<id column="stat_id" jdbcType="INTEGER" property="statId" />
|
||||||
<result column="addr_type" jdbcType="INTEGER" property="addrType" />
|
<result column="addr_type" jdbcType="INTEGER" property="addrType" />
|
||||||
<result column="trans_type" jdbcType="INTEGER" property="transType" />
|
<result column="trans_type" jdbcType="INTEGER" property="transType" />
|
||||||
<result column="entrance_id" jdbcType="INTEGER" property="entranceId" />
|
<result column="entrance_id" jdbcType="INTEGER" property="entranceId" />
|
||||||
<result column="link_num" jdbcType="BIGINT" property="linkNum" />
|
<result column="link_num" jdbcType="BIGINT" property="linkNum" />
|
||||||
<result column="c2s_pkt_num" jdbcType="BIGINT" property="c2sPktNum" />
|
<result column="c2s_pkt_num" jdbcType="BIGINT" property="c2sPktNum" />
|
||||||
<result column="s2c_pkt_num" jdbcType="BIGINT" property="s2cPktNum" />
|
<result column="s2c_pkt_num" jdbcType="BIGINT" property="s2cPktNum" />
|
||||||
<result column="c2s_byte_len" jdbcType="BIGINT" property="c2sByteLen" />
|
<result column="c2s_byte_len" jdbcType="BIGINT" property="c2sByteLen" />
|
||||||
<result column="s2c_byte_len" jdbcType="BIGINT" property="s2cByteLen" />
|
<result column="s2c_byte_len" jdbcType="BIGINT" property="s2cByteLen" />
|
||||||
<result column="stat_time" jdbcType="TIMESTAMP" property="statTime" />
|
<result column="pps" jdbcType="BIGINT" property="pps" />
|
||||||
</resultMap>
|
<result column="gbps" jdbcType="BIGINT" property="gbps" />
|
||||||
|
<result column="stat_time" jdbcType="TIMESTAMP" property="statTime" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<!-- 获取取阻断,监测等流量信息最近时间 -->
|
<!-- 获取取阻断,监测等流量信息最近时间 -->
|
||||||
<select id="getMaxReportTime" resultType="com.nis.domain.restful.dashboard.NtcTotalReport">
|
<select id="getMaxReportTime" resultType="com.nis.domain.restful.dashboard.NtcTotalReport">
|
||||||
@@ -950,17 +952,13 @@
|
|||||||
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
|
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
|
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
|
) total_traffic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 获取近一小时的带宽根据ip46,协议 tcp,udp变化 -->
|
<!-- 获取近一小时的带宽根据ip46,协议 tcp,udp变化 -->
|
||||||
<select id="getBandwidthTrans" resultMap="BandwidthResultMap">
|
<select id="getBandwidthTrans" resultMap="BandwidthResultMap">
|
||||||
select IFNULL((SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024,0) gbps,IFNULL(SUM(c2s_pkt_num+s2c_pkt_num)/300,0) pps,IFNULL(SUM(link_num),0) linkNum, stat_time time from traffic_trans_statistic
|
select (SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024 gbps, SUM(c2s_pkt_num+s2c_pkt_num)/300 pps, SUM(link_num) linkNum, stat_time time from traffic_trans_statistic
|
||||||
where <![CDATA[stat_time>=#{beginDate} and stat_time<=#{endDate} ]]>
|
where <![CDATA[stat_time>=#{beginDate} and stat_time<#{endDate} ]]>
|
||||||
<if test="addrType != null">
|
<if test="addrType != null">
|
||||||
and addr_type=#{addrType}
|
and addr_type=#{addrType}
|
||||||
</if>
|
</if>
|
||||||
@@ -972,8 +970,8 @@
|
|||||||
</select>
|
</select>
|
||||||
<!-- 获取近一小时的带宽根据ip46,协议 tcp,udp变化 -->
|
<!-- 获取近一小时的带宽根据ip46,协议 tcp,udp变化 -->
|
||||||
<select id="getBandwidthTrans2" resultMap="BandwidthResultMap">
|
<select id="getBandwidthTrans2" resultMap="BandwidthResultMap">
|
||||||
select addr_type,trans_type,entrance_id,IFNULL((SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024,0) gbps,IFNULL(SUM(c2s_pkt_num+s2c_pkt_num)/300,0) pps,IFNULL(SUM(link_num),0) linkNum, stat_time time from traffic_trans_statistic
|
select addr_type,trans_type,entrance_id, (SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024 gbps, SUM(c2s_pkt_num+s2c_pkt_num)/300 pps, SUM(link_num) linkNum, stat_time time from traffic_trans_statistic
|
||||||
where <![CDATA[stat_time<=#{endDate} and stat_time>=#{beginDate}]]>
|
where <![CDATA[stat_time<#{endDate} and stat_time>=#{beginDate}]]>
|
||||||
and addr_type !=0
|
and addr_type !=0
|
||||||
and trans_type!=0
|
and trans_type!=0
|
||||||
group by stat_time,addr_type,trans_type order by stat_time
|
group by stat_time,addr_type,trans_type order by stat_time
|
||||||
@@ -988,7 +986,7 @@
|
|||||||
<!-- entrance 1,2 ,动作为阻断,近一小时 间隔5分钟数据 -->
|
<!-- entrance 1,2 ,动作为阻断,近一小时 间隔5分钟数据 -->
|
||||||
<select id="getActionTrans" resultType="com.nis.domain.restful.NtcEntranceReport">
|
<select id="getActionTrans" resultType="com.nis.domain.restful.NtcEntranceReport">
|
||||||
select sum(sum) sum,report_time time from ntc_entrance_report r where
|
select sum(sum) sum,report_time time from ntc_entrance_report r where
|
||||||
<![CDATA[${serviceSql} and report_time<=#{endDate} and report_time>=#{beginDate}]]>
|
<![CDATA[${serviceSql} and report_time<#{endDate} and report_time>=#{beginDate}]]>
|
||||||
and entrance_id=#{entranceId}
|
and entrance_id=#{entranceId}
|
||||||
group by report_time order by report_time
|
group by report_time order by report_time
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -1011,11 +1011,11 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
list.add(i);
|
list.add(i);
|
||||||
}
|
}
|
||||||
serviceConfigMap.put(129, list);
|
serviceConfigMap.put(129, list);
|
||||||
delMaatConfig(serviceConfigMap);
|
delMaatConfig(serviceConfigMap,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean delMaatConfig(Map<Integer, List<Long>> serviceConfigMap) {
|
public boolean delMaatConfig(Map<Integer, List<Long>> serviceConfigMap,boolean isStart) {
|
||||||
if (serviceConfigMap != null && serviceConfigMap.size() > 0) {
|
if (serviceConfigMap != null && serviceConfigMap.size() > 0) {
|
||||||
Jedis resource = JedisUtils.getResource(0);
|
Jedis resource = JedisUtils.getResource(0);
|
||||||
Transaction transaction = resource.multi();
|
Transaction transaction = resource.multi();
|
||||||
@@ -1036,82 +1036,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
// 按序号选择Redis数据库
|
// 按序号选择Redis数据库
|
||||||
transaction.select(redisDb);
|
transaction.select(redisDb);
|
||||||
removeConfig(id, maatXmlConfig, maatVersion, service, transaction, redisDb,
|
removeConfig(id, maatXmlConfig, maatVersion, service, transaction, redisDb,
|
||||||
idRelaRedisDBIndex);
|
idRelaRedisDBIndex,isStart);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new ServiceRuntimeException("删除配置时,未发现对应的配置id信息,请检查配置参数是否正确",
|
|
||||||
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
||||||
}
|
|
||||||
transaction.incrBy("MAAT_VERSION", 1l);
|
|
||||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDb,
|
|
||||||
Integer.valueOf(maatVersionStr) + 1);
|
|
||||||
} else {
|
|
||||||
throw new ServiceRuntimeException("从" + redisDb
|
|
||||||
+ "号redis库中获取MAAT_VERSION的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
|
||||||
RestBusinessCode.GetMaatVersionFailure.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new ServiceRuntimeException("删除maat类配置时,未发现对应的配置信息,请检查配置参数是否正确",
|
|
||||||
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
||||||
}
|
|
||||||
if (removeMaatRelation(serviceConfigMap, transaction, null)
|
|
||||||
&& removeStatisticsReal(serviceConfigMap, transaction, null)) {
|
|
||||||
transaction.exec();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
transaction.discard();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (JedisConnectionException e) {
|
|
||||||
String error = "连接redis异常,删除maat配置失败," + e.getMessage();
|
|
||||||
logger.error(error + " " + ExceptionUtil.getExceptionMsg(e));
|
|
||||||
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
int businessCode = RestBusinessCode.service_runtime_error.getValue();
|
|
||||||
if (e instanceof ServiceRuntimeException) {
|
|
||||||
businessCode = ((ServiceRuntimeException) e).getErrorCode();
|
|
||||||
}
|
|
||||||
logger.error("删除maat配置发生了异常" + ExceptionUtil.getExceptionMsg(e));
|
|
||||||
transaction.discard();
|
|
||||||
throw new ServiceRuntimeException("删除maat配置发生了异常," + e.getMessage(), businessCode);
|
|
||||||
} finally {
|
|
||||||
// 释放连接到连接池
|
|
||||||
JedisUtils.returnResource(resource);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
|
|
||||||
{
|
|
||||||
throw new ServiceRuntimeException("Map参数信息不能为空,请检查!", RestBusinessCode.ConfigInfoMapIsNull.getValue());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean startStopMaatConfig(Map<Integer, List<Long>> serviceConfigMap, boolean isStart) {
|
|
||||||
if (serviceConfigMap != null && serviceConfigMap.size() > 0) {
|
|
||||||
Jedis resource = JedisUtils.getResource(0);
|
|
||||||
Transaction transaction = resource.multi();
|
|
||||||
try {
|
|
||||||
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
|
|
||||||
if (serviceConfigMap != null && serviceConfigMap.size() > 0) {
|
|
||||||
for (Integer service : serviceConfigMap.keySet()) {
|
|
||||||
Map<Integer, Set<Long>> compileIdAndDBReal = getCompileIdAndDBReal(
|
|
||||||
serviceConfigMap.get(service), service, idRelaRedisDBIndex);
|
|
||||||
for (Integer redisDb : compileIdAndDBReal.keySet()) {
|
|
||||||
String maatVersionStr = JedisUtils.get("MAAT_VERSION", redisDb);
|
|
||||||
if (maatVersionStr != null) {
|
|
||||||
Double maatVersion = Double.valueOf(maatVersionStr) + 1D;
|
|
||||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
||||||
Set<Long> list = compileIdAndDBReal.get(redisDb);
|
|
||||||
if (list != null && list.size() > 0) {
|
|
||||||
for (Long id : list) {
|
|
||||||
// 按序号选择Redis数据库
|
|
||||||
transaction.select(redisDb);
|
|
||||||
startStopConfig(id, maatXmlConfig, maatVersion, service, transaction, redisDb,
|
|
||||||
idRelaRedisDBIndex, isStart);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceRuntimeException("删除配置时,未发现对应的配置id信息,请检查配置参数是否正确",
|
throw new ServiceRuntimeException("删除配置时,未发现对应的配置id信息,请检查配置参数是否正确",
|
||||||
@@ -1165,6 +1090,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取关联关系中每个关系中的-前部分
|
* 获取关联关系中每个关系中的-前部分
|
||||||
*
|
*
|
||||||
@@ -1188,120 +1115,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
* @param service 业务类型
|
* @param service 业务类型
|
||||||
* @param redisTemplate
|
* @param redisTemplate
|
||||||
* @param maatRelation id对应关系对象
|
* @param maatRelation id对应关系对象
|
||||||
|
* @param isStart 是否将配置置为生效
|
||||||
*/
|
*/
|
||||||
private void removeConfig(Long id, MaatXmlConfig maatXmlConfig, Double maatVersion, int service,
|
private void removeConfig(Long id, MaatXmlConfig maatXmlConfig, Double maatVersion, int service,
|
||||||
Transaction transaction, int redisDBIndex, int idRelaRedisDBIndex) {
|
|
||||||
if (maatXmlConfig != null) {
|
|
||||||
Map<String, String> keyMap = new HashMap<>();
|
|
||||||
|
|
||||||
// 删除(重命名)编译配置
|
|
||||||
removeCompileAndGroupConfig(maatXmlConfig, id + "", 10, maatVersion, service, transaction, redisDBIndex,
|
|
||||||
null, null);// 10代表是编译配置
|
|
||||||
// 拼接编译与分组关系的Redis Key
|
|
||||||
String compileStr = "COMPILEGROUP:" + id;
|
|
||||||
// 获取当前编译配置与分组配置的关联关系
|
|
||||||
String compileStrVal = JedisUtils.get(compileStr, idRelaRedisDBIndex);// 根据编译id获取该编译下的分组关系
|
|
||||||
if (compileStrVal != null && !compileStrVal.trim().equals("")) {
|
|
||||||
String[] compileGroupStrArr = org.apache.commons.lang.StringUtils.split(compileStrVal, ";");
|
|
||||||
for (String compileGroup : compileGroupStrArr) {
|
|
||||||
if (compileGroup != null && !compileGroup.trim().equals("")) {
|
|
||||||
String groupCompileStrs = getRegionInfo(compileGroup);// 获取编译对应的分组信息,去除后面的redisdb信息
|
|
||||||
if (groupCompileStrs != null && !groupCompileStrs.trim().equals("")) {// 遍历编译和分组的信息
|
|
||||||
String[] split = org.apache.commons.lang.StringUtils.split(groupCompileStrs, ";");
|
|
||||||
|
|
||||||
for (String groupId : split) {// GROUPCOMPILE:groupid-redisdb
|
|
||||||
if (groupId != null && !groupId.trim().equals("")) {
|
|
||||||
String groupCompileAndDBStrs = null;
|
|
||||||
if (!keyMap.containsKey(groupId)) {
|
|
||||||
groupCompileAndDBStrs = JedisUtils.get(groupId, idRelaRedisDBIndex);
|
|
||||||
keyMap.put(groupId, groupCompileAndDBStrs);
|
|
||||||
} else {
|
|
||||||
groupCompileAndDBStrs = keyMap.get(groupId);
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] compileGroupArr = org.apache.commons.lang.StringUtils
|
|
||||||
.split(groupCompileAndDBStrs, ";");// 获取组对应的编译id
|
|
||||||
|
|
||||||
for (String groupAndCompileStr : compileGroupArr) {
|
|
||||||
if (groupAndCompileStr != null && !groupAndCompileStr.trim().equals("")) {
|
|
||||||
String compileId = getRegionInfo(groupAndCompileStr);
|
|
||||||
if (compileId != null && !compileId.trim().equals("")) {
|
|
||||||
// 被分组复用的业务,不能将域置为失效
|
|
||||||
if (!ServiceAndRDBIndexReal.serviceIsReuse(service)) {// 如果当前业务不允许被分组复用(普通的maat类配置),则可以将域置为失效,否则不将域置为失效
|
|
||||||
// 如果只有一个编译id且与上面的编译id相同则说明未被分组复用,可以将其下的所有域置失效,否则不处理域配置,只把编译,分组关系置为无效
|
|
||||||
if (compileId.equals(compileStr)) {//
|
|
||||||
String groupRegionKey = groupId.replace("GROUPCOMPILE",
|
|
||||||
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
|
||||||
String regionStrs = null;
|
|
||||||
if (!keyMap.containsKey(groupRegionKey)) {
|
|
||||||
regionStrs = JedisUtils.get(groupRegionKey,
|
|
||||||
idRelaRedisDBIndex);
|
|
||||||
keyMap.put(groupRegionKey, regionStrs);
|
|
||||||
} else {
|
|
||||||
regionStrs = keyMap.get(groupRegionKey);
|
|
||||||
}
|
|
||||||
if (regionStrs != null && !regionStrs.trim().equals("")) {
|
|
||||||
String[] regionStrArr = regionStrs.split(";");
|
|
||||||
for (String str : regionStrArr) {
|
|
||||||
if (str != null && !str.trim().equals("")) {
|
|
||||||
|
|
||||||
String regionStr = getRegionInfo(str);
|
|
||||||
if (regionStr != null
|
|
||||||
&& !regionStr.trim().equals("")) {
|
|
||||||
String[] regionKeyArr = regionStr.split(";");
|
|
||||||
if (regionKeyArr != null
|
|
||||||
&& regionKeyArr.length > 0) {
|
|
||||||
// 根据分组与域关联关系找到对应域配置然后删除(重命名)
|
|
||||||
removeRegionConfig(maatXmlConfig,
|
|
||||||
regionKeyArr, maatVersion, service,
|
|
||||||
transaction, redisDBIndex, null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new ServiceRuntimeException("从"
|
|
||||||
+ idRelaRedisDBIndex
|
|
||||||
+ "号redis库中无法获取MAAT配置分组与域的关联关系,key为"
|
|
||||||
+ groupRegionKey,
|
|
||||||
RestBusinessCode.KeyNotExistsInRedis
|
|
||||||
.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 根据分组与编译关联关系找到对应分组配置然后删除(重命名)
|
|
||||||
removeCompileAndGroupConfig(maatXmlConfig,
|
|
||||||
groupId.replace("GROUPCOMPILE:", ""), 11, maatVersion, service,
|
|
||||||
transaction, redisDBIndex, id + "", null);// 11代表是分组配置
|
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new ServiceRuntimeException(
|
|
||||||
"从" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置分组与编译的关联关系,key为"
|
|
||||||
+ groupId,
|
|
||||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new ServiceRuntimeException(
|
|
||||||
"从" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置编译与分组关联关系,key为" + compileStr,
|
|
||||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
|
|
||||||
{
|
|
||||||
throw new ServiceRuntimeException(
|
|
||||||
"无法从applicationConfig-maatRedis.xml配置文件中获取service为" + service + "对应的规则,请检查业务类型是否正确",
|
|
||||||
RestBusinessCode.NotFoundRedisRule.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startStopConfig(Long id, MaatXmlConfig maatXmlConfig, Double maatVersion, int service,
|
|
||||||
Transaction transaction, int redisDBIndex, int idRelaRedisDBIndex, boolean isStart) {
|
Transaction transaction, int redisDBIndex, int idRelaRedisDBIndex, boolean isStart) {
|
||||||
if (maatXmlConfig != null) {
|
if (maatXmlConfig != null) {
|
||||||
Map<String, String> keyMap = new HashMap<>();
|
Map<String, String> keyMap = new HashMap<>();
|
||||||
@@ -1457,9 +1273,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
}
|
}
|
||||||
if (isStart == null) {// 置为失效
|
if (isStart == null) {// 置为失效
|
||||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
} else if (isStart == true) {// 将失效置为生效
|
} else if (isStart) {// 将失效置为生效
|
||||||
maatKey = oldKey;
|
maatKey = oldKey;
|
||||||
oldKey=oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
oldKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
} else {// 将生效变为失效
|
} else {// 将生效变为失效
|
||||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
}
|
}
|
||||||
@@ -1505,7 +1321,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
if (oldKey != null && !oldKey.trim().equals("")) {
|
if (oldKey != null && !oldKey.trim().equals("")) {
|
||||||
if (isStart == null) {// 置为失效
|
if (isStart == null) {// 置为失效
|
||||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
} else if (isStart == true) {// 将失效置为生效
|
} else if (isStart) {// 将失效置为生效
|
||||||
maatKey = oldKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
maatKey = oldKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||||
} else {// 将生效变为失效
|
} else {// 将生效变为失效
|
||||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
@@ -1552,14 +1368,20 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
if (idList != null && idList.size() > 0) {
|
if (idList != null && idList.size() > 0) {
|
||||||
for (Long compileId : idList) {
|
for (Long compileId : idList) {
|
||||||
String effectiveRuleKey = "EFFECTIVE_RULE:" + maatTableName + "," + compileId;
|
String effectiveRuleKey = "EFFECTIVE_RULE:" + maatTableName + "," + compileId;
|
||||||
transaction.rename(effectiveRuleKey.toUpperCase(),
|
if (isStart) {
|
||||||
effectiveRuleKey.toUpperCase().replace("EFFECTIVE_RULE", "OBSOLETE_RULE"));
|
transaction.rename(
|
||||||
|
effectiveRuleKey.toUpperCase().replace("EFFECTIVE_RULE", "OBSOLETE_RULE"),
|
||||||
|
effectiveRuleKey.toUpperCase());
|
||||||
|
} else {
|
||||||
|
transaction.rename(effectiveRuleKey.toUpperCase(),
|
||||||
|
effectiveRuleKey.toUpperCase().replace("EFFECTIVE_RULE", "OBSOLETE_RULE"));
|
||||||
|
}
|
||||||
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是:{}", redisStatisticsRealDBIndex,
|
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是:{}", redisStatisticsRealDBIndex,
|
||||||
effectiveRuleKey.toUpperCase(),
|
effectiveRuleKey.toUpperCase(),
|
||||||
effectiveRuleKey.toUpperCase().replace("EFFECTIVE_RULE", "OBSOLETE_RULE"));
|
effectiveRuleKey.toUpperCase().replace("EFFECTIVE_RULE", "OBSOLETE_RULE"));
|
||||||
String zset = effectiveRuleKey.replace("EFFECTIVE_RULE:", "DEL,");
|
String zset = effectiveRuleKey.replace("EFFECTIVE_RULE:", "DEL,");
|
||||||
if (isStart == null || isStart == false) {
|
if (isStart == null || isStart == false) {
|
||||||
} else if (isStart == true) {
|
} else if (isStart) {
|
||||||
zset = effectiveRuleKey.replace("EFFECTIVE_RULE:", "ADD,");
|
zset = effectiveRuleKey.replace("EFFECTIVE_RULE:", "ADD,");
|
||||||
}
|
}
|
||||||
transaction.zadd("MAAT_UPDATE_STATUS", maatVersion, zset);
|
transaction.zadd("MAAT_UPDATE_STATUS", maatVersion, zset);
|
||||||
@@ -1640,23 +1462,63 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
String groupRegion = groupCompile.replace("GROUPCOMPILE",
|
String groupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||||
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||||
|
|
||||||
|
String groupRegionVal = JedisUtils.get(groupRegion,
|
||||||
|
idRelaRedisDBIndex);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
||||||
// 删除分组与域的关联关系
|
// 删除分组与域的关联关系
|
||||||
if (isStart == null) {// 删除
|
if (isStart == null) {// 删除
|
||||||
transaction.del(groupRegion);
|
transaction.del(groupRegion);
|
||||||
} else if (isStart == true) {// 将失效置为生效
|
} else if (isStart) {// 将失效置为生效
|
||||||
String groupRegionVal = JedisUtils.get(groupRegion,
|
|
||||||
idRelaRedisDBIndex);
|
|
||||||
groupRegionVal = groupRegionVal
|
groupRegionVal = groupRegionVal
|
||||||
.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||||
transaction.set(groupRegion, groupRegionVal);
|
String[] split = org.apache.commons.lang.StringUtils
|
||||||
|
.split(groupRegionVal, ";");
|
||||||
|
if (split.length > 1) {
|
||||||
|
Set<String> set = new HashSet<>();
|
||||||
|
for (String regionKeyStr : split) {
|
||||||
|
if (regionKeyStr != null && !regionKeyStr
|
||||||
|
.trim().equals("")) {
|
||||||
|
set.add(regionKeyStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (String regionKeyStr : set) {
|
||||||
|
sb.append(";");
|
||||||
|
sb.append(regionKeyStr);
|
||||||
|
}
|
||||||
|
transaction.set(groupRegion, sb.toString());// 避免有多个重复的region-key
|
||||||
|
} else {
|
||||||
|
transaction.set(groupRegion.toUpperCase(),
|
||||||
|
groupRegionVal);
|
||||||
|
}
|
||||||
} else {// 将生效变为失效
|
} else {// 将生效变为失效
|
||||||
String groupRegionVal = JedisUtils.get(groupRegion,
|
|
||||||
idRelaRedisDBIndex);
|
|
||||||
groupRegionVal = groupRegionVal
|
groupRegionVal = groupRegionVal
|
||||||
.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
transaction.set(groupRegion, groupRegionVal);
|
String[] split = org.apache.commons.lang.StringUtils
|
||||||
|
.split(groupRegionVal, ";");
|
||||||
|
if (split.length > 1) {
|
||||||
|
Set<String> set = new HashSet<>();
|
||||||
|
|
||||||
|
for (String regionKeyStr : split) {
|
||||||
|
if (regionKeyStr != null && !regionKeyStr
|
||||||
|
.trim().equals("")) {
|
||||||
|
set.add(regionKeyStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (String regionKeyStr : set) {
|
||||||
|
sb.append(";");
|
||||||
|
sb.append(regionKeyStr);
|
||||||
|
}
|
||||||
|
transaction.set(groupRegion, sb.toString());// 避免有多个重复的region-key
|
||||||
|
|
||||||
|
} else {
|
||||||
|
transaction.set(groupRegion.toUpperCase(),
|
||||||
|
groupRegionVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1676,9 +1538,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
// 删除分组与编译的关联关系
|
// 删除分组与编译的关联关系
|
||||||
if (groupCompileStrVal != null
|
if (groupCompileStrVal != null
|
||||||
&& !groupCompileStrVal.trim().equals("")) {
|
&& !groupCompileStrVal.trim().equals("")) {
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
String[] split = org.apache.commons.lang.StringUtils
|
String[] split = org.apache.commons.lang.StringUtils
|
||||||
.split(groupCompileStrVal, ";");
|
.split(groupCompileStrVal, ";");
|
||||||
|
Set<String> set = new HashSet<>();
|
||||||
for (String groupCompileAndDBStr : split) {
|
for (String groupCompileAndDBStr : split) {
|
||||||
if (groupCompileAndDBStr != null
|
if (groupCompileAndDBStr != null
|
||||||
&& !groupCompileAndDBStr.trim().equals("")) {
|
&& !groupCompileAndDBStr.trim().equals("")) {
|
||||||
@@ -1689,25 +1551,68 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
try {
|
try {
|
||||||
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
||||||
// 删除当前组所对应的编译
|
// 删除当前组所对应的编译
|
||||||
|
String groupRegionVal = JedisUtils.get(
|
||||||
|
groupCompile.toUpperCase(),
|
||||||
|
idRelaRedisDBIndex);
|
||||||
if (isStart == null) {// 删除
|
if (isStart == null) {// 删除
|
||||||
transaction.del(groupCompile.toUpperCase());// 删除编译与分组的关联关系
|
transaction.del(groupCompile.toUpperCase());// 删除编译与分组的关联关系
|
||||||
} else if (isStart == true) {// 将失效置为生效
|
} else if (isStart) {// 将失效置为生效
|
||||||
String groupRegionVal = JedisUtils.get(
|
|
||||||
groupCompile.toUpperCase(),
|
|
||||||
idRelaRedisDBIndex);
|
|
||||||
groupRegionVal = groupRegionVal.replace(
|
groupRegionVal = groupRegionVal.replace(
|
||||||
"OBSOLETE_RULE", "EFFECTIVE_RULE");
|
"OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||||
transaction.set(groupCompile.toUpperCase(),
|
String[] split2 = org.apache.commons.lang.StringUtils
|
||||||
groupRegionVal);
|
.split(groupRegionVal, ";");
|
||||||
|
if (split2.length > 1) {
|
||||||
|
Set<String> set1 = new HashSet<>();
|
||||||
|
for (String regionKeyStr : split2) {
|
||||||
|
if (regionKeyStr != null
|
||||||
|
&& !regionKeyStr.trim()
|
||||||
|
.equals("")) {
|
||||||
|
set1.add(regionKeyStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (String regionKeyStr : set1) {
|
||||||
|
sb.append(";");
|
||||||
|
sb.append(regionKeyStr);
|
||||||
|
}
|
||||||
|
transaction.set(
|
||||||
|
groupCompile.toUpperCase(),
|
||||||
|
sb.toString());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
transaction.set(
|
||||||
|
groupCompile.toUpperCase(),
|
||||||
|
groupRegionVal);
|
||||||
|
}
|
||||||
} else {// 将生效变为失效
|
} else {// 将生效变为失效
|
||||||
String groupRegionVal = JedisUtils.get(
|
|
||||||
groupCompile.toUpperCase(),
|
|
||||||
idRelaRedisDBIndex);
|
|
||||||
groupRegionVal = groupRegionVal.replace(
|
groupRegionVal = groupRegionVal.replace(
|
||||||
"EFFECTIVE_RULE", "OBSOLETE_RULE");
|
"EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
transaction.set(groupCompile.toUpperCase(),
|
|
||||||
groupRegionVal);
|
String[] split2 = org.apache.commons.lang.StringUtils
|
||||||
|
.split(groupRegionVal, ";");
|
||||||
|
if (split2.length > 1) {
|
||||||
|
|
||||||
|
Set<String> set2 = new HashSet<>();
|
||||||
|
for (String regionKeyStr : split2) {
|
||||||
|
if (regionKeyStr != null
|
||||||
|
&& !regionKeyStr.trim()
|
||||||
|
.equals("")) {
|
||||||
|
set2.add(regionKeyStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (String regionKeyStr : set2) {
|
||||||
|
sb.append(";");
|
||||||
|
sb.append(regionKeyStr);
|
||||||
|
}
|
||||||
|
transaction.set(
|
||||||
|
groupCompile.toUpperCase(),
|
||||||
|
sb.toString());
|
||||||
|
} else {
|
||||||
|
transaction.set(
|
||||||
|
groupCompile.toUpperCase(),
|
||||||
|
groupRegionVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceRuntimeException("从"
|
throw new ServiceRuntimeException("从"
|
||||||
@@ -1718,15 +1623,20 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
.getValue());
|
.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!groupCompileAndDBStr
|
// } else if (!groupCompileAndDBStr
|
||||||
.contains(compileStr.toUpperCase())) {
|
// .contains(compileStr.toUpperCase())) {
|
||||||
sb.append(groupCompileAndDBStr + ";");
|
} else {
|
||||||
|
set.add(groupCompileAndDBStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sb.length() > 0) {
|
if (set.size() > 0) {
|
||||||
transaction.set(groupCompile.toUpperCase(),
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.substring(0, sb.length() - 1));// 重新设置分组与编译
|
for (String regionKeyStr : set) {
|
||||||
|
sb.append(";");
|
||||||
|
sb.append(regionKeyStr);
|
||||||
|
}
|
||||||
|
transaction.set(groupCompile.toUpperCase(), sb.toString());// 重新设置分组与编译
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -1750,7 +1660,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
try {
|
try {
|
||||||
if (isStart == null) {// 删除
|
if (isStart == null) {// 删除
|
||||||
transaction.del(compileStr.toUpperCase());// 删除编译与分组的关联关系
|
transaction.del(compileStr.toUpperCase());// 删除编译与分组的关联关系
|
||||||
} else if (isStart == true) {// 将失效置为生效
|
} else if (isStart) {// 将失效置为生效
|
||||||
String groupRegionVal = JedisUtils.get(compileStr.toUpperCase(),
|
String groupRegionVal = JedisUtils.get(compileStr.toUpperCase(),
|
||||||
idRelaRedisDBIndex);
|
idRelaRedisDBIndex);
|
||||||
groupRegionVal = groupRegionVal.replace("OBSOLETE_RULE",
|
groupRegionVal = groupRegionVal.replace("OBSOLETE_RULE",
|
||||||
|
|||||||
@@ -76,17 +76,10 @@ public interface ConfigRedisService {
|
|||||||
* 删除maat类配置,key是业务类型,value是配置id集合
|
* 删除maat类配置,key是业务类型,value是配置id集合
|
||||||
*
|
*
|
||||||
* @param serviceConfigMap
|
* @param serviceConfigMap
|
||||||
|
* @param isStart 是否置为生效,
|
||||||
* @return 成功返回true,失败返回false或抛出异常
|
* @return 成功返回true,失败返回false或抛出异常
|
||||||
*/
|
*/
|
||||||
public boolean delMaatConfig(Map<Integer, List<Long>> serviceConfigMap);
|
public boolean delMaatConfig(Map<Integer, List<Long>> serviceConfigMap,boolean isStart);
|
||||||
/**
|
|
||||||
* 停启用maat类配置,key是业务类型,value是配置id集合
|
|
||||||
*
|
|
||||||
* @param serviceConfigMap
|
|
||||||
* @param isStart 是否置位生效,
|
|
||||||
* @return 成功返回true,失败返回false或抛出异常
|
|
||||||
*/
|
|
||||||
public boolean startStopMaatConfig(Map<Integer, List<Long>> serviceConfigMap, boolean isStart);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除分组复用的域配置
|
* 删除分组复用的域配置
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
|
|
||||||
if (!isConfigStartStop) {
|
if (!isConfigStartStop) {
|
||||||
// 所有的都删除成功返回true
|
// 所有的都删除成功返回true
|
||||||
if (!configRedisService.delMaatConfig(compileMap)) {
|
if (!configRedisService.delMaatConfig(compileMap,false)) {
|
||||||
throw new ServiceRuntimeException("取消MAAT配置时出现异常,具体原因不详,请联系管理员",
|
throw new ServiceRuntimeException("取消MAAT配置时出现异常,具体原因不详,请联系管理员",
|
||||||
RestBusinessCode.service_runtime_error.getValue());
|
RestBusinessCode.service_runtime_error.getValue());
|
||||||
}
|
}
|
||||||
@@ -380,7 +380,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
if (isValid == 0) {
|
if (isValid == 0) {
|
||||||
isStart = false;// 置为失效
|
isStart = false;// 置为失效
|
||||||
}
|
}
|
||||||
if (!configRedisService.startStopMaatConfig(compileMap, isStart)) {
|
if (!configRedisService.delMaatConfig(compileMap, isStart)) {
|
||||||
throw new ServiceRuntimeException("停启用MAAT配置时出现异常,具体原因不详,请联系管理员",
|
throw new ServiceRuntimeException("停启用MAAT配置时出现异常,具体原因不详,请联系管理员",
|
||||||
RestBusinessCode.service_runtime_error.getValue());
|
RestBusinessCode.service_runtime_error.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public class DashboardService extends BaseService {
|
|||||||
* @param transType
|
* @param transType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public List<HashMap> getBandwidthTrans(String addrType, Integer transType, String beginDate, String endDate) {
|
public List<HashMap> getBandwidthTrans(String addrType, Integer transType, String beginDate, String endDate) {
|
||||||
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
|
|
||||||
@@ -121,6 +122,7 @@ public class DashboardService extends BaseService {
|
|||||||
* @param transType
|
* @param transType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public List<HashMap> getBandwidthTrans2(String addrType, Integer transType, String beginDate, String endDate) {
|
public List<HashMap> getBandwidthTrans2(String addrType, Integer transType, String beginDate, String endDate) {
|
||||||
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
|
|
||||||
@@ -143,6 +145,7 @@ public class DashboardService extends BaseService {
|
|||||||
* @param entranceId
|
* @param entranceId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public HashMap getBandwidthTransEntrance(String addrType, Integer transType, String beginDate, String endDate,
|
public HashMap getBandwidthTransEntrance(String addrType, Integer transType, String beginDate, String endDate,
|
||||||
Integer entranceId) {
|
Integer entranceId) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
@@ -177,8 +180,8 @@ public class DashboardService extends BaseService {
|
|||||||
if (t >= pointTime && t < pointTime + inter) {
|
if (t >= pointTime && t < pointTime + inter) {
|
||||||
// 范围之内分到此pointTime组
|
// 范围之内分到此pointTime组
|
||||||
sumL = sumL + tt.getLinkNum();
|
sumL = sumL + tt.getLinkNum();
|
||||||
sumP = sumP + tt.getPps();
|
sumP = sumP + Long.parseLong(tt.getPps().substring(0, tt.getPps().lastIndexOf(".")));
|
||||||
sumG = sumG + tt.getGbps();
|
sumG = sumG + Long.parseLong(tt.getGbps().substring(0, tt.getGbps().lastIndexOf(".")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会
|
// 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会
|
||||||
@@ -220,6 +223,7 @@ public class DashboardService extends BaseService {
|
|||||||
* @param li
|
* @param li
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static List<Map> formatDateData(String begin, String end, List<Map> li) {
|
public static List<Map> formatDateData(String begin, String end, List<Map> li) {
|
||||||
List<Map> resList = new ArrayList<Map>();
|
List<Map> resList = new ArrayList<Map>();
|
||||||
Map<String, Comparable> m = new HashMap<String, Comparable>();
|
Map<String, Comparable> m = new HashMap<String, Comparable>();
|
||||||
@@ -260,6 +264,7 @@ public class DashboardService extends BaseService {
|
|||||||
* @param format 如:yyyy-MM-dd HH:mm:ss
|
* @param format 如:yyyy-MM-dd HH:mm:ss
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static Long dateToStamp(String date_str) {
|
public static Long dateToStamp(String date_str) {
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
@@ -277,6 +282,7 @@ public class DashboardService extends BaseService {
|
|||||||
* @param format 如:yyyy-MM-dd HH:mm:ss
|
* @param format 如:yyyy-MM-dd HH:mm:ss
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static String stampToDate(long timeStamp) {
|
public static String stampToDate(long timeStamp) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");// 这个是你要转成后的时间的格式
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");// 这个是你要转成后的时间的格式
|
||||||
String sd = sdf.format(new Date(timeStamp)); // 时间戳转换成时间
|
String sd = sdf.format(new Date(timeStamp)); // 时间戳转换成时间
|
||||||
@@ -286,100 +292,49 @@ public class DashboardService extends BaseService {
|
|||||||
/**
|
/**
|
||||||
* 根据service 动作查询近五分钟变化趋势 entrance 默认为1,2
|
* 根据service 动作查询近五分钟变化趋势 entrance 默认为1,2
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public List<HashMap> getActionTrans(String begin, String end, String serviceType) {
|
* public List<HashMap> getActionTrans(String begin, String end, String
|
||||||
String sql = "";
|
* serviceType) { String sql = ""; String sqlBlock =
|
||||||
String sqlBlock = "((service>=16 and service<=40) or (service>=258 and service<=273) or (service=576))"; // 阻断
|
* "((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 =
|
||||||
String sqlDrop = "((service>=1040 and service<=1042) or (service=3) or (service=5) or (service=25) or (service=28) or (service=274))"; // 丢弃
|
* "((service>=128 and service<=152) or (service>=384 and service<=513) or (service=592) or (service>=848 and service<=1030) or (service=1152))"
|
||||||
String sqlLoop = "((service=4) or (service>=832 and service<=834))"; // 回流
|
* ; // 监测 String sqlDrop =
|
||||||
// 区分动作
|
* "((service>=1040 and service<=1042) or (service=3) or (service=5) or (service=25) or (service=28) or (service=274))"
|
||||||
if (StringUtils.isNotBlank(serviceType)) {
|
* ; // 丢弃 String sqlLoop = "((service=4) or (service>=832 and service<=834))";
|
||||||
if (serviceType.equalsIgnoreCase("block")) {
|
* // 回流 // 区分动作 if (StringUtils.isNotBlank(serviceType)) { if
|
||||||
sql = sqlBlock;
|
* (serviceType.equalsIgnoreCase("block")) { sql = sqlBlock; } if
|
||||||
}
|
* (serviceType.equalsIgnoreCase("monitor")) { sql = sqlMonitor; } if
|
||||||
if (serviceType.equalsIgnoreCase("monitor")) {
|
* (serviceType.equalsIgnoreCase("drop")) { sql = sqlDrop; } if
|
||||||
sql = sqlMonitor;
|
* (serviceType.equalsIgnoreCase("loop")) { sql = sqlLoop; } }
|
||||||
}
|
* ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
if (serviceType.equalsIgnoreCase("drop")) {
|
* List<NtcEntranceReport> entrance1 = new ArrayList<NtcEntranceReport>();
|
||||||
sql = sqlDrop;
|
* List<NtcEntranceReport> entrance2 = new ArrayList<NtcEntranceReport>();
|
||||||
}
|
* HashMap m1 = new HashMap(); HashMap m2 = new HashMap(); entrance1 =
|
||||||
if (serviceType.equalsIgnoreCase("loop")) {
|
* ntcTotalReportDao.getActionTrans(begin, end, 1, sql); entrance2 =
|
||||||
sql = sqlLoop;
|
* ntcTotalReportDao.getActionTrans(begin, end, 2, sql); List timeList = new
|
||||||
}
|
* ArrayList(); List sumList1 = new ArrayList(); List sumList2 = new
|
||||||
}
|
* ArrayList();
|
||||||
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
|
*
|
||||||
List<NtcEntranceReport> entrance1 = new ArrayList<NtcEntranceReport>();
|
* Map<String, Comparable> m = new HashMap<String, Comparable>(); int inter =
|
||||||
List<NtcEntranceReport> entrance2 = new ArrayList<NtcEntranceReport>();
|
* 1000 * 60 * 5;// 间隔时间为五分钟 // 开始时间,结束时间 时间戳 Long b = dateToStamp(begin); Long
|
||||||
HashMap m1 = new HashMap();
|
* e = dateToStamp(end); int num = 0; Long pointTime = b; while (pointTime < e)
|
||||||
HashMap m2 = new HashMap();
|
* { Map rm = new HashMap(); Long sum1 = 0l; Long sum2 = 0l; if (pointTime >= e)
|
||||||
entrance1 = ntcTotalReportDao.getActionTrans(begin, end, 1, sql);
|
* { break; // 停止 } for (NtcEntranceReport e1 : entrance1) { // 实际时间 String time
|
||||||
entrance2 = ntcTotalReportDao.getActionTrans(begin, end, 2, sql);
|
* = e1.getTime(); Long t = dateToStamp(time); if (t >= pointTime && t <
|
||||||
List timeList = new ArrayList();
|
* pointTime + inter) { // 范围之内分到此pointTime组 sum1 = sum1 + e1.getSum(); } } for
|
||||||
List sumList1 = new ArrayList();
|
* (NtcEntranceReport e2 : entrance2) { // 实际时间 String time = e2.getTime(); Long
|
||||||
List sumList2 = new ArrayList();
|
* t = dateToStamp(time); if (t >= pointTime && t < pointTime + inter) { //
|
||||||
|
* 范围之内分到此pointTime组 sum2 = sum2 + e2.getSum(); } } //
|
||||||
Map<String, Comparable> m = new HashMap<String, Comparable>();
|
* 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会 if (pointTime >= e - inter && sum1 > 0) {
|
||||||
int inter = 1000 * 60 * 5;// 间隔时间为五分钟
|
* sumList1.add(sum1); } if (pointTime >= e - inter && sum2 > 0) {
|
||||||
// 开始时间,结束时间 时间戳
|
* sumList2.add(sum2); } if (pointTime >= e - inter && (sum1 > 0 || sum2 > 0)) {
|
||||||
Long b = dateToStamp(begin);
|
* timeList.add(stampToDate(pointTime)); } if (pointTime < e - inter) {
|
||||||
Long e = dateToStamp(end);
|
* sumList1.add(sum1); sumList2.add(sum2); timeList.add(stampToDate(pointTime));
|
||||||
int num = 0;
|
* } num = num + 1; pointTime = b + inter * num; } m1.put("count", sumList1);
|
||||||
Long pointTime = b;
|
* m1.put("statTime", timeList); m1.put("entranceId", 1); m2.put("count",
|
||||||
while (pointTime < e) {
|
* sumList2);// m2.put("statTime", timeList); m2.put("entranceId", 2);
|
||||||
Map rm = new HashMap();
|
* listMap.add(m1); listMap.add(m2); return listMap; }
|
||||||
Long sum1 = 0l;
|
*/
|
||||||
Long sum2 = 0l;
|
|
||||||
if (pointTime >= e) {
|
|
||||||
break; // 停止
|
|
||||||
}
|
|
||||||
for (NtcEntranceReport e1 : entrance1) {
|
|
||||||
// 实际时间
|
|
||||||
String time = e1.getTime();
|
|
||||||
Long t = dateToStamp(time);
|
|
||||||
if (t >= pointTime && t < pointTime + inter) {
|
|
||||||
// 范围之内分到此pointTime组
|
|
||||||
sum1 = sum1 + e1.getSum();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (NtcEntranceReport e2 : entrance2) {
|
|
||||||
// 实际时间
|
|
||||||
String time = e2.getTime();
|
|
||||||
Long t = dateToStamp(time);
|
|
||||||
if (t >= pointTime && t < pointTime + inter) {
|
|
||||||
// 范围之内分到此pointTime组
|
|
||||||
sum2 = sum2 + e2.getSum();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会
|
|
||||||
if (pointTime >= e - inter && sum1 > 0) {
|
|
||||||
sumList1.add(sum1);
|
|
||||||
}
|
|
||||||
if (pointTime >= e - inter && sum2 > 0) {
|
|
||||||
sumList2.add(sum2);
|
|
||||||
}
|
|
||||||
if (pointTime >= e - inter && (sum1 > 0 || sum2 > 0)) {
|
|
||||||
timeList.add(stampToDate(pointTime));
|
|
||||||
}
|
|
||||||
if (pointTime < e - inter) {
|
|
||||||
sumList1.add(sum1);
|
|
||||||
sumList2.add(sum2);
|
|
||||||
timeList.add(stampToDate(pointTime));
|
|
||||||
}
|
|
||||||
num = num + 1;
|
|
||||||
pointTime = b + inter * num;
|
|
||||||
}
|
|
||||||
m1.put("count", sumList1);
|
|
||||||
m1.put("statTime", timeList);
|
|
||||||
m1.put("entranceId", 1);
|
|
||||||
m2.put("count", sumList2);//
|
|
||||||
m2.put("statTime", timeList);
|
|
||||||
m2.put("entranceId", 2);
|
|
||||||
listMap.add(m1);
|
|
||||||
listMap.add(m2);
|
|
||||||
return listMap;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* 根据service 动作查询近五分钟变化趋势 entrance 默认为1,2
|
* 根据service 动作查询近五分钟变化趋势 entrance 默认为1,2
|
||||||
*/
|
*/
|
||||||
@@ -411,66 +366,68 @@ public class DashboardService extends BaseService {
|
|||||||
HashMap m2 = new HashMap();
|
HashMap m2 = new HashMap();
|
||||||
entrance1 = ntcTotalReportDao.getActionTrans(begin, end, 1, sql);
|
entrance1 = ntcTotalReportDao.getActionTrans(begin, end, 1, sql);
|
||||||
entrance2 = ntcTotalReportDao.getActionTrans(begin, end, 2, sql);
|
entrance2 = ntcTotalReportDao.getActionTrans(begin, end, 2, sql);
|
||||||
|
|
||||||
Map<String, Comparable> m = new HashMap<String, Comparable>();
|
Map<String, Comparable> m = new HashMap<String, Comparable>();
|
||||||
Date beginDate = DateUtils.parseDate(begin);
|
Date beginDate = DateUtils.parseDate(begin);
|
||||||
Date endDate = DateUtils.parseDate(end);
|
Date endDate = DateUtils.parseDate(end);
|
||||||
|
|
||||||
List<Date> dateRangeList = new ArrayList<Date>();
|
List<Date> dateRangeList = new ArrayList<Date>();
|
||||||
List<String> strDateRangeList = new ArrayList<String>();
|
List<String> strDateRangeList = new ArrayList<String>();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(beginDate);
|
calendar.setTime(beginDate);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
||||||
while (calendar.getTime().compareTo(endDate)<=0) {
|
while (calendar.getTime().compareTo(endDate) <= 0) {
|
||||||
dateRangeList.add(calendar.getTime());
|
dateRangeList.add(calendar.getTime());
|
||||||
strDateRangeList.add(sdf.format(calendar.getTime()));
|
strDateRangeList.add(sdf.format(calendar.getTime()));
|
||||||
calendar.add(Calendar.MINUTE, 5);
|
calendar.add(Calendar.MINUTE, 5);
|
||||||
}
|
}
|
||||||
//存放每个时间点的总数
|
// 存放每个时间点的总数
|
||||||
Map<String,List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
|
Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
|
||||||
int index=0;
|
int index = 0;
|
||||||
List sumList1 =new ArrayList();
|
List sumList1 = new ArrayList();
|
||||||
List sumList2 =new ArrayList();
|
List sumList2 = new ArrayList();
|
||||||
for (int i = 0; i < dateRangeList.size(); i++) {
|
for (int i = 0; i < dateRangeList.size(); i++) {
|
||||||
//存放一个时间点中总数
|
// 存放一个时间点中总数
|
||||||
Map<String, Long> ipCountMap = new HashMap<String, Long>();
|
Map<String, Long> ipCountMap = new HashMap<String, Long>();
|
||||||
Date date = dateRangeList.get(i);
|
Date date = dateRangeList.get(i);
|
||||||
Long num1 = 0L;
|
Long num1 = 0L;
|
||||||
Long num2 = 0L;
|
Long num2 = 0L;
|
||||||
for (int j = index; j < entrance1.size(); j++) {
|
for (int j = index; j < entrance1.size(); j++) {
|
||||||
NtcEntranceReport ipInfo = entrance1.get(j);
|
NtcEntranceReport ipInfo = entrance1.get(j);
|
||||||
if (ipInfo.getReportTime()!=null){
|
if (ipInfo.getReportTime() != null) {
|
||||||
if(ipInfo.getReportTime().compareTo(date)>=0&&(i+1<dateRangeList.size()&&ipInfo.getReportTime().compareTo(dateRangeList.get(i+1))<0)) {
|
if (ipInfo.getReportTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()
|
||||||
num1=num1+ipInfo.getSum();
|
&& ipInfo.getReportTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
|
||||||
}else{
|
num1 = num1 + ipInfo.getSum();
|
||||||
index = j;
|
} else {
|
||||||
break;
|
index = j;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sumList1.add(num1);
|
}
|
||||||
for (int j = index; j < entrance2.size(); j++) {
|
sumList1.add(num1);
|
||||||
NtcEntranceReport ipInfo = entrance2.get(j);
|
for (int j = index; j < entrance2.size(); j++) {
|
||||||
if (ipInfo.getReportTime()!=null){
|
NtcEntranceReport ipInfo = entrance2.get(j);
|
||||||
if(ipInfo.getReportTime().compareTo(date)>=0&&(i+1<dateRangeList.size()&&ipInfo.getReportTime().compareTo(dateRangeList.get(i+1))<0)) {
|
if (ipInfo.getReportTime() != null) {
|
||||||
num2=num2+ipInfo.getSum();
|
if (ipInfo.getReportTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()
|
||||||
}else{
|
&& ipInfo.getReportTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
|
||||||
index = j;
|
num2 = num2 + ipInfo.getSum();
|
||||||
break;
|
} else {
|
||||||
}
|
index = j;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sumList2.add(num2);
|
|
||||||
}
|
}
|
||||||
//整合 count time
|
sumList2.add(num2);
|
||||||
m1.put("count", sumList1);
|
}
|
||||||
m1.put("statTime", strDateRangeList);
|
// 整合 count time
|
||||||
m1.put("entranceId", 1);
|
m1.put("count", sumList1);
|
||||||
m2.put("count", sumList2);//
|
m1.put("statTime", strDateRangeList);
|
||||||
m2.put("statTime", strDateRangeList);
|
m1.put("entranceId", 1);
|
||||||
m2.put("entranceId", 2);
|
m2.put("count", sumList2);//
|
||||||
listMap.add(m1);
|
m2.put("statTime", strDateRangeList);
|
||||||
listMap.add(m2);
|
m2.put("entranceId", 2);
|
||||||
|
listMap.add(m1);
|
||||||
|
listMap.add(m2);
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,43 +502,44 @@ public class DashboardService extends BaseService {
|
|||||||
if (ipListTop10 != null && ipListTop10.size() > 0) {
|
if (ipListTop10 != null && ipListTop10.size() > 0) {
|
||||||
StringBuilder ipStr = new StringBuilder();
|
StringBuilder ipStr = new StringBuilder();
|
||||||
for (LinkedHashMap map : ipListTop10) {
|
for (LinkedHashMap map : ipListTop10) {
|
||||||
ipStr.append("'"+(String) map.get("ipAddr")+"',");
|
ipStr.append("'" + (String) map.get("ipAddr") + "',");
|
||||||
}
|
}
|
||||||
if (!StringUtil.isEmpty(ipStr)&&ipStr.indexOf(",")>0) {
|
if (!StringUtil.isEmpty(ipStr) && ipStr.indexOf(",") > 0) {
|
||||||
ipStr.deleteCharAt(ipStr.lastIndexOf(","));
|
ipStr.deleteCharAt(ipStr.lastIndexOf(","));
|
||||||
}
|
}
|
||||||
//如果所有IP在最后一个时间点的count都为0,则移除最后一个点
|
// 如果所有IP在最后一个时间点的count都为0,则移除最后一个点
|
||||||
//开始划分时间段,间隔5分钟
|
// 开始划分时间段,间隔5分钟
|
||||||
List<Date> dateRangeList = new ArrayList<Date>();
|
List<Date> dateRangeList = new ArrayList<Date>();
|
||||||
List<String> strDateRangeList = new ArrayList<String>();
|
List<String> strDateRangeList = new ArrayList<String>();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(beginDate);
|
calendar.setTime(beginDate);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
||||||
while (calendar.getTime().compareTo(endDate)<=0) {
|
while (calendar.getTime().compareTo(endDate) <= 0) {
|
||||||
dateRangeList.add(calendar.getTime());
|
dateRangeList.add(calendar.getTime());
|
||||||
strDateRangeList.add(sdf.format(calendar.getTime()));
|
strDateRangeList.add(sdf.format(calendar.getTime()));
|
||||||
calendar.add(Calendar.MINUTE, 5);
|
calendar.add(Calendar.MINUTE, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<TrafficIpActiveStatistic> ipInfoList = trafficIpActiveStatisticDao.ipActiveFiveMinute(ipStr.toString(),
|
ArrayList<TrafficIpActiveStatistic> ipInfoList = trafficIpActiveStatisticDao
|
||||||
beginDate, endDate);
|
.ipActiveFiveMinute(ipStr.toString(), beginDate, endDate);
|
||||||
//存放每个IP,每个时间点的总数
|
// 存放每个IP,每个时间点的总数
|
||||||
Map<String,List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
|
Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
|
||||||
int index=0;
|
int index = 0;
|
||||||
for (int i = 0; i < dateRangeList.size(); i++) {
|
for (int i = 0; i < dateRangeList.size(); i++) {
|
||||||
//存放一个时间点中每个IP的总数
|
// 存放一个时间点中每个IP的总数
|
||||||
Map<String, Long> ipCountMap = new HashMap<String, Long>();
|
Map<String, Long> ipCountMap = new HashMap<String, Long>();
|
||||||
Date date = dateRangeList.get(i);
|
Date date = dateRangeList.get(i);
|
||||||
for (int j = index; j < ipInfoList.size(); j++) {
|
for (int j = index; j < ipInfoList.size(); j++) {
|
||||||
TrafficIpActiveStatistic ipInfo = ipInfoList.get(j);
|
TrafficIpActiveStatistic ipInfo = ipInfoList.get(j);
|
||||||
if (ipInfo.getStatTime()!=null){
|
if (ipInfo.getStatTime() != null) {
|
||||||
if(ipInfo.getStatTime().compareTo(date)>=0&&(i+1<dateRangeList.size()&&ipInfo.getStatTime().compareTo(dateRangeList.get(i+1))<0)) {
|
if (ipInfo.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()
|
||||||
|
&& ipInfo.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
|
||||||
Long num = ipInfo.getCount();
|
Long num = ipInfo.getCount();
|
||||||
if (ipCountMap.containsKey(ipInfo.getIpAddr())) {
|
if (ipCountMap.containsKey(ipInfo.getIpAddr())) {
|
||||||
num=num+ipCountMap.get(ipInfo.getIpAddr());
|
num = num + ipCountMap.get(ipInfo.getIpAddr());
|
||||||
}
|
}
|
||||||
ipCountMap.put(ipInfo.getIpAddr(), num);
|
ipCountMap.put(ipInfo.getIpAddr(), num);
|
||||||
}else{
|
} else {
|
||||||
index = j;
|
index = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -591,21 +549,21 @@ public class DashboardService extends BaseService {
|
|||||||
String ip = (String) map.get("ipAddr");
|
String ip = (String) map.get("ipAddr");
|
||||||
Long sum = 0l;
|
Long sum = 0l;
|
||||||
if (ipCountMap.containsKey(ip)) {
|
if (ipCountMap.containsKey(ip)) {
|
||||||
sum=ipCountMap.get(ip);
|
sum = ipCountMap.get(ip);
|
||||||
}
|
}
|
||||||
if (ipCountListMap.containsKey(ip)) {
|
if (ipCountListMap.containsKey(ip)) {
|
||||||
ipCountListMap.get(ip).add(sum);
|
ipCountListMap.get(ip).add(sum);
|
||||||
}else{
|
} else {
|
||||||
List<Long> list = new ArrayList<Long>();
|
List<Long> list = new ArrayList<Long>();
|
||||||
list.add(sum);
|
list.add(sum);
|
||||||
ipCountListMap.put(ip, list);
|
ipCountListMap.put(ip, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//整合IP count time
|
// 整合IP count time
|
||||||
Iterator iterator = ipCountListMap.keySet().iterator();
|
Iterator iterator = ipCountListMap.keySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
String ip = iterator.next()+"";
|
String ip = iterator.next() + "";
|
||||||
Map ipTrafficMap = new HashMap();
|
Map ipTrafficMap = new HashMap();
|
||||||
ipTrafficMap.put("ipAddr", ip);
|
ipTrafficMap.put("ipAddr", ip);
|
||||||
ipTrafficMap.put("linkNum", ipCountListMap.get(ip));
|
ipTrafficMap.put("linkNum", ipCountListMap.get(ip));
|
||||||
@@ -622,23 +580,23 @@ public class DashboardService extends BaseService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<HashMap> ipActiveOneHour(Date beginDate, Date endDate) {
|
public List<HashMap> ipActiveOneHour(Date beginDate, Date endDate) {
|
||||||
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(beginDate, endDate);
|
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(beginDate, endDate);
|
||||||
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");
|
||||||
HashMap resMap = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr, beginDate,endDate);
|
HashMap resMap = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr, beginDate, endDate);
|
||||||
if(resMap!=null){
|
if (resMap != null) {
|
||||||
listMap.add(resMap);
|
listMap.add(resMap);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
@@ -696,12 +654,12 @@ public class DashboardService extends BaseService {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Map> getProtocolList(String startTime, String endTime,Integer[] protoType) {
|
public List<Map> getProtocolList(String startTime, String endTime, Integer[] protoType) {
|
||||||
// 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(startTime, endTime,protoType);
|
list = trafficProtocolStatisticDao.getProtocolList(startTime, endTime, protoType);
|
||||||
// }
|
// }
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -1101,8 +1059,8 @@ public class DashboardService extends BaseService {
|
|||||||
// String linkNumStr = String.valueOf(webIdAndCountMap.get("linkNum"));
|
// String linkNumStr = String.valueOf(webIdAndCountMap.get("linkNum"));
|
||||||
// String packetsStr = String.valueOf(webIdAndCountMap.get("pktCount"));
|
// String packetsStr = String.valueOf(webIdAndCountMap.get("pktCount"));
|
||||||
if (countStr != null) {
|
if (countStr != null) {
|
||||||
Long pl = (Long.parseLong(countStr))/(1024*1024*1024);
|
Long pl = (Long.parseLong(countStr)) / (1024 * 1024 * 1024);
|
||||||
if(pl>0) {
|
if (pl > 0) {
|
||||||
count += Long.parseLong(countStr);// 将count累加 转换单位小于0的不加
|
count += Long.parseLong(countStr);// 将count累加 转换单位小于0的不加
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1121,21 +1079,21 @@ public class DashboardService extends BaseService {
|
|||||||
Collections.sort(list, new Comparator<Object>() {
|
Collections.sort(list, new Comparator<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(Object o1, Object o2) {
|
||||||
if(o1==null&&o2!=null){
|
if (o1 == null && o2 != null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(o1!=null&&o2==null){
|
if (o1 != null && o2 == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(o1==o2&&o1==null){
|
if (o1 == o2 && o1 == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Map m1=(Map)o1;
|
Map m1 = (Map) o1;
|
||||||
Map m2=(Map)o2;
|
Map m2 = (Map) o2;
|
||||||
Object ob1 = m1.get("byteCount");
|
Object ob1 = m1.get("byteCount");
|
||||||
Object ob2 = m2.get("byteCount");
|
Object ob2 = m2.get("byteCount");
|
||||||
Long b1=Long.parseLong(ob1.toString());
|
Long b1 = Long.parseLong(ob1.toString());
|
||||||
Long b2=Long.parseLong(ob2.toString());
|
Long b2 = Long.parseLong(ob2.toString());
|
||||||
return -(b1).compareTo(b2);
|
return -(b1).compareTo(b2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1164,11 +1122,6 @@ public class DashboardService extends BaseService {
|
|||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<Map> getTopicAndDomainList(Date beginDate, Date endDate, String top) {
|
public List<Map> getTopicAndDomainList(Date beginDate, Date endDate, String top) {
|
||||||
|
|
||||||
Map<String, List<String>> topicIdAndIdMap = new HashMap<>();// 存储topicid和id的对应关系,一个topicid有多个id
|
Map<String, List<String>> topicIdAndIdMap = new HashMap<>();// 存储topicid和id的对应关系,一个topicid有多个id
|
||||||
@@ -1243,24 +1196,7 @@ public class DashboardService extends BaseService {
|
|||||||
}
|
}
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String[] getFiledTypeByName(String fieldName) {
|
public String[] getFiledTypeByName(String fieldName) {
|
||||||
if (fieldName == null) {
|
if (fieldName == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1286,8 +1222,9 @@ public class DashboardService extends BaseService {
|
|||||||
bandwidthListIPvx = ntcTotalReportDao.getBandwidthTransIPVx(beginDate, endDate);
|
bandwidthListIPvx = ntcTotalReportDao.getBandwidthTransIPVx(beginDate, endDate);
|
||||||
bandwidthListProtocol = ntcTotalReportDao.getBandwidthTransProtocol(beginDate, endDate);
|
bandwidthListProtocol = ntcTotalReportDao.getBandwidthTransProtocol(beginDate, endDate);
|
||||||
Map<String, Map> trafficMap = new HashMap<String, Map>();
|
Map<String, Map> trafficMap = new HashMap<String, Map>();
|
||||||
if((!StringUtil.isEmpty(bandwidthListIPvx)&&bandwidthListIPvx.size()>0)||(!StringUtil.isEmpty(bandwidthListProtocol)&&bandwidthListProtocol.size()>0)){
|
if ((!StringUtil.isEmpty(bandwidthListIPvx) && bandwidthListIPvx.size() > 0)
|
||||||
//划分时间段
|
|| (!StringUtil.isEmpty(bandwidthListProtocol) && bandwidthListProtocol.size() > 0)) {
|
||||||
|
// 划分时间段
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
Date startTime = sdf.parse(beginDate);
|
Date startTime = sdf.parse(beginDate);
|
||||||
Date endTime = sdf.parse(endDate);
|
Date endTime = sdf.parse(endDate);
|
||||||
@@ -1295,8 +1232,8 @@ public class DashboardService extends BaseService {
|
|||||||
List<String> strDateRangeList = new ArrayList<String>();
|
List<String> strDateRangeList = new ArrayList<String>();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(startTime);
|
calendar.setTime(startTime);
|
||||||
|
|
||||||
while (calendar.getTime().compareTo(endTime)<=0) {
|
while (calendar.getTime().compareTo(endTime) <= 0) {
|
||||||
dateRangeList.add(calendar.getTime());
|
dateRangeList.add(calendar.getTime());
|
||||||
strDateRangeList.add(sdf.format(calendar.getTime()));
|
strDateRangeList.add(sdf.format(calendar.getTime()));
|
||||||
calendar.add(Calendar.MINUTE, 5);
|
calendar.add(Calendar.MINUTE, 5);
|
||||||
@@ -1304,9 +1241,10 @@ public class DashboardService extends BaseService {
|
|||||||
String[] addrTypes = getFiledTypeByName("addr_type");
|
String[] addrTypes = getFiledTypeByName("addr_type");
|
||||||
String[] transTypes = getFiledTypeByName("trans_type");
|
String[] transTypes = getFiledTypeByName("trans_type");
|
||||||
String[] entranceIds = getFiledTypeByName("entrance_id");
|
String[] entranceIds = getFiledTypeByName("entrance_id");
|
||||||
if(bandwidthListIPvx!=null&&bandwidthListIPvx.size()>0&&bandwidthListProtocol!=null&&bandwidthListProtocol.size()>0&&addrTypes!=null&&addrTypes.length>0&&transTypes!=null&&transTypes.length>0
|
if (bandwidthListIPvx != null && bandwidthListIPvx.size() > 0 && bandwidthListProtocol != null
|
||||||
&&entranceIds!=null&&entranceIds.length>0){
|
&& bandwidthListProtocol.size() > 0 && addrTypes != null && addrTypes.length > 0
|
||||||
//按区域和类型构建Map
|
&& transTypes != null && transTypes.length > 0 && entranceIds != null && entranceIds.length > 0) {
|
||||||
|
// 按区域和类型构建Map
|
||||||
for (String entranceId : entranceIds) {
|
for (String entranceId : entranceIds) {
|
||||||
for (String addrType : addrTypes) {
|
for (String addrType : addrTypes) {
|
||||||
listMap.put("ipv" + addrType + "Type" + entranceId, new ArrayList<TrafficTransStatistic>());
|
listMap.put("ipv" + addrType + "Type" + entranceId, new ArrayList<TrafficTransStatistic>());
|
||||||
@@ -1317,10 +1255,10 @@ public class DashboardService extends BaseService {
|
|||||||
listMap.put("trans" + transType + "Type" + entranceId, new ArrayList<TrafficTransStatistic>());
|
listMap.put("trans" + transType + "Type" + entranceId, new ArrayList<TrafficTransStatistic>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//按区域和类型提取数据到列表中
|
// 按区域和类型提取数据到列表中
|
||||||
for (TrafficTransStatistic tts : bandwidthListIPvx) {
|
for (TrafficTransStatistic tts : bandwidthListIPvx) {
|
||||||
String addrType = tts.getAddrType();
|
String addrType = tts.getAddrType();
|
||||||
|
|
||||||
Integer entranceId = tts.getEntranceId();
|
Integer entranceId = tts.getEntranceId();
|
||||||
Integer transType = tts.getTransType();
|
Integer transType = tts.getTransType();
|
||||||
String key = "ipv" + addrType + "Type" + entranceId;
|
String key = "ipv" + addrType + "Type" + entranceId;
|
||||||
@@ -1338,7 +1276,7 @@ public class DashboardService extends BaseService {
|
|||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
String entranceId = key.substring(key.length() - 1);
|
String entranceId = key.substring(key.length() - 1);
|
||||||
ArrayList<TrafficTransStatistic> value = entry.getValue();
|
ArrayList<TrafficTransStatistic> value = entry.getValue();
|
||||||
resultMap.put(key, getNewData(dateRangeList,strDateRangeList,value));
|
resultMap.put(key, getNewData(dateRangeList, strDateRangeList, value));
|
||||||
}
|
}
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
@@ -1346,8 +1284,8 @@ public class DashboardService extends BaseService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map getNewData(List<Date> dateRangeList,List<String> timeList, List<TrafficTransStatistic> bandwidthList) {
|
private Map getNewData(List<Date> dateRangeList, List<String> timeList, List<TrafficTransStatistic> bandwidthList) {
|
||||||
Map<String,List> resulMap = new HashMap<String,List>();
|
Map<String, List> resulMap = new HashMap<String, List>();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < dateRangeList.size(); i++) {
|
for (int i = 0; i < dateRangeList.size(); i++) {
|
||||||
Date date = dateRangeList.get(i);
|
Date date = dateRangeList.get(i);
|
||||||
@@ -1357,12 +1295,14 @@ public class DashboardService extends BaseService {
|
|||||||
Long gbpsNum = 0L;
|
Long gbpsNum = 0L;
|
||||||
for (int j = index; j < bandwidthList.size(); j++) {
|
for (int j = index; j < bandwidthList.size(); j++) {
|
||||||
TrafficTransStatistic info = bandwidthList.get(j);
|
TrafficTransStatistic info = bandwidthList.get(j);
|
||||||
if (info.getStatTime()!=null){
|
if (info.getStatTime() != null) {
|
||||||
if(info.getStatTime().compareTo(date)>=0&&(i+1<dateRangeList.size()&&info.getStatTime().compareTo(dateRangeList.get(i+1))<0)) {
|
if (info.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()
|
||||||
linkNum =info.getLinkNum() +linkNum;
|
&& info.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
|
||||||
ppsNum = info.getPps()+ppsNum;
|
linkNum = info.getLinkNum() + linkNum;
|
||||||
gbpsNum = info.getGbps()+gbpsNum;
|
ppsNum = Long.parseLong(info.getPps().substring(0, info.getPps().lastIndexOf("."))) + ppsNum;
|
||||||
}else{
|
gbpsNum = Long.parseLong(info.getGbps().substring(0, info.getGbps().lastIndexOf(".")))
|
||||||
|
+ gbpsNum;
|
||||||
|
} else {
|
||||||
index = j;
|
index = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1373,10 +1313,10 @@ public class DashboardService extends BaseService {
|
|||||||
countMap.put("gbps", gbpsNum);
|
countMap.put("gbps", gbpsNum);
|
||||||
Iterator iterator = countMap.keySet().iterator();
|
Iterator iterator = countMap.keySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
String key = iterator.next()+"";
|
String key = iterator.next() + "";
|
||||||
if (resulMap.containsKey(key)) {
|
if (resulMap.containsKey(key)) {
|
||||||
resulMap.get(key).add(countMap.get(key));
|
resulMap.get(key).add(countMap.get(key));
|
||||||
}else {
|
} else {
|
||||||
List<Long> list = new ArrayList<Long>();
|
List<Long> list = new ArrayList<Long>();
|
||||||
list.add(countMap.get(key));
|
list.add(countMap.get(key));
|
||||||
resulMap.put(key, list);
|
resulMap.put(key, list);
|
||||||
@@ -1396,31 +1336,31 @@ public class DashboardService extends BaseService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* public List<HashMap> getDomainTrans(String beginDate, String endDate,
|
* public List<HashMap> getDomainTrans(String beginDate, String endDate, Integer
|
||||||
* Integer domain, Integer entranceId) { List<HashMap> listMap = new
|
* domain, Integer entranceId) { List<HashMap> listMap = new
|
||||||
* ArrayList<HashMap>(); HashMap resulMap = new HashMap();
|
* ArrayList<HashMap>(); HashMap resulMap = new HashMap();
|
||||||
* List<TrafficHttpFocusStatistic> domainList = new
|
* List<TrafficHttpFocusStatistic> domainList = new
|
||||||
* ArrayList<TrafficHttpFocusStatistic>(); domainList =
|
* ArrayList<TrafficHttpFocusStatistic>(); domainList =
|
||||||
* trafficHttpStatisticDao.getDomainTrans(entranceId, beginDate, endDate,
|
* trafficHttpStatisticDao.getDomainTrans(entranceId, beginDate, endDate,
|
||||||
* domain); List timeList = new ArrayList(); List countList = new
|
* domain); List timeList = new ArrayList(); List countList = new ArrayList();
|
||||||
* ArrayList(); if (domainList != null && domainList.size() > 0) {
|
* if (domainList != null && domainList.size() > 0) { Map<String, Comparable> m
|
||||||
* Map<String, Comparable> m = new HashMap<String, Comparable>(); int inter
|
* = new HashMap<String, Comparable>(); int inter = 1000 * 60 * 30;// 间隔时间为30分钟
|
||||||
* = 1000 * 60 * 30;// 间隔时间为30分钟 // 开始时间,结束时间 时间戳 Long b =
|
* // 开始时间,结束时间 时间戳 Long b = dateToStamp(beginDate); Long e =
|
||||||
* dateToStamp(beginDate); Long e = dateToStamp(endDate); int num = 0; Long
|
* dateToStamp(endDate); int num = 0; Long pointTime = b; while (pointTime < e)
|
||||||
* pointTime = b; while (pointTime < e) { Map rm = new HashMap(); Long sumL
|
* { Map rm = new HashMap(); Long sumL = 0l; if (pointTime >= e) { break; // 停止
|
||||||
* = 0l; if (pointTime >= e) { break; // 停止 } for (TrafficHttpFocusStatistic
|
* } for (TrafficHttpFocusStatistic tt : domainList) { // 实际时间 String time =
|
||||||
* tt : domainList) { // 实际时间 String time = tt.getTime(); Long t =
|
* tt.getTime(); Long t = dateToStamp(time); if (t >= pointTime && t < pointTime
|
||||||
* dateToStamp(time); if (t >= pointTime && t < pointTime + inter) { //
|
* + inter) { // 范围之内分到此pointTime组 sumL = sumL + tt.getCount(); } } //
|
||||||
* 范围之内分到此pointTime组 sumL = sumL + tt.getCount(); } } //
|
|
||||||
* 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会 if (pointTime >= e - inter && sumL > 0) {
|
* 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会 if (pointTime >= e - inter && sumL > 0) {
|
||||||
* countList.add(sumL); timeList.add(stampToDate(pointTime)); } if
|
* countList.add(sumL); timeList.add(stampToDate(pointTime)); } if (pointTime <
|
||||||
* (pointTime < e - inter) { timeList.add(stampToDate(pointTime));
|
* e - inter) { timeList.add(stampToDate(pointTime)); countList.add(sumL); } num
|
||||||
* countList.add(sumL); } num = num + 1; pointTime = b + inter * num; }
|
* = num + 1; pointTime = b + inter * num; } resulMap.put("count", countList);
|
||||||
* resulMap.put("count", countList); resulMap.put("statTime", timeList);
|
* resulMap.put("statTime", timeList); listMap.add(resulMap); } return listMap;
|
||||||
* listMap.add(resulMap); } return listMap; }
|
* }
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* 优化后的网站详情域名趋势查询
|
* 优化后的网站详情域名趋势查询
|
||||||
|
*
|
||||||
* @param beginDate
|
* @param beginDate
|
||||||
* @param endDate
|
* @param endDate
|
||||||
* @param domain
|
* @param domain
|
||||||
@@ -1433,134 +1373,139 @@ public class DashboardService extends BaseService {
|
|||||||
Date beginDate = DateUtils.parseDate(begin);
|
Date beginDate = DateUtils.parseDate(begin);
|
||||||
Date endDate = DateUtils.parseDate(end);
|
Date endDate = DateUtils.parseDate(end);
|
||||||
List<HashMap> listMap = new ArrayList<HashMap>();
|
List<HashMap> listMap = new ArrayList<HashMap>();
|
||||||
List<Date> dateRangeList = new ArrayList<Date>();
|
List<Date> dateRangeList = new ArrayList<Date>();
|
||||||
List<String> strDateRangeList = new ArrayList<String>();
|
List<String> strDateRangeList = new ArrayList<String>();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(beginDate);
|
calendar.setTime(beginDate);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
||||||
while (calendar.getTime().compareTo(endDate)<=0) {
|
while (calendar.getTime().compareTo(endDate) <= 0) {
|
||||||
dateRangeList.add(calendar.getTime());
|
dateRangeList.add(calendar.getTime());
|
||||||
strDateRangeList.add(sdf.format(calendar.getTime()));
|
strDateRangeList.add(sdf.format(calendar.getTime()));
|
||||||
calendar.add(Calendar.MINUTE, 5);
|
calendar.add(Calendar.MINUTE, 5);
|
||||||
}
|
}
|
||||||
//存放每个时间点的总数
|
// 存放每个时间点的总数
|
||||||
Map<String,List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
|
Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
|
||||||
int index=0;
|
int index = 0;
|
||||||
List countList =new ArrayList();
|
List countList = new ArrayList();
|
||||||
for (int i = 0; i < dateRangeList.size(); i++) {
|
for (int i = 0; i < dateRangeList.size(); i++) {
|
||||||
//存放一个时间点中总数
|
// 存放一个时间点中总数
|
||||||
Map<String, Long> ipCountMap = new HashMap<String, Long>();
|
Map<String, Long> ipCountMap = new HashMap<String, Long>();
|
||||||
Date date = dateRangeList.get(i);
|
Date date = dateRangeList.get(i);
|
||||||
Long num = 0L;
|
Long num = 0L;
|
||||||
for (int j = index; j < domainList.size(); j++) {
|
for (int j = index; j < domainList.size(); j++) {
|
||||||
TrafficHttpFocusStatistic ipInfo = domainList.get(j);
|
TrafficHttpFocusStatistic ipInfo = domainList.get(j);
|
||||||
if (ipInfo.getStatTime()!=null){
|
if (ipInfo.getStatTime() != null) {
|
||||||
if(ipInfo.getStatTime().compareTo(date)>=0&&(i+1<dateRangeList.size()&&ipInfo.getStatTime().compareTo(dateRangeList.get(i+1))<0)) {
|
if (ipInfo.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()
|
||||||
num=num+ipInfo.getCount();
|
&& ipInfo.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
|
||||||
}else{
|
num = num + ipInfo.getCount();
|
||||||
index = j;
|
} else {
|
||||||
break;
|
index = j;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
countList.add(num);
|
|
||||||
}
|
}
|
||||||
//整合 count time
|
countList.add(num);
|
||||||
HashMap ipTrafficMap = new HashMap();
|
}
|
||||||
ipTrafficMap.put("count", countList);
|
// 整合 count time
|
||||||
ipTrafficMap.put("statTime", strDateRangeList);
|
HashMap ipTrafficMap = new HashMap();
|
||||||
listMap.add(ipTrafficMap);
|
ipTrafficMap.put("count", countList);
|
||||||
|
ipTrafficMap.put("statTime", strDateRangeList);
|
||||||
|
listMap.add(ipTrafficMap);
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取活跃Port top10 的趋势图
|
* 获取活跃Port top10 的趋势图
|
||||||
* @throws ParseException
|
*
|
||||||
|
* @throws ParseException
|
||||||
*/
|
*/
|
||||||
public List<Map> findTrafficPortActive(String beginDate, String endDate, Integer[] portArray) throws ParseException {
|
public List<Map> findTrafficPortActive(String beginDate, String endDate, Integer[] portArray)
|
||||||
|
throws ParseException {
|
||||||
List<Map> listMap = new ArrayList<Map>();
|
List<Map> listMap = new ArrayList<Map>();
|
||||||
StringBuilder portStr = new StringBuilder();
|
StringBuilder portStr = new StringBuilder();
|
||||||
List<LinkedHashMap> portListTop10 = null;
|
List<LinkedHashMap> portListTop10 = null;
|
||||||
if(portArray!=null && portArray.length>0){//如果有传人参数,获取传人参数
|
if (portArray != null && portArray.length > 0) {// 如果有传人参数,获取传人参数
|
||||||
for(int pi=0;pi<portArray.length;pi++){
|
for (int pi = 0; pi < portArray.length; pi++) {
|
||||||
portStr.append("'"+portArray[pi]+"',");
|
portStr.append("'" + portArray[pi] + "',");
|
||||||
}
|
}
|
||||||
}else{//否则获取TOP10
|
} else {// 否则获取TOP10
|
||||||
portListTop10 = trafficPortActiveStatisticDao.findTrafficPortActiveTopN(beginDate, endDate);
|
portListTop10 = trafficPortActiveStatisticDao.findTrafficPortActiveTopN(beginDate, endDate);
|
||||||
for (LinkedHashMap map : portListTop10) {
|
for (LinkedHashMap map : portListTop10) {
|
||||||
portStr.append("'"+map.get("port")+"',");
|
portStr.append("'" + map.get("port") + "',");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!StringUtil.isEmpty(portStr)&&portStr.indexOf(",")>0) {
|
if (!StringUtil.isEmpty(portStr) && portStr.indexOf(",") > 0) {
|
||||||
portStr.deleteCharAt(portStr.lastIndexOf(","));
|
portStr.deleteCharAt(portStr.lastIndexOf(","));
|
||||||
}
|
}
|
||||||
Date beginDate1 = DateUtils.strToDate(beginDate, "yyyy-MM-dd HH:mm:ss");
|
Date beginDate1 = DateUtils.strToDate(beginDate, "yyyy-MM-dd HH:mm:ss");
|
||||||
Date endDate1 = DateUtils.strToDate(endDate, "yyyy-MM-dd HH:mm:ss");
|
Date endDate1 = DateUtils.strToDate(endDate, "yyyy-MM-dd HH:mm:ss");
|
||||||
//if (portListTop10 != null && portListTop10.size() > 0) {
|
// if (portListTop10 != null && portListTop10.size() > 0) {
|
||||||
//StringBuilder portStr = new StringBuilder();
|
// StringBuilder portStr = new StringBuilder();
|
||||||
if(!StringUtil.isEmpty(portStr)){
|
if (!StringUtil.isEmpty(portStr)) {
|
||||||
//如果所有IP在最后一个时间点的count都为0,则移除最后一个点
|
// 如果所有IP在最后一个时间点的count都为0,则移除最后一个点
|
||||||
//开始划分时间段,间隔5分钟
|
// 开始划分时间段,间隔5分钟
|
||||||
List<Date> dateRangeList = new ArrayList<Date>();
|
List<Date> dateRangeList = new ArrayList<Date>();
|
||||||
List<String> strDateRangeList = new ArrayList<String>();
|
List<String> strDateRangeList = new ArrayList<String>();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(beginDate1);
|
calendar.setTime(beginDate1);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
|
||||||
while (calendar.getTime().compareTo(endDate1)<=0) {
|
while (calendar.getTime().compareTo(endDate1) <= 0) {
|
||||||
dateRangeList.add(calendar.getTime());
|
dateRangeList.add(calendar.getTime());
|
||||||
strDateRangeList.add(sdf.format(calendar.getTime()));
|
strDateRangeList.add(sdf.format(calendar.getTime()));
|
||||||
calendar.add(Calendar.MINUTE, 5);
|
calendar.add(Calendar.MINUTE, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<TrafficPortActiveStatistic> portInfoList = trafficPortActiveStatisticDao.findTrafficPortActive(beginDate, endDate, portStr.toString());
|
ArrayList<TrafficPortActiveStatistic> portInfoList = trafficPortActiveStatisticDao
|
||||||
//存放每个IP,每个时间点的总数
|
.findTrafficPortActive(beginDate, endDate, portStr.toString());
|
||||||
Map<String,List<Long>> portCountListMap = new HashMap<String, List<Long>>();
|
// 存放每个IP,每个时间点的总数
|
||||||
int index=0;
|
Map<String, List<Long>> portCountListMap = new HashMap<String, List<Long>>();
|
||||||
|
int index = 0;
|
||||||
for (int i = 0; i < dateRangeList.size(); i++) {
|
for (int i = 0; i < dateRangeList.size(); i++) {
|
||||||
//存放一个时间点中每个IP的总数
|
// 存放一个时间点中每个IP的总数
|
||||||
Map<String, Long> portCountMap = new HashMap<String, Long>();
|
Map<String, Long> portCountMap = new HashMap<String, Long>();
|
||||||
Date date = dateRangeList.get(i);
|
Date date = dateRangeList.get(i);
|
||||||
for (int j = index; j < portInfoList.size(); j++) {
|
for (int j = index; j < portInfoList.size(); j++) {
|
||||||
TrafficPortActiveStatistic portInfo = portInfoList.get(j);
|
TrafficPortActiveStatistic portInfo = portInfoList.get(j);
|
||||||
if (portInfo.getStatTime()!=null){
|
if (portInfo.getStatTime() != null) {
|
||||||
if(portInfo.getStatTime().compareTo(date)>=0&&(i+1<dateRangeList.size()&&portInfo.getStatTime().compareTo(dateRangeList.get(i+1))<0)) {
|
if (portInfo.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()
|
||||||
|
&& portInfo.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
|
||||||
Long num = portInfo.getSum();
|
Long num = portInfo.getSum();
|
||||||
if (portCountMap.containsKey(portInfo.getPort())) {
|
if (portCountMap.containsKey(portInfo.getPort())) {
|
||||||
num=num+portCountMap.get(portInfo.getPort());
|
num = num + portCountMap.get(portInfo.getPort());
|
||||||
}
|
}
|
||||||
portCountMap.put(portInfo.getPort().toString(), num);
|
portCountMap.put(portInfo.getPort().toString(), num);
|
||||||
}else{
|
} else {
|
||||||
index = j;
|
index = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(portArray!=null && portArray.length>0){//如果有传人参数,获取传人参数
|
if (portArray != null && portArray.length > 0) {// 如果有传人参数,获取传人参数
|
||||||
for(int m=0;m<portArray.length;m++){
|
for (int m = 0; m < portArray.length; m++) {
|
||||||
String port = portArray[m].toString();
|
String port = portArray[m].toString();
|
||||||
Long sum = 0l;
|
Long sum = 0l;
|
||||||
if (portCountMap.containsKey(port)) {
|
if (portCountMap.containsKey(port)) {
|
||||||
sum=portCountMap.get(port);
|
sum = portCountMap.get(port);
|
||||||
}
|
}
|
||||||
if (portCountListMap.containsKey(port)) {
|
if (portCountListMap.containsKey(port)) {
|
||||||
portCountListMap.get(port).add(sum);
|
portCountListMap.get(port).add(sum);
|
||||||
}else{
|
} else {
|
||||||
List<Long> list = new ArrayList<Long>();
|
List<Long> list = new ArrayList<Long>();
|
||||||
list.add(sum);
|
list.add(sum);
|
||||||
portCountListMap.put(port, list);
|
portCountListMap.put(port, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(portListTop10!=null){
|
} else if (portListTop10 != null) {
|
||||||
for (LinkedHashMap map : portListTop10) {
|
for (LinkedHashMap map : portListTop10) {
|
||||||
String port = map.get("port").toString();
|
String port = map.get("port").toString();
|
||||||
Long sum = 0l;
|
Long sum = 0l;
|
||||||
if (portCountMap.containsKey(port)) {
|
if (portCountMap.containsKey(port)) {
|
||||||
sum=portCountMap.get(port);
|
sum = portCountMap.get(port);
|
||||||
}
|
}
|
||||||
if (portCountListMap.containsKey(port)) {
|
if (portCountListMap.containsKey(port)) {
|
||||||
portCountListMap.get(port).add(sum);
|
portCountListMap.get(port).add(sum);
|
||||||
}else{
|
} else {
|
||||||
List<Long> list = new ArrayList<Long>();
|
List<Long> list = new ArrayList<Long>();
|
||||||
list.add(sum);
|
list.add(sum);
|
||||||
portCountListMap.put(port, list);
|
portCountListMap.put(port, list);
|
||||||
@@ -1568,10 +1513,10 @@ public class DashboardService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//整合port sum time
|
// 整合port sum time
|
||||||
Iterator iterator = portCountListMap.keySet().iterator();
|
Iterator iterator = portCountListMap.keySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
String ip = iterator.next()+"";
|
String ip = iterator.next() + "";
|
||||||
Map trafficPortActiveMap = new HashMap();
|
Map trafficPortActiveMap = new HashMap();
|
||||||
trafficPortActiveMap.put("port", ip);
|
trafficPortActiveMap.put("port", ip);
|
||||||
trafficPortActiveMap.put("sum", portCountListMap.get(ip));
|
trafficPortActiveMap.put("sum", portCountListMap.get(ip));
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ import com.nis.web.service.BaseLogService;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TrafficReportService extends BaseLogService {
|
public class TrafficReportService extends BaseLogService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TrafficReportDao trafficReportDao;
|
protected TrafficReportDao trafficReportDao;
|
||||||
|
|
||||||
|
public Page<NtcRadiusReport> findNtcRadiusReport(Page page, NtcRadiusReport entity) throws Exception {
|
||||||
public Page<NtcRadiusReport> findNtcRadiusReport(Page page,NtcRadiusReport entity) throws Exception {
|
|
||||||
entity.setPage(page);
|
entity.setPage(page);
|
||||||
List resultList = null;
|
List resultList = null;
|
||||||
if ("1".equals(entity.getSearchBusinessType())) {
|
if ("1".equals(entity.getSearchBusinessType())) {
|
||||||
@@ -69,11 +68,7 @@ public class TrafficReportService extends BaseLogService {
|
|||||||
return page;
|
return page;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ip46,协议tcp,udp查询带宽
|
* 根据ip46,协议tcp,udp查询带宽
|
||||||
*
|
*
|
||||||
@@ -92,7 +87,6 @@ public class TrafficReportService extends BaseLogService {
|
|||||||
return listMap;
|
return listMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ip46,协议tcp,udp查询带宽
|
* 根据ip46,协议tcp,udp查询带宽
|
||||||
@@ -112,8 +106,16 @@ public class TrafficReportService extends BaseLogService {
|
|||||||
return listMap;
|
return listMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// long a = Long.parseLong("123.3");
|
||||||
|
Long.valueOf("123.3");
|
||||||
|
|
||||||
|
// long b = Long.parseLong("123.3",1);
|
||||||
|
|
||||||
|
long c = Long.valueOf("123.3").longValue();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询单个局点流量的数据信息
|
* 查询单个局点流量的数据信息
|
||||||
*
|
*
|
||||||
@@ -158,8 +160,11 @@ public class TrafficReportService extends BaseLogService {
|
|||||||
if (t >= pointTime && t < pointTime + inter) {
|
if (t >= pointTime && t < pointTime + inter) {
|
||||||
// 范围之内分到此pointTime组
|
// 范围之内分到此pointTime组
|
||||||
sumL = sumL + tt.getLinkNum();
|
sumL = sumL + tt.getLinkNum();
|
||||||
sumP = sumP + tt.getPps();
|
sumP = sumP +Long.parseLong(
|
||||||
sumG = sumG + tt.getGbps();
|
tt.getPps().substring(0,tt.getPps().lastIndexOf(".")));
|
||||||
|
sumG = sumG +
|
||||||
|
Long.parseLong(
|
||||||
|
tt.getGbps().substring(0,tt.getGbps().lastIndexOf(".")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会
|
// 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会
|
||||||
@@ -192,8 +197,7 @@ public class TrafficReportService extends BaseLogService {
|
|||||||
}
|
}
|
||||||
return resulMap;
|
return resulMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间戳 换成日期格式字符串转
|
* 时间戳 换成日期格式字符串转
|
||||||
*
|
*
|
||||||
@@ -206,8 +210,7 @@ public class TrafficReportService extends BaseLogService {
|
|||||||
String sd = sdf.format(new Date(timeStamp)); // 时间戳转换成时间
|
String sd = sdf.format(new Date(timeStamp)); // 时间戳转换成时间
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式字符串转换成时间戳
|
* 日期格式字符串转换成时间戳
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -217,14 +217,14 @@
|
|||||||
|
|
||||||
<!-- 日志数据源拦截器,该拦截路径下使用数据源C -->
|
<!-- 日志数据源拦截器,该拦截路径下使用数据源C -->
|
||||||
<mvc:interceptor>
|
<mvc:interceptor>
|
||||||
<mvc:mapping path="/service/ckLog/**" />
|
<mvc:mapping path="/service/log/v2/**" />
|
||||||
<bean class="com.nis.interceptor.DataSourceBInterceptor"></bean>
|
<bean class="com.nis.interceptor.DataSourceBInterceptor"></bean>
|
||||||
</mvc:interceptor>
|
</mvc:interceptor>
|
||||||
|
|
||||||
<!-- 数据源拦截器,该拦截路径下使用数据源B -->
|
<!-- 数据源拦截器,该拦截路径下使用数据源B -->
|
||||||
<mvc:interceptor>
|
<mvc:interceptor>
|
||||||
<mvc:mapping path="/service/cfg/**" />
|
<mvc:mapping path="/service/cfg/**" />
|
||||||
<mvc:mapping path="/service/log/**" />
|
<mvc:mapping path="/service/log/v1/**" />
|
||||||
<mvc:mapping path="/log/**" />
|
<mvc:mapping path="/log/**" />
|
||||||
<bean class="com.nis.interceptor.DataSourceAInterceptor"></bean>
|
<bean class="com.nis.interceptor.DataSourceAInterceptor"></bean>
|
||||||
</mvc:interceptor>
|
</mvc:interceptor>
|
||||||
|
|||||||
Reference in New Issue
Block a user