From c6576215a60e443d2875c0815dfcae1cbe23074c Mon Sep 17 00:00:00 2001 From: renkaige Date: Tue, 9 Oct 2018 14:12:07 +0800 Subject: [PATCH] =?UTF-8?q?1:=E5=AE=8C=E6=88=90nms=E5=8F=A6=E5=A4=96?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E6=8E=A5=E5=8F=A3=202:=E4=BF=AE=E6=94=B9swag?= =?UTF-8?q?ger=E4=B8=ADindex.html=E9=A1=B5=E9=9D=A2=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AF=86=E5=88=ABurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/restful/NmsInfoController.java | 22 +++- .../java/com/nis/web/dao/NmsDiRuleDao.java | 7 + .../java/com/nis/web/dao/NmsDiRuleDao.xml | 44 +++++++ .../web/dao/TrafficNetflowPortInfoDao.java | 7 + .../nis/web/dao/TrafficNetflowPortInfoDao.xml | 32 +++++ .../web/service/restful/NmsDiRuleService.java | 23 ++++ .../TrafficNetflowPortInfoService.java | 23 ++++ .../TrafficNmsServerStatisticService.java | 1 - src/main/webapp/swagger/index.html | 121 ++++++++++-------- 9 files changed, 227 insertions(+), 53 deletions(-) create mode 100644 src/main/java/com/nis/web/dao/NmsDiRuleDao.java create mode 100644 src/main/java/com/nis/web/dao/NmsDiRuleDao.xml create mode 100644 src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.java create mode 100644 src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.xml create mode 100644 src/main/java/com/nis/web/service/restful/NmsDiRuleService.java create mode 100644 src/main/java/com/nis/web/service/restful/TrafficNetflowPortInfoService.java diff --git a/src/main/java/com/nis/web/controller/restful/NmsInfoController.java b/src/main/java/com/nis/web/controller/restful/NmsInfoController.java index 8a7cc7c..702931d 100644 --- a/src/main/java/com/nis/web/controller/restful/NmsInfoController.java +++ b/src/main/java/com/nis/web/controller/restful/NmsInfoController.java @@ -20,6 +20,8 @@ import com.nis.util.Constants; import com.nis.web.controller.BaseRestController; import com.nis.web.service.AuditLogThread; import com.nis.web.service.ServicesRequestLogService; +import com.nis.web.service.restful.NmsDiRuleService; +import com.nis.web.service.restful.TrafficNetflowPortInfoService; import com.nis.web.service.restful.TrafficNmsServerStatisticService; import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiOperation; @@ -33,6 +35,10 @@ public class NmsInfoController extends BaseRestController { protected ServicesRequestLogService servicesRequestLogService; @Autowired TrafficNmsServerStatisticService trafficNmsServerStatisticService; + @Autowired + NmsDiRuleService nmsDiRuleService; + @Autowired + TrafficNetflowPortInfoService trafficNetflowPortInfoService; @RequestMapping(value = "/nms/v1/saveServerStatus", method = RequestMethod.POST) @ApiOperation(value = "存储NMS系统上报的服务器状态接口", httpMethod = "POST", response = Map.class, notes = "接收NMS系统上报的服务器状态信息") @@ -70,7 +76,13 @@ public class NmsInfoController extends BaseRestController { AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, nmsDiRuleList); try { - + if (nmsDiRuleList != null && nmsDiRuleList.getNmsDiRuleList() != null + && nmsDiRuleList.getNmsDiRuleList().size() > 0) { + nmsDiRuleService.saveNmsDiRuleInfo(nmsDiRuleList.getNmsDiRuleList()); + } else { + throw new RestServiceException(thread, System.currentTimeMillis() - start, "参数nmsDiRuleList不能为空", + RestBusinessCode.missing_args.getValue()); + } } catch (Exception e) { throw new RestServiceException(thread, System.currentTimeMillis() - start, "上报NmsDiRule信息异常:" + e.getMessage(), RestBusinessCode.unknow_error.getValue()); @@ -89,6 +101,14 @@ public class NmsInfoController extends BaseRestController { AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, trafficNetflowPortInfoList); try { + if (trafficNetflowPortInfoList != null && trafficNetflowPortInfoList.getTrafficNetflowPortInfoList() != null + && trafficNetflowPortInfoList.getTrafficNetflowPortInfoList().size() > 0) { + trafficNetflowPortInfoService + .saveTrafficNetflowPortInfo(trafficNetflowPortInfoList.getTrafficNetflowPortInfoList()); + } else { + throw new RestServiceException(thread, System.currentTimeMillis() - start, + "参数trafficNetflowPortInfoList不能为空", RestBusinessCode.missing_args.getValue()); + } } catch (Exception e) { throw new RestServiceException(thread, System.currentTimeMillis() - start, diff --git a/src/main/java/com/nis/web/dao/NmsDiRuleDao.java b/src/main/java/com/nis/web/dao/NmsDiRuleDao.java new file mode 100644 index 0000000..a63d4dc --- /dev/null +++ b/src/main/java/com/nis/web/dao/NmsDiRuleDao.java @@ -0,0 +1,7 @@ +package com.nis.web.dao; + +import com.nis.domain.restful.NmsDiRule; + +@MyBatisDao +public interface NmsDiRuleDao extends CrudDao { +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/NmsDiRuleDao.xml b/src/main/java/com/nis/web/dao/NmsDiRuleDao.xml new file mode 100644 index 0000000..ad4e1c8 --- /dev/null +++ b/src/main/java/com/nis/web/dao/NmsDiRuleDao.xml @@ -0,0 +1,44 @@ + + + + + INSERT INTO + nms_di_rule(detection_info_id , + serviceindex , + servicecode , + servicedesc, + agedtime , + clientnum , + refluxport , + rulenumber , + usedrulenum , + leftrulenum , + hittotalnum , + detectioned_state , + seq_id , + detection_set_info_id , + data_check_time , + data_arrive_time , + data_check_time_digital , + data_arrive_time_digital + ) VALUES ( + #{detectionInfoId}, + #{serviceIndex}, + #{serviceCode}, + #{serviceDesc}, + #{agedTime}, + #{clientNum}, + #{refluxPort}, + #{ruleNumber}, + #{usedRuleNum}, + #{leftRuleNum}, + #{hitTotalNum}, + #{detectionedState}, + #{seqId}, + #{detectionSetInfoId}, + #{dataCheckTime}, + #{dataArriveTime}, + #{dataCheckTimeDigital}, + #{dataArriveTimeDigital}) + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.java b/src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.java new file mode 100644 index 0000000..e32286c --- /dev/null +++ b/src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.java @@ -0,0 +1,7 @@ +package com.nis.web.dao; + +import com.nis.domain.restful.TrafficNetflowPortInfo; + +@MyBatisDao +public interface TrafficNetflowPortInfoDao extends CrudDao { +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.xml b/src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.xml new file mode 100644 index 0000000..362b2e9 --- /dev/null +++ b/src/main/java/com/nis/web/dao/TrafficNetflowPortInfoDao.xml @@ -0,0 +1,32 @@ + + + + + INSERT INTO + traffic_netflow_port_info(PORT , + NODE_NAME , + NODE_IP , + PORT_DESC, + BANDWIDTH , + INOCTETS , + OUTOCTETS , + INOCTETS_SPEED , + OUTOCTETS_SPEED , + INPKTS_SPEED , + OUTPKTS_SPEED , + RECV_TIME + ) VALUES ( + #{port}, + #{nodeName}, + #{nodeIp}, + #{portDesc}, + #{bandwidth}, + #{inoctets}, + #{outoctets}, + #{inoctetsSpeed}, + #{outoctetsSpeed}, + #{inpktsSpeed}, + #{outpktsSpeed}, + #{recvTime}) + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/restful/NmsDiRuleService.java b/src/main/java/com/nis/web/service/restful/NmsDiRuleService.java new file mode 100644 index 0000000..8288812 --- /dev/null +++ b/src/main/java/com/nis/web/service/restful/NmsDiRuleService.java @@ -0,0 +1,23 @@ +package com.nis.web.service.restful; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.nis.domain.restful.NmsDiRule; +import com.nis.web.dao.NmsDiRuleDao; + +@Service +public class NmsDiRuleService { + @Autowired + NmsDiRuleDao nmsDiRuleDao; + + @Transactional + public void saveNmsDiRuleInfo(List nmsDiRuleList) { + for (NmsDiRule nmsDiRule : nmsDiRuleList) { + nmsDiRuleDao.insert(nmsDiRule); + } + } +} diff --git a/src/main/java/com/nis/web/service/restful/TrafficNetflowPortInfoService.java b/src/main/java/com/nis/web/service/restful/TrafficNetflowPortInfoService.java new file mode 100644 index 0000000..62cf482 --- /dev/null +++ b/src/main/java/com/nis/web/service/restful/TrafficNetflowPortInfoService.java @@ -0,0 +1,23 @@ +package com.nis.web.service.restful; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.nis.domain.restful.TrafficNetflowPortInfo; +import com.nis.web.dao.TrafficNetflowPortInfoDao; + +@Service +public class TrafficNetflowPortInfoService { + @Autowired + TrafficNetflowPortInfoDao trafficNetflowPortInfoDao; + + @Transactional + public void saveTrafficNetflowPortInfo(List trafficNetflowPortInfoList) { + for (TrafficNetflowPortInfo trafficNetflowPortInfo : trafficNetflowPortInfoList) { + trafficNetflowPortInfoDao.insert(trafficNetflowPortInfo); + } + } +} diff --git a/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java b/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java index 93ca9b8..0cee95e 100644 --- a/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java +++ b/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java @@ -21,6 +21,5 @@ public class TrafficNmsServerStatisticService { trafficNmsServerStatisticDao.insertAbnormalMachine(trafficNmsServerStatistic.getId(), trafficNmsServerStatistic.getAbnormalMachineList()); } - Integer.parseInt(null); } } diff --git a/src/main/webapp/swagger/index.html b/src/main/webapp/swagger/index.html index e45f1e4..344fdf0 100644 --- a/src/main/webapp/swagger/index.html +++ b/src/main/webapp/swagger/index.html @@ -1,49 +1,61 @@ - - - Galaxy UI - - - - - - - + + +Galaxy UI + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + -