合并代码

This commit is contained in:
renkaige
2019-01-07 10:19:40 +06:00
parent 44de9e1f25
commit a8b9ffc219
12 changed files with 583 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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());
}
}