|
@@ -1,12 +1,5 @@
|
|
|
package com.nokia.alarm.service;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.hl.opnc.AbilityResponse;
|
|
|
import com.hl.opnc.ResponseBody;
|
|
@@ -17,8 +10,13 @@ import com.nokia.alarm.entity.ResultInfo;
|
|
|
import com.nokia.alarm.entity.ResultMap;
|
|
|
import com.nokia.alarm.util.ExportUtil;
|
|
|
import com.nokia.alarm.util.SDKUtil;
|
|
|
-
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -36,11 +34,26 @@ public class AlarmSaveToFileService {
|
|
|
MessageCfg cfg = SDKUtil.getBody(date);
|
|
|
AbilityResponse response = manager.post(methodUrl, null, JSON.toJSONString(cfg));
|
|
|
try {
|
|
|
- ResponseBody resObj = response.getRespObj();
|
|
|
+ String responseStr = response.getRespStr();
|
|
|
+ ResponseBody resObj;
|
|
|
+ try {
|
|
|
+ resObj = JSON.parseObject(responseStr, ResponseBody.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("返回消息json解析错误: {}", responseStr);
|
|
|
+ e.printStackTrace();
|
|
|
+ return;
|
|
|
+ }
|
|
|
String body = (String) resObj.getUNI_NET_BODY();
|
|
|
- log.info(body);
|
|
|
+// log.info(body);
|
|
|
// body = body.replace("null", "\"\"");
|
|
|
- ResultInfo info = JSON.parseObject(body, ResultInfo.class);
|
|
|
+ ResultInfo info;
|
|
|
+ try {
|
|
|
+ info = JSON.parseObject(body, ResultInfo.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("返回消息json解析错误: {}", responseStr);
|
|
|
+ e.printStackTrace();
|
|
|
+ return;
|
|
|
+ }
|
|
|
int rows = info.getTotal();
|
|
|
log.info("新增告警返回数据{}条", rows);
|
|
|
List<ResultMap> results = info.getResult();
|
|
@@ -57,7 +70,7 @@ public class AlarmSaveToFileService {
|
|
|
log.error("新增告警gpload失败: {}", e.getMessage());
|
|
|
}
|
|
|
log.info("查询新增告警完成=====================================================");
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
log.info("查询新增告警出错=====================================================");
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
@@ -76,10 +89,25 @@ public class AlarmSaveToFileService {
|
|
|
MessageCfg cfg = SDKUtil.gethistoryBody(date);
|
|
|
AbilityResponse response = manager.post(methodUrl, null, JSON.toJSONString(cfg));
|
|
|
try {
|
|
|
- ResponseBody resObj = response.getRespObj();
|
|
|
+ String responseStr = response.getRespStr();
|
|
|
+ ResponseBody resObj;
|
|
|
+ try {
|
|
|
+ resObj = JSON.parseObject(responseStr, ResponseBody.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("返回消息json解析错误: {}", responseStr);
|
|
|
+ e.printStackTrace();
|
|
|
+ return;
|
|
|
+ }
|
|
|
String body = (String) resObj.getUNI_NET_BODY();
|
|
|
// body = body.replace("null", "\"\"");
|
|
|
- ResultInfo info = JSON.parseObject(body, ResultInfo.class);
|
|
|
+ ResultInfo info;
|
|
|
+ try {
|
|
|
+ info = JSON.parseObject(body, ResultInfo.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("返回消息json解析错误: {}", responseStr);
|
|
|
+ e.printStackTrace();
|
|
|
+ return;
|
|
|
+ }
|
|
|
int rows = info.getTotal();
|
|
|
log.info("消除告警返回数据{}条", rows);
|
|
|
List<ResultMap> results = info.getResult();
|
|
@@ -96,7 +124,7 @@ public class AlarmSaveToFileService {
|
|
|
log.error("消除告警gpload失败: {}", e.getMessage());
|
|
|
}
|
|
|
log.info("查询消除告警完成=====================================================");
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
log.info("查询消除告警出错=====================================================");
|
|
|
e.printStackTrace();
|
|
|
}
|