diff options
| author | renkaige <[email protected]> | 2019-05-20 14:26:16 +0800 |
|---|---|---|
| committer | renkaige <[email protected]> | 2019-05-20 14:26:16 +0800 |
| commit | f862efd37862550db05fd155b1163bb1f0ec94a3 (patch) | |
| tree | 34f1606d8c93625d03f29937023e9b1fd6320985 | |
| parent | 8359cf3a2a3985c87e151630c21e66233c5f0153 (diff) | |
修改v1版本流量统计带宽查询接口从clickhouse中查询
| -rw-r--r-- | src/main/java/com/nis/web/controller/restful/DashboardServiceController.java | 50 | ||||
| -rw-r--r-- | src/main/java/com/nis/web/service/restful/DashboardService.java | 38 |
2 files changed, 77 insertions, 11 deletions
diff --git a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java index 83ce616..2b07da1 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -215,6 +215,53 @@ public class DashboardServiceController extends BaseRestController { cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
beginDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());
}
+ CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_B);
+ resultMap = dashboardService.getBandwidthTransByQuoTaType(beginDate, endDate, searchQuotaType,
+ searchDirection);
+ } catch (Exception e) {
+ auditLogThread.setExceptionInfo("带宽实时统计数据检索失败:" + e.getMessage());
+ logger.error("带宽实时统计数据检索失败:" + ExceptionUtil.getExceptionMsg(e));
+ if (e instanceof RestServiceException) {
+ throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start,
+ "带宽实时统计数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
+ } else if (e instanceof ServiceRuntimeException) {
+ throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
+ "带宽实时统计数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
+ } else {
+ throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
+ "带宽实时统计数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
+ }
+ } finally {
+ CustomerContextHolder.clearCustomerType();
+ }
+ return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "带宽实时统计数据检索成功",
+ resultMap, 0);
+ }
+
+
+
+
+
+
+ /**
+ * 根据ip46,协议tcp,udp查询带宽
+ */
+ @RequestMapping(value = "trafficBandwidthTransThreeOld", method = RequestMethod.GET)
+ @ApiOperation(value = "带宽根据ip46,协议tcp,udp查询详情", httpMethod = "GET", notes = "对应带宽根据IPv4,6,协议tcp,udp统计数据显示")
+ public Map<String, ?> trafficBandwidthTransThreeOld(String beginDate, String endDate, String searchQuotaType,
+ Model model, Integer searchDirection, HttpServletRequest request, HttpServletResponse response) {
+ long start = System.currentTimeMillis();
+ AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
+ null);
+ Map resultMap = new HashMap();
+ try {
+ if (StringUtils.isEmpty(beginDate) && StringUtils.isEmpty(endDate)) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+ endDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());// 获取到完整的时间
+ cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
+ beginDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());
+ }
resultMap = dashboardService.getBandwidthTransEntrance(beginDate, endDate, searchQuotaType,
searchDirection);
@@ -235,6 +282,9 @@ public class DashboardServiceController extends BaseRestController { return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "带宽实时统计数据检索成功",
resultMap, 0);
}
+
+
+
/**
* 流量统计活跃端口统计
diff --git a/src/main/java/com/nis/web/service/restful/DashboardService.java b/src/main/java/com/nis/web/service/restful/DashboardService.java index c6dff6a..823c45b 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -37,6 +37,7 @@ import com.nis.domain.restful.dashboard.TrafficIpActiveStatistic; import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic;
import com.nis.domain.restful.dashboard.TrafficProtocolStatistic;
import com.nis.domain.restful.dashboard.TrafficTransStatistic;
+import com.nis.domain.restful.dashboard.TrafficTransStatisticCK;
import com.nis.domain.restful.dashboard.TrafficUaStatistic;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
@@ -44,6 +45,7 @@ import com.nis.util.Constants; import com.nis.util.DateUtils;
import com.nis.util.StringUtils;
import com.nis.web.dao.IspInfoDao;
+import com.nis.web.dao.TrafficReportDao;
import com.nis.web.dao.dashboard.NtcTotalReportDao;
import com.nis.web.dao.dashboard.TrafficAppStatisticDao;
import com.nis.web.dao.dashboard.TrafficAsnStatisticDao;
@@ -76,6 +78,9 @@ public class DashboardService extends BaseService { public TrafficPortActiveStatisticDao trafficPortActiveStatisticDao;
@Autowired
private IspInfoDao ispInfoDao;
+
+ @Autowired
+ protected TrafficReportService trafficReportService;
// ip地址类型
private final String[] addrTypes = { "4", "6" };
// tcp udp
@@ -309,8 +314,7 @@ public class DashboardService extends BaseService { /**
* 日期格式字符串转换成时间戳
*
- * @param date_str
- * 字符串日期
+ * @param date_str 字符串日期
* @return
*/
@Deprecated
@@ -327,8 +331,7 @@ public class DashboardService extends BaseService { /**
* 时间戳 换成日期格式字符串转
*
- * @param timeStamp
- * 1544602212000
+ * @param timeStamp 1544602212000
* @return
*/
@Deprecated
@@ -1301,6 +1304,22 @@ public class DashboardService extends BaseService { return fieldType == null ? null : fieldType.split(",");
}
+ public Map<?, ?> getBandwidthTransByQuoTaType(String beginDate, String endDate, String searchQuotaType,
+ Integer searchDirection) {
+ TrafficTransStatisticCK trafficTransStatisticCK = new TrafficTransStatisticCK();
+ trafficTransStatisticCK.setSearchBusinessType(1);
+ trafficTransStatisticCK.setBeginDate(beginDate);
+ trafficTransStatisticCK.setEndDate(endDate);
+ if (searchQuotaType.toLowerCase().equals("gbps")) {
+ trafficTransStatisticCK.setSearchQuotaType(1);
+ } else if (searchQuotaType.toLowerCase().equals("pps")) {
+ trafficTransStatisticCK.setSearchQuotaType(2);
+ } else if (searchQuotaType.toLowerCase().equals("linknumber")) {
+ trafficTransStatisticCK.setSearchQuotaType(3);
+ }
+ return trafficReportService.getBandwidthTransByQuoTaType(trafficTransStatisticCK);
+ }
+
public Map<String, Map> getBandwidthTransEntrance(String beginDate, String endDate, String searchQuotaType,
Integer searchDirection) throws ParseException {
Map<String, Map> resultMap = new HashMap<String, Map>();
@@ -1782,15 +1801,12 @@ public class DashboardService extends BaseService { }
return resultMap;
}
-
-
-
public Map getAppBpsTrend(TrafficAppBpsStatistic entity) {
List<TrafficAppBpsStatistic> list = new ArrayList<TrafficAppBpsStatistic>();
list = trafficAppStatisticDao.getAppBpsTrend(entity);
Map resultMap = new HashMap();
- Long gbps = 1024l*1024l*1024l*60l;
+ Long gbps = 1024l * 1024l * 1024l * 60l;
if (!StringUtil.isEmpty(list)) {
Date beginDate = DateUtils.parseDate(entity.getSearchStartTime());
Date endDate = DateUtils.parseDate(entity.getSearchEndTime());
@@ -1919,14 +1935,14 @@ public class DashboardService extends BaseService { break;
}
c2sList.add(date.getTime());
- c2sList.add(c2sNum/60);
+ c2sList.add(c2sNum / 60);
resultC2sList.add(c2sList);
s2cList.add(date.getTime());
- s2cList.add(s2cNum/60);
+ s2cList.add(s2cNum / 60);
resultS2cList.add(s2cList);
totalList.add(date.getTime());
- totalList.add(totalNum/60);
+ totalList.add(totalNum / 60);
resultTotalList.add(totalList);
// c2sTotal+=c2sNum;
|
