1、把sql语句中的时间条件查询改为左闭右开

2、DashboardService中无用的方法添加@Deprecated注解
This commit is contained in:
zhangdongxu
2018-12-24 19:08:01 +08:00
parent c50d92d265
commit ac5d0cc739
8 changed files with 30 additions and 24 deletions

View File

@@ -170,11 +170,11 @@
</if>
<if
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
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>
</where>
<choose>

View File

@@ -170,11 +170,11 @@
</if>
<if
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
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>
</where>
<choose>
@@ -960,7 +960,7 @@
<!-- 获取近一小时的带宽根据ip46协议 tcp,udp变化 -->
<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
where <![CDATA[stat_time>=#{beginDate} and stat_time<=#{endDate} ]]>
where <![CDATA[stat_time>=#{beginDate} and stat_time<#{endDate} ]]>
<if test="addrType != null">
and addr_type=#{addrType}
</if>
@@ -973,7 +973,7 @@
<!-- 获取近一小时的带宽根据ip46协议 tcp,udp变化 -->
<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
where <![CDATA[stat_time<=#{endDate} and stat_time>=#{beginDate}]]>
where <![CDATA[stat_time<#{endDate} and stat_time>=#{beginDate}]]>
and addr_type !=0
and trans_type!=0
group by stat_time,addr_type,trans_type order by stat_time
@@ -988,7 +988,7 @@
<!-- entrance 1,2 ,动作为阻断,近一小时 间隔5分钟数据 -->
<select id="getActionTrans" resultType="com.nis.domain.restful.NtcEntranceReport">
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}
group by report_time order by report_time
</select>

View File

@@ -129,7 +129,7 @@
<!-- entrance 1,2 ,动作为阻断,近一小时 间隔5分钟数据 -->
<select id="getActionTrans" resultType="com.nis.domain.restful.NtcEntranceReport">
select sum(sum) sum,report_time reportTime 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}
group by report_time order by report_time
</select>

View File

@@ -32,7 +32,7 @@
SELECT app_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets,
((SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024) AS GByte
FROM traffic_app_statistic WHERE
<![CDATA[ stat_time>= #{beginTime} and stat_time<= #{endTime}]]>
<![CDATA[ stat_time>= #{beginTime} and stat_time< #{endTime}]]>
<if test="appType!=null">
and app_type in
<foreach collection="appType" index="index" item="item" open="(" separator="," close=")">

View File

@@ -125,7 +125,7 @@ FROM
<select id="getTrafficHttpDomain" resultType="java.util.HashMap">
select web_id webId, max(unique_num) uniqueNum,entrance_id entranceId,SUM(c2s_byte_len + s2c_byte_len) byteCount,
sum(c2s_pkt_num + s2c_pkt_num) pktCount from traffic_http_focus_statistic t where
<![CDATA[ stat_time> #{beginDate} and stat_time<= #{endDate}]]>
<![CDATA[ stat_time>= #{beginDate} and stat_time< #{endDate}]]>
<if test="domain!=null">
and web_id in
<foreach collection="domain" index="index" item="item" open="(" separator="," close=")">

View File

@@ -71,7 +71,7 @@
<select id="ipActiveOneHour" resultType="java.util.HashMap">
SELECT ip_addr ipAddr,area_id areaId,SUM(c2s_byte_len+s2c_byte_len) count, link_num linkNum ,c2s_pkt_num c2sPktNum,s2c_pkt_num s2cPktNum,c2s_byte_len c2sByteLen,s2c_byte_len s2cByteLen,date_format(stat_time, '%Y-%m-%d %H:%i:%s') statTime FROM traffic_ip_active_statistic
WHERE ip_addr=#{ipAddr}
and <![CDATA[ stat_time> #{beginDate} and stat_time<=#{endDate}]]> GROUP BY statTime
and <![CDATA[ stat_time>= #{beginDate} and stat_time<#{endDate}]]> GROUP BY statTime
ORDER BY count DESC LIMIT 1
</select>

View File

@@ -29,7 +29,7 @@
SELECT proto_type,SUM(link_num) AS link_num,SUM(c2s_pkt_num+s2c_pkt_num) AS packets,
((SUM(c2s_byte_len+s2c_byte_len)*8)/300/1024/1024/1024) AS GByte
FROM traffic_protocol_statistic WHERE
<![CDATA[ stat_time>= #{beginTime} and stat_time<= #{endTime}]]>
<![CDATA[ stat_time>= #{beginTime} and stat_time< #{endTime}]]>
<if test="protoType!=null">
and proto_type in
<foreach collection="protoType" index="index" item="item" open="(" separator="," close=")">

View File

@@ -102,6 +102,7 @@ public class DashboardService extends BaseService {
* @param transType
* @return
*/
@Deprecated
public List<HashMap> getBandwidthTrans(String addrType, Integer transType, String beginDate, String endDate) {
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
@@ -121,6 +122,7 @@ public class DashboardService extends BaseService {
* @param transType
* @return
*/
@Deprecated
public List<HashMap> getBandwidthTrans2(String addrType, Integer transType, String beginDate, String endDate) {
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
@@ -143,6 +145,7 @@ public class DashboardService extends BaseService {
* @param entranceId
* @return
*/
@Deprecated
public HashMap getBandwidthTransEntrance(String addrType, Integer transType, String beginDate, String endDate,
Integer entranceId) {
long start = System.currentTimeMillis();
@@ -220,6 +223,7 @@ public class DashboardService extends BaseService {
* @param li
* @return
*/
@Deprecated
public static List<Map> formatDateData(String begin, String end, List<Map> li) {
List<Map> resList = new ArrayList<Map>();
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
* @return
*/
@Deprecated
public static Long dateToStamp(String date_str) {
try {
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
* @return
*/
@Deprecated
public static String stampToDate(long timeStamp) {
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");// 这个是你要转成后的时间的格式
String sd = sdf.format(new Date(timeStamp)); // 时间戳转换成时间
@@ -622,23 +628,23 @@ public class DashboardService extends BaseService {
* @return
*/
public List<HashMap> ipActiveOneHour(Date beginDate, Date endDate) {
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
// TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
ArrayList<HashMap> listMap = new ArrayList<HashMap>();
if (maxStatTime != null && maxStatTime.getStatTime() != null) {
Date statTime = maxStatTime.getStatTime();
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(beginDate, endDate);
if (list != null && list.size() > 0) {
for (LinkedHashMap map : list) {
if (map.get("ipAddr") != null) {
String ipAddr = (String) map.get("ipAddr");
HashMap resMap = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr, beginDate,endDate);
if(resMap!=null){
listMap.add(resMap);
}
// if (maxStatTime != null && maxStatTime.getStatTime() != null) {
// Date statTime = maxStatTime.getStatTime();
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(beginDate, endDate);
if (list != null && list.size() > 0) {
for (LinkedHashMap map : list) {
if (map.get("ipAddr") != null) {
String ipAddr = (String) map.get("ipAddr");
HashMap resMap = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr, beginDate,endDate);
if(resMap!=null){
listMap.add(resMap);
}
}
}
}
// }
return listMap;
}