新增網站詳情統計域名統計
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package com.nis.domain.restful.dashboard;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class TrafficHttpFocusStatistic {
|
||||
|
||||
private Long stat_id;
|
||||
private Integer web_id;
|
||||
private Long unique_num;
|
||||
private Long link_num;
|
||||
private Long c2s_pkt_num;
|
||||
private Long s2c_pkt_num;
|
||||
private Long c2s_byte_len;
|
||||
private Long s2c_byte_len;
|
||||
private Integer entrance_id;
|
||||
private Date stat_time;
|
||||
|
||||
private String time;
|
||||
private Long count;
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public Long getCount() {
|
||||
return count;
|
||||
}
|
||||
public void setCount(Long count) {
|
||||
this.count = count;
|
||||
}
|
||||
public Long getStat_id() {
|
||||
return stat_id;
|
||||
}
|
||||
public void setStat_id(Long stat_id) {
|
||||
this.stat_id = stat_id;
|
||||
}
|
||||
public Integer getWeb_id() {
|
||||
return web_id;
|
||||
}
|
||||
public void setWeb_id(Integer web_id) {
|
||||
this.web_id = web_id;
|
||||
}
|
||||
public Long getUnique_num() {
|
||||
return unique_num;
|
||||
}
|
||||
public void setUnique_num(Long unique_num) {
|
||||
this.unique_num = unique_num;
|
||||
}
|
||||
public Long getLink_num() {
|
||||
return link_num;
|
||||
}
|
||||
public void setLink_num(Long link_num) {
|
||||
this.link_num = link_num;
|
||||
}
|
||||
public Long getC2s_pkt_num() {
|
||||
return c2s_pkt_num;
|
||||
}
|
||||
public void setC2s_pkt_num(Long c2s_pkt_num) {
|
||||
this.c2s_pkt_num = c2s_pkt_num;
|
||||
}
|
||||
public Long getS2c_pkt_num() {
|
||||
return s2c_pkt_num;
|
||||
}
|
||||
public void setS2c_pkt_num(Long s2c_pkt_num) {
|
||||
this.s2c_pkt_num = s2c_pkt_num;
|
||||
}
|
||||
public Long getC2s_byte_len() {
|
||||
return c2s_byte_len;
|
||||
}
|
||||
public void setC2s_byte_len(Long c2s_byte_len) {
|
||||
this.c2s_byte_len = c2s_byte_len;
|
||||
}
|
||||
public Long getS2c_byte_len() {
|
||||
return s2c_byte_len;
|
||||
}
|
||||
public void setS2c_byte_len(Long s2c_byte_len) {
|
||||
this.s2c_byte_len = s2c_byte_len;
|
||||
}
|
||||
public Integer getEntrance_id() {
|
||||
return entrance_id;
|
||||
}
|
||||
public void setEntrance_id(Integer entrance_id) {
|
||||
this.entrance_id = entrance_id;
|
||||
}
|
||||
public Date getStat_time() {
|
||||
return stat_time;
|
||||
}
|
||||
public void setStat_time(Date stat_time) {
|
||||
this.stat_time = stat_time;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -758,7 +758,7 @@ public class DashboardServiceController extends BaseRestController {
|
||||
|
||||
@RequestMapping(value = "trafficWebsiteListNoTime", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "网站流量分析详情统计", httpMethod = "GET", notes = "对应网站http分类显示")
|
||||
public Map<String, ?> trafficWebsiteListNoTime(@RequestParam String beginDate, @RequestParam String endDate,Model model, HttpServletRequest request,
|
||||
public Map<String, ?> trafficWebsiteListNoTime(Integer domain,Integer entranceId , @RequestParam String beginDate, @RequestParam String endDate,Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
@@ -770,7 +770,7 @@ public class DashboardServiceController extends BaseRestController {
|
||||
Date begin = DateUtils.parseDate(beginDate);
|
||||
Date end = DateUtils.parseDate(endDate);
|
||||
// 带查询时间查询所有
|
||||
List<Map> websiteChart = dashboardService.getWebsiteDetails(begin, end);
|
||||
List<Map> websiteChart = dashboardService.getWebsiteDetails(begin, end,domain,entranceId);
|
||||
if (websiteChart != null && websiteChart.size() > 0) {
|
||||
list = websiteChart;
|
||||
}
|
||||
@@ -781,7 +781,7 @@ public class DashboardServiceController extends BaseRestController {
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
|
||||
Date end1 = cal.getTime();
|
||||
// 带查询时间查询所有
|
||||
List<Map> websiteChart = dashboardService.getWebsiteDetails(begin1, end1);
|
||||
List<Map> websiteChart = dashboardService.getWebsiteDetails(begin1, end1,domain,entranceId);
|
||||
if (websiteChart != null && websiteChart.size() > 0) {
|
||||
list = websiteChart;
|
||||
}
|
||||
@@ -929,4 +929,38 @@ public class DashboardServiceController extends BaseRestController {
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "HTTP网站主题分类分析数据检索成功",
|
||||
list, 0);
|
||||
}
|
||||
@RequestMapping(value = "trafficDomainTrans", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "域名详情趋势", httpMethod = "GET", notes = "域名UV")
|
||||
public Map<String, ?> trafficDomainTrans(String beginDate, String endDate, Model model, Integer domain,Integer entranceId,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||||
null);
|
||||
List<HashMap> list = new ArrayList<HashMap>();
|
||||
try {
|
||||
|
||||
// 带查询时间查询所有
|
||||
List<HashMap> websiteChart = dashboardService.getDomainTrans(beginDate, endDate,domain,entranceId);
|
||||
if (websiteChart != null && websiteChart.size() > 0) {
|
||||
list = websiteChart;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
auditLogThread.setExceptionInfo("HTTP网站主题分类分析数据检索失败:" + e.getMessage());
|
||||
logger.error("HTTP网站域名分类分析数据检索失败:" + ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"HTTP网站域名分类分析数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"HTTP网站域名分类分析数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"HTTP网站域名分类分析数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
}
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "HTTP网站域名分类分析数据检索成功",
|
||||
list, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.restful.dashboard.TrafficHttpFocusStatistic;
|
||||
import com.nis.domain.restful.dashboard.TrafficHttpStatistic;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
|
||||
@@ -27,4 +28,8 @@ public interface TrafficHttpStatisticDao {
|
||||
List<Map> getHttpStatisticNoLinkAndPkt(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
|
||||
List<Map> getTrafficHttpStatistic(@Param("statTime") Date statTime, @Param("endTime") Date endTime);
|
||||
List getIdByWebSiteId(@Param("websiteId") Integer websiteId);
|
||||
|
||||
List<Map> getTrafficHttpDomain(@Param("beginDate")Date beginDate,@Param("endDate") Date endDate,@Param("domain")Integer domain,@Param("entranceId")Integer entranceId);
|
||||
List<TrafficHttpFocusStatistic> getDomainTrans(@Param("entranceId")Integer entranceId,@Param("beginDate")String beginDate,@Param("endDate")String endDate,@Param("domain")Integer domain);
|
||||
|
||||
}
|
||||
@@ -121,4 +121,26 @@ FROM
|
||||
</if>
|
||||
|
||||
</select>
|
||||
<!--获取域名 -->
|
||||
<select id="getTrafficHttpDomain" resultType="java.util.HashMap">
|
||||
select web_id webId, 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}]]>
|
||||
<if test="domain!=null">
|
||||
and web_id=#{domain}
|
||||
</if>
|
||||
<if test="entranceId!=null">
|
||||
and entrance_id=#{entranceId}
|
||||
</if>
|
||||
group by web_id order by uniqueNum
|
||||
</select>
|
||||
<select id="getDomainTrans" resultType="com.nis.domain.restful.dashboard.TrafficHttpFocusStatistic">
|
||||
select stat_time time, unique_num count from traffic_http_focus_statistic t where
|
||||
<![CDATA[ stat_time>= #{beginDate} and stat_time< #{endDate}]]>
|
||||
and web_id=#{domain}
|
||||
<if test="entranceId!=null">
|
||||
and entrance_id=#{entranceId}
|
||||
</if>
|
||||
order by stat_time
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Service;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@Service
|
||||
public class DashboardService extends BaseService {
|
||||
|
||||
@@ -807,8 +806,8 @@ public class DashboardService extends BaseService {
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
public List<Map> getWebsiteDetails(Date beginDate, Date endDate) {
|
||||
List<Map> list = trafficHttpStatisticDao.getTrafficHttpStatistic(beginDate, endDate);
|
||||
public List<Map> getWebsiteDetails(Date beginDate, Date endDate,Integer domain,Integer entranceId) {
|
||||
List<Map> list = trafficHttpStatisticDao.getTrafficHttpDomain(beginDate, endDate,domain,entranceId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1130,5 +1129,61 @@ public class DashboardService extends BaseService {
|
||||
}
|
||||
return resulMap;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param beginDate
|
||||
* @param endDate
|
||||
* @param domain
|
||||
* @param entranceId
|
||||
* @return
|
||||
*/
|
||||
public List<HashMap> getDomainTrans(String beginDate, String endDate, Integer domain, Integer entranceId) {
|
||||
List<HashMap> listMap = new ArrayList<HashMap>();
|
||||
HashMap resulMap= new HashMap();
|
||||
List<TrafficHttpFocusStatistic> domainList = new ArrayList<TrafficHttpFocusStatistic>();
|
||||
domainList = trafficHttpStatisticDao.getDomainTrans(entranceId, beginDate, endDate, domain);
|
||||
List timeList = new ArrayList();
|
||||
List countList = new ArrayList();
|
||||
if (domainList != null && domainList.size() > 0) {
|
||||
Map<String, Comparable> m = new HashMap<String, Comparable>();
|
||||
int inter = 1000 * 60 * 30;// 间隔时间为30分钟
|
||||
// 开始时间,结束时间 时间戳
|
||||
Long b = dateToStamp(beginDate);
|
||||
Long e = dateToStamp(endDate);
|
||||
int num = 0;
|
||||
Long pointTime = b;
|
||||
while (pointTime < e) {
|
||||
Map rm = new HashMap();
|
||||
Long sumL = 0l;
|
||||
if (pointTime >= e) {
|
||||
break; // 停止
|
||||
}
|
||||
for (TrafficHttpFocusStatistic tt : domainList) {
|
||||
// 实际时间
|
||||
String time = tt.getTime();
|
||||
Long t = dateToStamp(time);
|
||||
if (t >= pointTime && t < pointTime + inter) {
|
||||
// 范围之内分到此pointTime组
|
||||
sumL = sumL + tt.getCount();
|
||||
}
|
||||
}
|
||||
// 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会
|
||||
if (pointTime >= e - inter && sumL > 0) {
|
||||
countList.add(sumL);
|
||||
timeList.add(stampToDate(pointTime));
|
||||
}
|
||||
if (pointTime < e - inter) {
|
||||
timeList.add(stampToDate(pointTime));
|
||||
countList.add(sumL);
|
||||
}
|
||||
num = num + 1;
|
||||
pointTime = b + inter * num;
|
||||
}
|
||||
resulMap.put("count", countList);
|
||||
resulMap.put("statTime", timeList);
|
||||
listMap.add(resulMap);
|
||||
}
|
||||
return listMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user