1:添加nms上报服务器信息的接口
2:修改读取app*-rule.properties的方法
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.nis.web.controller.restful;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.nis.domain.restful.TrafficNmsServerStatistic;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestConstants;
|
||||
import com.nis.restful.RestServiceException;
|
||||
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.TrafficNmsServerStatisticService;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
import com.wordnik.swagger.annotations.ApiParam;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${servicePath}")
|
||||
@Api(value = "NmsInfoController", description = "接收nms提交的系统状态等数据,将数据入库供服务推送给大屏")
|
||||
public class NmsInfoController extends BaseRestController {
|
||||
@Autowired
|
||||
protected ServicesRequestLogService servicesRequestLogService;
|
||||
@Autowired
|
||||
TrafficNmsServerStatisticService trafficNmsServerStatisticService;
|
||||
|
||||
@RequestMapping(value = "/nms/v1/saveServerStatus", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "存储NMS系统上报的服务器状态接口", httpMethod = "POST", response = Map.class, notes = "接收NMS系统上报的服务器状态信息")
|
||||
@ApiParam(value = "存储NMS系统上报的服务器状态接口", name = "saveServerStatus", required = true)
|
||||
public Map<String, Object> saveServerStatus(@RequestBody TrafficNmsServerStatistic trafficNmsServerStatistic,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
trafficNmsServerStatistic);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(RestConstants.REST_SERVICE_HTTP_STATUS, HttpStatus.OK);
|
||||
try {
|
||||
TrafficNmsServerStatistic saveNmsServer = trafficNmsServerStatisticService
|
||||
.saveNmsServer(trafficNmsServerStatistic);
|
||||
try {
|
||||
trafficNmsServerStatisticService.saveAbnormalMachine(saveNmsServer.getId(),
|
||||
saveNmsServer.getAbnormalMachineList());
|
||||
} catch (Exception e) {
|
||||
trafficNmsServerStatisticService.delNmsServer(saveNmsServer);
|
||||
throw e;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "上报服务器状态信息异常:" + e.getMessage(),
|
||||
RestBusinessCode.unknow_error.getValue());
|
||||
}
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "上报服务器状态信息成功",
|
||||
Constants.IS_DEBUG ? trafficNmsServerStatistic : null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.nis.web.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.restful.AbnormalMachine;
|
||||
import com.nis.domain.restful.TrafficNmsServerStatistic;
|
||||
|
||||
@MyBatisDao
|
||||
public interface TrafficNmsServerStatisticDao extends CrudDao<TrafficNmsServerStatistic> {
|
||||
|
||||
public void insertAbnormalMachine(@Param("nmsServerId") Integer nmsServerId,@Param("list") List<AbnormalMachine> abnormalMachineList);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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.TrafficNmsServerStatisticDao">
|
||||
|
||||
|
||||
|
||||
<insert id="insert" parameterType="trafficNmsServerStatistic"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO
|
||||
traffic_nmsserver_statistic(
|
||||
commit_time ,
|
||||
area ,
|
||||
total ,
|
||||
normal ,
|
||||
abnormal
|
||||
) VALUES (
|
||||
#{commitTime},
|
||||
#{area},
|
||||
#{total},
|
||||
#{normal},
|
||||
#{abnormal}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="delete" parameterType="trafficNmsServerStatistic"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
delete from
|
||||
traffic_nmsserver_statistic
|
||||
where id=#{id}
|
||||
</insert>
|
||||
|
||||
|
||||
<insert id="insertAbnormalMachine" parameterType="trafficNmsServerStatistic">
|
||||
INSERT INTO traffic_abnormal_machine(
|
||||
nmsserver_id ,
|
||||
hostName ,
|
||||
ip
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{nmsServerId},
|
||||
#{item.hostName},
|
||||
#{item.ip}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.AbnormalMachine;
|
||||
import com.nis.domain.restful.TrafficNmsServerStatistic;
|
||||
import com.nis.web.dao.TrafficNmsServerStatisticDao;
|
||||
|
||||
@Service
|
||||
public class TrafficNmsServerStatisticService {
|
||||
@Autowired
|
||||
TrafficNmsServerStatisticDao trafficNmsServerStatisticDao;
|
||||
|
||||
public TrafficNmsServerStatistic saveNmsServer(TrafficNmsServerStatistic trafficNmsServerStatistic) {
|
||||
trafficNmsServerStatisticDao.insert(trafficNmsServerStatistic);
|
||||
return trafficNmsServerStatistic;
|
||||
}
|
||||
|
||||
public void saveAbnormalMachine(Integer id, List<AbnormalMachine> abnormalMachineList) {
|
||||
trafficNmsServerStatisticDao.insertAbnormalMachine(id, abnormalMachineList);
|
||||
}
|
||||
|
||||
public void delNmsServer(TrafficNmsServerStatistic trafficNmsServerStatistic) {
|
||||
trafficNmsServerStatisticDao.delete(trafficNmsServerStatistic);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user