合并代码
This commit is contained in:
@@ -109,6 +109,26 @@ public abstract class LogEntity<T> implements Serializable {
|
||||
protected String searchCapIp;//处理机IP
|
||||
protected String searchFoundStartTime;//开始发现时间
|
||||
protected String searchFoundEndTime;//结束发现时间
|
||||
|
||||
//add by dxy 2019-01-05 仅限于NtcConnRecordLog需求,考虑以后可能会放开其他日志查询,所以放到公共类
|
||||
protected String searchServerLocate;//serverLocate
|
||||
protected String searchClientLocate;//clientLocate
|
||||
|
||||
public String getSearchServerLocate() {
|
||||
return searchServerLocate;
|
||||
}
|
||||
|
||||
public void setSearchServerLocate(String searchServerLocate) {
|
||||
this.searchServerLocate = searchServerLocate;
|
||||
}
|
||||
|
||||
public String getSearchClientLocate() {
|
||||
return searchClientLocate;
|
||||
}
|
||||
|
||||
public void setSearchClientLocate(String searchClientLocate) {
|
||||
this.searchClientLocate = searchClientLocate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前实体分页对象
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.nis.domain.LogEntity;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@@ -28,7 +29,23 @@ public class NtcConnRecordLog extends LogEntity<NtcConnRecordLog> {
|
||||
protected String c2sByteNum;
|
||||
@ApiModelProperty(value = "", required = true)
|
||||
protected String s2cByteNum;
|
||||
|
||||
@ApiModelProperty(value = "", required = true)
|
||||
protected Long protoId;
|
||||
@ApiModelProperty(value = "", required = true)
|
||||
protected Long appId;
|
||||
@ApiModelProperty(value = "", required = true)
|
||||
protected Long webId;
|
||||
|
||||
protected String searchSAsn;//sAsn
|
||||
protected String searchDAsn;//dAsn
|
||||
protected String searchAppId;//app
|
||||
protected String searchWebId;//web
|
||||
protected String searchProtoId;//proto
|
||||
//protected String searchServerLocate;//serverLocate
|
||||
//protected String searchClientLocate;//clientLocate
|
||||
|
||||
@JsonIgnore
|
||||
public String getAppLabel() {
|
||||
return appLabel;
|
||||
}
|
||||
@@ -69,4 +86,76 @@ public class NtcConnRecordLog extends LogEntity<NtcConnRecordLog> {
|
||||
this.s2cByteNum = s2cByteNum;
|
||||
}
|
||||
|
||||
public Long getProtoId() {
|
||||
return protoId;
|
||||
}
|
||||
|
||||
public void setProtoId(Long protoId) {
|
||||
this.protoId = protoId;
|
||||
}
|
||||
|
||||
public Long getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(Long appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public Long getWebId() {
|
||||
return webId;
|
||||
}
|
||||
|
||||
public void setWebId(Long webId) {
|
||||
this.webId = webId;
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchSAsn() {
|
||||
return searchSAsn;
|
||||
}
|
||||
|
||||
public void setSearchSAsn(String searchSAsn) {
|
||||
this.searchSAsn = searchSAsn;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchDAsn() {
|
||||
return searchDAsn;
|
||||
}
|
||||
|
||||
public void setSearchDAsn(String searchDAsn) {
|
||||
this.searchDAsn = searchDAsn;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchAppId() {
|
||||
return searchAppId;
|
||||
}
|
||||
|
||||
public void setSearchAppId(String searchAppId) {
|
||||
this.searchAppId = searchAppId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchWebId() {
|
||||
return searchWebId;
|
||||
}
|
||||
|
||||
public void setSearchWebId(String searchWebId) {
|
||||
this.searchWebId = searchWebId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchProtoId() {
|
||||
return searchProtoId;
|
||||
}
|
||||
|
||||
public void setSearchProtoId(String searchProtoId) {
|
||||
this.searchProtoId = searchProtoId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.nis.domain.restful.dashboard;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
public class AppConnRecordStatistic extends AppTrendEntity{
|
||||
|
||||
protected String ipAddr;
|
||||
protected String pktNum;
|
||||
protected String byteNum;
|
||||
protected String logNum; //日志数量
|
||||
|
||||
public AppConnRecordStatistic() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
public AppConnRecordStatistic(String ipAddr, String pktNum, String byteNum,
|
||||
String logNum) {
|
||||
super();
|
||||
this.ipAddr = ipAddr;
|
||||
this.pktNum = pktNum;
|
||||
this.byteNum = byteNum;
|
||||
this.logNum = logNum;
|
||||
}
|
||||
public String getIpAddr() {
|
||||
return ipAddr;
|
||||
}
|
||||
public void setIpAddr(String ipAddr) {
|
||||
this.ipAddr = ipAddr;
|
||||
}
|
||||
public String getPktNum() {
|
||||
return pktNum;
|
||||
}
|
||||
public void setPktNum(String pktNum) {
|
||||
this.pktNum = pktNum;
|
||||
}
|
||||
public String getByteNum() {
|
||||
return byteNum;
|
||||
}
|
||||
public void setByteNum(String byteNum) {
|
||||
this.byteNum = byteNum;
|
||||
}
|
||||
public String getLogNum() {
|
||||
return logNum;
|
||||
}
|
||||
public void setLogNum(String logNum) {
|
||||
this.logNum = logNum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.nis.domain.restful.dashboard;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
public class AppTrendEntity{
|
||||
|
||||
private String searchAppId;
|
||||
private String searchStartTime;
|
||||
private String searchEndTime;
|
||||
private String searchEntranceId;
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchAppId() {
|
||||
return searchAppId;
|
||||
}
|
||||
public void setSearchAppId(String searchAppId) {
|
||||
this.searchAppId = searchAppId;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchStartTime() {
|
||||
return searchStartTime;
|
||||
}
|
||||
public void setSearchStartTime(String searchStartTime) {
|
||||
this.searchStartTime = searchStartTime;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchEndTime() {
|
||||
return searchEndTime;
|
||||
}
|
||||
public void setSearchEndTime(String searchEndTime) {
|
||||
this.searchEndTime = searchEndTime;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchEntranceId() {
|
||||
return searchEntranceId;
|
||||
}
|
||||
public void setSearchEntranceId(String searchEntranceId) {
|
||||
this.searchEntranceId = searchEntranceId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.nis.domain.restful.dashboard;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class TrafficAppFocusStatistic extends AppTrendEntity{
|
||||
|
||||
private Date time;
|
||||
private Long sipNum;
|
||||
private Long dipNum;
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
public Long getSipNum() {
|
||||
return sipNum;
|
||||
}
|
||||
public void setSipNum(Long sipNum) {
|
||||
this.sipNum = sipNum;
|
||||
}
|
||||
public Long getDipNum() {
|
||||
return dipNum;
|
||||
}
|
||||
public void setDipNum(Long dipNum) {
|
||||
this.dipNum = dipNum;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nis.web.controller.restful;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -19,7 +20,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.nis.datasource.CustomerContextHolder;
|
||||
import com.nis.domain.restful.NtcConnNumReport;
|
||||
import com.nis.domain.restful.NtcRadiusReport;
|
||||
import com.nis.domain.restful.dashboard.AppConnRecordStatistic;
|
||||
import com.nis.domain.restful.dashboard.AppTrendEntity;
|
||||
import com.nis.domain.restful.dashboard.TrafficAppFocusStatistic;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
@@ -985,4 +991,161 @@ public class DashboardServiceController extends BaseRestController {
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "流量各指标趋势统计成功",
|
||||
restMap, 0);
|
||||
}
|
||||
/**
|
||||
* @Description:
|
||||
* @author(zdx)
|
||||
* @date 2019年1月4日 下午8:57:32
|
||||
* @param model
|
||||
* @param entity
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "trafficAppTrend", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "App趋势详情查询", httpMethod = "GET", notes = "对App趋势详情提供数据查询服务")
|
||||
public Map<String, ?> trafficAppTrend(TrafficAppFocusStatistic entity, Model model,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||||
null);
|
||||
Map resultMap = new HashMap();
|
||||
try {
|
||||
//验证
|
||||
checkAppTrendCondition(entity);
|
||||
if (StringUtil.isEmpty(entity.getSearchStartTime())
|
||||
&& StringUtil.isEmpty(entity.getSearchEndTime())) {
|
||||
Map<String, String> map = DateUtils.getLocalTime(null, null, Constants.LOG_LOCAL_TIME, "hour");
|
||||
entity.setSearchStartTime(map.get("startTime"));
|
||||
entity.setSearchEndTime(map.get("endTime"));
|
||||
}
|
||||
//将数据源切换到本地clickhouse
|
||||
CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_B);
|
||||
resultMap = dashboardService.getAppTrend(entity);
|
||||
CustomerContextHolder.clearCustomerType();
|
||||
} catch (Exception e) {
|
||||
auditLogThread.setExceptionInfo("App趋势详情数据检索失败:" + e.getMessage());
|
||||
logger.error("App趋势详情数据检索失败:" + ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"App趋势详情数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"App趋势详情数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"App趋势详情数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "App趋势详情数据检索成功",
|
||||
resultMap, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @author(zdx)
|
||||
* @date 2019年1月4日 下午8:57:12
|
||||
* @param beginDate
|
||||
* @param endDate
|
||||
* @param model
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "appConnRecordTop100", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "App通联关系Top100", httpMethod = "GET", notes = "对App通联关系Top100提供查询服务。")
|
||||
public Map<String, ?> appConnRecordTop100(AppConnRecordStatistic entity,Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||||
null);
|
||||
List<AppConnRecordStatistic> list = new ArrayList<AppConnRecordStatistic>();
|
||||
try {
|
||||
//验证
|
||||
checkAppTrendCondition(entity);
|
||||
if (StringUtil.isEmpty(entity.getSearchStartTime())
|
||||
&& StringUtil.isEmpty(entity.getSearchEndTime())) {
|
||||
Map<String, String> map = DateUtils.getLocalTime(null, null, Constants.LOG_LOCAL_TIME, "hour");
|
||||
entity.setSearchStartTime(map.get("startTime"));
|
||||
entity.setSearchEndTime(map.get("endTime"));
|
||||
}
|
||||
CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_B);
|
||||
list = dashboardService.appConnRecordTop100(entity);
|
||||
CustomerContextHolder.clearCustomerType();
|
||||
} catch (Exception e) {
|
||||
auditLogThread.setExceptionInfo("App通联关系Top100数据检索失败:" + e.getMessage());
|
||||
logger.error("App通联关系Top100检索失败:" + ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"App通联关系Top100数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"App通联关系Top100数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"App通联关系Top100数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
}
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "App通联关系Top100数据检索成功", list,
|
||||
0);
|
||||
}
|
||||
/**
|
||||
*/
|
||||
public void checkAppTrendCondition(AppTrendEntity entity) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
int timeCount = 0;
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchStartTime())) {
|
||||
sdf.parse(entity.getSearchStartTime());
|
||||
timeCount++;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RestServiceException("searchStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchStartTime参数错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchEndTime())) {
|
||||
sdf.parse(entity.getSearchEndTime());
|
||||
timeCount++;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RestServiceException("searchEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchEndTime参数错误", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
if (timeCount == 1) {
|
||||
throw new RestServiceException("searchStartTime和searchEndTime参数必须同时填写",
|
||||
RestBusinessCode.config_integrity_error.getValue());
|
||||
}
|
||||
//验证AppId和EntranceId必须是数值
|
||||
checkNumericCondition(entity.getSearchAppId(),"searchAppId");
|
||||
checkNumericCondition(entity.getSearchEntranceId(),"searchEntranceId");
|
||||
logger.info("用户行为日志统计参数校验结束----" + System.currentTimeMillis());
|
||||
|
||||
}
|
||||
public void checkNumericCondition(String condition, String condName) {
|
||||
if (!StringUtil.isEmpty(condition)) {
|
||||
Boolean flag = false;
|
||||
if (condition.contains(",")) {
|
||||
String services[] = condition.split(",");
|
||||
for (String service : services) {
|
||||
if (!StringUtil.isNumeric(service)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!StringUtil.isNumeric(condition)) {
|
||||
flag = true;
|
||||
}
|
||||
if (flag) {
|
||||
throw new RestServiceException(condName + "参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,6 +696,7 @@ public class NtcLogSearchController extends BaseRestController {
|
||||
ntcConnRecordLog.setSearchFoundEndTime(map.get("endTime"));
|
||||
}
|
||||
ntcLogService.queryConditionCheck(auditLogThread, start, ntcConnRecordLog, NtcConnRecordLog.class, page);
|
||||
ntcLogService.ntcConnRecordLogsQueryConditionCheck(auditLogThread, start, ntcConnRecordLog, NtcConnRecordLog.class, page);
|
||||
logDataService.getData(page, ntcConnRecordLog);
|
||||
} catch (Exception e) {
|
||||
auditLogThread.setExceptionInfo("通联关系日志检索失败:" + e.getMessage());
|
||||
|
||||
@@ -1523,6 +1523,15 @@
|
||||
<result column="c2s_byte_num" jdbcType="VARCHAR" property="c2sByteNum" />
|
||||
<result column="s2c_byte_num" jdbcType="VARCHAR" property="s2cByteNum" />
|
||||
|
||||
<result column="proto_id" jdbcType="BIGINT" property="protoId" />
|
||||
<result column="app_id" jdbcType="BIGINT" property="appId" />
|
||||
<result column="web_id" jdbcType="BIGINT" property="webId" />
|
||||
<!--
|
||||
<result column="os_id" jdbcType="BIGINT" property="osId" />
|
||||
<result column="bs_id" jdbcType="BIGINT" property="bsId" />
|
||||
<result column="behav_id" jdbcType="BIGINT" property="behavId" />
|
||||
-->
|
||||
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -5,7 +5,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.restful.dashboard.AppConnRecordStatistic;
|
||||
import com.nis.domain.restful.dashboard.TrafficAppFocusStatistic;
|
||||
import com.nis.domain.restful.dashboard.TrafficAppStatistic;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
@MyBatisDao
|
||||
@@ -14,4 +15,6 @@ public interface TrafficAppStatisticDao {
|
||||
TrafficAppStatistic getMaxStatTime();
|
||||
List<Map> appChart(@Param("statTime")Date statTime);
|
||||
List<Map> getAppList(@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("appType")Integer[] appType);
|
||||
List<TrafficAppFocusStatistic> getAppTrend(TrafficAppFocusStatistic entity);
|
||||
List<AppConnRecordStatistic> appConnRecordTop100(AppConnRecordStatistic entity);
|
||||
}
|
||||
@@ -42,4 +42,29 @@
|
||||
GROUP BY app_type ) p
|
||||
LEFT JOIN ui_code_app_dic c ON p.app_type=c.view_code ORDER BY p.GByte DESC
|
||||
</select>
|
||||
<!-- App 趋势详情 -->
|
||||
<select id="getAppTrend" parameterType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic" resultType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic">
|
||||
select stat_time time, max(unique_sip_num) sipNum,max(unique_dip_num) dipNum from traffic_app_focus_statistic t where
|
||||
<![CDATA[ stat_time>= toDateTime(#{searchStartTime}) and stat_time< toDateTime(#{searchEndTime})
|
||||
and app_id=toInt64(#{searchAppId}) ]]>
|
||||
<if test="searchEntranceId">
|
||||
<![CDATA[and entrance_id=toInt64(#{searchEntranceId}) ]]>
|
||||
</if>
|
||||
|
||||
group by stat_time
|
||||
order by stat_time
|
||||
</select>
|
||||
<!-- App通联关系Top100 -->
|
||||
<select id="appConnRecordTop100" parameterType="com.nis.domain.restful.dashboard.AppConnRecordStatistic" resultType="com.nis.domain.restful.dashboard.AppConnRecordStatistic">
|
||||
select found_time,s_ip ipAddr, sum(c2s_byte_num + s2c_byte_num) byteNum, sum(c2s_pkt_num + s2c_pkt_num) pktNum, count(found_time) logNum
|
||||
from tbs_ods_ntc_conn_record_log t where
|
||||
<![CDATA[ found_time>= toDateTime(#{searchStartTime}) and found_time< toDateTime(#{searchEndTime})
|
||||
and app_id=toInt64(#{searchAppId}) ]]>
|
||||
<if test="searchEntranceId">
|
||||
<![CDATA[and entrance_id=toInt64(#{searchEntranceId}) ]]>
|
||||
</if>
|
||||
|
||||
group by found_time,s_ip
|
||||
order by logNum limit 100
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -22,7 +22,9 @@ import org.springframework.stereotype.Service;
|
||||
import com.beust.jcommander.internal.Maps;
|
||||
import com.nis.domain.restful.NtcConnNumReport;
|
||||
import com.nis.domain.restful.NtcEntranceReport;
|
||||
import com.nis.domain.restful.dashboard.AppConnRecordStatistic;
|
||||
import com.nis.domain.restful.dashboard.NtcTotalReport;
|
||||
import com.nis.domain.restful.dashboard.TrafficAppFocusStatistic;
|
||||
import com.nis.domain.restful.dashboard.TrafficAppStatistic;
|
||||
import com.nis.domain.restful.dashboard.TrafficHttpFocusStatistic;
|
||||
import com.nis.domain.restful.dashboard.TrafficIpActiveStatistic;
|
||||
@@ -1633,4 +1635,68 @@ public class DashboardService extends BaseService {
|
||||
}
|
||||
return restMap;
|
||||
}
|
||||
|
||||
public Map getAppTrend(TrafficAppFocusStatistic entity) {
|
||||
List<TrafficAppFocusStatistic> appFocusList = new ArrayList<TrafficAppFocusStatistic>();
|
||||
appFocusList = trafficAppStatisticDao.getAppTrend(entity);
|
||||
Map resultMap = new HashMap();
|
||||
if(!StringUtil.isEmpty(appFocusList)){
|
||||
Date beginDate = DateUtils.parseDate(entity.getSearchStartTime());
|
||||
Date endDate = DateUtils.parseDate(entity.getSearchEndTime());
|
||||
List<Date> dateRangeList = new ArrayList<Date>();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(beginDate);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
while (calendar.getTime().compareTo(endDate) < 0) {
|
||||
dateRangeList.add(calendar.getTime());
|
||||
calendar.add(Calendar.MINUTE, 1);
|
||||
}
|
||||
// 存放每个时间点的总数
|
||||
Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
|
||||
int index = 0;
|
||||
List resultSipList = new ArrayList();
|
||||
List resultDipList = new ArrayList();
|
||||
Long sipTotal = 0L;
|
||||
Long dipTotal = 0L;
|
||||
for (int i = 0; i < dateRangeList.size(); i++) {
|
||||
// 存放一个时间点中总数
|
||||
List sipList = new ArrayList();
|
||||
List dipList = new ArrayList();
|
||||
Date date = dateRangeList.get(i);
|
||||
Long sipNum = 0L;
|
||||
Long dipNum = 0L;
|
||||
for (int j = index; j < appFocusList.size(); j++) {
|
||||
TrafficAppFocusStatistic info = appFocusList.get(j);
|
||||
if (info.getTime() != null) {
|
||||
if (info.getTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()?info.getTime().compareTo(dateRangeList.get(i + 1)) < 0:true)) {
|
||||
sipNum = sipNum + info.getSipNum();
|
||||
dipNum = dipNum + info.getDipNum();
|
||||
} else {
|
||||
index = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
sipList.add(date.getTime());
|
||||
sipList.add(sipNum);
|
||||
resultSipList.add(sipList);
|
||||
dipList.add(date.getTime());
|
||||
dipList.add(dipNum);
|
||||
resultDipList.add(dipList);
|
||||
sipTotal+=sipNum;
|
||||
dipTotal+=dipNum;
|
||||
}
|
||||
resultMap.put("sipResult", resultSipList);
|
||||
resultMap.put("dipResult", resultDipList);
|
||||
resultMap.put("sipSum", sipTotal);
|
||||
resultMap.put("dipSum", dipTotal);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public List<AppConnRecordStatistic> appConnRecordTop100(AppConnRecordStatistic entity) {
|
||||
List<AppConnRecordStatistic> list = new ArrayList<AppConnRecordStatistic>();
|
||||
list = trafficAppStatisticDao.appConnRecordTop100(entity);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.NtcConnRecordLog;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
@@ -13,4 +21,85 @@ import com.nis.web.service.BaseLogService;
|
||||
@Service
|
||||
public class NtcLogService extends BaseLogService {
|
||||
|
||||
/**
|
||||
* 验证日志查询条件格式是否正确
|
||||
*
|
||||
* @param thread
|
||||
* @param start
|
||||
* @param entity
|
||||
* @param clazz
|
||||
* @param page
|
||||
*/
|
||||
public void ntcConnRecordLogsQueryConditionCheck(AuditLogThread thread, long start, NtcConnRecordLog entity, Class clazz, Page page) {
|
||||
logger.info("ntcConnRecordLogsQueryConditionCheck start----" + System.currentTimeMillis());
|
||||
|
||||
//app protocol website
|
||||
if (!StringUtil.isBlank(entity.getSearchAppId())) {
|
||||
String[] split = org.apache.commons.lang.StringUtils.split(entity.getSearchAppId(), ",");
|
||||
if (split.length > 10) {
|
||||
throw new RestServiceException("searchAppId max(10)",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
for (String appId : split) {
|
||||
try {
|
||||
Long.parseLong(appId);
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchAppId error", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (!StringUtil.isBlank(entity.getSearchProtoId())) {
|
||||
String[] split = org.apache.commons.lang.StringUtils.split(entity.getSearchProtoId(), ",");
|
||||
if (split.length > 10) {
|
||||
throw new RestServiceException("searchProtoId max(10)",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
for (String protoId : split) {
|
||||
try {
|
||||
Long.parseLong(protoId);
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchAppId error", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (!StringUtil.isBlank(entity.getSearchWebId())) {
|
||||
String[] split = org.apache.commons.lang.StringUtils.split(entity.getSearchWebId(), ",");
|
||||
if (split.length > 10) {
|
||||
throw new RestServiceException("searchWebId max(10)",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
for (String appId : split) {
|
||||
try {
|
||||
Long.parseLong(appId);
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchWebId 参数错误", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchDirection())) {
|
||||
Integer.parseInt(entity.getSearchDirection());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RestServiceException("getSearchDirection参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("getSearchDirection参数错误", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchEntranceId())) {
|
||||
Long.parseLong(entity.getSearchEntranceId());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RestServiceException("searchEntranceId参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchEntranceId参数错误", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
logger.info("ntcConnRecordLogsQueryConditionCheck end----" + System.currentTimeMillis());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user