Browse Source

修改部署内容

dev-jc
yj 2 years ago
parent
commit
2453ae14e1
  1. 39
      device_cars/pom.xml
  2. 27
      device_cars/src/main/java/com/xr/device_car/DeviceCarApplication.java
  3. 32
      device_cars/src/main/java/com/xr/device_car/config/common/Const.java
  4. 42
      device_cars/src/main/java/com/xr/device_car/config/common/LocalDateConverter.java
  5. 41
      device_cars/src/main/java/com/xr/device_car/config/common/LocalDateTimeConverter.java
  6. 281
      device_cars/src/main/java/com/xr/device_car/config/common/RESTClient.java
  7. 3
      device_cars/src/main/java/com/xr/device_car/config/common/WebConfig.java
  8. 21
      device_cars/src/main/java/com/xr/device_car/config/getconfigvalue/StaticProperties.java
  9. 33
      device_cars/src/main/java/com/xr/device_car/config/udp/UdbConfig.java
  10. 68
      device_cars/src/main/java/com/xr/device_car/config/udp/UdpClientConfig.java
  11. 153
      device_cars/src/main/java/com/xr/device_car/config/utils/AnalysisXml.java
  12. 4
      device_cars/src/main/java/com/xr/device_car/config/utils/CodeGenUtil.java
  13. 151
      device_cars/src/main/java/com/xr/device_car/config/utils/DigestsUtils.java
  14. 139
      device_cars/src/main/java/com/xr/device_car/config/utils/EasyExcelUtil.java
  15. 125
      device_cars/src/main/java/com/xr/device_car/config/utils/FileUtil.java
  16. 59
      device_cars/src/main/java/com/xr/device_car/config/utils/Files.java
  17. 52
      device_cars/src/main/java/com/xr/device_car/config/utils/HkComUtil.java
  18. 55
      device_cars/src/main/java/com/xr/device_car/config/utils/HttpResponseBean.java
  19. 72
      device_cars/src/main/java/com/xr/device_car/config/utils/MinioUtil.java
  20. 141
      device_cars/src/main/java/com/xr/device_car/config/utils/OnvifUtils.java
  21. 231
      device_cars/src/main/java/com/xr/device_car/config/utils/PythonExecutor.java
  22. 21
      device_cars/src/main/java/com/xr/device_car/config/utils/StaticPropUtil.java
  23. 9
      device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/DeviceCameraController.java
  24. 55
      device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/FocalLengthConfigController.java
  25. 38
      device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterConfigController.java
  26. 177
      device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterInitializationController.java
  27. 72
      device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/SendUdpLogController.java
  28. 17
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/BallheadPT.java
  29. 23
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DeviceCamera.java
  30. 120
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DigestBean.java
  31. 15
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterConfig.java
  32. 53
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterInitialization.java
  33. 2
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterReadingRecord.java
  34. 32
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifAuthBean.java
  35. 53
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifBean.java
  36. 38
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifCredentials.java
  37. 68
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/SendUdpLog.java
  38. 68
      device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/xslx/SendUdpLogXslx.java
  39. 20
      device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/MeterInitializationMapper.java
  40. 20
      device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/SendUdpLogMapper.java
  41. 16
      device_cars/src/main/java/com/xr/device_car/modules/analysis/service/IMeterInitializationService.java
  42. 13
      device_cars/src/main/java/com/xr/device_car/modules/analysis/service/SendUdpLogService.java
  43. 7
      device_cars/src/main/java/com/xr/device_car/modules/analysis/service/UdpClientService.java
  44. 20
      device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/MeterInitializationServiceImpl.java
  45. 24
      device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/SendUdpLogServiceImpl.java
  46. 48
      device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/UdpClientServiceImpl.java
  47. 19
      device_cars/src/main/resources/application-dev.yml
  48. 14
      device_cars/src/main/resources/application-prod.yml
  49. 14
      device_cars/src/main/resources/application-test.yml
  50. 3
      device_cars/src/main/resources/application.yml
  51. 12
      device_cars/src/main/resources/digest/AbsoluteMove.wsdl
  52. 6
      device_cars/src/main/resources/digest/GetDeviceInformation.wsdl
  53. 6
      device_cars/src/main/resources/digest/GetPTZ.wsdl
  54. 8
      device_cars/src/main/resources/digest/GetPresets.wsdl
  55. 6
      device_cars/src/main/resources/digest/GetProfiles.wsdl
  56. 8
      device_cars/src/main/resources/digest/GetSnapshotUrl.wsdl
  57. 8
      device_cars/src/main/resources/digest/GetStatus.wsdl
  58. 25
      device_cars/src/main/resources/digest/GetStreamUri.wsdl
  59. 9
      device_cars/src/main/resources/digest/GotoPreset.wsdl
  60. 11
      device_cars/src/main/resources/modules/analysis/MeterConfigMapper.xml
  61. 14
      device_cars/src/main/resources/modules/analysis/MeterInitializationMapper.xml
  62. 22
      device_cars/src/main/resources/modules/analysis/SendUdpLogMapper.xml
  63. 2
      device_display/pom.xml
  64. 10
      device_display/src/main/java/com/xr/device_display/modules/analysis/dto/HistogramDto.java
  65. 12
      device_display/src/main/java/com/xr/device_display/modules/analysis/dto/dataset.java
  66. 4
      device_display/src/main/java/com/xr/device_display/modules/analysis/service/impl/MeterReadingRecordServiceImpl.java
  67. 2
      device_display/src/main/resources/application-dev.yml
  68. 2
      device_display/src/main/resources/application-prod.yml
  69. 2
      device_display/src/main/resources/application-test.yml
  70. 2
      device_display/src/main/resources/application.yml
  71. 4
      device_iec104/src/main/java/com/xr/iec104Server/iec104/server/SysDataHandler.java
  72. 2
      device_iec104/src/main/resources/application-dev.yml
  73. 2
      device_iec104/src/main/resources/application-prod.yml
  74. 2
      device_iec61850clent/src/main/java/com/xr/iec61850clent/Iec61850ClentApplication.java
  75. 422
      device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ExcelUtil.java
  76. 151
      device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/IEC61850Config.java
  77. 4
      device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ModeUtil.java
  78. 24
      device_iec61850clent/src/main/java/com/xr/iec61850clent/models/entity/ExcelConfig.java
  79. BIN
      device_iec61850clent/src/main/resources/IEC61850.xlsx
  80. 2
      device_iec61850clent/src/main/resources/application-dev.yml
  81. 6
      device_iec61850clent/src/main/resources/application-prod.yml
  82. 2
      device_iec61850clent/src/main/resources/application-test.yml
  83. 81
      device_iec61850server/src/main/java/com/xr/iec61850server/models/entity/Lds5000.java
  84. 18
      device_iec61850server/src/main/java/com/xr/iec61850server/models/mapper/Lds5000Mapper.java
  85. 13
      device_iec61850server/src/main/java/com/xr/iec61850server/models/service/Lds5000Service.java
  86. 22
      device_iec61850server/src/main/java/com/xr/iec61850server/models/service/impl/Lds5000ServiceImpl.java
  87. 2
      device_iec61850server/src/main/resources/application-dev.yml
  88. 2
      device_iec61850server/src/main/resources/application-prod.yml
  89. 2
      device_iec61850server/src/main/resources/application-test.yml
  90. 2
      device_iec61850server/src/main/resources/application.yml
  91. 28
      device_iec61850server/src/main/resources/mappers/Lds5000Mapper.xml
  92. 120
      device_modbus/src/main/java/com/xr/clent/utils/ModbusRtuUtil.java
  93. 2
      device_modbus/src/main/resources/application-dev.yml
  94. 2
      device_modbus/src/main/resources/application-prod.yml
  95. 42
      device_udpclent/pom.xml
  96. 2
      device_udpclent/src/main/java/com/xr/device_udpclent/DeviceUdpclentApplication.java
  97. 22
      device_udpclent/src/main/java/com/xr/device_udpclent/common/config/BodyRequestConfig.java
  98. 32
      device_udpclent/src/main/java/com/xr/device_udpclent/common/config/Const.java
  99. 59
      device_udpclent/src/main/java/com/xr/device_udpclent/common/config/FormRequestConfig.java
  100. 55
      device_udpclent/src/main/java/com/xr/device_udpclent/common/config/HttpResponseBean.java

39
device_cars/pom.xml

@ -149,6 +149,11 @@
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
@ -173,7 +178,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
<version>${joda.time.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.ibatis/ibatis-sqlmap-->
<!-- <dependency>-->
@ -356,38 +361,6 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>3.0.10</version>
</dependency>
<!-- 引入easyPOI -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies>
<build>

27
device_cars/src/main/java/com/xr/device_car/DeviceCarApplication.java

@ -1,41 +1,27 @@
package com.xr.device_car;
import cn.hutool.extra.spring.SpringUtil;
import com.xr.device_car.client.config.Iec104Config;
import com.xr.device_car.config.utils.FileUtil;
import com.xr.device_car.config.utils.Files;
import com.xr.device_car.modules.analysis.entity.FocalLengthConfig;
import com.xr.device_car.modules.analysis.service.FocalLengthConfigService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import java.io.File;
import java.util.Date;
import java.util.List;
@SpringBootApplication
@EnableScheduling//开启定时任务
@EnableAsync//开启异步
@MapperScan("com.xr.device_car.modules.**.mapper")
@EnableDiscoveryClient
@EnableFeignClients
@Import(SpringUtil.class)
//public class DeviceCarApplication implements CommandLineRunner {
public class DeviceCarApplication{
@Value("${netty.address}")
private String address;
@ -66,12 +52,9 @@ public class DeviceCarApplication{
// @Async
// @Override
// public void run(String... args) throws Exception {
// FocalLengthConfigService focalLengthConfigService = SpringUtil.getBean(FocalLengthConfigService.class);
// List<FocalLengthConfig> list=focalLengthConfigService.list();
// for (FocalLengthConfig config:list){
// byte[] b=config.getFocalPicture();
// File file = new File("D:\\images\\zhongshan\\"+config.getConfigId()+".jpg");
// FileUtil.readInputStream(file,b);
// }
// Iec104Config iec104Config = new Iec104Config();
// iec104Config.setFrameAmountMax((short) 2);
// iec104Config.setTerminnalAddress((short) 1);
// Iec104MasterFactory.createTcpClientMaster("192.168.3.10",2404).setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
// }
}

32
device_cars/src/main/java/com/xr/device_car/config/common/Const.java

@ -1,32 +0,0 @@
package com.xr.device_car.config.common;
public interface Const {
/**
* 请求onvifurl拼接
*/
String REQUEST_ONVIF_URL = "http://%s:%d/onvif/media_service";
String ABSOLUTE_MOVE= "http://%s:%d/onvif/ptz_service";
String PTZ_MOVE= "http://%s:%d/onvif/PTZ";
/**
* 请求onvifurl拼接
*/
String REQUEST_DEVICE_ONVIF_URL = "http://%s:%d/onvif/device_service";
/**
*返回的respon 中的headers
*/
String HEADERS_ONVIF_WWW_AUTHENTICATE= "WWW-Authenticate";
/**
* token
*/
String EQUEST_ONVIF_TOKEN="Digest username=\"%s\", realm=\"%s\", qop=\"%s\", algorithm=\"%s\", uri=\"%s\", nonce=\"%s\", nc=%s, cnonce=\"%s\", opaque=\"%s\", response=\"%s\"";
}

42
device_cars/src/main/java/com/xr/device_car/config/common/LocalDateConverter.java

@ -1,42 +0,0 @@
package com.xr.device_car.config.common;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* @Author: ChenTaoTao
* @Date: 2022/3/28 10:07
* @Describe:
*/
public class LocalDateConverter implements Converter<LocalDate> {
@Override
public Class<LocalDate> supportJavaTypeKey() {
return LocalDate.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public LocalDate convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return LocalDate.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
@Override
public WriteCellData<String> convertToExcelData(LocalDate value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new WriteCellData<>(value.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
}
}

41
device_cars/src/main/java/com/xr/device_car/config/common/LocalDateTimeConverter.java

@ -1,41 +0,0 @@
package com.xr.device_car.config.common;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @Author: ChenTaoTao
* @Date: 2022/3/28 10:07
* @Describe:
*/
public class LocalDateTimeConverter implements Converter<LocalDateTime> {
@Override
public Class<LocalDateTime> supportJavaTypeKey() {
return LocalDateTime.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public LocalDateTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return LocalDateTime.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
@Override
public WriteCellData<String> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new WriteCellData<>(value.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
}
}

281
device_cars/src/main/java/com/xr/device_car/config/common/RESTClient.java

@ -1,281 +0,0 @@
package com.xr.device_car.config.common;
import com.xr.device_car.config.utils.HttpResponseBean;
import org.apache.http.*;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import java.io.IOException;
import java.net.ConnectException;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Http请求客户端
* @author ChenYongHeng
* @since 2019/5/27
*/
public class RESTClient {
private static Logger log = LoggerFactory.getLogger(RESTClient.class);
private volatile static RESTClient HttpClientConnectionPool;
private static final String USERAGENT = "SZ-JAVA";
private static final String CHARSET = "UTF-8";
private static final int MAX_TOTAL_CONNECTIONS = 200;
private static final int MAX_ROUTE_CONNECTIONS = 100;
/**
* 连接时间
*/
private static final int CONNECT_TIMEOUT = 5000;
/**
* 获取内容时间
*/
private static final int SOCKET_TIMEOUT = 30000;
private static PoolingHttpClientConnectionManager cm = null;
private static CloseableHttpClient HTTP_CLIENTS;
/**
* 初始化连接池
*/
static{
try {
cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(MAX_TOTAL_CONNECTIONS);
// 默认设置为2
cm.setDefaultMaxPerRoute(MAX_ROUTE_CONNECTIONS);
// 客户端请求的默认设置
RequestConfig defaultRequestConfig = RequestConfig.custom()
.setSocketTimeout(SOCKET_TIMEOUT)
.setConnectTimeout(CONNECT_TIMEOUT)
.setConnectionRequestTimeout(CONNECT_TIMEOUT)
.setRedirectsEnabled(false)
.setCookieSpec(CookieSpecs.STANDARD_STRICT)
.build();
// 请求重试处理
HttpRequestRetryHandler httpRequestRetryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception,
int executionCount, HttpContext context) {
// 如果超过最大重试次数,那么就不要继续了
if (executionCount >= 2) {
return false;
}
// 如果服务器丢掉了连接,那么就重试
if (exception instanceof NoHttpResponseException) {
return true;
}
// 不要重试SSL握手异常
if (exception instanceof SSLHandshakeException) {
return false;
}
HttpRequest request = (HttpRequest) context.getAttribute(HttpClientContext.HTTP_REQUEST);
boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
// 如果请求被认为是幂等的,那么就重试
if (idempotent) {
return true;
}
return false;
}
};
// https 信任所有
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (chain, authType) -> true).build();
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
HTTP_CLIENTS = HttpClients.custom()
.setConnectionManager(cm)
.setDefaultRequestConfig(defaultRequestConfig)
.setRetryHandler(httpRequestRetryHandler)
//https
.setSSLSocketFactory(sslSocketFactory)
.build();
} catch (Exception e) {
e.printStackTrace();
}
}
private RESTClient(){}
/**
* 获取HttpClientConnectionPool对象这是单例方法
*
* @return
*/
public static RESTClient getClientConnectionPool() {
if (HttpClientConnectionPool == null) {
synchronized (RESTClient.class) {
if (HttpClientConnectionPool == null) {
HttpClientConnectionPool = new RESTClient();
}
}
}
return HttpClientConnectionPool;
}
/**
* 一般情况下是AuthToken使用
* @param url
* @param xmlFileName
* @return
*/
public HttpResponseBean postXML(String url, String xmlFileName){
return postXML( url, xmlFileName,"");
}
/**
* 一般情况下是DigestBean使用
* @param url
* @param xmlFileName
* @param auth
* @return
*/
public HttpResponseBean postXML(String url,String xmlFileName,String auth){
HttpPost httpPost = new HttpPost(url);
String seqNum = String.valueOf(System.currentTimeMillis());
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/soap+xml; charset=utf-8");
if(StringUtils.hasLength(xmlFileName))httpPost.setEntity(new StringEntity(xmlFileName, ContentType.APPLICATION_JSON));
if(StringUtils.hasLength(auth)) httpPost.setHeader("Authorization",auth);
log.info(seqNum+">>> "+httpPost.toString());
log.info(seqNum+"Body>>> " +xmlFileName);
return httpPost(httpPost,seqNum);
}
/**
* Post方法封装发送post请求获取响应内容
*/
public String fetchByPostMethod(String url, String jsonStr) {
String resultStr = null;
HttpPost httpPost = httpPostAddHeader(url, jsonStr);
String seqNum = String.valueOf(System.currentTimeMillis());
log.info(seqNum + ">>> " + httpPost.toString());
log.info(seqNum + "Body>>> " + jsonStr);
HttpResponse response;
try {
response = HTTP_CLIENTS.execute(httpPost);
HttpEntity entity = response.getEntity();
resultStr = EntityUtils.toString(entity, CHARSET);
EntityUtils.consume(entity);
} catch (IOException ce) {// 服务器请求失败
log.error(ce.getMessage());
} finally {
httpPost.abort();
}
log.info(seqNum + "<<< " + resultStr);
return resultStr;
}
/**
* 添加头部信息
* @param url
* @param jsonStr
* @return
*/
private HttpPost httpPostAddHeader(String url, String jsonStr){
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new StringEntity(jsonStr, ContentType.APPLICATION_JSON));
httpPost.addHeader(HttpHeaders.USER_AGENT, USERAGENT);
httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
return httpPost;
}
/**
* httppost
* @param httpPost
* @param seqNum
* @return
*/
private HttpResponseBean httpPost(HttpPost httpPost,String seqNum ) {
String resultStr = null;
HttpResponse response = null;
try{
response = HTTP_CLIENTS.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
if(statusCode == HttpStatus.SC_UNAUTHORIZED) {
//如果是401直接返回
return new HttpResponseBean(null, Arrays.asList(response.getAllHeaders()),response.getStatusLine().getStatusCode());
}
HttpEntity entity = response.getEntity();
resultStr = EntityUtils.toString(entity,CHARSET);
EntityUtils.consume(entity);
}catch (ConnectException ce){// 服务器请求失败
log.error("ConnectException fetchByPostMethod---->>>{}",ce.getMessage());
} catch (IOException e) {
log.error("IOException fetchByPostMethod---->>>{}",e.getMessage());
}finally {
httpPost.abort();
}
log.info(seqNum+"<<< "+resultStr);
if(response != null) return new HttpResponseBean(resultStr, Arrays.asList(response.getAllHeaders()),response.getStatusLine().getStatusCode());
return null;
}
/**
* 正则获取字符编码
* @param content_type
* @return
*/
private static String getCharSetFromContentType(String content_type){
String regex = "charset=\\s*(\\S*[^;])";
Pattern pattern = Pattern.compile(regex,Pattern.DOTALL);
Matcher matcher = pattern.matcher(content_type);
if(matcher.find()){
return matcher.group(1);
}else{
return null;
}
}
}

3
device_cars/src/main/java/com/xr/device_car/config/common/WebConfig.java

@ -18,6 +18,7 @@ public class WebConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor())
.addPathPatterns("/**").excludePathPatterns("/user/webLogin")
.excludePathPatterns("/user/login","/user/getUserByToken","/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
.excludePathPatterns("/user/login","/user/getUserByToken","/deviceCamera/deviceCameraList","/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**",
"/dataAnalysisCamera/getComer");
}
}

21
device_cars/src/main/java/com/xr/device_car/config/getconfigvalue/StaticProperties.java

@ -14,25 +14,4 @@ public class StaticProperties {
@Value("${upLoad.url}")
private String url;
@Value("${python.path}")
private String pythonPath;
@Value("${python.modelPath}")
private String modelPath;
@Value("${minio.url}")
private String minioUrl;
@Value("${minio.accessKey}")
private String minioAccess;
@Value("${minio.secretKey}")
private String minioSecret;
@Value("${udp.server.host}")
private String udpHost;
@Value("${udp.server.port}")
private Integer udpPort;
}

33
device_cars/src/main/java/com/xr/device_car/config/udp/UdbConfig.java

@ -1,33 +0,0 @@
package com.xr.device_car.config.udp;
import com.xr.device_car.modules.analysis.entity.MeterConfig;
import com.xr.device_car.modules.analysis.entity.MeterReadingRecord;
import lombok.Data;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;
@Data
public class UdbConfig {
//获取资源信息配置报文
public static String getUdbConfig(List<MeterConfig> list){
StringBuffer buffer=new StringBuffer();
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
buffer.append(new Date().getTime()+ new Random().nextInt(9000)+1000).append("\t");
buffer.append("<!Entity=表计识别信息转发配置 ver='V1.0' time='"+sdf.format(new Date())+"'(文件最新时间)!>");
buffer.append("<DeviceInfo::设备资源信息>");
for(MeterConfig config:list){
buffer.append("站序号").append("\t");//站序号
buffer.append(config.getId()).append("\t");//监控索引号
buffer.append("中山站").append("/").append(config.getOwningInterval()).append("/").append(config.getDeviceName()).append("/").append(config.getMeterName()).append("\t");//设备名称=站名称+间隔名称+设备名称+开关名称
buffer.append(config.getMeterCode()).append("\t");//实物ID目前取表计ID
buffer.append("否").append(";");//是否联动信号目前取否,目前结尾符号位;
}
buffer.append("</DeviceInfo::设备资源信息>");
return buffer.toString();
}
}

68
device_cars/src/main/java/com/xr/device_car/config/udp/UdpClientConfig.java

@ -1,68 +0,0 @@
package com.xr.device_car.config.udp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xr.device_car.config.utils.StaticPropUtil;
import com.xr.device_car.modules.analysis.entity.SendUdpLog;
import com.xr.device_car.modules.analysis.service.SendUdpLogService;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.util.CharsetUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.net.InetSocketAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
@Configuration
public class UdpClientConfig {
@Autowired
private SendUdpLogService sendUdpLogService;
@Bean
public DatagramChannel udpChannel() {
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new SimpleChannelInboundHandler<DatagramPacket>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
// 处理接收到的数据
String data = msg.content().toString(CharsetUtil.UTF_8);
QueryWrapper<SendUdpLog> queryWrapper=new QueryWrapper();
queryWrapper.eq("message_id",data.split(":")[0]);
SendUdpLog sendUdpLog = sendUdpLogService.getOne(queryWrapper);
if(sendUdpLog !=null){
sendUdpLog.setResTime(new Date());
sendUdpLog.setResMsg(data);
sendUdpLogService.updateById(sendUdpLog);
}
System.out.println("Received data: " + data);
}
});
return (DatagramChannel) bootstrap.bind(0).sync().channel();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Bean
public InetSocketAddress udpServerAddress() {
return new InetSocketAddress(StaticPropUtil.udpHost, StaticPropUtil.udpPort);
}
}

153
device_cars/src/main/java/com/xr/device_car/config/utils/AnalysisXml.java

@ -1,153 +0,0 @@
package com.xr.device_car.config.utils;
import com.xr.device_car.modules.analysis.entity.BallheadPT;
import org.apache.commons.lang.StringEscapeUtils;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class AnalysisXml {
/**
* 解析xml[Profiles] 获取 token
* @param resultStr
* @return
*/
public static List<String> analysisTokens(String resultStr){
// 解析body
// 转换返回结果中的特殊字符,返回的结果中会将xml转义,此处需要反转移
String xmlStr = StringEscapeUtils.unescapeXml(resultStr);
SAXReader reader = new SAXReader();
try {
Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)));
Element root = document.getRootElement();
List<Element> elements = root.element("Body").element("GetProfilesResponse").elements("Profiles");
return elements.stream().map(element -> element.attribute("token").getText()).collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 解析xml[ProfilesName] 获取 token
* @param resultStr
* @return
*/
public static List<String> analysisProfiles(String resultStr){
// 解析body
// 转换返回结果中的特殊字符,返回的结果中会将xml转义,此处需要反转移
String xmlStr = StringEscapeUtils.unescapeXml(resultStr);
SAXReader reader = new SAXReader();
try {
Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)));
Element root = document.getRootElement();
List<Element> elements = root.element("Body").element("GetProfilesResponse").elements("Preset");
return elements.stream().map(element -> element.element("Name").getText()
).collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 解析xml[MediaUri] 获取 token
* @param resultStr
* @return
*/
public static String analysisSnapshotUrl(String resultStr){
// 解析body
// 转换返回结果中的特殊字符,返回的结果中会将xml转义,此处需要反转移
String xmlStr = StringEscapeUtils.unescapeXml(resultStr).replace("&", "&amp;");
SAXReader reader = new SAXReader();
try {
Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)));
Element rootElement = document.getRootElement();
Element element = rootElement.element("Body").element("GetSnapshotUriResponse").element("MediaUri");
List<Element> elements=element.elements("Uri");
return String.valueOf(elements.get(0).getData());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 解析xml[MediaUri] 获取 streamUrl
* @param resultStr
* @return
*/
public static String analysisStreamUrl(String resultStr){
// 解析body
// 转换返回结果中的特殊字符,返回的结果中会将xml转义,此处需要反转移
String xmlStr = StringEscapeUtils.unescapeXml(resultStr).replace("&", "&amp;");
SAXReader reader = new SAXReader();
try {
Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)));
Element rootElement = document.getRootElement();
Element element = rootElement.element("Body").element("GetStreamUriResponse").element("MediaUri");
List<Element> elements=element.elements("Uri");
return String.valueOf(elements.get(0).getData());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static List<BallheadPT> getBallheadPTs(String resultStr){
List<BallheadPT> ballheadPTS=new ArrayList<>();
String xmlStr = StringEscapeUtils.unescapeXml(resultStr).replace("&", "&amp;");
SAXReader reader = new SAXReader();
try {
Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)));
Element root = document.getRootElement();
List<Element> elements = root.element("Body").element("GetPresetsResponse").elements("Preset");
for(Element element:elements){
BallheadPT pt=new BallheadPT();
String id = element.attribute(0).getValue();
pt.setId(id);
String name = String.valueOf(element.element("Name").getText());
pt.setName(name);
List<Element> ele=element.elements("PTZPosition");
pt.setX(String.valueOf(ele.get(0).element("PanTilt").attribute(0).getValue()));
pt.setY(String.valueOf(ele.get(0).element("PanTilt").attribute(1).getValue()));
pt.setZ(String.valueOf(ele.get(0).element("Zoom").attribute(0).getValue()));
ballheadPTS.add(pt);
}
} catch (Exception e) {
e.printStackTrace();
}
return ballheadPTS;
}
public static BallheadPT getStatus(String resultStr){
String xmlStr = StringEscapeUtils.unescapeXml(resultStr).replace("&", "&amp;");
SAXReader reader = new SAXReader();
try {
Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)));
Element root = document.getRootElement();
Element element = root.element("Body").element("GetStatusResponse").element("PTZStatus").element("Position");
String x=String.valueOf(element.element("PanTilt").attribute(0).getValue());
String y=String.valueOf(element.element("PanTilt").attribute(1).getValue());
String z=String.valueOf(element.element("Zoom").attribute(0).getValue());
BallheadPT pt=new BallheadPT();
pt.setX(x);
pt.setY(y);
pt.setZ(z);
return pt;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

4
device_cars/src/main/java/com/xr/device_car/config/utils/CodeGenUtil.java

@ -30,7 +30,7 @@ public class CodeGenUtil {
CodeGenUtil codeGenUtil = new CodeGenUtil();
boolean b = codeGenUtil.generateByTables(dataSourceConfig, "com.xr.device_car.modules.analysis",
"gaoby", "device_cars",
"meter_initialization");
"meter_reading");
System.out.println(b);
}
@ -162,7 +162,7 @@ public class CodeGenUtil {
* @return 数据源配置 DataSourceConfig
*/
private static DataSourceConfig getDataSourceConfig() {
String dbUrl = "jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false";
String dbUrl = "jdbc:mysql://116.196.120.81:3306/image_analysis?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false";
return new DataSourceConfig()
.setDbType(DbType.MYSQL)
.setUrl(dbUrl)

151
device_cars/src/main/java/com/xr/device_car/config/utils/DigestsUtils.java

@ -1,151 +0,0 @@
package com.xr.device_car.config.utils;
import org.apache.commons.codec.binary.Hex;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author dzp
* @date Created in 2022/5/12 14:39
* @description
*/
public class DigestsUtils {
/**
*
* respon
* HA1 = MD5<username>:<reaml>:<psd>
* HA2 = MD5(<method>:<disgestUriPath>)
* response = MD5(HA1:<nonce>:<nc>:<conce>:<qop>:HA2)
* 给wsse的使用
* 加密遵循RFC2671规范 将相关参数加密生成一个MD5字符串,并返回
* http_da_calc_HA1("onvif_test", "IP Camera(C7233)", "onvif123",
* "5a5446694d3259774e474d36596a6735596a646b4d6a493d", "00000002", "512bb12866dcbc1f", "auth",
* "GET", "/onvif-http/snapshot?Profile_1", "MD5");
* @param username 用户名
* @param realm 401 返回的是 应该是名称
* @param password 密码
* @param nonce 401 返回的
* @param nc 16进制请求认证计数器, 00000001
* @param cnonce 客户端随机数
* @param qop auth
* @param method 请求
* @param uri 地址 getSnapshotUil返回的
* @param algorithm 加密方式 一般情况下是MD5
* @return 获取response
*/
public static String http_da_calc_HA1(String username, String realm, String password,
String nonce, String nc, String cnonce, String qop,
String method, String uri, String algorithm) {
String HA1, HA2;
if ("MD5-sess".equals(algorithm)) {
HA1 = HA1_MD5_sess(username, realm, password, nonce, cnonce);
} else {
HA1 = HA1_MD5(username, realm, password);
}
byte[] md5Byte = md5(HA1.getBytes());
HA1 = new String(Hex.encodeHex(md5Byte));
md5Byte = md5(HA2(method, uri).getBytes());
HA2 = new String(Hex.encodeHex(md5Byte));
String original = HA1 + ":" + (nonce + ":" + nc + ":" + cnonce + ":" + qop) + ":" + HA2;
md5Byte = md5(original.getBytes());
return new String(Hex.encodeHex(md5Byte));
}
/**
* algorithm值为MD5时规则
*/
private static String HA1_MD5(String username, String realm, String password) {
return username + ":" + realm + ":" + password;
}
/**
* algorithm值为MD5-sess时规则
*/
private static String HA1_MD5_sess(String username, String realm, String password, String nonce, String cnonce) {
// MD5(username:realm:password):nonce:cnonce
String s = HA1_MD5(username, realm, password);
byte[] md5Byte = md5(s.getBytes());
String smd5 = new String(Hex.encodeHex(md5Byte));
return smd5 + ":" + nonce + ":" + cnonce;
}
private static String HA2(String method, String uri) {
return method + ":" + uri;
}
/**
* 对输入字符串进行md5散列.
*/
public static byte[] md5(byte[] input) {
return digest(input, "MD5", null, 1);
}
/**
* 对字符串进行散列, 支持md5与sha1算法.
*/
private static byte[] digest(byte[] input, String algorithm, byte[] salt, int iterations) {
try {
MessageDigest digest = MessageDigest.getInstance(algorithm);
if (salt != null) {
digest.update(salt);
}
byte[] result = digest.digest(input);
for (int i = 1; i < iterations; i++) {
digest.reset();
result = digest.digest(result);
}
return result;
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
}
/**
* 字符串中匹配字符串
* @param qopPattern
* @param str
* @return
*/
public static String getStr(Pattern qopPattern, String str){
Matcher matcher = qopPattern.matcher(str);
if (matcher.find()) {
return matcher.group(1);
} else {
return null;
}
}
/**
* 获取nonce
* @return
*/
public static String getNonce(int index) {
String base = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < index; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
}

139
device_cars/src/main/java/com/xr/device_car/config/utils/EasyExcelUtil.java

@ -1,139 +0,0 @@
package com.xr.device_car.config.utils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.RowWriteHandler;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.handler.context.RowWriteHandlerContext;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.api.R;
import com.xr.device_car.config.common.LocalDateConverter;
import com.xr.device_car.config.common.LocalDateTimeConverter;
import com.xr.device_car.modules.analysis.entity.xslx.SendUdpLogXslx;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @Author: ChenTaoTao
* @Date: 2022/3/19 16:51
* @Describe: 文件导出
*/
@Slf4j
public class EasyExcelUtil {
public static <T> void writeExcel(HttpServletResponse response, List<T> data, Class tClass, String name){
try {
List<Class> list=convertList(data,tClass);
String dateStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
name = name+dateStr;
//防止下载时中文乱码
name = new String(name.getBytes("UTF-8"), "ISO-8859-1");
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
//添加这个是防止前端拿不到Content-disposition
response.setHeader("Content-Disposition", "attachment;filename=" + name+".xlsx");
response.setHeader("Access-Control-Expose-Headers","Content-disposition");
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), tClass).autoCloseStream(Boolean.FALSE).sheet(name).registerConverter(new LocalDateConverter()).registerConverter(new LocalDateTimeConverter())
.registerWriteHandler(getCellStyleStrategy()).doWrite(list);
} catch (Exception e) {
log.error("文件导出失败,错误信息{}",e);
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
R r = R.failed("文件下载失败");
try {
response.getWriter().println(JSON.toJSONString(r));
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
private static HorizontalCellStyleStrategy getCellStyleStrategy() {
// 创建标题样式和内容样式
WriteCellStyle headerStyle = new WriteCellStyle();
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
WriteCellStyle contentStyle = new WriteCellStyle();
contentStyle.setBorderLeft(BorderStyle.THIN);
contentStyle.setBorderTop(BorderStyle.THIN);
contentStyle.setBorderRight(BorderStyle.THIN);
contentStyle.setBorderBottom(BorderStyle.THIN);
return new HorizontalCellStyleStrategy(headerStyle,contentStyle);
}
public static <T, S> List<S> convertList(List<T> list, Class<S> targetClass) throws NoSuchFieldException, IllegalAccessException, ParseException, NoSuchMethodException, InvocationTargetException, InstantiationException {
List<S> resultList = new ArrayList<>();
for (T sourceObj : list) {
S targetObj = targetClass.getDeclaredConstructor().newInstance();
Field[] sourceFields = sourceObj.getClass().getDeclaredFields();
Field[] targetFields = targetClass.getDeclaredFields();
for (Field sourceField : sourceFields) {
Field targetField = getField(targetFields, sourceField.getName());
if (targetField != null) {
sourceField.setAccessible(true);
targetField.setAccessible(true);
Object sourceValue = sourceField.get(sourceObj);
Object targetValue = convertFieldValue(sourceValue, targetField.getType(),sourceField.getType());
targetField.set(targetObj, targetValue);
}
}
resultList.add(targetObj);
}
return resultList;
}
private static Field getField(Field[] fields, String fieldName) {
for (Field field : fields) {
if (field.getName().equals(fieldName)) {
return field;
}
}
return null;
}
private static Object convertFieldValue(Object value, Class<?> targetType,Class<?> type1) throws ParseException {
if (type1 == String.class) {
return value.toString();
} else if (targetType == String.class && value instanceof Date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(value);
}
return value;
}
}

125
device_cars/src/main/java/com/xr/device_car/config/utils/FileUtil.java

@ -1,125 +0,0 @@
package com.xr.device_car.config.utils;
import org.springframework.core.io.ClassPathResource;
import java.io.*;
public class FileUtil {
/**
* 读取文件
*/
public static String fileReader(String url) throws IOException {
File file = new File(url);
StringBuilder result = new StringBuilder();
//构造一个BufferedReader类来读取文件
BufferedReader br = new BufferedReader(new FileReader(file));
String s = null;
//使用readLine方法,一次读一行
while ((s = br.readLine()) != null) {
result.append(s);
}
br.close();
return result.toString();
}
/**
* 读取文件
*/
public static String fileReader(ClassPathResource classPathResource ) {
InputStream fis= null;
ByteArrayOutputStream baos=null;
try {
fis = classPathResource.getInputStream();
byte[] buffer = new byte[1024];
baos = new ByteArrayOutputStream();
int len = 0;
while((len = fis.read(buffer)) != -1){
baos.write(buffer,0,len);
}
return baos.toString();
}catch (Exception e) {
// 未读取到数据
e.printStackTrace();
}finally {
try {
if(fis != null)fis.close();
if(baos != null)baos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//todo 未读取到数据
return null;
}
/**
* 写入数据
* @param path
* @param data
* @return
*/
public static boolean readInputStream(String path,byte[] data) {
//得到图片的二进制数据,以二进制封装得到数据,具有通用性
FileOutputStream outStream=null;
try {
//new一个文件对象用来保存图片,默认保存当前工程根目录
File imageFile = new File(path);
//创建输出流
outStream = new FileOutputStream(imageFile);
//写入数据
outStream.write(data);
return true;
} catch (Exception e) {
e.printStackTrace();
}finally {
//关闭输出流
if(outStream!= null) {
try {
outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return false;
}
/**
* 写入数据
* @param file
* @param data
* @return
*/
public static boolean readInputStream(File file,byte[] data) {
//得到图片的二进制数据,以二进制封装得到数据,具有通用性
FileOutputStream outStream=null;
try {
//创建输出流
outStream = new FileOutputStream(file);
//写入数据
outStream.write(data);
return true;
} catch (Exception e) {
e.printStackTrace();
}finally {
//关闭输出流
if(outStream!= null) {
try {
outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return false;
}
}

59
device_cars/src/main/java/com/xr/device_car/config/utils/Files.java

@ -8,15 +8,9 @@ import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Path;
import java.util.Base64;
import java.util.Date;
import java.util.Random;
import java.util.UUID;
public class Files {
@ -97,30 +91,6 @@ public class Files {
BufferedImage bimg= ImageIO.read(is2);
return bimg;
}
public static BufferedImage urlByImages(String url,String username,String password) throws IOException {
BufferedImage bimg=null;
try {
// 设置身份验证
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password.toCharArray());
}
});
// 创建URL对象并打开连接
URL uri = new URL(url);
URLConnection connection = uri.openConnection();
// 获取输入流
InputStream inputStream = connection.getInputStream();
bimg= ImageIO.read(inputStream);
// 关闭流
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
return bimg;
}
public static BufferedImage urlByImage(String url) throws IOException {
URL urlfile = new URL(url);
@ -293,35 +263,6 @@ public class Files {
return StaticPropUtil.imageUrl+rqImg;
}
public static File saveImageForPath(BufferedImage bufferedImage,String imgPath) throws Exception{
File file =new File(imgPath);
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
ImageIO.write(bufferedImage,"jpg",file);
return file;
}
public static String multipartFileToPath(MultipartFile file) throws IOException {
String fileName = StaticPropUtil.imagePath+file.getName();
File file1 = new File(fileName);
file.transferTo(file1);
fileName = fileName.replace("\\","\\\\");
return fileName;
}
public static String base64ToPath(String base64Image)throws IOException {
base64Image = base64Image.replaceFirst("data:image/[^;]+;base64,", "");
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
String fileName = StaticPropUtil.imagePath+ new Date().getTime()+ new Random().nextInt(9000)+1000+".png";
File dest = new File(fileName);
try (FileOutputStream fos = new FileOutputStream(dest)) {
fos.write(imageBytes);
}
fileName = fileName.replace("\\","\\\\");
return fileName;
}

52
device_cars/src/main/java/com/xr/device_car/config/utils/HkComUtil.java

@ -1,52 +0,0 @@
package com.xr.device_car.config.utils;
import com.xr.device_car.modules.analysis.entity.BallheadPT;
import com.xr.device_car.modules.analysis.entity.DeviceCamera;
import com.xr.device_car.modules.analysis.entity.OnvifAuthBean;
import com.xr.device_car.modules.analysis.entity.OnvifBean;
import org.springframework.util.CollectionUtils;
import java.awt.image.BufferedImage;
import java.util.List;
public class HkComUtil {
public static BufferedImage getBole(DeviceCamera device) throws Exception{ //拉取枪机图片
OnvifAuthBean onvifBean= new OnvifAuthBean(device.getDeviceIp(),80,device.getAccount(),device.getPassword());
String url= OnvifBean.getRequestUrl(onvifBean);
String auth = OnvifUtils.getAuthorization("digest",onvifBean,"digest/GetProfiles.wsdl", url);
System.out.println("鉴权:"+auth);
//获取Token
List<String> profileTokens = OnvifUtils.getProfileTokens(onvifBean,auth);
System.out.println("Token:"+profileTokens);
onvifBean.setAuth(auth);
if(!CollectionUtils.isEmpty(profileTokens)){
String snapshotUrl=null;
String token = profileTokens.get(0);
BallheadPT ballheadPT=OnvifUtils.getPtzStatus(token,onvifBean);
//如果类型是球机转换指定点位
if(device.getDeviceType().equals("3") && OnvifUtils.ptzCamera(token,onvifBean,device.getX(),device.getY(),device.getZ())){
Thread.sleep(1000);
//拉取图片
snapshotUrl = OnvifUtils.getSnapshotUrl(token,onvifBean);
if(snapshotUrl!=null){
//转回原来位置
OnvifUtils.ptzCamera(token,onvifBean,ballheadPT.getX(),ballheadPT.getY(),ballheadPT.getZ());
}
//如果类型是固定枪机,直接获取图片
}else{
snapshotUrl = OnvifUtils.getSnapshotUrl(token,onvifBean);
}
//返回图片地址
return Files.urlByImages(snapshotUrl,device.getAccount(),device.getPassword());
}
return null;
}
}

55
device_cars/src/main/java/com/xr/device_car/config/utils/HttpResponseBean.java

@ -1,55 +0,0 @@
package com.xr.device_car.config.utils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import java.util.List;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class HttpResponseBean {
private String body;
private List<Header> headers;
private Integer status;
/**
* 获取头部信息
* @param name
* @return
*/
public Header getFirstHeader(final String name) {
for (int i = 0; i < this.headers.size(); i++) {
final Header header = this.headers.get(i);
if (header.getName().equalsIgnoreCase(name)) {
return header;
}
}
return null;
}
/***
* 判断是否成功
*/
public static boolean isSuccess(HttpResponseBean httpResponseBean){
return httpResponseBean!= null && HttpStatus.SC_OK ==httpResponseBean.getStatus();
}
/***
* 判断是否是401
*/
public static boolean isUnAuthorzied(HttpResponseBean httpResponseBean){
return httpResponseBean!= null && HttpStatus.SC_UNAUTHORIZED ==httpResponseBean.getStatus();
}
public HttpResponseBean(String body) {
this.body = body;
}
}

72
device_cars/src/main/java/com/xr/device_car/config/utils/MinioUtil.java

@ -1,72 +0,0 @@
package com.xr.device_car.config.utils;
import io.minio.MinioClient;
import io.minio.errors.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import org.xmlpull.v1.XmlPullParserException;
import java.io.*;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;
public class MinioUtil {
private final static Logger log= LoggerFactory.getLogger(MinioUtil.class);
private static MinioClient minioClient;
private static MinioClient minioInit(){
try {
if(minioClient == null){
minioClient = new MinioClient(StaticPropUtil.minioUrl, StaticPropUtil.minioAccess, StaticPropUtil.minioSecret);
}
} catch (InvalidEndpointException e) {
throw new RuntimeException(e);
} catch (InvalidPortException e) {
throw new RuntimeException(e);
}
return minioClient;
}
public static String uploadMultipartFile(MultipartFile file) throws Exception {
MinioClient minioClient = minioInit();
InputStream is = file.getInputStream();
//使用uuid生成新的唯一文件名
String fileName = UUID.randomUUID().toString().replace("-", "") + file.getOriginalFilename();
//获取文件类型
String contentType = file.getContentType();//把文件放置Minio桶
minioClient.putObject("meter", fileName, is, contentType);
//获取访问路径
String url = minioClient.presignedGetObject("meter", fileName);
if (url != null) {
//返回路径不为空,即上传文件成功
return url.split("\\?")[0];
} else {
//上传失败
return"上传失败";
}
}
public static String uploadFile(File file) throws IOException, InvalidArgumentException, InvalidBucketNameException, InsufficientDataException, XmlPullParserException, ErrorResponseException, NoSuchAlgorithmException, NoResponseException, InvalidKeyException, InternalException, InvalidExpiresRangeException {
MinioClient minioClient = minioInit();
InputStream is = new FileInputStream(file);
//使用uuid生成新的唯一文件名
String fileName = UUID.randomUUID().toString().replace("-", "") + file.getName();
//获取文件类型
String contentType = fileName.substring(fileName.lastIndexOf(".")+1);//把文件放置Minio桶
minioClient.putObject("meter", fileName, is, contentType);
//获取访问路径
String url = minioClient.presignedGetObject("meter", fileName);
if (url != null) {
//返回路径不为空,即上传文件成功
return url.split("\\?")[0];
} else {
//上传失败
return"上传失败";
}
}
}

141
device_cars/src/main/java/com/xr/device_car/config/utils/OnvifUtils.java

@ -1,141 +0,0 @@
package com.xr.device_car.config.utils;
import com.xr.device_car.config.common.RESTClient;
import com.xr.device_car.modules.analysis.entity.BallheadPT;
import com.xr.device_car.modules.analysis.entity.DigestBean;
import com.xr.device_car.modules.analysis.entity.OnvifAuthBean;
import com.xr.device_car.modules.analysis.entity.OnvifBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StringUtils;
import java.util.List;
import static com.xr.device_car.config.common.Const.HEADERS_ONVIF_WWW_AUTHENTICATE;
public class OnvifUtils {
/**
* 获取鉴权
* @param authType
* @param requestOnvifBean
* @param wsdl
* @param requestUrl
* @return
*/
public static String getAuthorization(String authType, OnvifBean requestOnvifBean, String wsdl, String requestUrl) {
//参数
// 读取GetProfiles.wsdl
String getProfiles = FileUtil.fileReader(new ClassPathResource(wsdl));
HttpResponseBean httpResponseBean = RESTClient.getClientConnectionPool()
.postXML(requestUrl, getProfiles);
//如果是401的话 获取WWW-Authenticate 重新请求
if (HttpResponseBean.isUnAuthorzied(httpResponseBean)) {
DigestBean digestBean = new DigestBean().getDigestBean(authType,requestOnvifBean, httpResponseBean.getFirstHeader(HEADERS_ONVIF_WWW_AUTHENTICATE).getValue());
return digestBean.getToken();
}
return null;
}
/**
* 获取Token
* @param requestOnvifBean
* @param auth
* @return
*/
public static List<String> getProfileTokens(OnvifBean requestOnvifBean, String auth) {
//请求url
String requestUrl = OnvifBean.getRequestUrl(requestOnvifBean);
//参数
// 读取GetProfiles.wsdl
String getProfiles = FileUtil.fileReader(new ClassPathResource("digest/GetProfiles.wsdl"));
HttpResponseBean httpResponseBean = RESTClient.getClientConnectionPool()
.postXML(requestUrl, getProfiles,auth);
if(httpResponseBean != null) {
String resultStr = httpResponseBean.getBody();
if (HttpResponseBean.isSuccess(httpResponseBean) && StringUtils.hasLength(resultStr)) {
return AnalysisXml.analysisTokens(resultStr);
}
}
return null;
}
/**
* 获取截图地址
* @param profileToken token
* @param requestOnvifBean
* @return
*/
public static String getSnapshotUrl(String profileToken, OnvifAuthBean requestOnvifBean) {
String requestUrl = OnvifBean.getRequestUrl(requestOnvifBean);
//参数
// 读取GetProfiles.wsdl
String snapshotUrlWsdl = FileUtil.fileReader(new ClassPathResource("digest/GetSnapshotUrl.wsdl"));
HttpResponseBean httpResponseBean = RESTClient.getClientConnectionPool()
.postXML(requestUrl, String.format(snapshotUrlWsdl,profileToken),requestOnvifBean.getAuth());
String resultStr = httpResponseBean.getBody();
if(StringUtils.hasLength(resultStr) && HttpResponseBean.isSuccess(httpResponseBean)) {
return AnalysisXml.analysisSnapshotUrl(resultStr);
}
return null;
}
//绝对位置转动球机
public static boolean ptzCamera(String profileToken,OnvifAuthBean requestOnvifBean,String x,String y,String z){
String requestUrl = OnvifBean.getRequestUrl(requestOnvifBean);
String snapshotUrlWsdl = FileUtil.fileReader(new ClassPathResource("digest/AbsoluteMove.wsdl"));
String wsdl = String.format(snapshotUrlWsdl,profileToken,x,y,z);
HttpResponseBean httpResponseBean = RESTClient.getClientConnectionPool()
.postXML(requestUrl, wsdl,requestOnvifBean.getAuth());
String resultStr = httpResponseBean.getBody();
if(StringUtils.hasLength(resultStr) && HttpResponseBean.isSuccess(httpResponseBean)) {
return true;
}
return false;
}
//获取球机当前位置
public static BallheadPT getPtzStatus(String token,OnvifAuthBean requestOnvifBean){
String requestUrl = OnvifBean.getRequestUrl(requestOnvifBean);
String snap = FileUtil.fileReader(new ClassPathResource("digest/GetStatus.wsdl"));
String wsdl = String.format(snap,token);
HttpResponseBean httpResponseBean = RESTClient.getClientConnectionPool()
.postXML(requestUrl, wsdl,requestOnvifBean.getAuth());
String resultStr = httpResponseBean.getBody();
if(StringUtils.hasLength(resultStr) && HttpResponseBean.isSuccess(httpResponseBean)) {
return AnalysisXml.getStatus(resultStr);
}
return null;
}
//获取所有预置点
public static List<BallheadPT> getBallHeadPts(String profileToken,OnvifAuthBean requestOnvifBean){
String requestUrl = OnvifBean.getRequestUrl(requestOnvifBean);
String snapshotUrlWsdl = FileUtil.fileReader(new ClassPathResource("digest/GetPresets.wsdl"));
String wsdl = String.format(snapshotUrlWsdl,profileToken);
HttpResponseBean httpResponseBean = RESTClient.getClientConnectionPool()
.postXML(requestUrl, wsdl,requestOnvifBean.getAuth());
String resultStr = httpResponseBean.getBody();
if(StringUtils.hasLength(resultStr) && HttpResponseBean.isSuccess(httpResponseBean)) {
return AnalysisXml.getBallheadPTs(resultStr);
}
return null;
}
//前往指定预置点
public static boolean gotoBallHeadPts(String profileToken, OnvifAuthBean requestOnvifBean, BallheadPT ballheadPT){
String requestUrl = OnvifBean.getRequestUrl(requestOnvifBean);
String snapshotUrlWsdl = FileUtil.fileReader(new ClassPathResource("digest/GotoPreset.wsdl"));
String wsdl = String.format(snapshotUrlWsdl,profileToken,ballheadPT.getId());
HttpResponseBean httpResponseBean = RESTClient.getClientConnectionPool()
.postXML(requestUrl, wsdl,requestOnvifBean.getAuth());
String resultStr = httpResponseBean.getBody();
if(StringUtils.hasLength(resultStr) && HttpResponseBean.isSuccess(httpResponseBean)) {
return true;
}
return false;
}
}

231
device_cars/src/main/java/com/xr/device_car/config/utils/PythonExecutor.java

@ -1,231 +0,0 @@
package com.xr.device_car.config.utils;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xr.device_car.modules.analysis.entity.MeterInitialization;
import com.xr.device_car.modules.analysis.service.IMeterInitializationService;
import com.xr.device_car.modules.analysis.service.MeterConfigService;
import com.xr.device_car.modules.analysis.service.impl.MeterInitializationServiceImpl;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class PythonExecutor {
public static void main(String[] args) throws Exception {
try {
String pythonPath = StaticPropUtil.pythonPath;
ProcessBuilder processBuilder = new ProcessBuilder(pythonPath);
// 启动子进程
Process process = processBuilder.start();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
bw.write("import sys\n");
bw.write("sys.path.append(\"D:\\smartGrid\\smartGrid\\models\")\n");
bw.write("import indicatorLightStatus as ils\n");
bw.write("import switchRecognition as sr\n");
bw.write("import liquidLevel as ll\n");
bw.write("liquid_level_image_path = 'D:\\smartGrid\\smartGrid\\weights\\DIGITAL_METER (41).JPG'\n");
bw.write("ll.calculate_rgb_min_max([[112,\"D:\\smartGrid\\smartGrid\\weights\\DIGITAL_METER (41).JPG\"]])\n");
bw.write("print(\"Liquid level weights initialized.\")\n");
bw.write("liquid_level_image_path = 'D:\\smartGrid\\smartGrid\\weights\\DIGITAL_METER (10).JPG'\n");
bw.write("liquid_level = ll.calculate_liquid_level([112,liquid_level_image_path])\n");
bw.write("print(f\"Liquid level: {liquid_level}\")\n");
bw.close();
// 获取子进程的输出流
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
// 读取输出
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
// 等待进程执行完成
int exitCode = process.waitFor();
System.out.println("Exit Code: " + exitCode);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
private static boolean meterInit(String code) throws Exception {
String pythonPath = StaticPropUtil.pythonPath;
String modelPath = StaticPropUtil.modelPath;
ProcessBuilder processBuilder = new ProcessBuilder(pythonPath);
// 启动子进程
Process process = processBuilder.start();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
bw.write("import sys\n");
String imports = "sys.path.append(\"%s\")\n";
bw.write(String.format(imports, modelPath));
bw.write("import indicatorLightStatus as ils\n");
bw.write("import switchRecognition as sr\n");
bw.write("import liquidLevel as ll\n");
bw.write(code);
bw.write("print(\"success\")\n");
bw.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
List<String> list = new ArrayList<>();
String line;
// 读取输出
while ((line = reader.readLine()) != null) {
list.add(line);
System.out.println(line);
}
BufferedReader exception = new BufferedReader(new InputStreamReader(process.getErrorStream()));
List<String> list1 = new ArrayList<>();
String line1;
// 读取输出
while ((line1 = exception.readLine()) != null) {
list1.add(line1);
System.out.println(line1);
}
// 等待进程执行完成
int exitCode = process.waitFor();
System.out.println("Exit Code: " + exitCode);
if (list.contains("success") && list1.isEmpty()) {
return true;
}
return false;
}
/**
* 初始化算法
* id 表计配置ID
* sfType 4 灯光 3 开关 5 液位计
*/
public static boolean meterInit(Integer id, String sfType) throws Exception {
IMeterInitializationService meterInitializationService = SpringUtil.getBean(MeterInitializationServiceImpl.class);
QueryWrapper<MeterInitialization> query = new QueryWrapper<>();
query.eq("meter_id", id);
query.orderByAsc("serial");
List<MeterInitialization> list = meterInitializationService.list(query);
List<String> path = list.stream().map(n -> n.getImgAddress()).collect(Collectors.toList());
String ph = "";
for (String str : path) {
str = str.replace("\\", "\\\\");
ph += "\"" + str + "\"" + ",";
}
ph = ph.substring(0, ph.length() - 1);
String code = "";
if (sfType.equals("4")) {
List<List<Object>> list1 = new ArrayList<>();
List<Object> list2 = new ArrayList<>();
list2.add(id);
List<String> list3 = new ArrayList<>();
list3.add(ph);
list2.add(list3);
list1.add(list2);
code = "ils.calculate_luminance_threshold(" + Arrays.toString(list1.toArray()) + ")\n";
}
if (sfType.equals("3")) {
List<String> list1 = new ArrayList<>();
path.add(0, id + "");
list1.add(ph);
code = "sr.initialize(" + Arrays.toString(list1.toArray()) + ")\n";
}
if (sfType.equals("5")) {
List<String> list1 = new ArrayList<>();
// list1.add(id.toString());
//path.add(0, id + "");
list1.add(ph);
// String params = String.join( list1);
//Arrays.toString(list1.toArray())
code = "ll.calculate_rgb_min_max("+"[["+id+ ","+ ph +"]]"+")\n";
}
return meterInit(code);
}
/**
* 读取结果
* id 表计id
* path 图片路径
* sfType 1 灯光 2 开关 3 液位计 4 指针
*/
public static String readNumber(Integer id, String path, String sfType) throws Exception {
String pythonPath = StaticPropUtil.pythonPath;
String modelPath = StaticPropUtil.modelPath;
ProcessBuilder processBuilder = new ProcessBuilder(pythonPath);
// 启动子进程
Process process = processBuilder.start();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
bw.write("import sys\n");
String imports = "sys.path.append(\"%s\")\n";
bw.write(String.format(imports, modelPath));
bw.write("import indicatorLightStatus as ils\n");
bw.write("import switchRecognition as sr\n");
bw.write("import liquidLevel as ll\n");
bw.write("indicator_light_image_path = '" + path + "'\n");
if (sfType.equals("4")) {
bw.write("value = ils.check_indicator_light_status(" + id + ",indicator_light_image_path)\n");
}
if (sfType.equals("3")) {
bw.write("value = sr.read_numbers(" + id + ",indicator_light_image_path)\n");
}
if (sfType.equals("5")) {
bw.write("value = ll.calculate_liquid_level([" + id + ",indicator_light_image_path,\"down\"])\n");
}
if (sfType.equals("0")) {
bw.write("rotate_angle, value = pr.getPointerAngleAndNum(" + id + ", indicator_light_image_path)\n");
}
bw.write("print(f\"value:{value}\")");
bw.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
List<String> list = new ArrayList<>();
String line;
// 读取输出
while ((line = reader.readLine()) != null) {
list.add(line);
}
BufferedReader exception = new BufferedReader(new InputStreamReader(process.getErrorStream()));
List<String> list1 = new ArrayList<>();
String line1;
// 读取输出
while ((line1 = exception.readLine()) != null) {
list.add(line1);
}
// if(list.contains("value")){
// String value = list.get(list.indexOf("value")).split(":")[1];
// File file = new File(path);
// if(file.exists()){
// file.delete();
// }
// return value;
// }
for (String element : list) {
if (element.contains("value")) {
String[] parts = element.split(":");
File file = new File(path);
if (file.exists()) {
file.delete();
}
if (parts.length > 1) {
String result = parts[1].trim();
return result;
}
}
}
return null;
}
}

21
device_cars/src/main/java/com/xr/device_car/config/utils/StaticPropUtil.java

@ -8,30 +8,9 @@ public class StaticPropUtil {
public static String imageUrl;
public static String pythonPath;
public static String modelPath;
public static String minioUrl;
public static String minioAccess;
public static String minioSecret;
public static String udpHost;
public static Integer udpPort;
public static void initDingDingProp(StaticProperties dingProperties){
imagePath = dingProperties.getPath();
imageUrl = dingProperties.getUrl();
pythonPath=dingProperties.getPythonPath();
modelPath=dingProperties.getModelPath();
minioUrl=dingProperties.getMinioUrl();
minioAccess=dingProperties.getMinioAccess();
minioSecret=dingProperties.getMinioSecret();
udpHost=dingProperties.getUdpHost();
udpPort=dingProperties.getUdpPort();
}
}

9
device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/DeviceCameraController.java

@ -80,15 +80,6 @@ public class DeviceCameraController {
if (StringUtils.isNotBlank(deviceCamera.getDeviceIp())) {
wrapper.like("device_ip", deviceCamera.getDeviceIp());
}
// 算法类型
if (StringUtils.isNotBlank(deviceCamera.getAlgorithmType()) && !deviceCamera.getAlgorithmType().equals("")){
if (deviceCamera.getAlgorithmType().equals("3")){
wrapper.in("device_type",3,4);
}else {
wrapper.in("device_type",1,2);
}
}
IPage<DeviceCamera> deviceCameraList = deviceCameraService.page(pg, wrapper);
System.out.println(deviceCameraList);
return Result.OK(deviceCameraList);

55
device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/FocalLengthConfigController.java

@ -3,24 +3,22 @@ package com.xr.device_car.modules.analysis.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xr.device_car.config.common.Result;
import com.xr.device_car.config.utils.*;
import com.xr.device_car.config.utils.AdbUtil;
import com.xr.device_car.config.utils.Files;
import com.xr.device_car.config.utils.UserUtils;
import com.xr.device_car.modules.analysis.entity.DeviceCamera;
import com.xr.device_car.modules.analysis.entity.FocalLengthConfig;
import com.xr.device_car.modules.analysis.entity.MeterConfig;
import com.xr.device_car.modules.analysis.entity.MeterType;
import com.xr.device_car.modules.analysis.scheduled.TaskScheduler;
import com.xr.device_car.modules.analysis.service.DeviceCameraService;
import com.xr.device_car.modules.analysis.service.FocalLengthConfigService;
import com.xr.device_car.modules.analysis.service.MeterConfigService;
import com.xr.device_car.modules.analysis.service.MeterTypeService;
import com.xr.device_car.modules.system.entity.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
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.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -44,9 +42,6 @@ public class FocalLengthConfigController {
private MeterConfigService meterConfigService;
@Autowired
private DeviceCameraService deviceCameraService;
@Autowired
private MeterTypeService meterTypeService;
@Autowired
private TaskScheduler taskScheduler;
@ -100,10 +95,8 @@ public class FocalLengthConfigController {
String deviceType="";
if(device.getDeviceType().equals("1")){
deviceType="usb";
}else if(device.getDeviceType().equals("2")){
deviceType="mipi";
}else{
return Result.OK("保存成功!");
deviceType="mipi";
}
file.createNewFile();
StringBuffer stringBuffer = new StringBuffer();
@ -212,15 +205,14 @@ public class FocalLengthConfigController {
@RequestMapping("/addFocalLength")
public Result<?> addFocalLength(FocalLengthConfig focalLengthConfig) throws Exception {
UserInfo userInfo= UserUtils.currentUser();
MeterConfig meterConfig=meterConfigService.getById(focalLengthConfig.getConfigId());
DeviceCamera deviceCamera = deviceCameraService.getById(meterConfig.getCameraId());
BufferedImage bufferedImage=null;
if(deviceCamera.getDeviceType().equals("1")|| deviceCamera.getDeviceType().equals("2")){
bufferedImage= AdbUtil.getCamDevice();
}
if(deviceCamera.getDeviceType().equals("3") || deviceCamera.getDeviceType().equals("4")){ // 拉取球机
bufferedImage= HkComUtil.getBole(deviceCamera);
}
// MeterConfig meterConfig=meterConfigService.getById(focalLengthConfig.getConfigId());
// DeviceCamera deviceCamera = deviceCameraService.getById(meterConfig.getCameraId());
BufferedImage bufferedImage= AdbUtil.getCamDevice();
// if(deviceCamera.getDeviceType().equals("1")){
// bufferedImage=taskScheduler.getImgBySerial(deviceCamera);
// }else{
// bufferedImage=taskScheduler.getImgByInternet(deviceCamera);
// }
byte [] bytes= Files.bufferedImageToByte(bufferedImage);
focalLengthConfig.setFocalPicture(bytes);
focalLengthConfig.setCreateTime(new Date());
@ -366,27 +358,4 @@ public class FocalLengthConfigController {
return null;
}
/**
* AI识别测试
* Param file 截图文件
* Param id 表计编号
* */
@RequestMapping("/testRecognition")
public Result<?> testRecognition(@RequestParam("base64Image") String base64Image,@RequestParam("id") Integer id){
Result result = new Result();
String readValue= null;
try{
MeterConfig meter = meterConfigService.getById(id);
MeterType type = meterTypeService.getById(meter.getTypeId());
// String path = Files.multipartFileToPath(file);
String path = Files.base64ToPath(base64Image);
readValue = PythonExecutor.readNumber(id,path,type.getMeterShape());
}catch (Exception e){
e.printStackTrace();
return Result.error(e.getMessage());
}
return result.OK(readValue);
}
}

38
device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterConfigController.java

@ -6,14 +6,12 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xr.device_car.config.common.Result;
import com.xr.device_car.config.udp.UdbConfig;
import com.xr.device_car.config.utils.*;
import com.xr.device_car.modules.analysis.entity.*;
import com.xr.device_car.modules.analysis.scheduled.TaskScheduler;
import com.xr.device_car.modules.analysis.service.*;
import com.xr.device_car.modules.analysis.vo.MeterMaxMinSaveVo;
import com.xr.device_car.modules.system.entity.UserInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -34,7 +32,6 @@ import java.util.List;
@RestController
@RequestMapping("analysis/meterConfig")
@RequiredArgsConstructor
public class MeterConfigController {
private final MeterConfigService meterConfigService;
@ -49,7 +46,17 @@ public class MeterConfigController {
private final IScheduleSettingService scheduleSettingService;
private final UdpClientService udpClientService;
@Autowired
public MeterConfigController(MeterConfigService meterConfigService,DeviceCameraService deviceCameraService,
MeterTypeService meterTypeService,FocalLengthConfigService focalLengthConfigService,
TaskScheduler taskScheduler,IScheduleSettingService scheduleSettingService){
this.meterConfigService=meterConfigService;
this.deviceCameraService=deviceCameraService;
this.meterTypeService=meterTypeService;
this.focalLengthConfigService=focalLengthConfigService;
this.taskScheduler=taskScheduler;
this.scheduleSettingService=scheduleSettingService;
}
@RequestMapping("/getMeterConfigPage")
public IPage<MeterConfig> getMeterConfigPage(MeterConfig meterConfig, HttpServletRequest req){
@ -61,11 +68,8 @@ public class MeterConfigController {
if(StringUtils.isNotEmpty(meterConfig.getDeviceType())){
query.like("a.device_type",meterConfig.getDeviceType());
}
if(StringUtils.isNotEmpty(meterConfig.getDeviceType())){
query.like("a.device_type",meterConfig.getDeviceType());
}
if(StringUtils.isNotEmpty(meterConfig.getAlgorithmType())){
query.like("a.algorithm_type",meterConfig.getAlgorithmType());
if(StringUtils.isNotEmpty(meterConfig.getDeviceName())){
query.like("a.device_name",meterConfig.getDeviceName());
}
if(StringUtils.isNotEmpty(meterConfig.getTypeId())){
query.eq("a.type_id",meterConfig.getTypeId());
@ -253,20 +257,4 @@ public class MeterConfigController {
}
//同步配置文件到udp主机
@RequestMapping("/sendSynchronizationUdp")
public Result<?> sendSynchronizationUdp(){
try{
QueryWrapper<MeterConfig> query=new QueryWrapper<>();
query.eq("status",1);
List<MeterConfig> list = meterConfigService.list(query);
String sendMsg = UdbConfig.getUdbConfig(list);
udpClientService.sendData(sendMsg);
}catch (Exception e){
e.printStackTrace();
return Result.OK("同步失败!");
}
return Result.OK("同步成功!");
}
}

177
device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterInitializationController.java

@ -1,177 +0,0 @@
package com.xr.device_car.modules.analysis.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xr.device_car.config.common.Result;
import com.xr.device_car.config.utils.*;
import com.xr.device_car.modules.analysis.entity.DeviceCamera;
import com.xr.device_car.modules.analysis.entity.MeterConfig;
import com.xr.device_car.modules.analysis.entity.MeterInitialization;
import com.xr.device_car.modules.analysis.entity.MeterType;
import com.xr.device_car.modules.analysis.service.DeviceCameraService;
import com.xr.device_car.modules.analysis.service.IMeterInitializationService;
import com.xr.device_car.modules.analysis.service.MeterConfigService;
import com.xr.device_car.modules.analysis.service.MeterTypeService;
import io.minio.MinioClient;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.InputStream;
import java.util.*;
import java.awt.image.BufferedImage;
/**
* <p>
* 表计算法初始化 前端控制器
* </p>
*
* @author gaoby
* @since 2023-11-20
*/
@RestController
@RequestMapping("/meterInitialization")
@RequiredArgsConstructor
public class MeterInitializationController {
@Value("${upLoad.file}")
private String uploadDir;
private final MeterConfigService meterConfigService;
private final DeviceCameraService deviceCameraService;
private final IMeterInitializationService iMeterInitializationService;
private final MeterTypeService meterTypeService;
@PostMapping("pullImages")
public Result<?> pullImages(MeterInitialization meterInitialization){
MeterConfig config=meterConfigService.getById(meterInitialization.getMeterId());
DeviceCamera deviceCamera = deviceCameraService.getById(config.getCameraId());
BufferedImage bufferedImage=null;
try {
if(deviceCamera.getDeviceType().equals("1")|| deviceCamera.getDeviceType().equals("2")){
bufferedImage= AdbUtil.getCamDevice();
}
if(deviceCamera.getDeviceType().equals("3") || deviceCamera.getDeviceType().equals("4")){ // 拉取球机
bufferedImage= HkComUtil.getBole(deviceCamera);
}
long l = new Date().getTime();
String path = StaticPropUtil.imagePath +l+".png";
File file=Files.saveImageForPath(bufferedImage,path);
String url = MinioUtil.uploadFile(file);
QueryWrapper<MeterInitialization> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("meter_id",meterInitialization.getMeterId());
queryWrapper.orderByDesc("serial");
List<MeterInitialization> meterInitialization1=iMeterInitializationService.list(queryWrapper);
MeterInitialization meterInitialization2 = getMeterInitialization(meterInitialization, meterInitialization1, path,url);
iMeterInitializationService.save(meterInitialization2);
}catch (Exception e){
e.printStackTrace();
return Result.error(e.getMessage());
}
return Result.OK("拉取成功!");
}
private static MeterInitialization getMeterInitialization(MeterInitialization meterInitialization, List<MeterInitialization> meterInitialization1, String path,String url) {
MeterInitialization meterInitialization2=new MeterInitialization();
meterInitialization2.setMeterId(meterInitialization.getMeterId());
if(meterInitialization1.isEmpty()){
meterInitialization2.setSerial(0);
}else{
meterInitialization2.setSerial(meterInitialization1.get(0).getSerial()+1);
}
meterInitialization2.setValue(meterInitialization.getValue());
meterInitialization2.setImgAddress(path);
meterInitialization2.setImg(url);
return meterInitialization2;
}
@PostMapping("/uploadImg")
public Result<?> uploadImg(@RequestParam("imgFile") MultipartFile imgFile,@RequestParam("value") String value,@RequestParam("serial") String serial,@RequestParam("meterId") String meterId) throws Exception {
if (!imgFile.isEmpty()) {
// 获取文件名
String fileName = Objects.requireNonNull(imgFile.getOriginalFilename());
File folder = new File(StaticPropUtil.imagePath);
// 检查文件夹是否存在,如果不存在就创建它
if (!folder.exists()) {
folder.mkdirs(); // 创建文件夹及其父文件夹(如果不存在)
}
// 构建上传路径
String filePath = StaticPropUtil.imagePath + File.separator + fileName;
String imgAddress = StaticPropUtil.imagePath + fileName;
// 保存文件
File dest = new File(filePath);
imgFile.transferTo(dest);
// 上传至minIo服务器
String url = MinioUtil.uploadMultipartFile(imgFile);
if (url.equals("上传失败")){
Result.error("图片上传至服务器异常");
}
MeterInitialization meterInitialization = new MeterInitialization();
meterInitialization.setImg(url);
meterInitialization.setImgAddress(imgAddress);
meterInitialization.setMeterId(Integer.valueOf(meterId));
meterInitialization.setSerial(Integer.valueOf(serial));
meterInitialization.setValue(value);
QueryWrapper<MeterInitialization> wrapper = new QueryWrapper<>();
wrapper.eq("meter_id",meterInitialization.getMeterId());
iMeterInitializationService.save(meterInitialization);
return Result.OK("上传成功!");
}
return Result.error("上传图片异常,请联系管理员");
}
@PostMapping(value = "/queryPageList")
public Result<?> queryPageList(MeterInitialization meterInitialization, HttpServletRequest req)throws Exception{
// Page<MeterInitialization> pg = StringFormatterUtil.returnPage(req);
QueryWrapper<MeterInitialization> wrapper = StringFormatterUtil.returnQuery(req);
// meterId
if (ObjectUtil.isNotEmpty(meterInitialization.getMeterId())){
wrapper.eq("meter_id",meterInitialization.getMeterId());
}
wrapper.orderByAsc("serial");
List<MeterInitialization> meterInitializationList = iMeterInitializationService.list(wrapper);
return Result.OK(meterInitializationList);
}
@PostMapping(value = "/delImg")
public Result<?> delImg(Integer id) throws Exception {
iMeterInitializationService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 初始化算法
*/
@PostMapping("initMeter")
public Result<?> initMeter(Integer meterId){
try{
MeterConfig meterConfig=meterConfigService.getById(meterId);
MeterType meterType = meterTypeService.getById(meterConfig.getTypeId());
if(PythonExecutor.meterInit(meterId,meterType.getMeterShape())){
meterConfig.setInitStatus("1");
meterConfigService.updateById(meterConfig);
}else{
return Result.error("初始化失败");
}
}catch (Exception e){
e.printStackTrace();
return Result.error(e.getMessage());
}
return Result.OK("初始化完成");
}
}

72
device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/SendUdpLogController.java

@ -1,72 +0,0 @@
package com.xr.device_car.modules.analysis.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xr.device_car.config.utils.EasyExcelUtil;
import com.xr.device_car.config.utils.StringFormatterUtil;
import com.xr.device_car.modules.analysis.entity.SendUdpLog;
import com.xr.device_car.modules.analysis.entity.xslx.SendUdpLogXslx;
import com.xr.device_car.modules.analysis.service.SendUdpLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
@RestController
@RequestMapping("/udpLog")
@RequiredArgsConstructor
public class SendUdpLogController {
private final SendUdpLogService sendUdpLogService;
@RequestMapping("/pageList")
public IPage<SendUdpLog> pageList(SendUdpLog sendUdpLog, HttpServletRequest req){
Page<SendUdpLog> page = StringFormatterUtil.returnPage(req);
QueryWrapper<SendUdpLog> query=new QueryWrapper<>();
if(!sendUdpLog.getMessageId().isEmpty()){
query.eq("message_id", sendUdpLog.getMessageId());
}
if(sendUdpLog.getStartDate()!=null){
query.ge("request_time", sendUdpLog.getStartDate());
}
if(sendUdpLog.getEndDate()!=null){
query.lt("request_time", sendUdpLog.getEndDate());
}
query.orderByDesc("request_time");
return sendUdpLogService.page(page,query);
}
@RequestMapping("/downloadExcel")
public void downloadExcel(@RequestBody String data,HttpServletResponse res){
System.out.println(data);
Map<String,Object> object = (Map<String, Object>) JSONObject.parse(data);
SendUdpLog sendUdpLog = JSONObject.parseObject(data,SendUdpLog.class);
List<String> list = (List<String>) object.get("ids");
List<SendUdpLog> sendUdpLogs =new ArrayList<>();
if(list.isEmpty()){
QueryWrapper<SendUdpLog> query=new QueryWrapper<>();
if(!sendUdpLog.getMessageId().isEmpty()){
query.eq("message_id", sendUdpLog.getMessageId());
}
if(sendUdpLog.getStartDate()!=null){
query.ge("request_time", sendUdpLog.getStartDate());
}
if(sendUdpLog.getEndDate()!=null){
query.lt("request_time", sendUdpLog.getEndDate());
}
sendUdpLogs = sendUdpLogService.list(query);
}else{
sendUdpLogs = sendUdpLogService.listByIds(list);
}
EasyExcelUtil.writeExcel(res,sendUdpLogs,SendUdpLogXslx.class,"UDP日志");
}
}

17
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/BallheadPT.java

@ -1,17 +0,0 @@
package com.xr.device_car.modules.analysis.entity;
import lombok.Data;
@Data
public class BallheadPT {
private String id;
private String name;
private String x;
private String y;
private String z;
}

23
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DeviceCamera.java

@ -37,7 +37,7 @@ public class DeviceCamera implements Serializable {
private String deviceNo;
/**
* 类型(1 usb 2 mipi 3 球机 4 枪机)
* 类型(1 usb 2 mipi)
*/
@ExcelProperty(value = "类型")
private String deviceType;
@ -54,22 +54,6 @@ public class DeviceCamera implements Serializable {
@ExcelProperty(value = "端口")
private String devicePort;
/**
* 账号
*/
private String account;
/**
* 密码
*/
private String password;
private String x;
private String y;
private String z;
/**
* 摄像头型号
*/
@ -140,9 +124,4 @@ public class DeviceCamera implements Serializable {
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
* 算法类型
*/
@TableField(exist = false)
private String algorithmType;
}

120
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DigestBean.java

@ -1,120 +0,0 @@
package com.xr.device_car.modules.analysis.entity;
import com.xr.device_car.config.common.Const;
import com.xr.device_car.config.utils.DigestsUtils;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.regex.Pattern;
@Data
public class DigestBean {
/**
* 用户名
*/
private String username;
/**
* 服务端401返回的 名称
*/
private String realm;
/**
* auth
*/
private String qop;
/**
* 加密方式 一般情况下是MD5
*/
private String algorithm="MD5";
/**
*路径
*/
private String uri="/onvif/media_service";
/***
* 服务端401返回的
*/
private String nonce;
/**
* 16进制请求认证计数器,第一次 00000001
*/
private String nc="00000001";
/**
* 客户端密码随机数
*/
private String cnonce;
/**
* 默认为空
*/
private String opaque="";
/**
* http_da_calc_HA1 获取的
*/
private String response;
/**
* 获取DigestBean对象
* @param onvifBean
* @param value
* @return
*/
public DigestBean getDigestBean(String authType,OnvifBean onvifBean, String value){
this.setUsername(onvifBean.getUserName());
// Digest realm="Login to a81d6710d0de6749fcdba591802e3864",qop="auth",nonce="b252aWYtZGlnZXN0OjQzNDIyNTEwNTQw", opaque="", stale="false"
//正则匹配
this.setRealm(DigestsUtils.getStr(Pattern.compile("realm=\"(.*?)\""),value));
this.setQop(DigestsUtils.getStr(Pattern.compile("qop=\"(.*?)\""),value));
this.setNonce(DigestsUtils.getStr(Pattern.compile("nonce=\"(.*?)\""),value));
this.setCnonce(DigestsUtils.getNonce(32));
if("None".equalsIgnoreCase(authType)) {
this.setResponse(getResponseHA1NoAuth(this, onvifBean.getPassWord()));
}else {
this.setResponse(getResponseHA1Auth(this, onvifBean.getPassWord()));
}
return this;
}
/**
* 获取Response
* @param pwd
* @return
*/
private static String getResponseHA1Auth(DigestBean digestBean,String pwd){
return getResponseHA1(digestBean,pwd,"","POST");
}
/**
* 获取Response
* @param pwd
* @return
*/
private static String getResponseHA1NoAuth(DigestBean digestBean,String pwd){
return getResponseHA1(digestBean,pwd,"","GET");
}
/**
* 获取Response
* @param pwd
* @return
*/
private static String getResponseHA1(DigestBean digestBean,String pwd,String uri,String method){
return DigestsUtils.http_da_calc_HA1(digestBean.getUsername(), digestBean.getRealm(), pwd,
digestBean.getNonce(), String.valueOf(digestBean.getNc()), digestBean.getCnonce(), digestBean.getQop(),
method, StringUtils.hasLength(uri)?uri:digestBean.getUri(), "MD5");
}
/**
* 获取token
* @return
*/
public String getToken(){
return String.format(Const.EQUEST_ONVIF_TOKEN,this.username, this.realm,
this.qop,this.algorithm,this.uri,this.nonce, String.valueOf(this.nc),
this.cnonce,this.opaque,this.response);
}
}

15
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterConfig.java

@ -84,9 +84,9 @@ public class MeterConfig implements Serializable {
private Date firstTime;
/**
* 算法类型 1usb2mipi 3内部算法
* 焦距类型 1定焦2变焦
*/
private String algorithmType;
private String focalLength;
/**
* 执行间隔时间
@ -123,11 +123,6 @@ public class MeterConfig implements Serializable {
*/
private String remarks;
/**
* 初始化状态
*/
private String initStatus;
/**
* 创建人
*/
@ -181,7 +176,7 @@ public class MeterConfig implements Serializable {
&& (this.getTypeId() == null ? other.getTypeId() == null : this.getTypeId().equals(other.getTypeId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getFirstTime() == null ? other.getFirstTime() == null : this.getFirstTime().equals(other.getFirstTime()))
&& (this.getAlgorithmType() == null ? other.getAlgorithmType() == null : this.getAlgorithmType().equals(other.getAlgorithmType()))
&& (this.getFocalLength() == null ? other.getFocalLength() == null : this.getFocalLength().equals(other.getFocalLength()))
&& (this.getIntervalTime() == null ? other.getIntervalTime() == null : this.getIntervalTime().equals(other.getIntervalTime()))
&& (this.getFocalNumber() == null ? other.getFocalNumber() == null : this.getFocalNumber().equals(other.getFocalNumber()))
&& (this.getParameterConfig() == null ? other.getParameterConfig() == null : this.getParameterConfig().equals(other.getParameterConfig()))
@ -208,7 +203,7 @@ public class MeterConfig implements Serializable {
result = prime * result + ((getTypeId() == null) ? 0 : getTypeId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getFirstTime() == null) ? 0 : getFirstTime().hashCode());
result = prime * result + ((getAlgorithmType() == null) ? 0 : getAlgorithmType().hashCode());
result = prime * result + ((getFocalLength() == null) ? 0 : getFocalLength().hashCode());
result = prime * result + ((getIntervalTime() == null) ? 0 : getIntervalTime().hashCode());
result = prime * result + ((getFocalNumber() == null) ? 0 : getFocalNumber().hashCode());
result = prime * result + ((getParameterConfig() == null) ? 0 : getParameterConfig().hashCode());
@ -238,7 +233,7 @@ public class MeterConfig implements Serializable {
sb.append(", typeId=").append(typeId);
sb.append(", status=").append(status);
sb.append(", firstTime=").append(firstTime);
sb.append(", algorithmType=").append(algorithmType);
sb.append(", focalLength=").append(focalLength);
sb.append(", intervalTime=").append(intervalTime);
sb.append(", focalNumber=").append(focalNumber);
sb.append(", parameterConfig=").append(parameterConfig);

53
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterInitialization.java

@ -1,53 +0,0 @@
package com.xr.device_car.modules.analysis.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 表计算法初始化
* </p>
*
* @author gaoby
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class MeterInitialization implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 请求图片路径
*/
private String img;
/**
* 盘符路径
*/
private String imgAddress;
/**
* 常量值
*/
private String value;
/**
* 表计id
*/
private Integer meterId;
private Integer Serial;
}

2
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterReadingRecord.java

@ -34,8 +34,6 @@ public class MeterReadingRecord implements Serializable {
private String readingType;
private String dataType;
/**
* 表计类型id
*/

32
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifAuthBean.java

@ -1,32 +0,0 @@
package com.xr.device_car.modules.analysis.entity;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class OnvifAuthBean extends OnvifBean {
/**
* 自定义参数
*/
private String auth;
public OnvifAuthBean(String ip, Integer port, String userName, String passWord, String profileToken, String auth) {
super(ip, port, userName, passWord);
this.auth = auth;
}
public OnvifAuthBean(String ip, Integer port, String userName, String passWord) {
super(ip, port, userName, passWord);
}
public void setAuth(String auth){
this.auth=auth;
}
public String getAuth(){
return this.auth;
}
}

53
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifBean.java

@ -1,53 +0,0 @@
package com.xr.device_car.modules.analysis.entity;
import com.xr.device_car.config.common.Const;
import lombok.Data;
@Data
public class OnvifBean {
private String ip;
private Integer port;
private String userName;
private String passWord;
private String x;
private String y;
private String z;
public static String getRequestUrl(OnvifBean requestOnvifBean) {
return String.format(Const.REQUEST_ONVIF_URL,requestOnvifBean.getIp(),requestOnvifBean.getPort());
}
public static String getPTZUrl(OnvifBean requestOnvifBean){
return String.format(Const.ABSOLUTE_MOVE,requestOnvifBean.getIp(),requestOnvifBean.getPort());
}
public static String getPTZ(OnvifBean requestOnvifBean){
return String.format(Const.PTZ_MOVE,requestOnvifBean.getIp(),requestOnvifBean.getPort());
}
public OnvifBean(String ip, Integer port) {
this.ip = ip;
this.port = port;
}
public OnvifBean(String ip, Integer port,String userName,String passWord) {
this.ip = ip;
this.port = port;
this.userName=userName;
this.passWord=passWord;
}
}

38
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifCredentials.java

@ -1,38 +0,0 @@
package com.xr.device_car.modules.analysis.entity;
import lombok.Data;
/**
* onvif 连接信息
* @author zf
*/
@Data
public class OnvifCredentials {
/**
* 92.168.xx.yy, or http://host[:port]
*/
private String host;
/**
* admin
*/
private String user;
/**
* secret
*/
private String password;
/**
* "MediaProfile000" If empty, will use first profile.
*/
private String profile;
public OnvifCredentials(String host, String user, String password, String profile) {
this.host = host;
this.user = user;
this.password = password;
this.profile = profile;
}
public String details() {
return host + "," + user + "," + password + "," + profile;
}
}

68
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/SendUdpLog.java

@ -1,68 +0,0 @@
package com.xr.device_car.modules.analysis.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xr.device_car.config.common.LocalDateTimeConverter;
import lombok.Data;
/**
* udb消息日志表
* @TableName send_udb_log
*/
@TableName(value ="send_udp_log")
@Data
public class SendUdpLog implements Serializable {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 消息主键
*/
private String messageId;
/**
* 发送状态(0成功1失败)
*/
private String requestStatus;
/**
* 发送报文
*/
private String requestMsg;
/**
* 发送时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date requestTime;
/**
* 接收报文
*/
private String resMsg;
/**
* 返回时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date resTime;
@TableField(exist = false)
private Date startDate;
@TableField(exist = false)
private Date endDate;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

68
device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/xslx/SendUdpLogXslx.java

@ -1,68 +0,0 @@
package com.xr.device_car.modules.analysis.entity.xslx;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xr.device_car.modules.analysis.entity.SendUdpLog;
import lombok.Data;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
* udb消息日志表
* @TableName send_udb_log
*/
@TableName(value ="send_udp_log")
@Data
public class SendUdpLogXslx implements Serializable {
/**
* 消息主键
*/
@ExcelProperty(value = "消息主键")
private String messageId;
/**
* 发送状态(0成功1失败)
*/
@ExcelProperty(value="发送状态")
private String requestStatus;
/**
* 发送报文
*/
@ExcelProperty(value="发送报文")
private String requestMsg;
/**
* 发送时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value="发送时间")
private String requestTime;
/**
* 接收报文
*/
@ExcelProperty(value="接收报文")
private String resMsg;
/**
* 返回时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value="返回时间")
private String resTime;
public String getRequestStatus(){
if(this.requestStatus.equals("0")){
return "成功";
}
return "失败";
}
}

20
device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/MeterInitializationMapper.java

@ -1,20 +0,0 @@
package com.xr.device_car.modules.analysis.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.xr.device_car.modules.analysis.entity.MeterInitialization;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 表计算法初始化 Mapper 接口
* </p>
*
* @author gaoby
* @since 2023-11-20
*/
@DS("db2")
@Mapper
public interface MeterInitializationMapper extends BaseMapper<MeterInitialization> {
}

20
device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/SendUdpLogMapper.java

@ -1,20 +0,0 @@
package com.xr.device_car.modules.analysis.mapper;
import com.xr.device_car.modules.analysis.entity.SendUdpLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 范亚杰
* @description 针对表send_udb_log(udb消息日志表)的数据库操作Mapper
* @createDate 2023-11-29 13:41:51
* @Entity com.xr.device_car.modules.analysis.entity.SendUdbLog
*/
@Mapper
public interface SendUdpLogMapper extends BaseMapper<SendUdpLog> {
}

16
device_cars/src/main/java/com/xr/device_car/modules/analysis/service/IMeterInitializationService.java

@ -1,16 +0,0 @@
package com.xr.device_car.modules.analysis.service;
import com.xr.device_car.modules.analysis.entity.MeterInitialization;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 表计算法初始化 服务类
* </p>
*
* @author gaoby
* @since 2023-11-20
*/
public interface IMeterInitializationService extends IService<MeterInitialization> {
}

13
device_cars/src/main/java/com/xr/device_car/modules/analysis/service/SendUdpLogService.java

@ -1,13 +0,0 @@
package com.xr.device_car.modules.analysis.service;
import com.xr.device_car.modules.analysis.entity.SendUdpLog;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 范亚杰
* @description 针对表send_udb_log(udb消息日志表)的数据库操作Service
* @createDate 2023-11-29 13:41:51
*/
public interface SendUdpLogService extends IService<SendUdpLog> {
}

7
device_cars/src/main/java/com/xr/device_car/modules/analysis/service/UdpClientService.java

@ -1,7 +0,0 @@
package com.xr.device_car.modules.analysis.service;
public interface UdpClientService {
void sendData(String data);
}

20
device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/MeterInitializationServiceImpl.java

@ -1,20 +0,0 @@
package com.xr.device_car.modules.analysis.service.impl;
import com.xr.device_car.modules.analysis.entity.MeterInitialization;
import com.xr.device_car.modules.analysis.mapper.MeterInitializationMapper;
import com.xr.device_car.modules.analysis.service.IMeterInitializationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 表计算法初始化 服务实现类
* </p>
*
* @author gaoby
* @since 2023-11-20
*/
@Service
public class MeterInitializationServiceImpl extends ServiceImpl<MeterInitializationMapper, MeterInitialization> implements IMeterInitializationService {
}

24
device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/SendUdpLogServiceImpl.java

@ -1,24 +0,0 @@
package com.xr.device_car.modules.analysis.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xr.device_car.modules.analysis.entity.SendUdpLog;
import com.xr.device_car.modules.analysis.service.SendUdpLogService;
import com.xr.device_car.modules.analysis.mapper.SendUdpLogMapper;
import org.springframework.stereotype.Service;
/**
* @author 范亚杰
* @description 针对表send_udb_log(udb消息日志表)的数据库操作Service实现
* @createDate 2023-11-29 13:41:51
*/
@Service
@DS("db2")
public class SendUdpLogServiceImpl extends ServiceImpl<SendUdpLogMapper, SendUdpLog>
implements SendUdpLogService {
}

48
device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/UdpClientServiceImpl.java

@ -1,48 +0,0 @@
package com.xr.device_car.modules.analysis.service.impl;
import com.xr.device_car.modules.analysis.entity.SendUdpLog;
import com.xr.device_car.modules.analysis.service.SendUdpLogService;
import com.xr.device_car.modules.analysis.service.UdpClientService;
import io.netty.buffer.Unpooled;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.DatagramPacket;
import io.netty.util.CharsetUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.net.InetSocketAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
@Service
public class UdpClientServiceImpl implements UdpClientService {
@Autowired
private DatagramChannel udpChannel;
@Autowired
private InetSocketAddress udpServerAddress;
@Autowired
private SendUdpLogService sendUdpLogService;
@Override
public void sendData(String data) {
SendUdpLog sendUdpLog =new SendUdpLog();
sendUdpLog.setRequestMsg(data);
sendUdpLog.setRequestTime(new Date());
sendUdpLog.setMessageId(data.split("\t")[0]);
try {
udpChannel.writeAndFlush(new DatagramPacket(
Unpooled.copiedBuffer(data, CharsetUtil.UTF_8), udpServerAddress)).sync();
sendUdpLog.setRequestStatus("0");
} catch (Exception e) {
sendUdpLog.setRequestStatus("1");
sendUdpLog.setResMsg(e.getMessage());
sendUdpLog.setResTime(new Date());
e.printStackTrace();
}
sendUdpLogService.save(sendUdpLog);
}
}

19
device_cars/src/main/resources/application-dev.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://116.196.120.81:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 5ea47c0bdd7146ebbd53020eca@672307
#Hikari连接池配置
@ -63,12 +63,9 @@ analysis:
url: http://192.168.1.123:9000/vi/syncrec
upLoad:
path: D:\\images\\images\\
path: D:\\device_car\\analysis\\upload\\
url: http://localhost:85/upload/
file: D:\\images\\images\\
python:
path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe
modelPath: D:\\smartGrid\\smartGrid\\models
netty:
address: 192.168.3.20
port: 2404
@ -83,12 +80,4 @@ eureka:
healthcheck:
enabled: true
service-url:
defaultZone: http://localhost:8084/eureka
minio:
url: http://192.168.1.210:9000
accessKey: minioadmin
secretKey: minioadmin
udp:
server:
host: localhost
port: 9300
defaultZone: http://localhost:8084/eureka

14
device_cars/src/main/resources/application-prod.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.1.252:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://192.168.1.252:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
#Hikari连接池配置
@ -65,22 +65,12 @@ analysis:
upLoad:
path: /home/project/upload
url: http://192.168.1.252:85/upload/
python:
path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe
modelPath: D:\\smartGrid\\smartGrid\\models
netty:
address: 192.168.1.252
port: 2405
data:
pathUrl: http://192.168.1.252:8081/api/dataAnalysisCamera/getComer
udp:
server:
host: localhost
port: 9300
minio:
url: http://192.168.1.210:9000
accessKey: minioadmin
secretKey: minioadmin
eureka:
instance:
instance-id: ${spring.cloud.client.ip-address}:${server.port}

14
device_cars/src/main/resources/application-test.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://localhost:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
#Hikari连接池配置
@ -65,20 +65,10 @@ analysis:
upLoad:
path: D:\\device_car\\analysis\\upload\\
url: http://localhost:85/upload/
python:
path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe
modelPath: D:\\smartGrid\\smartGrid\\models
netty:
address: 192.168.3.20
port: 2404
minio:
url: http://192.168.1.210:9000
accessKey: minioadmin
secretKey: minioadmin
udp:
server:
host: localhost
port: 9300
data:
pathUrl: http://192.168.1.82:8081/api/dataAnalysisCamera/getComer
#pathUrl: http://192.168.1.44:8081/api/dataAnalysisCamera/getComer

3
device_cars/src/main/resources/application.yml

@ -2,7 +2,7 @@ spring:
profiles:
#active: dev #开发环境
# active: test #测试环境5
active: dev #生产环境
active: prod #生产环境
# active: prod #生产环境
application:
name: deviceCars
@ -79,4 +79,3 @@ hystrix:
# 熔断器超时时间,默认:1000/毫秒
timeoutInMilliseconds: 20000

12
device_cars/src/main/resources/digest/AbsoluteMove.wsdl

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<s:Body>
<tptz:AbsoluteMove>
<tptz:ProfileToken>%s</tptz:ProfileToken>
<tptz:Position>
<tt:PanTilt y="%s" x="%s" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace" />
<tt:Zoom x="%s" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace" />
</tptz:Position>
</tptz:AbsoluteMove>
</s:Body>
</s:Envelope>

6
device_cars/src/main/resources/digest/GetDeviceInformation.wsdl

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<soap:Body>
<tds:GetOnvifInformation />
</soap:Body>
</soap:Envelope>

6
device_cars/src/main/resources/digest/GetPTZ.wsdl

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl">
<s:Body>
<tptz:GetConfigurations />
</s:Body>
</s:Envelope>

8
device_cars/src/main/resources/digest/GetPresets.wsdl

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<s:Body>
<tptz:GetPresets>
<tptz:ProfileToken>%s</tptz:ProfileToken>
</tptz:GetPresets>
</s:Body>
</s:Envelope>

6
device_cars/src/main/resources/digest/GetProfiles.wsdl

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<soap:Body>
<trt:GetProfiles />
</soap:Body>
</soap:Envelope>

8
device_cars/src/main/resources/digest/GetSnapshotUrl.wsdl

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<soap:Body>
<trt:GetSnapshotUri>
<trt:ProfileToken>%s</trt:ProfileToken>
</trt:GetSnapshotUri>
</soap:Body>
</soap:Envelope>

8
device_cars/src/main/resources/digest/GetStatus.wsdl

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<s:Body>
<tptz:GetStatus>
<tptz:ProfileToken>%s</tptz:ProfileToken>
</tptz:GetStatus>
</s:Body>
</s:Envelope>

25
device_cars/src/main/resources/digest/GetStreamUri.wsdl

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<s:Header xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>%s</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%s</wsse:Password>
<wsse:Nonce>%s</wsse:Nonce>
<wsu:Created>%s</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</s:Header>
<soap:Body>
<GetStreamUri xmlns="http://www.onvif.org/ver10/media/wsdl">
<StreamSetup>
<!-- Attribute Wild card could not be matched. Generated XML may not be valid. -->
<Stream xmlns="http://www.onvif.org/ver10/schema">RTP-Unicast</Stream>
<Transport xmlns="http://www.onvif.org/ver10/schema">
<Protocol>%s</Protocol>
</Transport>
</StreamSetup>
<ProfileToken>%s</ProfileToken>
</GetStreamUri>
</soap:Body>
</soap:Envelope>

9
device_cars/src/main/resources/digest/GotoPreset.wsdl

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<s:Body>
<tptz:GotoPreset>
<tptz:ProfileToken>%s</tptz:ProfileToken>
<tptz:PresetToken>%s</tptz:PresetToken>
</tptz:GotoPreset>
</s:Body>
</s:Envelope>

11
device_cars/src/main/resources/modules/analysis/MeterConfigMapper.xml

@ -17,13 +17,12 @@
<result property="typeId" column="type_id" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="firstTime" column="first_time" jdbcType="TIMESTAMP"/>
<result property="algorithmType" column="algorithm_type" jdbcType="VARCHAR"/>
<result property="focalLength" column="focal_length" jdbcType="VARCHAR"/>
<result property="intervalTime" column="interval_time" jdbcType="INTEGER"/>
<result property="intervalType" column="interval_type" jdbcType="INTEGER"/>
<result property="focalNumber" column="focal_number" jdbcType="INTEGER"/>
<result property="parameterConfig" column="parameter_config" jdbcType="VARCHAR"/>
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
<result property="initStatus" column="init_status" jdbcType="VARCHAR"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
@ -39,14 +38,14 @@
a.identification_interval,a.device_name,a.device_type,
a.meter_code,a.meter_name,a.camera_id,
a.type_id,a.status,a.first_time,
a.algorithm_type,a.interval_time,a.focal_number,
a.parameter_config,a.remarks,a.init_status,a.create_user,
a.focal_length,a.interval_time,a.focal_number,
a.parameter_config,a.remarks,a.create_user,
a.create_time,a.update_user,a.update_time,
</sql>
<select id="selectConfigByPage" resultType="com.xr.device_car.modules.analysis.entity.MeterConfig">
<select id="selectConfigByPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
b.device_type cameraType,b.position cameraName,c.type_alias,b.device_ip ip from meter_config a
b.device_type,b.position,c.type_alias,b.device_ip from meter_config a
left join device_camera b on a.camera_id = b.id
left join meter_type c on a.type_id=c.id
${ew.customSqlSegment}

14
device_cars/src/main/resources/modules/analysis/MeterInitializationMapper.xml

@ -1,14 +0,0 @@
<?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.xr.device_car.modules.analysis.mapper.MeterInitializationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.xr.device_car.modules.analysis.entity.MeterInitialization">
<id column="id" property="id" />
<result column="img" property="img" />
<result column="img_address" property="imgAddress" />
<result column="value" property="value" />
<result column="meter_id" property="meterId"/>
</resultMap>
</mapper>

22
device_cars/src/main/resources/modules/analysis/SendUdpLogMapper.xml

@ -1,22 +0,0 @@
<?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.xr.device_car.modules.analysis.mapper.SendUdpLogMapper">
<resultMap id="BaseResultMap" type="com.xr.device_car.modules.analysis.entity.SendUdpLog">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="messageId" column="message_id" jdbcType="VARCHAR"/>
<result property="requestStatus" column="requst_status" jdbcType="VARCHAR"/>
<result property="requestMsg" column="request_msg" jdbcType="VARCHAR"/>
<result property="requestTime" column="request_time" jdbcType="TIMESTAMP"/>
<result property="resMsg" column="res_msg" jdbcType="VARCHAR"/>
<result property="resTime" column="res_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,message_id,request_status,
request_msg,request_time,res_msg,
res_time
</sql>
</mapper>

2
device_display/pom.xml

@ -145,7 +145,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
<version>${joda.time.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>

10
device_display/src/main/java/com/xr/device_display/modules/analysis/dto/HistogramDto.java

@ -1,10 +0,0 @@
package com.xr.device_display.modules.analysis.dto;
import lombok.Data;
@Data
public class HistogramDto {
private dataset dataset;
}

12
device_display/src/main/java/com/xr/device_display/modules/analysis/dto/dataset.java

@ -1,12 +0,0 @@
package com.xr.device_display.modules.analysis.dto;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class dataset {
List<List<Object>> source;
}

4
device_display/src/main/java/com/xr/device_display/modules/analysis/service/impl/MeterReadingRecordServiceImpl.java

@ -121,14 +121,12 @@ public class MeterReadingRecordServiceImpl extends ServiceImpl<MeterReadingRecor
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 获取第二天日期
LocalDate nextDay = currentDate.plusDays(1);
// 构建查询条件:在过去7天内的记录
LocalDate sevenDaysAgo = currentDate.minusDays(days);
LambdaQueryWrapper<MeterReadingRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(MeterReadingRecord::getMeterCode, meterCode);
lambdaQueryWrapper.between(MeterReadingRecord::getReadingTime, sevenDaysAgo, nextDay);
lambdaQueryWrapper.between(MeterReadingRecord::getReadingTime, sevenDaysAgo, currentDate);
lambdaQueryWrapper.orderByAsc(MeterReadingRecord::getReadingTime);
// 查询记录

2
device_display/src/main/resources/application-dev.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://116.196.120.81:3306/image_analysis?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://116.196.120.81:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 5ea47c0bdd7146ebbd53020eca@672307
#Hikari连接池配置

2
device_display/src/main/resources/application-prod.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.1.252:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://192.168.1.252:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
#Hikari连接池配置

2
device_display/src/main/resources/application-test.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://localhost:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
#Hikari连接池配置

2
device_display/src/main/resources/application.yml

@ -22,7 +22,7 @@ spring:
basename: i18n/messages
profiles:
# active: prod #开发环境
active: dev #测试环境5
active: prod #测试环境5
#active: prod #生产环境
# active: prod #生产环境
application:

4
device_iec104/src/main/java/com/xr/iec104Server/iec104/server/SysDataHandler.java

@ -50,7 +50,7 @@ public class SysDataHandler implements DataHandler {
//回复总召唤确认
System.out.print("响应总召唤指令:");
ctx.writeAndFlush(BasicInstruction104.getYesGeneralCallRuleDetail104());
Thread.sleep(1000);
Thread.sleep(3000);
//发送总召唤数据
QueryWrapper<ForwardChannel> query=new QueryWrapper<>();
query.eq("device_id", StaticPropUtil.deviceId);
@ -65,7 +65,7 @@ public class SysDataHandler implements DataHandler {
//发送结束总召唤指令
System.out.print("总召唤遥测数据:");
ctx.writeAndFlush(detail);
Thread.sleep(1000);
Thread.sleep(3000);
//发送结束总召唤指令
System.out.print("总召唤结束指令:");
ctx.writeAndFlush(BasicInstruction104.getEndGeneralCallRuleDetail104());

2
device_iec104/src/main/resources/application-dev.yml

@ -17,7 +17,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://116.196.120.81:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 5ea47c0bdd7146ebbd53020eca@672307
db3:

2
device_iec104/src/main/resources/application-prod.yml

@ -17,7 +17,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://localhost:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: root
db3:

2
device_iec61850clent/src/main/java/com/xr/iec61850clent/Iec61850ClentApplication.java

@ -30,7 +30,7 @@ public class Iec61850ClentApplication implements CommandLineRunner {
@Override
@Async
public void run(String[] args){
Iec61850clent iec61850clent=new Iec61850clent(args,"192.168.1.83",102);
Iec61850clent iec61850clent=new Iec61850clent(args,"192.168.1.137",102);
executor.execute(iec61850clent);
// Iec61850clent iec61850clent1=new Iec61850clent(args,"192.168.1.138",102);
// executor.submit(iec61850clent1);

422
device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ExcelUtil.java

@ -1,422 +0,0 @@
package com.xr.iec61850clent.common.util;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.List;
public class ExcelUtil {
public static final int CELL_TYPE_INTEGER = 1;
public static final int CELL_TYPE_DOUBLE = 2;
public static final int CELL_TYPE_STRING = 3;
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String UNSUPPORT_CELL_TYPE = "UNSUPPORT CELL TYPE";
/**
* 特殊字符转义
*/
public static String[] SpecialChar = {"'", "\"", "[", "]"};
/**
* 得到workBook
*
* @return
* @throws IOException
*/
public static XSSFWorkbook getWorkbook(InputStream in) throws IOException {
XSSFWorkbook wb = new XSSFWorkbook(in);
return wb;
}
/**
* 得到第一个sheet
*
* @param wb
* @return
*/
public static XSSFSheet getFirstSheet(XSSFWorkbook wb) {
return wb.getSheetAt(0);
}
/**
* 得到指定的一个sheet
*
* @param wb
* @param sheetIndex
* @return
*/
public static HSSFSheet getSheet(HSSFWorkbook wb, int sheetIndex) {
return wb.getSheetAt(sheetIndex);
}
/**
* 通过名称 得到一个指定sheet
*
* @param wb
* @param sheetName
* @return
*/
public static HSSFSheet getSheet(HSSFWorkbook wb, String sheetName) {
return wb.getSheet(sheetName);
}
/**
* 得到 第一行的值
*
* @param sheet
* @return
* @throws Exception
*/
public static String[] getFirstSheetRow(HSSFSheet sheet) throws Exception {
return getSheetRow(sheet, 0);
}
/**
* 得到 第一行的值
*
* @param sheet
* @return
* @throws Exception
*/
public static String[] getFirstSheetRow_xlsx(XSSFSheet sheet) throws Exception {
return getSheetRow_xlsx(sheet, 0);
}
/**
*
* 得到 指定sheet中 一行的值
*
* @param rowNum
* @return
* @throws Exception
*/
public static String[] getSheetRow(HSSFSheet sheet, int rowNum) throws Exception {
HSSFRow sheetRow = sheet.getRow(rowNum);
if (sheetRow == null)
return null;
return getSheetRow(sheet, rowNum, sheetRow.getLastCellNum());
}
/**
*
* 得到 指定sheet中 一行的值
*
* @param rowNum
* @return
* @throws Exception
*/
public static String[] getSheetRow_xlsx(XSSFSheet sheet, int rowNum) throws Exception {
XSSFRow sheetRow = sheet.getRow(rowNum);
if (sheetRow == null)
return null;
return getSheetRow_xlsx(sheet, rowNum, sheetRow.getLastCellNum());
}
/**
*
* 判断一个sheet的某一行是否都没有填写数据
*
* @param sheet
* @param rowNum
* @return
* @throws Exception
*/
public static boolean isNullsRow(HSSFSheet sheet, int rowNum) throws Exception {
HSSFRow sheetRow = sheet.getRow(rowNum);
if (sheetRow != null) {
int len = sheetRow.getPhysicalNumberOfCells();
for (int i = 0; i < len; i++) {
@SuppressWarnings("deprecation")
HSSFCell cell = sheetRow.getCell((short) i);
if (cell != null && !getSheetCell(cell).equals("")) {
return false;
}
}
return true;
} else {
return true;
}
}
/**
*
* sheet中一行的值
*
* @param sheet
* @param rowNum
* @return
* @throws Exception
*/
@SuppressWarnings("deprecation")
public static String[] getSheetRow(HSSFSheet sheet, int rowNum, int colNum) throws Exception {
HSSFRow sheetRow = sheet.getRow(rowNum);
if (sheetRow == null)
return null;
HSSFCell sheetCell = null;
if (colNum == -1) {
return null;
}
String[] obj = new String[colNum];
for (int i = 0; i < colNum; i++) {
sheetCell = sheetRow.getCell((short) i);
if (sheetCell == null) {
obj[i] = "NULL";
continue;
}
obj[i] = getSheetCell(sheetCell);
}
return obj;
}
/**
*
* sheet中一行的值
*
* @param sheet
* @param rowNum
* @return
* @throws Exception
*/
@SuppressWarnings("deprecation")
public static String[] getSheetRow_xlsx(XSSFSheet sheet, int rowNum, int colNum) throws Exception {
XSSFRow sheetRow = sheet.getRow(rowNum);
if (sheetRow == null)
return null;
XSSFCell sheetCell = null;
if (colNum == -1) {
return null;
}
String[] obj = new String[colNum];
for (int i = 0; i < colNum; i++) {
sheetCell = sheetRow.getCell((short) i);
if (sheetCell == null) {
obj[i] = "NULL";
continue;
}
obj[i] = getCellValue_xlsx(sheetCell);
// obj[i] = getSheetCell(sheetCell);
}
return obj;
}
public static String getCellValue_xlsx(Cell cell) throws Exception {
if (cell == null || cell.toString().trim().equals("")) {
return "";
} else {
return cell.toString();
}
}
public static String getCellTypeByRowAndCol(HSSFSheet sheet, int row, int col) {
HSSFRow sheetRow = sheet.getRow(row);
if (sheetRow == null) {
return null;
}
@SuppressWarnings("deprecation")
HSSFCell cell = sheetRow.getCell((short) col);
return getSheetCellType(cell);
}
public static String getSheetCellType(HSSFCell sheetCell) {
if (sheetCell == null) {
return null;
}
return sheetCell.getCellType() + "";
}
public static String getStringByRowAndCol(HSSFSheet sheet, int row, int col) throws Exception {
return getStringByRowAndCol(sheet, row, col, true);
}
public static String getStringByRowAndCol_xlsx(XSSFSheet sheet, int row, int col) throws Exception {
return getStringByRowAndCol_xlsx(sheet, row, col, true);
}
// 得到单元格的值
public static String getStringByRowAndCol_xlsx(XSSFSheet sheet, int row, int col, boolean flag)
throws Exception {
XSSFRow sheetRow = sheet.getRow(row);
if (sheetRow == null) {
return null;
}
@SuppressWarnings("deprecation")
XSSFCell cell = sheetRow.getCell((short) col);
return getCellValue_xlsx(cell);
}
// 得到单元格的值
public static String getStringByRowAndCol(HSSFSheet sheet, int row, int col, boolean flag)
throws Exception {
HSSFRow sheetRow = sheet.getRow(row);
if (sheetRow == null) {
return null;
}
@SuppressWarnings("deprecation")
HSSFCell cell = sheetRow.getCell((short) col);
return getSheetCell(cell, flag);
}
/**
* 得到单元格的值
*
* @return
*/
public static String getSheetCell(HSSFCell sheetCell) throws Exception {
return getSheetCell(sheetCell, true);
}
/**
*
* @param sheetCell
* @param flag true 表示需要去掉 excel中的特殊字符 false 保持元值
* @return
* @throws Exception
*/
public static String getSheetCell(HSSFCell sheetCell, boolean flag) throws Exception {
String obj = null;
if (sheetCell == null) {
return obj;
}
int cellType = sheetCell.getCellType();
switch (cellType) {
case HSSFCell.CELL_TYPE_BLANK:
obj = sheetCell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
obj = sheetCell.getBooleanCellValue() + "";
break;
case HSSFCell.CELL_TYPE_ERROR:
obj = sheetCell.getErrorCellValue() + "";
break;
case HSSFCell.CELL_TYPE_FORMULA:
obj = sheetCell.getCellFormula();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(sheetCell)) {
obj = dateTimeFormat(sheetCell.getDateCellValue());
} else {
obj = String.valueOf(sheetCell.getNumericCellValue());
if (obj.indexOf("E") != -1) {
DecimalFormat df = new DecimalFormat();
try {
obj = (df.parse(obj)).toString();
} catch (Exception e) {
e.printStackTrace();
obj = "";
}
}
if (obj.endsWith(".0")) {
obj = obj.substring(0, obj.length() - 2);
}
}
break;
case HSSFCell.CELL_TYPE_STRING:
obj = sheetCell.getRichStringCellValue().getString();
break;
default:
obj = UNSUPPORT_CELL_TYPE;
break;
}
if (obj != null && !obj.trim().equals("")) {
obj = obj.trim();
if (flag) {
for (int i = 0; i < SpecialChar.length; i++) {
obj = encoding(obj);
}
}
}
return obj;
}
public static Object getSheetCell(HSSFCell sheetCell, int dataType) throws Exception {
String strObj = getSheetCell(sheetCell, true);
Object obj = null;
if (strObj == null || strObj.trim().equals(""))
return null;
switch (dataType) {
case CELL_TYPE_INTEGER:
obj = new Integer(strObj);
break;
default:
break;
}
return obj;
}
/**
* 判断单元格的日期格式
*
* @param date
* @return
* @throws Exception
*/
public static String dateTimeFormat(java.util.Date date) throws Exception {
SimpleDateFormat pdf = new SimpleDateFormat(DATE_TIME_FORMAT);
String dateStr = "";
try {
if (date != null) {
dateStr = pdf.format(date);
}
return dateStr;
} catch (Exception e) {
e.printStackTrace();
throw new Exception("EXCEL 中日期格式不对!");
}
}
/**
* 特殊字符替换
*
* @param _src
* @return
* @throws NullPointerException
*/
public static String encoding(String _src) throws NullPointerException {
if (_src == null)
throw new NullPointerException("value of parameter '_src' is null.");
StringBuilder result = new StringBuilder();
if (_src != null) {
_src = _src.trim();
for (int pos = 0; pos < _src.length(); pos++) {
switch (_src.charAt(pos)) {
case '[':
result.append("");
break;
case ']':
result.append("");
break;
case '\'':
result.append("");
break;
case '"':
result.append("");
break;
default:
result.append(_src.charAt(pos));
break;
}
}
}
return result.toString();
}
}

151
device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/IEC61850Config.java

@ -1,151 +0,0 @@
package com.xr.iec61850clent.common.util;
import com.xr.iec61850clent.models.entity.ExcelConfig;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@Component
public class IEC61850Config {
private static final ThreadLocal<List<ExcelConfig>> CURRENT_CONFIG = new ThreadLocal<>();
@PostConstruct
public void setExcelConfig(){
List<ExcelConfig> excelConfigs = readExcel();
CURRENT_CONFIG.set(excelConfigs);
}
public static List<ExcelConfig> readExcel(){
InputStream inputStream = IEC61850Config.class.getClassLoader().getResourceAsStream("IEC61850.xlsx");
XSSFWorkbook wb = null;
XSSFSheet sheet = null; // 创建工作sheet
List<ExcelConfig> dataList = new ArrayList<>();
try {
wb = ExcelUtil.getWorkbook(inputStream);
sheet = ExcelUtil.getFirstSheet(wb);
int readRowCount =sheet.getPhysicalNumberOfRows();
// 解析sheet 的行
for (int j = sheet.getFirstRowNum(); j < readRowCount; j++) {
ExcelConfig excelConfig=new ExcelConfig();
Row row = sheet.getRow(j);
if(j == 0){
continue;
}
if (row == null) {
continue;
}
if (row.getFirstCellNum() < 0) {
continue;
}
// 解析sheet 的列
Cell cell0 = row.getCell(0);
cell0.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setDeviceIp(getCellValue(wb, cell0));
Cell cell1 = row.getCell(1);
cell1.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setDevice(getCellValue(wb, cell1));
Cell cell2 = row.getCell(2);
cell1.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setName(getCellValue(wb, cell2));
Cell cell3 = row.getCell(3);
cell1.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setConnectId(getCellValue(wb, cell3));
Cell cell4 = row.getCell(4);
cell1.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setAddress(getCellValue(wb, cell4));
Cell cell5 = row.getCell(5);
cell1.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setGgio(getCellValue(wb, cell5));
Cell cell6 = row.getCell(6);
cell1.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setAng(getCellValue(wb, cell6));
Cell cell7 = row.getCell(7);
cell1.setCellType(Cell.CELL_TYPE_STRING);
excelConfig.setMsg(getCellValue(wb, cell7));
dataList.add(excelConfig);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return dataList;
}
private static String getCellValue(Workbook wb, Cell cell) {
Object columnValue = null;
if (cell != null) {
DecimalFormat df = new DecimalFormat("0");// 格式化 number
// String
// 字符
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化日期字符串
DecimalFormat nf = new DecimalFormat("0.00");// 格式化数字
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
columnValue = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
if ("@".equals(cell.getCellStyle().getDataFormatString())) {
columnValue = df.format(cell.getNumericCellValue());
} else if ("General".equals(cell.getCellStyle().getDataFormatString())) {
columnValue = nf.format(cell.getNumericCellValue());
} else {
columnValue = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
}
break;
case Cell.CELL_TYPE_BOOLEAN:
columnValue = cell.getBooleanCellValue();
break;
case Cell.CELL_TYPE_BLANK:
columnValue = "";
break;
case Cell.CELL_TYPE_FORMULA:
// 格式单元格
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateFormulaCell(cell);
CellValue cellValue = evaluator.evaluate(cell);
columnValue = cellValue.getNumberValue();
break;
default:
columnValue = cell.toString();
}
}
return columnValue.toString();
}
public static ExcelConfig getExcelConfig(String ip,String node){
List<ExcelConfig> list = CURRENT_CONFIG.get();
if(null == list || list.isEmpty()){
list = readExcel();
CURRENT_CONFIG.set(list);
}
for(ExcelConfig config:list){
String node1 = config.getName()+config.getConnectId()+config.getAddress()+config.getGgio()+"."+config.getAng();
if(ip.equals(config.getDeviceIp()) && node.equals(node1)){
return config;
}
}
return null;
}
}

4
device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ModeUtil.java

@ -2,7 +2,6 @@ package com.xr.iec61850clent.common.util;
import com.beanit.iec61850bean.FcModelNode;
import com.beanit.iec61850bean.ModelNode;
import com.xr.iec61850clent.models.entity.ExcelConfig;
import com.xr.iec61850clent.models.entity.Lds5000;
import java.io.ByteArrayOutputStream;
@ -16,9 +15,8 @@ public class ModeUtil {
public static Lds5000 getLdsVlue(String ip,FcModelNode node){
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
ExcelConfig eunm = IEC61850Config.getExcelConfig(ip,node.getReference().toString());
Lds5000 lds5000=null;
// Iec61850Eunm eunm=Iec61850Eunm.getIec61850EunmByIp(ip,node.getReference().toString());
Iec61850Eunm eunm=Iec61850Eunm.getIec61850EunmByIp(ip,node.getReference().toString());
if(eunm!=null){
lds5000=new Lds5000();
if(eunm.getDevice().equals("一体化电源")){

24
device_iec61850clent/src/main/java/com/xr/iec61850clent/models/entity/ExcelConfig.java

@ -1,24 +0,0 @@
package com.xr.iec61850clent.models.entity;
import lombok.Data;
@Data
public class ExcelConfig {
private String deviceIp;
private String device;
private String name;
private String connectId;
private String address;
private String ggio;
private String ang;
private String msg;
}

BIN
device_iec61850clent/src/main/resources/IEC61850.xlsx

Binary file not shown.

2
device_iec61850clent/src/main/resources/application-dev.yml

@ -17,7 +17,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://116.196.120.81:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 5ea47c0bdd7146ebbd53020eca@672307
db3:

6
device_iec61850clent/src/main/resources/application-prod.yml

@ -11,19 +11,19 @@ spring:
db1:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.1.93:3306/device_system?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://192.168.1.252:3306/device_system?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.1.93:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://192.168.1.252:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
db3:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.1.93:3306/modbusrtu?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://192.168.1.252:3306/modbusrtu?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
# db1:

2
device_iec61850clent/src/main/resources/application-test.yml

@ -17,7 +17,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://localhost:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
db3:

81
device_iec61850server/src/main/java/com/xr/iec61850server/models/entity/Lds5000.java

@ -1,81 +0,0 @@
package com.xr.iec61850server.models.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
* @TableName lds5000
*/
@TableName(value ="lds5000")
@Data
public class Lds5000 implements Serializable {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 客户端ip
*/
private String clentIp;
/**
* 描述
*/
private String ldsDesc;
/**
* 类型
*/
private String fc;
/**
* 0表计1一体化电源
*/
private Integer type;
/**
* 结果节点
*/
private String node;
/**
* 状态0true 1false
*/
private String q;
/**
* 时间
*/
private LocalDateTime t;
/**
* 状态类
*/
private String stVal;
/**
* 模拟值
*/
private String f;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

18
device_iec61850server/src/main/java/com/xr/iec61850server/models/mapper/Lds5000Mapper.java

@ -1,18 +0,0 @@
package com.xr.iec61850server.models.mapper;
import com.xr.iec61850server.models.entity.Lds5000;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 范亚杰
* @description 针对表lds5000的数据库操作Mapper
* @createDate 2023-09-19 14:54:07
* @Entity com.xr.iec61850server.models.entity.Lds5000
*/
public interface Lds5000Mapper extends BaseMapper<Lds5000> {
}

13
device_iec61850server/src/main/java/com/xr/iec61850server/models/service/Lds5000Service.java

@ -1,13 +0,0 @@
package com.xr.iec61850server.models.service;
import com.xr.iec61850server.models.entity.Lds5000;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 范亚杰
* @description 针对表lds5000的数据库操作Service
* @createDate 2023-09-19 14:54:07
*/
public interface Lds5000Service extends IService<Lds5000> {
}

22
device_iec61850server/src/main/java/com/xr/iec61850server/models/service/impl/Lds5000ServiceImpl.java

@ -1,22 +0,0 @@
package com.xr.iec61850server.models.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xr.iec61850server.models.entity.Lds5000;
import com.xr.iec61850server.models.service.Lds5000Service;
import com.xr.iec61850server.models.mapper.Lds5000Mapper;
import org.springframework.stereotype.Service;
/**
* @author 范亚杰
* @description 针对表lds5000的数据库操作Service实现
* @createDate 2023-09-19 14:54:07
*/
@Service
public class Lds5000ServiceImpl extends ServiceImpl<Lds5000Mapper, Lds5000>
implements Lds5000Service{
}

2
device_iec61850server/src/main/resources/application-dev.yml

@ -17,7 +17,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://116.196.120.81:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 5ea47c0bdd7146ebbd53020eca@672307
db3:

2
device_iec61850server/src/main/resources/application-prod.yml

@ -17,7 +17,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://localhost:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: root
db3:

2
device_iec61850server/src/main/resources/application-test.yml

@ -17,7 +17,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://localhost:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
db3:

2
device_iec61850server/src/main/resources/application.yml

@ -1,6 +1,6 @@
spring:
profiles:
active: dev #开发环境
active: test #开发环境
# active: test #测试环境5
#active: prod #生产环境
# active: prod #生产环境

28
device_iec61850server/src/main/resources/mappers/Lds5000Mapper.xml

@ -1,28 +0,0 @@
<?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.xr.iec61850server.models.mapper.Lds5000Mapper">
<resultMap id="BaseResultMap" type="com.xr.iec61850server.models.entity.Lds5000">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="clentIp" column="clent_ip" jdbcType="VARCHAR"/>
<result property="ldsDesc" column="lds_desc" jdbcType="VARCHAR"/>
<result property="fc" column="fc" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="node" column="node" jdbcType="VARCHAR"/>
<result property="q" column="q" jdbcType="VARCHAR"/>
<result property="t" column="t" jdbcType="TIMESTAMP"/>
<result property="stVal" column="st_val" jdbcType="VARCHAR"/>
<result property="f" column="f" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,clent_ip,lds_desc,
fc,type,node,
q,t,st_val,
f,create_time,update_time
</sql>
</mapper>

120
device_modbus/src/main/java/com/xr/clent/utils/ModbusRtuUtil.java

@ -1,120 +0,0 @@
package com.xr.clent.utils;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class ModbusRtuUtil {
public static void main(String[] args) {
// String str="FE 04 1A 08 D2 0C 35 06 6C 60 79 90 1C 04 04 00 00 00 00 00 00 00 00 00 00 00 00 CF 0A";
// String str16[] = str.split("\\s+");
// System.out.println("设备地址:"+Integer.parseInt(str16[0], 16));
// System.out.println("功能码:"+Integer.parseInt(str16[1], 16));
// System.out.println("字节数:"+Integer.parseInt(str16[2], 16));
// System.out.println("温度:"+hexToDecimal(str16[3]+str16[4]));
// System.out.println("湿度:"+hexToDecimal(str16[5]+str16[6]));
// System.out.println("CO2:"+hexToDecimal(str16[7]+str16[8]));
// System.out.println("光照:"+hexToDecimal(str16[9]+str16[10]));
// System.out.println("大气压:"+hexToDecimal(str16[11]+str16[12]));
// System.out.println("风速:"+hexToDecimal(str16[13]+str16[14]));
// System.out.println("风向:"+hexToDecimal(str16[15]+str16[16]));
// System.out.println("土壤湿度:"+hexToDecimal(str16[17]+str16[18]));
// System.out.println("土壤温度:"+hexToDecimal(str16[19]+str16[20]));
// System.out.println("PM2.5:"+hexToDecimal(str16[21]+str16[22]));
// System.out.println("PM1.0:"+hexToDecimal(str16[23]+str16[24]));
// System.out.println("PM10:"+hexToDecimal(str16[25]+str16[26]));
// System.out.println("校验码:"+str16[27]+str16[28]);
readHex();
}
public static void readHex(){
String str = "FE 04 3C 00 00 00 00 00 00 00 00 00 00 00 00 F0 00 45 13 D0 00 45 30 40 00 44 45 CC 00 46 01 3D 00 47 C7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1F F1";
String str16[] = str.split("\\s+");
int lth=str16.length;
System.out.println("设备地址:"+Integer.parseInt(str16[0], 16));
System.out.println("功能码:"+Integer.parseInt(str16[1], 16));
System.out.println("字节数:"+Integer.parseInt(str16[2], 16));
System.out.println("校验码:"+str16[lth-1]+" "+str16[lth-2]);
String [] strs = Arrays.copyOfRange(str16, 3, lth-2);
String s = "";
Map<Integer,String> map=new HashMap<>();
map.put(1,"单次雨量");
map.put(2,"瞬时雨量");
map.put(3,"总雨量");
map.put(4,"温度");
map.put(5,"湿度");
map.put(6,"CO2");
map.put(7,"光照");
map.put(8,"大气压");
map.put(9,"风速");
map.put(10,"风向");
map.put(11,"土壤湿度");
map.put(12,"土壤温度");
map.put(13,"PM2.5");
map.put(14,"PM1.0");
map.put(15,"PM10");
for(int i=0;i<strs.length-1;i++){
s+=strs[i];
if(s.length() == 8){
int b =(i+1)/4;
String name = map.get(b);
BigDecimal d = new BigDecimal(1);
if(b == 4 || b ==5 || b==7|| b==9){
d = new BigDecimal("0.01");
}
if (b == 8){
d = new BigDecimal("0.001");
}
if(b == 10 || b == 12 || b == 11){
d = new BigDecimal("0.1");
}
s=s.substring(s.length()-4)+s.substring(0,4);
System.out.println(name+":"+new BigDecimal(hexStringToJavaFloat(s)).multiply(d));
s="";
}
}
}
public static int hexToDecimal(String hex) {
int decimal = 0;
int length = hex.length();
for (int i = 0; i < length; i++) {
char c = hex.charAt(i);
int digit = Character.digit(c, 16);
decimal += digit * Math.pow(16, 2 * (length - i - 1));
}
return decimal;
}
public static float hexStringToJavaFloat(String message){
// 将字符串转换为字节数组
byte[] bytes = hexStringToByteArray(message);
// 创建一个ByteBuffer
ByteBuffer buffer = ByteBuffer.wrap(bytes);
// 获取float值
return buffer.getFloat();
}
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
}

2
device_modbus/src/main/resources/application-dev.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://116.196.120.81:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 5ea47c0bdd7146ebbd53020eca@672307
db3:

2
device_modbus/src/main/resources/application-prod.yml

@ -19,7 +19,7 @@ spring:
db2:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://localhost:3306/image_analysis_jc?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: root
db3:

42
device_udpclent/pom.xml

@ -96,39 +96,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-stream-binder-kafka</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.python</groupId>-->
<!-- <artifactId>jython-slim</artifactId>-->
<!-- <version>2.7.2</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.github.milg0</groupId>-->
<!-- <artifactId>onvif</artifactId>-->
<!-- <version>16.3.16</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.65.Final</version>
</dependency>
</dependencies>
@ -141,13 +112,6 @@
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>

2
device_udpclent/src/main/java/com/xr/device_udpclent/DeviceUdpclentApplication.java

@ -5,11 +5,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableAsync//开启异步
@EnableScheduling//开启定时任务
@EnableDiscoveryClient
@EnableFeignClients
public class DeviceUdpclentApplication {

22
device_udpclent/src/main/java/com/xr/device_udpclent/common/config/BodyRequestConfig.java

@ -1,22 +0,0 @@
package com.xr.device_udpclent.common.config;
import lombok.Data;
@Data
public class BodyRequestConfig {
private String ip;
private Integer port;
private String username;
private String password;
private String agreement;
private String uri;
private String entity;
}

32
device_udpclent/src/main/java/com/xr/device_udpclent/common/config/Const.java

@ -1,32 +0,0 @@
package com.xr.device_udpclent.common.config;
public interface Const {
/**
* 请求onvifurl拼接
*/
String REQUEST_ONVIF_URL = "http://%s:%d/onvif/media_service";
String ABSOLUTE_MOVE= "http://%s:%d/onvif/ptz_service";
String PTZ_MOVE= "http://%s:%d/onvif/PTZ";
/**
* 请求onvifurl拼接
*/
String REQUEST_DEVICE_ONVIF_URL = "http://%s:%d/onvif/device_service";
/**
*返回的respon 中的headers
*/
String HEADERS_ONVIF_WWW_AUTHENTICATE= "WWW-Authenticate";
/**
* token
*/
String EQUEST_ONVIF_TOKEN="Digest username=\"%s\", realm=\"%s\", qop=\"%s\", algorithm=\"%s\", uri=\"%s\", nonce=\"%s\", nc=%s, cnonce=\"%s\", opaque=\"%s\", response=\"%s\"";
}

59
device_udpclent/src/main/java/com/xr/device_udpclent/common/config/FormRequestConfig.java

@ -1,59 +0,0 @@
package com.xr.device_udpclent.common.config;
import lombok.Data;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@Data
public class FormRequestConfig {
/**
* 协议http或者https
*/
private String agreement = "http";
/**
* example 175.13.254.22
*/
private String ip;
/**
* 端口
*/
private Integer port = 80;
/**
* 账号
* example admin
*/
private String username;
/**
* 原密码
* example 123456
*/
private String password;
/**
* 除了协议ip端口后面的uri
* example /ISAPI/System/TwowayAudio/channels
*/
private String uri;
/**
* 请求参数
*/
private Map<String,String> formData = new HashMap<>();
private File file;
/**
* 文件请求的name
*/
private String fileName;
/**
* application/json
* text/xml
*/
private String type = "application/json";
}

55
device_udpclent/src/main/java/com/xr/device_udpclent/common/config/HttpResponseBean.java

@ -1,55 +0,0 @@
package com.xr.device_udpclent.common.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import java.util.List;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class HttpResponseBean {
private String body;
private List<Header> headers;
private Integer status;
/**
* 获取头部信息
* @param name
* @return
*/
public Header getFirstHeader(final String name) {
for (int i = 0; i < this.headers.size(); i++) {
final Header header = this.headers.get(i);
if (header.getName().equalsIgnoreCase(name)) {
return header;
}
}
return null;
}
/***
* 判断是否成功
*/
public static boolean isSuccess(HttpResponseBean httpResponseBean){
return httpResponseBean!= null && HttpStatus.SC_OK ==httpResponseBean.getStatus();
}
/***
* 判断是否是401
*/
public static boolean isUnAuthorzied(HttpResponseBean httpResponseBean){
return httpResponseBean!= null && HttpStatus.SC_UNAUTHORIZED ==httpResponseBean.getStatus();
}
public HttpResponseBean(String body) {
this.body = body;
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save