1:添加串联设备端口异常报警接口

This commit is contained in:
renkaige
2019-02-15 15:12:01 +08:00
parent 368b0c73c6
commit 598d0b3e3a
6 changed files with 166 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.NmsDiRuleList;
import com.nis.domain.restful.TrafficNetflowPortInfoList;
import com.nis.domain.restful.TrafficNmsServerStatisticList;
import com.nis.domain.restful.TrafficSeriesDevicePortInfoList;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.restful.ServiceRuntimeException;
@@ -25,6 +26,7 @@ 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.nis.web.service.restful.TrafficSeriesDevicePortInfoService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
@@ -41,6 +43,8 @@ public class NmsInfoController extends BaseRestController {
NmsDiRuleService nmsDiRuleService;
@Autowired
TrafficNetflowPortInfoService trafficNetflowPortInfoService;
@Autowired
TrafficSeriesDevicePortInfoService trafficSeriesDevicePortInfoService;
@RequestMapping(value = "/nms/v1/saveServerStatus", method = RequestMethod.POST)
@ApiOperation(value = "存储NMS系统上报的服务器状态接口", httpMethod = "POST", response = Map.class, notes = "接收NMS系统上报的服务器状态信息")
@@ -119,7 +123,7 @@ public class NmsInfoController extends BaseRestController {
try {
if (trafficNetflowPortInfoList != null && trafficNetflowPortInfoList.getTrafficNetflowPortInfoList() != null
&& trafficNetflowPortInfoList.getTrafficNetflowPortInfoList().size() > 0) {
thread.setContent("NMS系统上报上报trafficNetflowPort信息数量为"+trafficNetflowPortInfoList.getTrafficNetflowPortInfoList().size());
thread.setContent("NMS系统上报trafficNetflowPort信息数量为"+trafficNetflowPortInfoList.getTrafficNetflowPortInfoList().size());
trafficNetflowPortInfoService
.saveTrafficNetflowPortInfo(trafficNetflowPortInfoList.getTrafficNetflowPortInfoList());
} else {
@@ -137,5 +141,36 @@ public class NmsInfoController extends BaseRestController {
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"上报trafficNetflowPort信息成功", Constants.IS_DEBUG ? trafficNetflowPortInfoList : null);
}
@RequestMapping(value = "/nms/v1/trafficSeriesDevicePortInfo", method = RequestMethod.POST)
@ApiOperation(value = "存储串联设备端口告警信息接口", httpMethod = "POST", response = Map.class, notes = "接收NMS系统上报的串联设备端口告警信息")
@ApiParam(value = "存储串联设备端口告警信息接口", name = "saveTrafficSeriesDevicePortInfo", required = true)
public Map<String, Object> saveTrafficSeriesDevicePortInfo(
@RequestBody TrafficSeriesDevicePortInfoList trafficSeriesDevicePortInfoList, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
trafficSeriesDevicePortInfoList);
try {
if (trafficSeriesDevicePortInfoList != null && trafficSeriesDevicePortInfoList.getTrafficSeriesDevicePortInfoList() != null
&& trafficSeriesDevicePortInfoList.getTrafficSeriesDevicePortInfoList().size() > 0) {
thread.setContent("NMS系统上报串联设备端口告警信息数量为"+trafficSeriesDevicePortInfoList.getTrafficSeriesDevicePortInfoList().size());
trafficSeriesDevicePortInfoService
.saveTrafficSeriesDevicePortInfo(trafficSeriesDevicePortInfoList.getTrafficSeriesDevicePortInfoList());
} else {
throw new RestServiceException("参数trafficSeriesDevicePortInfoList不能为空", RestBusinessCode.missing_args.getValue());
}
} catch (Exception e) {
if (e instanceof RestServiceException) {
throw (RestServiceException) e;
} else {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"上报串联设备端口告警信息异常:" + e.getMessage(), RestBusinessCode.unknow_error.getValue());
}
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"上报串联设备端口告警信息成功", Constants.IS_DEBUG ? trafficSeriesDevicePortInfoList : null);
}
}

View File

@@ -0,0 +1,7 @@
package com.nis.web.dao;
import com.nis.domain.restful.TrafficSeriesDevicePortInfo;
@MyBatisDao
public interface TrafficSeriesDevicePortInfoDao extends CrudDao<TrafficSeriesDevicePortInfo> {
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace="com.nis.web.dao.TrafficSeriesDevicePortInfoDao">
<insert id="insert" parameterType="trafficSeriesDevicePortInfo">
INSERT INTO
traffic_seriesdevice_port_info(
commit_time,
area,port,status
) VALUES (
#{commitTime},
#{area},
#{port},
#{status})
</insert>
</mapper>

View File

@@ -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.TrafficSeriesDevicePortInfo;
import com.nis.web.dao.TrafficSeriesDevicePortInfoDao;
@Service
public class TrafficSeriesDevicePortInfoService {
@Autowired
TrafficSeriesDevicePortInfoDao trafficSeriesDevicePortInfoDao;
@Transactional
public void saveTrafficSeriesDevicePortInfo(List<TrafficSeriesDevicePortInfo> trafficSeriesDevicePortInfoList) {
for (TrafficSeriesDevicePortInfo trafficSeriesDevicePortInfo : trafficSeriesDevicePortInfoList) {
trafficSeriesDevicePortInfoDao.insert(trafficSeriesDevicePortInfo);
}
}
}