修改nms上报接口支持批量提交,修改为阀门中域添加额外属性时的阀门库编号
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.wordnik.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Title: TrafficNmsServerStatistic</p>
|
||||
* <p>Description: 记录nms服务器信息,全网机器总量,正常在线机器总数,异常机器列表</p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年8月17日
|
||||
*
|
||||
*/
|
||||
@ApiModel(value = "TrafficNmsServerStatistic对象", description = "nms上报的服务器相关信息对象类")
|
||||
public class TrafficNmsServerStatisticList implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<TrafficNmsServerStatistic> trafficNmsServerList;
|
||||
|
||||
public List<TrafficNmsServerStatistic> getTrafficNmsServerList() {
|
||||
return trafficNmsServerList;
|
||||
}
|
||||
|
||||
public void setTrafficNmsServerList(List<TrafficNmsServerStatistic> trafficNmsServerList) {
|
||||
this.trafficNmsServerList = trafficNmsServerList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +1,19 @@
|
||||
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.domain.restful.TrafficNmsServerStatisticList;
|
||||
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;
|
||||
@@ -38,30 +36,28 @@ public class NmsInfoController extends BaseRestController {
|
||||
@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) {
|
||||
public Map<String, Object> saveServerStatus(
|
||||
@RequestBody TrafficNmsServerStatisticList trafficNmsServerStatisticList, 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);
|
||||
trafficNmsServerStatisticList);
|
||||
try {
|
||||
TrafficNmsServerStatistic saveNmsServer = trafficNmsServerStatisticService
|
||||
.saveNmsServer(trafficNmsServerStatistic);
|
||||
try {
|
||||
trafficNmsServerStatisticService.saveAbnormalMachine(saveNmsServer.getId(),
|
||||
saveNmsServer.getAbnormalMachineList());
|
||||
} catch (Exception e) {
|
||||
trafficNmsServerStatisticService.delNmsServer(saveNmsServer);
|
||||
throw e;
|
||||
|
||||
if (trafficNmsServerStatisticList != null && trafficNmsServerStatisticList.getTrafficNmsServerList() != null
|
||||
&& trafficNmsServerStatisticList.getTrafficNmsServerList().size() > 0) {
|
||||
trafficNmsServerStatisticService.saveNmsInfo(trafficNmsServerStatisticList.getTrafficNmsServerList());
|
||||
} else {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "参数trafficNmsServerList不能为空",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
|
||||
} 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);
|
||||
Constants.IS_DEBUG ? trafficNmsServerStatisticList : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
@Service()
|
||||
public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
private static Logger logger = LoggerFactory.getLogger(ConfigJedisServiceimpl.class);
|
||||
private static final int TAPREDISDB = Configurations.getIntProperty("tapRedisDb", 7);
|
||||
private static final int TAPREDISDB = Configurations.getIntProperty("tapRedisDb", 5);
|
||||
// 用于在实时统计配置后面添加时间,方便读取入库时间
|
||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ 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.AbnormalMachine;
|
||||
import com.nis.domain.restful.TrafficNmsServerStatistic;
|
||||
import com.nis.web.dao.TrafficNmsServerStatisticDao;
|
||||
|
||||
@@ -14,16 +14,13 @@ 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);
|
||||
@Transactional
|
||||
public void saveNmsInfo(List<TrafficNmsServerStatistic> trafficNmsServerList) {
|
||||
for (TrafficNmsServerStatistic trafficNmsServerStatistic : trafficNmsServerList) {
|
||||
trafficNmsServerStatisticDao.insert(trafficNmsServerStatistic);
|
||||
trafficNmsServerStatisticDao.insertAbnormalMachine(trafficNmsServerStatistic.getId(),
|
||||
trafficNmsServerStatistic.getAbnormalMachineList());
|
||||
}
|
||||
Integer.parseInt(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user