Commit bf2517d8 authored by chenzhao's avatar chenzhao

广固获取南瑞实时数据接口开发

parent bf0b39b1
package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.service.impl.SyncDataServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@RestController
@Api(tags = "南瑞Api调用")
@RequestMapping(value = "/nrApi", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class NRApiInvocationController {
@Autowired
private SyncDataServiceImpl syncDataService;
@RequestMapping(value = "/getRealTimeData", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "get", value = "获取南瑞实时数据")
public ResponseModel<JSONObject> getRealTimeData() {
try {
return CommonResponseUtil.success( syncDataService.getNrRealTime());
} catch (InterruptedException e) {
e.printStackTrace();
}
return CommonResponseUtil.failure();
}
}
......@@ -60,6 +60,9 @@ public class SyncDataServiceImpl implements ISyncDataService {
@Value("${dcs.url.sendalarm}")
private String sendAlarmUrl;
@Value("${dcs.url.realtime}")
private String realtimeUrl;
@Value("${dcs.x.hw.id}")
private String xHwId;
......@@ -539,4 +542,37 @@ public class SyncDataServiceImpl implements ISyncDataService {
redisUtils.set("equipAndCarIotCodes", JSONObject.toJSONString(equipAndCars));
}
public JSONObject getNrRealTime() throws InterruptedException {
try {
String authorization = dcsUtil.getDcsToken();
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Authorization", authorization);
headerMap.put("token", authorization.split(" ")[1]);
headerMap.put("X-HW-ID", xHwId);
headerMap.put("X-HW-APPKEY", xHwAppKey);
if (StringUtils.isNotBlank(authorization)) {
RequestVo requestVo = new RequestVo();
requestVo.setId(1L);
requestVo.setClientId("serv-x01");
Map<String, Object> bodyMap = new HashMap<>();
bodyMap.put("datatype","analog");
bodyMap.put("keys", Arrays.asList("0000YC000101004B14","0000YC000101004623","0000YC000101004624"));
requestVo.setBody(bodyMap);
logger.info("===============告警存入header:" + JSON.toJSONString(headerMap) + ";\n==================告警存入body: " + JSON.toJSONString(requestVo));
String s = HttpContentTypeUtil.sendHttpPostJsonWithHeader(realtimeUrl, JSON.toJSONString(requestVo), headerMap);
logger.info("===============告警推送联调返回数据:" + JSON.toJSONString(s));
return JSONObject.parseObject(s);
}
} catch (Exception e) {
logger.error("getNrRealTime数据接口请求异常:" + e.getMessage());
}
return null;
}
}
......@@ -84,22 +84,25 @@ isSendApp=false
#告警推送开关,若无推送需求进行关闭(false)
dcs.send.message=false
#请求头参数
dcs.client-id=fire_system
dcs.client.secret=fire_system
dcs.client-id=testxj
dcs.client.secret=testxj
dcs.grant-type=client_credentials
dcs.scope=all
dcs.token-key=dcs_token_key
#华为roma秘钥每个站有区别与集成商索取
dcs.x.hw.id=io.cs
dcs.x.hw.appKey=i!YmnHgJ=Ysz8V+O@ZG237inQKfixkQ.-#-P3IlR8fO%.#F!g%35Z#@tp$6G+52v
dcs.x.hw.id=guanggu__io.cs
dcs.x.hw.appKey=8-BWqQ!q@92I#3yVN9s2442@-rU1P!VY%$.Wm!0p3X-imcV-GVj7%+98!919667v
dcs.url.token=http://10.192.62.114:443/v1/cs/auth-service/oauth/token
# \u7531\u4E8E\u76EE\u524D\u6709\u4E0D\u6B62\u4E00\u4E2A\u6570\u5B57\u7AD9\u5E73\u53F0\u5BF9\u5E94\u63A5\u53E3\u89C4\u8303\u4E0D\u4E00\u81F4\uFF0C\u6240\u4EE5\u6B64\u5904\u589E\u52A0\u914D\u7F6E\uFF0Ctrue\u8868\u793A\u9002\u7528\u4E8E\u5357\u745E\u79D1\u6280\u7684\u63A5\u53E3\u89C4\u8303
#平台集成商是否科技接口,(科技为true、继保和许继为false)
dcs.NRKJ.use=false
dcs.source.type=\u9ad8\u7ea7\u5e94\u7528
#数字化平台3.0权限接口
dcs.url.token=http://172.21.101.123/udaap-ddis/v1/cs/auth-service/oauth/token
#数字化平台3.0告警存储接口
dcs.url.sendalarm=http://172.21.101.101/v1/cs/alarm-service/appalarm/sendalarm
#南瑞实时查询数据接口调用
dcs.url.realtime=http://172.21.101.101/v1/cs/realdata-service/data/realtime
#################################################################################
#\u7CFB\u7EDF\u4E0A\u7EBF\u65F6\u95F4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment