更改
This commit is contained in:
30
pom.xml
30
pom.xml
@@ -55,12 +55,11 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>mqs-client-njcn</artifactId>
|
||||
@@ -125,6 +124,26 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 引入org.json所需依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -135,13 +154,6 @@
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
|
||||
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
@@ -32,13 +32,14 @@ public class ClientHandler extends Thread {
|
||||
|
||||
public String topicMsg = "{\"HRPhV_H14_phsC\":\"0.0000\",\"HRPhV_H14_phsB\":\"0.0000\",\"HRPhV_H14_phsA\":\"0.0000\",\"HRPhV_H2_phsB\":\"0.0100\",\"HRPhV_H2_phsA\":\"0.0100\",\"HRPhV_H2_phsC\":\"0.0100\",\"HRPhV_H15_phsA\":\"0.0120\",\"TotW\":\"19771.1367\",\"HRPhV_H15_phsB\":\"0.0120\",\"HRPhV_H15_phsC\":\"0.0120\",\"FreqDev\":\"0.0000\",\"PPV_phsAB\":\"384.0318\",\"A_phsC\":\"60.7116\",\"TotPF\":\"0.4946\",\"A_phsA\":\"60.7123\",\"A_phsB\":\"60.7111\",\"PPV_phsBC\":\"383.3656\",\"HRPhV_H25_phsB\":\"0.0080\",\"HRPhV_H25_phsC\":\"0.0080\",\"HRPhV_H25_phsA\":\"0.0080\",\"DataTag\":\"0\",\"HRPhV_H20_phsA\":\"0.0000\",\"HRPhV_H20_phsB\":\"0.0000\",\"HRPhV_H20_phsC\":\"0.0000\",\"PPV_phsCA\":\"383.3637\",\"HRPhV_H3_phsB\":\"0.0640\",\"HRPhV_H3_phsC\":\"0.0640\",\"HRPhV_H9_phsC\":\"0.0220\",\"ThdPhV_phsA\":\"0.0913\",\"HRPhV_H9_phsB\":\"0.0220\",\"HRPhV_H9_phsA\":\"0.0220\",\"ThdPhV_phsB\":\"0.0913\",\"ThdPhV_phsC\":\"0.0913\",\"HRPhV_H19_phsC\":\"0.0100\",\"HRPhV_H19_phsB\":\"0.0100\",\"HRPhV_H19_phsA\":\"0.0100\",\"HRPhV_H16_phsA\":\"0.0000\",\"HRPhV_H13_phsA\":\"0.0140\",\"HRPhV_H16_phsC\":\"0.0000\",\"HRPhV_H13_phsB\":\"0.0140\",\"HRPhV_H16_phsB\":\"0.0000\",\"TotVA\":\"39977.2305\",\"HRPhV_H13_phsC\":\"0.0140\",\"HRPhV_H6_phsB\":\"0.0026\",\"HRPhV_H3_phsA\":\"0.0640\",\"HRPhV_H6_phsA\":\"0.0026\",\"HRPhV_H10_phsA\":\"0.0026\",\"HRPhV_H10_phsB\":\"0.0026\",\"HRPhV_H6_phsC\":\"0.0026\",\"HRPhV_H10_phsC\":\"0.0026\",\"ImbNgV\":\"0.0012\",\"TotVar\":\"34745.9492\",\"HRPhV_H7_phsC\":\"0.0280\",\"HRPhV_H7_phsB\":\"0.0280\",\"HRPhV_H22_phsC\":\"0.0000\",\"HRPhV_H22_phsB\":\"0.0000\",\"ImbZroV\":\"0.0012\",\"HRPhV_H22_phsA\":\"0.0000\",\"HRPhV_H7_phsA\":\"0.0280\",\"HRPhV_H8_phsA\":\"0.0026\",\"HRPhV_H23_phsB\":\"0.0080\",\"PhV_phsA\":\"221.9935\",\"HRPhV_H8_phsB\":\"0.0026\",\"HRPhV_H23_phsC\":\"0.0080\",\"HRPhV_H8_phsC\":\"0.0026\",\"PhV_phsB\":\"221.9947\",\"PhV_phsC\":\"221.9979\",\"HRPhV_H23_phsA\":\"0.0080\",\"PstPhV_phsC\":\"3.2942\",\"PstPhV_phsA\":\"3.3086\",\"PstPhV_phsB\":\"3.2987\",\"Freq\":\"50.0000\",\"HRPhV_H11_phsA\":\"0.0180\",\"HRPhV_H11_phsB\":\"0.0180\",\"HRPhV_H17_phsC\":\"0.0100\",\"HRPhV_H11_phsC\":\"0.0180\",\"HRPhV_H17_phsB\":\"0.0100\",\"HRPhV_H17_phsA\":\"0.0100\",\"SeqV_C2\":\"0.0715\",\"HRPhV_H4_phsB\":\"0.0050\",\"SeqV_C1\":\"60.4601\",\"HRPhV_H4_phsA\":\"0.0050\",\"SeqV_C0\":\"0.0714\",\"PhVDev_phsC\":\"0.0119\",\"HRPhV_H5_phsA\":\"0.0400\",\"HRPhV_H5_phsB\":\"0.0400\",\"HRPhV_H5_phsC\":\"0.0400\",\"PhVDev_phsB\":\"0.0119\",\"HRPhV_H12_phsC\":\"0.0010\",\"PltPhV_phsA\":\"0.0000\",\"PhVDev_phsA\":\"0.0119\",\"HRPhV_H12_phsB\":\"0.0010\",\"HRPhV_H4_phsC\":\"0.0050\",\"HRPhV_H18_phsB\":\"0.0000\",\"HRPhV_H18_phsC\":\"0.0000\",\"HRPhV_H12_phsA\":\"0.0010\",\"HRPhV_H18_phsA\":\"0.0000\",\"HFundPhV_phsC\":\"220.8052\",\"HRPhV_H21_phsC\":\"0.0080\",\"HRPhV_H21_phsB\":\"0.0080\",\"HRPhV_H24_phsC\":\"0.0000\",\"HFundPhV_phsA\":\"220.8056\",\"HRPhV_H21_phsA\":\"0.0080\",\"HFundPhV_phsB\":\"220.8055\",\"HRPhV_H24_phsB\":\"0.0000\",\"PltPhV_phsC\":\"0.0000\",\"HRPhV_H24_phsA\":\"0.0000\",\"PltPhV_phsB\":\"0.0000\",\"time\":\"20240704T152745Z\"}";
|
||||
|
||||
public String devId;
|
||||
public String devId="暂无数据";
|
||||
|
||||
private Consumer consumer;
|
||||
|
||||
@GetMapping("message")
|
||||
private Map<String,String> message() {
|
||||
Map<String,String> map = JSONObject.parseObject(topicMsg, Map.class);
|
||||
map.put("customDevId",devId);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
123
src/main/java/com/njcn/roma/client/TestNorthApi.java
Normal file
123
src/main/java/com/njcn/roma/client/TestNorthApi.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package com.njcn.roma.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.TrustStrategy;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.ssl.SSLContextBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class TestNorthApi {
|
||||
|
||||
private static final String ApicHost = "10.10.10.1:1443";
|
||||
private static final String appId = "roma.link.test";
|
||||
private static final String appKey = "ic+HsXPRCA****";
|
||||
|
||||
private static final String deviceId="D6111KOQk";
|
||||
|
||||
|
||||
//测命令下发时用到的,替换成自己的serviceName和commandName
|
||||
private static final String serviceName="service";
|
||||
private static final String commandName="command";
|
||||
|
||||
|
||||
/**
|
||||
* 创建ssl连接,设置客户端信任所有证书
|
||||
* @return CloseableHttpClient
|
||||
* @throws KeyStoreException
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
private static CloseableHttpClient createSSLClient() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (chain, authType) -> true).build();
|
||||
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new String[]{"TLSv1.2"}, null,
|
||||
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求时的header
|
||||
* @param httpUriRequest
|
||||
*/
|
||||
private static void setSSLHeader(HttpUriRequest httpUriRequest) {
|
||||
long time = System.currentTimeMillis();
|
||||
String authorization = DigestUtils.sha256Hex(appId + appKey + time);
|
||||
httpUriRequest.addHeader("Content-Type", "application/json");
|
||||
httpUriRequest.addHeader("Authorization", authorization);
|
||||
httpUriRequest.addHeader("timestamp", String.valueOf(time));
|
||||
}
|
||||
/**
|
||||
* 解析响应结果
|
||||
* @param httpUriRequest
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyStoreException
|
||||
* @throws KeyManagementException
|
||||
* @throws IOException
|
||||
*/
|
||||
private static HttpEntity getSSLResponse(HttpUriRequest httpUriRequest) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {
|
||||
CloseableHttpClient httpClient = createSSLClient();
|
||||
CloseableHttpResponse response = httpClient.execute(httpUriRequest);
|
||||
HttpEntity responseEntity = response.getEntity();
|
||||
System.out.println("响应状态为:" + response.getStatusLine());
|
||||
if (responseEntity != null) {
|
||||
System.out.println("响应内容长度为:" + responseEntity.getContentLength());
|
||||
System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
|
||||
}
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令下发
|
||||
*
|
||||
* @param serviceName
|
||||
* @param commandName
|
||||
* @param cmdComtent
|
||||
* @throws JSONException
|
||||
* @throws IOException
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyStoreException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static void deviceCommands(String serviceName, String commandName, JSONObject cmdComtent) throws JSONException, IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
String url = "https://" + ApicHost + "/iot/1.0/deviceCommands?appId=" + appId;
|
||||
HttpPost httpPost = new HttpPost(url); //创建post请求
|
||||
|
||||
JSONObject cmdContent = new JSONObject();
|
||||
cmdContent.put("serviceId", serviceName);
|
||||
cmdContent.put("method", commandName);
|
||||
cmdContent.put("paras", cmdComtent);
|
||||
JSONObject cmdBody = new JSONObject();
|
||||
cmdBody.put("command", cmdContent);
|
||||
cmdBody.put("deviceId", deviceId);
|
||||
|
||||
setSSLHeader(httpPost); //设置请求的header
|
||||
StringEntity stringEntity = new StringEntity(cmdBody.toString(), "utf-8");
|
||||
httpPost.setEntity(stringEntity);//设置请求的body
|
||||
getSSLResponse(httpPost);//获取响应结果
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
JSONObject commandContent = new JSONObject();
|
||||
commandContent.put("status", "on");
|
||||
deviceCommands(serviceName, commandName, commandContent);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,4 +35,8 @@ public class RestTemplateConfig {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
package com.njcn.roma.controller;
|
||||
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.roma.pojo.CommandDTO;
|
||||
import com.njcn.roma.pojo.UpSendPojo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.TrustStrategy;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.ssl.SSLContextBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -12,9 +24,18 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.IOException;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -49,39 +70,33 @@ public class SendCommandController {
|
||||
* @date 2024/6/25
|
||||
*/
|
||||
@GetMapping("up")
|
||||
public String sendToDev(){
|
||||
String time = String.valueOf(new Date().getTime());
|
||||
String sha = DigestUtil.sha256Hex(appId+appKey+time);
|
||||
System.out.println("加密秘钥"+sha);
|
||||
|
||||
// 请求头信息
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.valueOf("application/json;charset=UTF-8"));
|
||||
headers.add("timestamp",time);
|
||||
headers.add("Authorization",sha);
|
||||
|
||||
// 请求体内容
|
||||
UpSendPojo param = new UpSendPojo();
|
||||
param.setDeviceId("666666");
|
||||
|
||||
CommandDTO commandDTO = new CommandDTO();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("","");
|
||||
commandDTO.setJsonObject(jsonObject);
|
||||
commandDTO.setServiceId("123");
|
||||
commandDTO.setMethod("aaa");
|
||||
param.setCommandDTO(commandDTO);
|
||||
|
||||
// 组装请求信息
|
||||
HttpEntity<UpSendPojo> httpEntity=new HttpEntity<>(param,headers);
|
||||
|
||||
System.out.println(httpEntity.getHeaders());
|
||||
System.out.println(httpEntity.getBody());
|
||||
|
||||
|
||||
ResponseEntity responseEntity = restTemplate.postForEntity(sendIp,httpEntity,String.class);
|
||||
System.out.println("返回状态:"+ responseEntity.getStatusCode());
|
||||
return Objects.requireNonNull(responseEntity.getBody()).toString();
|
||||
public String sendToDev(@RequestParam("serviceId")String serviceId,@RequestParam("method")String method,@RequestParam(value = "deviceId",defaultValue = "D2899233167kupZT")String deviceId){
|
||||
org.json.JSONObject commandContent = new JSONObject();
|
||||
commandContent.put("status", "on");
|
||||
try {
|
||||
deviceCommands(deviceId,serviceId,method,commandContent);
|
||||
} catch (IOException e) {
|
||||
System.out.println("IOException---------------------------");
|
||||
e.printStackTrace();
|
||||
return "执行异常";
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
System.out.println("NoSuchAlgorithmException---------------------------");
|
||||
e.printStackTrace();
|
||||
return "执行异常";
|
||||
} catch (KeyStoreException e) {
|
||||
System.out.println("KeyStoreException---------------------------");
|
||||
e.printStackTrace();
|
||||
return "执行异常";
|
||||
} catch (KeyManagementException e) {
|
||||
System.out.println("KeyManagementException---------------------------");
|
||||
e.printStackTrace();
|
||||
return "执行异常";
|
||||
}catch (Exception e){
|
||||
System.out.println("Exception---------------------------");
|
||||
e.printStackTrace();
|
||||
return "执行异常";
|
||||
}
|
||||
return "执行成功";
|
||||
}
|
||||
|
||||
|
||||
@@ -90,4 +105,82 @@ public class SendCommandController {
|
||||
public String test(){
|
||||
return "6666";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建ssl连接,设置客户端信任所有证书
|
||||
* @return CloseableHttpClient
|
||||
* @throws KeyStoreException
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
private CloseableHttpClient createSSLClient() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (chain, authType) -> true).build();
|
||||
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new String[]{"TLSv1.2"}, null,
|
||||
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求时的header
|
||||
* @param httpUriRequest
|
||||
*/
|
||||
private void setSSLHeader(HttpUriRequest httpUriRequest) {
|
||||
long time = System.currentTimeMillis();
|
||||
String authorization = DigestUtils.sha256Hex(appId + appKey + time);
|
||||
httpUriRequest.addHeader("Content-Type", "application/json");
|
||||
httpUriRequest.addHeader("Authorization", authorization);
|
||||
httpUriRequest.addHeader("timestamp", String.valueOf(time));
|
||||
}
|
||||
/**
|
||||
* 解析响应结果
|
||||
* @param httpUriRequest
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyStoreException
|
||||
* @throws KeyManagementException
|
||||
* @throws IOException
|
||||
*/
|
||||
private org.apache.http.HttpEntity getSSLResponse(HttpUriRequest httpUriRequest) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {
|
||||
CloseableHttpClient httpClient = createSSLClient();
|
||||
CloseableHttpResponse response = httpClient.execute(httpUriRequest);
|
||||
org.apache.http.HttpEntity responseEntity = response.getEntity();
|
||||
System.out.println("响应状态为:" + response.getStatusLine());
|
||||
if (responseEntity != null) {
|
||||
System.out.println("响应内容长度为:" + responseEntity.getContentLength());
|
||||
System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
|
||||
}
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令下发
|
||||
*
|
||||
* @param serviceName
|
||||
* @param commandName
|
||||
* @param cmdComtent
|
||||
* @throws JSONException
|
||||
* @throws IOException
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyStoreException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public void deviceCommands(String deviceId,String serviceName, String commandName, org.json.JSONObject cmdComtent) throws JSONException, IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
String url = "https://" + sendIp + "/iot/1.0/deviceCommands?appId=" + appId;
|
||||
HttpPost httpPost = new HttpPost(url); //创建post请求
|
||||
|
||||
org.json.JSONObject cmdContent = new org.json.JSONObject();
|
||||
cmdContent.put("serviceId", serviceName);
|
||||
cmdContent.put("method", commandName);
|
||||
cmdContent.put("paras", cmdComtent);
|
||||
org.json.JSONObject cmdBody = new org.json.JSONObject();
|
||||
cmdBody.put("command", cmdContent);
|
||||
cmdBody.put("deviceId", deviceId);
|
||||
|
||||
setSSLHeader(httpPost); //设置请求的header
|
||||
StringEntity stringEntity = new StringEntity(cmdBody.toString(), "utf-8");
|
||||
httpPost.setEntity(stringEntity);//设置请求的body
|
||||
getSSLResponse(httpPost);//获取响应结果
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,7 @@ public class CommandDTO {
|
||||
private String method;
|
||||
|
||||
private JSONObject jsonObject;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ public class UpSendPojo {
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private String appId;
|
||||
|
||||
private CommandDTO commandDTO;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
|
||||
roma:
|
||||
acceptIp: 25.36.190.3:19776
|
||||
sendIp: https://25.36.190.7:11443/iot/1.0/deviceCommands
|
||||
sendIp: 25.36.190.7:11443
|
||||
appId: X_DNZLXT
|
||||
appKey: IoKU7u47seGwzO4CqGmCaQ==
|
||||
|
||||
|
||||
@@ -1,292 +1,292 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>迁移</title>
|
||||
<link rel="stylesheet" href="./element.css"/>
|
||||
<script src="./vue.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div id="table" class="col-sm-12">
|
||||
<table id="areaTable" class="table table-striped table-bordered dataTable no-footer"
|
||||
style="width:100%;cellspacing:0;margin-bottom: 0px;" role="grid" aria-describedby="example_info">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th class="table-middle">数据名称</th>
|
||||
<th class="table-middle">A/AB/0</th>
|
||||
<th class="table-middle">B/BC/+</th>
|
||||
<th class="table-middle">C/CA/-</th>
|
||||
<th class="table-middle">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>相电压总有效值(V)</td>
|
||||
<td>{{data.PhV_phsA}}</td>
|
||||
<td>{{data.PhV_phsB}}</td>
|
||||
<td>{{data.PhV_phsC}}</td>
|
||||
<td>-</td>
|
||||
<!--<!DOCTYPE html>-->
|
||||
<!--<html lang="en">-->
|
||||
<!--<head>-->
|
||||
<!-- <meta charset="UTF-8"/>-->
|
||||
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"/>-->
|
||||
<!-- <title>迁移</title>-->
|
||||
<!-- <link rel="stylesheet" href="./element.css"/>-->
|
||||
<!-- <script src="./vue.js"></script>-->
|
||||
<!--</head>-->
|
||||
<!--<body>-->
|
||||
<!--<div id="app">-->
|
||||
<!-- <div id="table" class="col-sm-12">-->
|
||||
<!-- <table id="areaTable" class="table table-striped table-bordered dataTable no-footer"-->
|
||||
<!-- style="width:100%;cellspacing:0;margin-bottom: 0px;" role="grid" aria-describedby="example_info">-->
|
||||
<!-- <thead>-->
|
||||
<!-- <tr role="row">-->
|
||||
<!-- <th class="table-middle">数据名称</th>-->
|
||||
<!-- <th class="table-middle">A/AB/0</th>-->
|
||||
<!-- <th class="table-middle">B/BC/+</th>-->
|
||||
<!-- <th class="table-middle">C/CA/-</th>-->
|
||||
<!-- <th class="table-middle">Total</th>-->
|
||||
<!-- </tr>-->
|
||||
<!-- </thead>-->
|
||||
<!-- <tbody>-->
|
||||
<!-- <tr>-->
|
||||
<!-- <td>相电压总有效值(V)</td>-->
|
||||
<!-- <td>{{data.PhV_phsA}}</td>-->
|
||||
<!-- <td>{{data.PhV_phsB}}</td>-->
|
||||
<!-- <td>{{data.PhV_phsC}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>电流总有效值(A)</td>
|
||||
<td>{{data.A_phsA}}</td>
|
||||
<td>{{data.A_phsB}}</td>
|
||||
<td>{{data.A_phsC}}</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>电流总有效值(A)</td>-->
|
||||
<!-- <td>{{data.A_phsA}}</td>-->
|
||||
<!-- <td>{{data.A_phsB}}</td>-->
|
||||
<!-- <td>{{data.A_phsC}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>线电压总有效值(V)</td>
|
||||
<td>{{data.PPV_phsAB}}</td>
|
||||
<td>{{data.PPV_phsBC}}</td>
|
||||
<td>{{data.PPV_phsCA}}</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>线电压总有效值(V)</td>-->
|
||||
<!-- <td>{{data.PPV_phsAB}}</td>-->
|
||||
<!-- <td>{{data.PPV_phsBC}}</td>-->
|
||||
<!-- <td>{{data.PPV_phsCA}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>相电压偏差(%)</td>
|
||||
<td>{{data.PhVDev_phsA}}</td>
|
||||
<td>{{data.PhVDev_phsB}}</td>
|
||||
<td>{{data.PhVDev_phsC}}</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>相电压偏差(%)</td>-->
|
||||
<!-- <td>{{data.PhVDev_phsA}}</td>-->
|
||||
<!-- <td>{{data.PhVDev_phsB}}</td>-->
|
||||
<!-- <td>{{data.PhVDev_phsC}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>线电压偏差(%)</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>线电压偏差(%)</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>频率(Hz)</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td>{{data.Freq}}</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>频率(Hz)</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
<!-- <td>{{data.Freq}}</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>频率偏差(Hz)</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td>{{data.FreqDev}}</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>频率偏差(Hz)</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
<!-- <td>{{data.FreqDev}}</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>电压序分量(V)</td>
|
||||
<td>{{data.SeqV_C0}}</td>
|
||||
<td>{{data.SeqV_C1}}</td>
|
||||
<td>{{data.SeqV_C2}}</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>电压序分量(V)</td>-->
|
||||
<!-- <td>{{data.SeqV_C0}}</td>-->
|
||||
<!-- <td>{{data.SeqV_C1}}</td>-->
|
||||
<!-- <td>{{data.SeqV_C2}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>电流序分量(A)</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>电流序分量(A)</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>总有功功率(W)</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>{{data.TotW}}</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>总有功功率(W)</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>{{data.TotW}}</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>总无功功率(Var)</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>{{data.TotVar}}</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>总无功功率(Var)</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>{{data.TotVar}}</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>总视在功率(VA)</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>{{data.TotVA}}</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>总视在功率(VA)</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>{{data.TotVA}}</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
|
||||
<tr>
|
||||
<td>视在功率因数</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>{{data.TotPF}}</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>视在功率因数</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>{{data.TotPF}}</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
|
||||
<tr>
|
||||
<td>位移功率因数</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>位移功率因数</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
|
||||
<tr>
|
||||
<td>电压波动</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>电压波动</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
|
||||
<tr>
|
||||
<td>短时闪变</td>
|
||||
<td>{{data.PstPhV_phsA}}</td>
|
||||
<td>{{data.PstPhV_phsB}}</td>
|
||||
<td>{{data.PstPhV_phsC}}</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>短时闪变</td>-->
|
||||
<!-- <td>{{data.PstPhV_phsA}}</td>-->
|
||||
<!-- <td>{{data.PstPhV_phsB}}</td>-->
|
||||
<!-- <td>{{data.PstPhV_phsC}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
|
||||
<tr>
|
||||
<td>长时闪变</td>
|
||||
<td>{{data.PltPhV_phsA}}</td>
|
||||
<td>{{data.PltPhV_phsB}}</td>
|
||||
<td>{{data.PltPhV_phsC}}</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>长时闪变</td>-->
|
||||
<!-- <td>{{data.PltPhV_phsA}}</td>-->
|
||||
<!-- <td>{{data.PltPhV_phsB}}</td>-->
|
||||
<!-- <td>{{data.PltPhV_phsC}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
|
||||
<tr>
|
||||
<td>电压谐波畸变率(%)</td>
|
||||
<td>{{data.ThdPhV_phsA}}</td>
|
||||
<td>{{data.ThdPhV_phsB}}</td>
|
||||
<td>{{data.ThdPhV_phsC}}</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>电压谐波畸变率(%)</td>-->
|
||||
<!-- <td>{{data.ThdPhV_phsA}}</td>-->
|
||||
<!-- <td>{{data.ThdPhV_phsB}}</td>-->
|
||||
<!-- <td>{{data.ThdPhV_phsC}}</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td>电流谐波畸变率(%)</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>/</td>
|
||||
<td>-</td>
|
||||
<!-- <tr>-->
|
||||
<!-- <td>电流谐波畸变率(%)</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>/</td>-->
|
||||
<!-- <td>-</td>-->
|
||||
|
||||
</tr>
|
||||
<!-- </tr>-->
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- </tbody>-->
|
||||
<!-- </table>-->
|
||||
<!-- </div>-->
|
||||
|
||||
|
||||
</div>
|
||||
<!--</div>-->
|
||||
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js"
|
||||
}
|
||||
}
|
||||
<!--<script type="importmap">-->
|
||||
<!-- {-->
|
||||
<!-- "imports": {-->
|
||||
<!-- "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js"-->
|
||||
<!-- }-->
|
||||
<!-- }-->
|
||||
|
||||
|
||||
</script>
|
||||
<script type="module">
|
||||
import {createApp, onMounted, ref} from 'vue'
|
||||
<!--</script>-->
|
||||
<!--<script type="module">-->
|
||||
<!-- import {createApp, onMounted, ref} from 'vue'-->
|
||||
|
||||
createApp({
|
||||
setup() {
|
||||
<!-- createApp({-->
|
||||
<!-- setup() {-->
|
||||
|
||||
const data = ref([]);
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const response = await fetch('/message');
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
data.value = await response.json();
|
||||
<!-- const data = ref([]);-->
|
||||
<!-- const fetchData = async () => {-->
|
||||
<!-- try {-->
|
||||
<!-- const response = await fetch('/message');-->
|
||||
<!-- if (!response.ok) {-->
|
||||
<!-- throw new Error('Network response was not ok');-->
|
||||
<!-- }-->
|
||||
<!-- data.value = await response.json();-->
|
||||
|
||||
console.log(111111111, data.value)
|
||||
} catch (error) {
|
||||
console.error('Fetch error:', error);
|
||||
}
|
||||
};
|
||||
setInterval(fetchData, 1000);
|
||||
<!-- console.log(111111111, data.value)-->
|
||||
<!-- } catch (error) {-->
|
||||
<!-- console.error('Fetch error:', error);-->
|
||||
<!-- }-->
|
||||
<!-- };-->
|
||||
<!-- setInterval(fetchData, 1000);-->
|
||||
|
||||
return {
|
||||
fetchData,
|
||||
data
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
<style>
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
<!-- return {-->
|
||||
<!-- fetchData,-->
|
||||
<!-- data-->
|
||||
<!-- }-->
|
||||
<!-- }-->
|
||||
<!-- }).mount('#app');-->
|
||||
<!--</script>-->
|
||||
<!--</body>-->
|
||||
<!--<style>-->
|
||||
<!-- table {-->
|
||||
<!-- width: 100%;-->
|
||||
<!-- border-collapse: collapse;-->
|
||||
<!-- }-->
|
||||
|
||||
table caption {
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
margin: 1em 0;
|
||||
}
|
||||
<!-- table caption {-->
|
||||
<!-- font-size: 2em;-->
|
||||
<!-- font-weight: bold;-->
|
||||
<!-- margin: 1em 0;-->
|
||||
<!-- }-->
|
||||
|
||||
th, td {
|
||||
border: 1px solid #999;
|
||||
text-align: center;
|
||||
padding: 10px 0;
|
||||
}
|
||||
<!-- th, td {-->
|
||||
<!-- border: 1px solid #999;-->
|
||||
<!-- text-align: center;-->
|
||||
<!-- padding: 10px 0;-->
|
||||
<!-- }-->
|
||||
|
||||
table thead tr {
|
||||
background-color: #008c8c;
|
||||
color: #fff;
|
||||
}
|
||||
<!-- table thead tr {-->
|
||||
<!-- background-color: #008c8c;-->
|
||||
<!-- color: #fff;-->
|
||||
<!-- }-->
|
||||
|
||||
table tbody tr:nth-child(odd) {
|
||||
background-color: #eee;
|
||||
}
|
||||
<!-- table tbody tr:nth-child(odd) {-->
|
||||
<!-- background-color: #eee;-->
|
||||
<!-- }-->
|
||||
|
||||
table tbody tr:hover {
|
||||
background-color: #ccc;
|
||||
}
|
||||
<!-- table tbody tr:hover {-->
|
||||
<!-- background-color: #ccc;-->
|
||||
<!-- }-->
|
||||
|
||||
table tbody tr td:first-child {
|
||||
color: #3d34fc;
|
||||
}
|
||||
<!-- table tbody tr td:first-child {-->
|
||||
<!-- color: #3d34fc;-->
|
||||
<!-- }-->
|
||||
|
||||
table tfoot tr td {
|
||||
text-align: right;
|
||||
padding-right: 20px;
|
||||
}
|
||||
<!-- table tfoot tr td {-->
|
||||
<!-- text-align: right;-->
|
||||
<!-- padding-right: 20px;-->
|
||||
<!-- }-->
|
||||
|
||||
#app {
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
<!-- #app {-->
|
||||
<!-- padding: 10px;-->
|
||||
<!-- }-->
|
||||
<!--</style>-->
|
||||
<!--</html>-->
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<button class="el-button" @click="fetchData">读取</button>
|
||||
|
||||
</div>
|
||||
<div style="float: left">装置标识:{{data.customDevId}}</div>
|
||||
<div v-if="data.time" style="float: right">{{data.time.substring(0,4)+'-'+data.time.substring(4,6)+'-'+data.time.substring(6,8)+' '+data.time.substring(9,11)+':'+data.time.substring(11,13)+':'+data.time.substring(13,15)}}</div>
|
||||
<table v-if="!changeFlag">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user