diff --git a/device_cars/pom.xml b/device_cars/pom.xml index 530a228..78f0fb7 100644 --- a/device_cars/pom.xml +++ b/device_cars/pom.xml @@ -149,6 +149,11 @@ commons-discovery 0.2 + + wsdl4j + wsdl4j + 1.6.3 + org.junit.jupiter junit-jupiter-api @@ -173,7 +178,7 @@ joda-time joda-time - ${joda-time.version} + ${joda.time.version} @@ -356,38 +361,6 @@ org.springframework.cloud spring-cloud-starter-openfeign - - - org.apache.httpcomponents - httpclient - 4.5 - - - org.apache.httpcomponents - httpmime - 4.5 - - - org.apache.httpcomponents - httpcore - 4.4.1 - - - org.dom4j - dom4j - 2.1.3 - - - io.minio - minio - 3.0.10 - - - - com.alibaba - easyexcel - 3.3.2 - diff --git a/device_cars/src/main/java/com/xr/device_car/DeviceCarApplication.java b/device_cars/src/main/java/com/xr/device_car/DeviceCarApplication.java index aee30f6..271de88 100644 --- a/device_cars/src/main/java/com/xr/device_car/DeviceCarApplication.java +++ b/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 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(); // } } diff --git a/device_cars/src/main/java/com/xr/device_car/config/common/Const.java b/device_cars/src/main/java/com/xr/device_car/config/common/Const.java deleted file mode 100644 index b08e0dc..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/common/Const.java +++ /dev/null @@ -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\""; - - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/common/LocalDateConverter.java b/device_cars/src/main/java/com/xr/device_car/config/common/LocalDateConverter.java deleted file mode 100644 index 5d45c3f..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/common/LocalDateConverter.java +++ /dev/null @@ -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 { - - @Override - public Class 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 convertToExcelData(LocalDate value, ExcelContentProperty contentProperty, - GlobalConfiguration globalConfiguration) { - return new WriteCellData<>(value.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - } - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/common/LocalDateTimeConverter.java b/device_cars/src/main/java/com/xr/device_car/config/common/LocalDateTimeConverter.java deleted file mode 100644 index 72e555f..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/common/LocalDateTimeConverter.java +++ /dev/null @@ -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 { - @Override - public Class 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 convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, - GlobalConfiguration globalConfiguration) { - return new WriteCellData<>(value.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - } - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/common/RESTClient.java b/device_cars/src/main/java/com/xr/device_car/config/common/RESTClient.java deleted file mode 100644 index e57e74e..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/common/RESTClient.java +++ /dev/null @@ -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; - } - } - - - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/common/WebConfig.java b/device_cars/src/main/java/com/xr/device_car/config/common/WebConfig.java index 97c5953..27cde3f 100644 --- a/device_cars/src/main/java/com/xr/device_car/config/common/WebConfig.java +++ b/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"); } } \ No newline at end of file diff --git a/device_cars/src/main/java/com/xr/device_car/config/getconfigvalue/StaticProperties.java b/device_cars/src/main/java/com/xr/device_car/config/getconfigvalue/StaticProperties.java index 73239f7..36aba31 100644 --- a/device_cars/src/main/java/com/xr/device_car/config/getconfigvalue/StaticProperties.java +++ b/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; - } diff --git a/device_cars/src/main/java/com/xr/device_car/config/udp/UdbConfig.java b/device_cars/src/main/java/com/xr/device_car/config/udp/UdbConfig.java deleted file mode 100644 index 9efbac5..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/udp/UdbConfig.java +++ /dev/null @@ -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 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(""); - buffer.append(""); - 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(""); - return buffer.toString(); - } - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/udp/UdpClientConfig.java b/device_cars/src/main/java/com/xr/device_car/config/udp/UdpClientConfig.java deleted file mode 100644 index c98bf62..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/udp/UdpClientConfig.java +++ /dev/null @@ -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() { - @Override - protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { - // 处理接收到的数据 - String data = msg.content().toString(CharsetUtil.UTF_8); - QueryWrapper 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); - } - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/AnalysisXml.java b/device_cars/src/main/java/com/xr/device_car/config/utils/AnalysisXml.java deleted file mode 100644 index 3d41049..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/AnalysisXml.java +++ /dev/null @@ -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 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 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 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 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("&", "&"); - 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 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("&", "&"); - 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 elements=element.elements("Uri"); - return String.valueOf(elements.get(0).getData()); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static List getBallheadPTs(String resultStr){ - List ballheadPTS=new ArrayList<>(); - String xmlStr = StringEscapeUtils.unescapeXml(resultStr).replace("&", "&"); - SAXReader reader = new SAXReader(); - try { - Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))); - Element root = document.getRootElement(); - List 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 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("&", "&"); - 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; - } - - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/CodeGenUtil.java b/device_cars/src/main/java/com/xr/device_car/config/utils/CodeGenUtil.java index 4ac5cbc..9c8e7eb 100644 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/CodeGenUtil.java +++ b/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) diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/DigestsUtils.java b/device_cars/src/main/java/com/xr/device_car/config/utils/DigestsUtils.java deleted file mode 100644 index 5aea281..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/DigestsUtils.java +++ /dev/null @@ -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(::) - * HA2 = MD5(:) - * response = MD5(HA1:::::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(); - } - -} - diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/EasyExcelUtil.java b/device_cars/src/main/java/com/xr/device_car/config/utils/EasyExcelUtil.java deleted file mode 100644 index 4d26d3a..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/EasyExcelUtil.java +++ /dev/null @@ -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 void writeExcel(HttpServletResponse response, List data, Class tClass, String name){ - try { - List 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 List convertList(List list, Class targetClass) throws NoSuchFieldException, IllegalAccessException, ParseException, NoSuchMethodException, InvocationTargetException, InstantiationException { - List 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; - } - - - - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/FileUtil.java b/device_cars/src/main/java/com/xr/device_car/config/utils/FileUtil.java deleted file mode 100644 index 3d2ed92..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/FileUtil.java +++ /dev/null @@ -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; - - } - - - - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/Files.java b/device_cars/src/main/java/com/xr/device_car/config/utils/Files.java index 0a310fb..9ec0767 100644 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/Files.java +++ b/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; - - } diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/HkComUtil.java b/device_cars/src/main/java/com/xr/device_car/config/utils/HkComUtil.java deleted file mode 100644 index c03d80a..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/HkComUtil.java +++ /dev/null @@ -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 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; - } -} - - - - - - - diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/HttpResponseBean.java b/device_cars/src/main/java/com/xr/device_car/config/utils/HttpResponseBean.java deleted file mode 100644 index 6be8fc7..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/HttpResponseBean.java +++ /dev/null @@ -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
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; - } -} - diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/MinioUtil.java b/device_cars/src/main/java/com/xr/device_car/config/utils/MinioUtil.java deleted file mode 100644 index dcd7af6..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/MinioUtil.java +++ /dev/null @@ -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"上传失败"; - } - } - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/OnvifUtils.java b/device_cars/src/main/java/com/xr/device_car/config/utils/OnvifUtils.java deleted file mode 100644 index beab0ce..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/OnvifUtils.java +++ /dev/null @@ -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 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 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; - } -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/PythonExecutor.java b/device_cars/src/main/java/com/xr/device_car/config/utils/PythonExecutor.java deleted file mode 100644 index 67d6302..0000000 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/PythonExecutor.java +++ /dev/null @@ -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 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 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 query = new QueryWrapper<>(); - query.eq("meter_id", id); - query.orderByAsc("serial"); - List list = meterInitializationService.list(query); - List 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> list1 = new ArrayList<>(); - List list2 = new ArrayList<>(); - list2.add(id); - List 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 list1 = new ArrayList<>(); - path.add(0, id + ""); - list1.add(ph); - code = "sr.initialize(" + Arrays.toString(list1.toArray()) + ")\n"; - } - if (sfType.equals("5")) { - List 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 list = new ArrayList<>(); - String line; - // 读取输出 - while ((line = reader.readLine()) != null) { - list.add(line); - } - - BufferedReader exception = new BufferedReader(new InputStreamReader(process.getErrorStream())); - List 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; - } - - -} diff --git a/device_cars/src/main/java/com/xr/device_car/config/utils/StaticPropUtil.java b/device_cars/src/main/java/com/xr/device_car/config/utils/StaticPropUtil.java index b138ba2..6392613 100644 --- a/device_cars/src/main/java/com/xr/device_car/config/utils/StaticPropUtil.java +++ b/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(); } } diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/DeviceCameraController.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/DeviceCameraController.java index 90df665..1fa145d 100644 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/DeviceCameraController.java +++ b/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 deviceCameraList = deviceCameraService.page(pg, wrapper); System.out.println(deviceCameraList); return Result.OK(deviceCameraList); diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/FocalLengthConfigController.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/FocalLengthConfigController.java index 07c5922..c8ac05b 100644 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/FocalLengthConfigController.java +++ b/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); - } - } diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterConfigController.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterConfigController.java index a370df7..8fa99a6 100644 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterConfigController.java +++ b/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 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 query=new QueryWrapper<>(); - query.eq("status",1); - List list = meterConfigService.list(query); - String sendMsg = UdbConfig.getUdbConfig(list); - udpClientService.sendData(sendMsg); - }catch (Exception e){ - e.printStackTrace(); - return Result.OK("同步失败!"); - } - return Result.OK("同步成功!"); - } - } diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterInitializationController.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterInitializationController.java deleted file mode 100644 index fcb6e9b..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/MeterInitializationController.java +++ /dev/null @@ -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; - -/** - *

- * 表计算法初始化 前端控制器 - *

- * - * @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 queryWrapper=new QueryWrapper<>(); - queryWrapper.eq("meter_id",meterInitialization.getMeterId()); - queryWrapper.orderByDesc("serial"); - List 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 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 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 pg = StringFormatterUtil.returnPage(req); - QueryWrapper wrapper = StringFormatterUtil.returnQuery(req); - // meterId - if (ObjectUtil.isNotEmpty(meterInitialization.getMeterId())){ - wrapper.eq("meter_id",meterInitialization.getMeterId()); - } - wrapper.orderByAsc("serial"); - List 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("初始化完成"); - } - -} - diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/SendUdpLogController.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/SendUdpLogController.java deleted file mode 100644 index 1e574c4..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/controller/SendUdpLogController.java +++ /dev/null @@ -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 pageList(SendUdpLog sendUdpLog, HttpServletRequest req){ - Page page = StringFormatterUtil.returnPage(req); - QueryWrapper 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 object = (Map) JSONObject.parse(data); - SendUdpLog sendUdpLog = JSONObject.parseObject(data,SendUdpLog.class); - List list = (List) object.get("ids"); - List sendUdpLogs =new ArrayList<>(); - if(list.isEmpty()){ - QueryWrapper 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日志"); - } - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/BallheadPT.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/BallheadPT.java deleted file mode 100644 index 73d3d85..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/BallheadPT.java +++ /dev/null @@ -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; - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DeviceCamera.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DeviceCamera.java index 32577bc..e42d303 100644 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DeviceCamera.java +++ b/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; } \ No newline at end of file diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DigestBean.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DigestBean.java deleted file mode 100644 index 411e30b..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/DigestBean.java +++ /dev/null @@ -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); - } - - -} - diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterConfig.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterConfig.java index 5c8b1a4..fc6b77c 100644 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterConfig.java +++ b/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); diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterInitialization.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterInitialization.java deleted file mode 100644 index 1a2527b..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterInitialization.java +++ /dev/null @@ -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; - -/** - *

- * 表计算法初始化 - *

- * - * @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; - - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterReadingRecord.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterReadingRecord.java index 727fd88..a8956b8 100644 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/MeterReadingRecord.java +++ b/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 */ diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifAuthBean.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifAuthBean.java deleted file mode 100644 index d503b0d..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifAuthBean.java +++ /dev/null @@ -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; - } - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifBean.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifBean.java deleted file mode 100644 index 9e9901c..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifBean.java +++ /dev/null @@ -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; - } - - -} - diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifCredentials.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifCredentials.java deleted file mode 100644 index 0c0eb91..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/OnvifCredentials.java +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/SendUdpLog.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/SendUdpLog.java deleted file mode 100644 index 544c5ff..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/SendUdpLog.java +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/xslx/SendUdpLogXslx.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/xslx/SendUdpLogXslx.java deleted file mode 100644 index 28ccec9..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/entity/xslx/SendUdpLogXslx.java +++ /dev/null @@ -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 "失败"; - } -} \ No newline at end of file diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/MeterInitializationMapper.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/MeterInitializationMapper.java deleted file mode 100644 index 7773536..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/MeterInitializationMapper.java +++ /dev/null @@ -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; - -/** - *

- * 表计算法初始化 Mapper 接口 - *

- * - * @author gaoby - * @since 2023-11-20 - */ -@DS("db2") -@Mapper -public interface MeterInitializationMapper extends BaseMapper { - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/SendUdpLogMapper.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/SendUdpLogMapper.java deleted file mode 100644 index 1e439eb..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/mapper/SendUdpLogMapper.java +++ /dev/null @@ -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 { - -} - - - - diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/IMeterInitializationService.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/IMeterInitializationService.java deleted file mode 100644 index 2ee53aa..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/IMeterInitializationService.java +++ /dev/null @@ -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; - -/** - *

- * 表计算法初始化 服务类 - *

- * - * @author gaoby - * @since 2023-11-20 - */ -public interface IMeterInitializationService extends IService { - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/SendUdpLogService.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/SendUdpLogService.java deleted file mode 100644 index 16e67c4..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/SendUdpLogService.java +++ /dev/null @@ -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 { - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/UdpClientService.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/UdpClientService.java deleted file mode 100644 index 2019a7b..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/UdpClientService.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.xr.device_car.modules.analysis.service; - -public interface UdpClientService { - - void sendData(String data); - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/MeterInitializationServiceImpl.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/MeterInitializationServiceImpl.java deleted file mode 100644 index 5600d05..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/MeterInitializationServiceImpl.java +++ /dev/null @@ -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; - -/** - *

- * 表计算法初始化 服务实现类 - *

- * - * @author gaoby - * @since 2023-11-20 - */ -@Service -public class MeterInitializationServiceImpl extends ServiceImpl implements IMeterInitializationService { - -} diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/SendUdpLogServiceImpl.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/SendUdpLogServiceImpl.java deleted file mode 100644 index cfd072e..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/SendUdpLogServiceImpl.java +++ /dev/null @@ -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 - implements SendUdpLogService { - -} - - - - diff --git a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/UdpClientServiceImpl.java b/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/UdpClientServiceImpl.java deleted file mode 100644 index 3a99836..0000000 --- a/device_cars/src/main/java/com/xr/device_car/modules/analysis/service/impl/UdpClientServiceImpl.java +++ /dev/null @@ -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); - } -} diff --git a/device_cars/src/main/resources/application-dev.yml b/device_cars/src/main/resources/application-dev.yml index 6788324..132618f 100644 --- a/device_cars/src/main/resources/application-dev.yml +++ b/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 \ No newline at end of file + defaultZone: http://localhost:8084/eureka \ No newline at end of file diff --git a/device_cars/src/main/resources/application-prod.yml b/device_cars/src/main/resources/application-prod.yml index c805c60..ccdc40d 100644 --- a/device_cars/src/main/resources/application-prod.yml +++ b/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} diff --git a/device_cars/src/main/resources/application-test.yml b/device_cars/src/main/resources/application-test.yml index 95a1939..443b502 100644 --- a/device_cars/src/main/resources/application-test.yml +++ b/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 diff --git a/device_cars/src/main/resources/application.yml b/device_cars/src/main/resources/application.yml index 8d7945b..1bfd782 100644 --- a/device_cars/src/main/resources/application.yml +++ b/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 - diff --git a/device_cars/src/main/resources/digest/AbsoluteMove.wsdl b/device_cars/src/main/resources/digest/AbsoluteMove.wsdl deleted file mode 100644 index 7bb64b3..0000000 --- a/device_cars/src/main/resources/digest/AbsoluteMove.wsdl +++ /dev/null @@ -1,12 +0,0 @@ - - - - - %s - - - - - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GetDeviceInformation.wsdl b/device_cars/src/main/resources/digest/GetDeviceInformation.wsdl deleted file mode 100644 index 9b65996..0000000 --- a/device_cars/src/main/resources/digest/GetDeviceInformation.wsdl +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GetPTZ.wsdl b/device_cars/src/main/resources/digest/GetPTZ.wsdl deleted file mode 100644 index 5de3704..0000000 --- a/device_cars/src/main/resources/digest/GetPTZ.wsdl +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GetPresets.wsdl b/device_cars/src/main/resources/digest/GetPresets.wsdl deleted file mode 100644 index de30d8c..0000000 --- a/device_cars/src/main/resources/digest/GetPresets.wsdl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - %s - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GetProfiles.wsdl b/device_cars/src/main/resources/digest/GetProfiles.wsdl deleted file mode 100644 index 92dc2cd..0000000 --- a/device_cars/src/main/resources/digest/GetProfiles.wsdl +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GetSnapshotUrl.wsdl b/device_cars/src/main/resources/digest/GetSnapshotUrl.wsdl deleted file mode 100644 index 3b6f76a..0000000 --- a/device_cars/src/main/resources/digest/GetSnapshotUrl.wsdl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - %s - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GetStatus.wsdl b/device_cars/src/main/resources/digest/GetStatus.wsdl deleted file mode 100644 index 15f1e73..0000000 --- a/device_cars/src/main/resources/digest/GetStatus.wsdl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - %s - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GetStreamUri.wsdl b/device_cars/src/main/resources/digest/GetStreamUri.wsdl deleted file mode 100644 index b8fae91..0000000 --- a/device_cars/src/main/resources/digest/GetStreamUri.wsdl +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - %s - %s - %s - %s - - - - - - - - RTP-Unicast - - %s - - - %s - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/digest/GotoPreset.wsdl b/device_cars/src/main/resources/digest/GotoPreset.wsdl deleted file mode 100644 index 330014e..0000000 --- a/device_cars/src/main/resources/digest/GotoPreset.wsdl +++ /dev/null @@ -1,9 +0,0 @@ - - - - - %s - %s - - - \ No newline at end of file diff --git a/device_cars/src/main/resources/modules/analysis/MeterConfigMapper.xml b/device_cars/src/main/resources/modules/analysis/MeterConfigMapper.xml index 8dc1a49..678e454 100644 --- a/device_cars/src/main/resources/modules/analysis/MeterConfigMapper.xml +++ b/device_cars/src/main/resources/modules/analysis/MeterConfigMapper.xml @@ -17,13 +17,12 @@ - + - @@ -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, - select - 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} diff --git a/device_cars/src/main/resources/modules/analysis/MeterInitializationMapper.xml b/device_cars/src/main/resources/modules/analysis/MeterInitializationMapper.xml deleted file mode 100644 index aa1034a..0000000 --- a/device_cars/src/main/resources/modules/analysis/MeterInitializationMapper.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/device_cars/src/main/resources/modules/analysis/SendUdpLogMapper.xml b/device_cars/src/main/resources/modules/analysis/SendUdpLogMapper.xml deleted file mode 100644 index 9b7afe9..0000000 --- a/device_cars/src/main/resources/modules/analysis/SendUdpLogMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - id,message_id,request_status, - request_msg,request_time,res_msg, - res_time - - diff --git a/device_display/pom.xml b/device_display/pom.xml index 5a69753..6d6a2f7 100644 --- a/device_display/pom.xml +++ b/device_display/pom.xml @@ -145,7 +145,7 @@ joda-time joda-time - ${joda-time.version} + ${joda.time.version} cn.hutool diff --git a/device_display/src/main/java/com/xr/device_display/modules/analysis/dto/HistogramDto.java b/device_display/src/main/java/com/xr/device_display/modules/analysis/dto/HistogramDto.java deleted file mode 100644 index 9e2474f..0000000 --- a/device_display/src/main/java/com/xr/device_display/modules/analysis/dto/HistogramDto.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.xr.device_display.modules.analysis.dto; - -import lombok.Data; - -@Data -public class HistogramDto { - - private dataset dataset; - -} diff --git a/device_display/src/main/java/com/xr/device_display/modules/analysis/dto/dataset.java b/device_display/src/main/java/com/xr/device_display/modules/analysis/dto/dataset.java deleted file mode 100644 index 2e57e50..0000000 --- a/device_display/src/main/java/com/xr/device_display/modules/analysis/dto/dataset.java +++ /dev/null @@ -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> source; -} diff --git a/device_display/src/main/java/com/xr/device_display/modules/analysis/service/impl/MeterReadingRecordServiceImpl.java b/device_display/src/main/java/com/xr/device_display/modules/analysis/service/impl/MeterReadingRecordServiceImpl.java index b24ae06..a4dfcb3 100644 --- a/device_display/src/main/java/com/xr/device_display/modules/analysis/service/impl/MeterReadingRecordServiceImpl.java +++ b/device_display/src/main/java/com/xr/device_display/modules/analysis/service/impl/MeterReadingRecordServiceImpl.java @@ -121,14 +121,12 @@ public class MeterReadingRecordServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(MeterReadingRecord::getMeterCode, meterCode); - lambdaQueryWrapper.between(MeterReadingRecord::getReadingTime, sevenDaysAgo, nextDay); + lambdaQueryWrapper.between(MeterReadingRecord::getReadingTime, sevenDaysAgo, currentDate); lambdaQueryWrapper.orderByAsc(MeterReadingRecord::getReadingTime); // 查询记录 diff --git a/device_display/src/main/resources/application-dev.yml b/device_display/src/main/resources/application-dev.yml index 41f90b4..bda9915 100644 --- a/device_display/src/main/resources/application-dev.yml +++ b/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连接池配置 diff --git a/device_display/src/main/resources/application-prod.yml b/device_display/src/main/resources/application-prod.yml index 4eaa6a9..bb3136b 100644 --- a/device_display/src/main/resources/application-prod.yml +++ b/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连接池配置 diff --git a/device_display/src/main/resources/application-test.yml b/device_display/src/main/resources/application-test.yml index 220f551..fc5d3f7 100644 --- a/device_display/src/main/resources/application-test.yml +++ b/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连接池配置 diff --git a/device_display/src/main/resources/application.yml b/device_display/src/main/resources/application.yml index 9c44951..a066839 100644 --- a/device_display/src/main/resources/application.yml +++ b/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: diff --git a/device_iec104/src/main/java/com/xr/iec104Server/iec104/server/SysDataHandler.java b/device_iec104/src/main/java/com/xr/iec104Server/iec104/server/SysDataHandler.java index 1b6f46a..1e80e6f 100644 --- a/device_iec104/src/main/java/com/xr/iec104Server/iec104/server/SysDataHandler.java +++ b/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 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()); diff --git a/device_iec104/src/main/resources/application-dev.yml b/device_iec104/src/main/resources/application-dev.yml index 2407832..c5951f5 100644 --- a/device_iec104/src/main/resources/application-dev.yml +++ b/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: diff --git a/device_iec104/src/main/resources/application-prod.yml b/device_iec104/src/main/resources/application-prod.yml index 13e7eaf..fc5dfd7 100644 --- a/device_iec104/src/main/resources/application-prod.yml +++ b/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: diff --git a/device_iec61850clent/src/main/java/com/xr/iec61850clent/Iec61850ClentApplication.java b/device_iec61850clent/src/main/java/com/xr/iec61850clent/Iec61850ClentApplication.java index 242f3a8..5cc4435 100644 --- a/device_iec61850clent/src/main/java/com/xr/iec61850clent/Iec61850ClentApplication.java +++ b/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); diff --git a/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ExcelUtil.java b/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ExcelUtil.java deleted file mode 100644 index 5729d89..0000000 --- a/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ExcelUtil.java +++ /dev/null @@ -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(); - } - -} diff --git a/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/IEC61850Config.java b/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/IEC61850Config.java deleted file mode 100644 index 0a6b804..0000000 --- a/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/IEC61850Config.java +++ /dev/null @@ -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> CURRENT_CONFIG = new ThreadLocal<>(); - - @PostConstruct - public void setExcelConfig(){ - List excelConfigs = readExcel(); - CURRENT_CONFIG.set(excelConfigs); - } - - public static List readExcel(){ - InputStream inputStream = IEC61850Config.class.getClassLoader().getResourceAsStream("IEC61850.xlsx"); - XSSFWorkbook wb = null; - XSSFSheet sheet = null; // 创建工作sheet - List 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 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; - } - -} \ No newline at end of file diff --git a/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ModeUtil.java b/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ModeUtil.java index dffddc3..146fbec 100644 --- a/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ModeUtil.java +++ b/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("一体化电源")){ diff --git a/device_iec61850clent/src/main/java/com/xr/iec61850clent/models/entity/ExcelConfig.java b/device_iec61850clent/src/main/java/com/xr/iec61850clent/models/entity/ExcelConfig.java deleted file mode 100644 index 368b025..0000000 --- a/device_iec61850clent/src/main/java/com/xr/iec61850clent/models/entity/ExcelConfig.java +++ /dev/null @@ -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; - -} diff --git a/device_iec61850clent/src/main/resources/IEC61850.xlsx b/device_iec61850clent/src/main/resources/IEC61850.xlsx deleted file mode 100644 index 90e4037..0000000 Binary files a/device_iec61850clent/src/main/resources/IEC61850.xlsx and /dev/null differ diff --git a/device_iec61850clent/src/main/resources/application-dev.yml b/device_iec61850clent/src/main/resources/application-dev.yml index ba5a3aa..488b80b 100644 --- a/device_iec61850clent/src/main/resources/application-dev.yml +++ b/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: diff --git a/device_iec61850clent/src/main/resources/application-prod.yml b/device_iec61850clent/src/main/resources/application-prod.yml index 04106c4..e2f1ffd 100644 --- a/device_iec61850clent/src/main/resources/application-prod.yml +++ b/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: diff --git a/device_iec61850clent/src/main/resources/application-test.yml b/device_iec61850clent/src/main/resources/application-test.yml index 8b01f66..2875bbd 100644 --- a/device_iec61850clent/src/main/resources/application-test.yml +++ b/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: diff --git a/device_iec61850server/src/main/java/com/xr/iec61850server/models/entity/Lds5000.java b/device_iec61850server/src/main/java/com/xr/iec61850server/models/entity/Lds5000.java deleted file mode 100644 index d5ca871..0000000 --- a/device_iec61850server/src/main/java/com/xr/iec61850server/models/entity/Lds5000.java +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/device_iec61850server/src/main/java/com/xr/iec61850server/models/mapper/Lds5000Mapper.java b/device_iec61850server/src/main/java/com/xr/iec61850server/models/mapper/Lds5000Mapper.java deleted file mode 100644 index 2bb89fa..0000000 --- a/device_iec61850server/src/main/java/com/xr/iec61850server/models/mapper/Lds5000Mapper.java +++ /dev/null @@ -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 { - -} - - - - diff --git a/device_iec61850server/src/main/java/com/xr/iec61850server/models/service/Lds5000Service.java b/device_iec61850server/src/main/java/com/xr/iec61850server/models/service/Lds5000Service.java deleted file mode 100644 index 80e8c73..0000000 --- a/device_iec61850server/src/main/java/com/xr/iec61850server/models/service/Lds5000Service.java +++ /dev/null @@ -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 { - -} diff --git a/device_iec61850server/src/main/java/com/xr/iec61850server/models/service/impl/Lds5000ServiceImpl.java b/device_iec61850server/src/main/java/com/xr/iec61850server/models/service/impl/Lds5000ServiceImpl.java deleted file mode 100644 index 4994141..0000000 --- a/device_iec61850server/src/main/java/com/xr/iec61850server/models/service/impl/Lds5000ServiceImpl.java +++ /dev/null @@ -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 - implements Lds5000Service{ - -} - - - - diff --git a/device_iec61850server/src/main/resources/application-dev.yml b/device_iec61850server/src/main/resources/application-dev.yml index f89e542..41914ce 100644 --- a/device_iec61850server/src/main/resources/application-dev.yml +++ b/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: diff --git a/device_iec61850server/src/main/resources/application-prod.yml b/device_iec61850server/src/main/resources/application-prod.yml index 4d4823f..2a66e14 100644 --- a/device_iec61850server/src/main/resources/application-prod.yml +++ b/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: diff --git a/device_iec61850server/src/main/resources/application-test.yml b/device_iec61850server/src/main/resources/application-test.yml index 6131f1b..52c6872 100644 --- a/device_iec61850server/src/main/resources/application-test.yml +++ b/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: diff --git a/device_iec61850server/src/main/resources/application.yml b/device_iec61850server/src/main/resources/application.yml index 2e5c686..a9dade4 100644 --- a/device_iec61850server/src/main/resources/application.yml +++ b/device_iec61850server/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: dev #开发环境 + active: test #开发环境 # active: test #测试环境5 #active: prod #生产环境 # active: prod #生产环境 diff --git a/device_iec61850server/src/main/resources/mappers/Lds5000Mapper.xml b/device_iec61850server/src/main/resources/mappers/Lds5000Mapper.xml deleted file mode 100644 index 2962d29..0000000 --- a/device_iec61850server/src/main/resources/mappers/Lds5000Mapper.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - id,clent_ip,lds_desc, - fc,type,node, - q,t,st_val, - f,create_time,update_time - - diff --git a/device_modbus/src/main/java/com/xr/clent/utils/ModbusRtuUtil.java b/device_modbus/src/main/java/com/xr/clent/utils/ModbusRtuUtil.java deleted file mode 100644 index c87b764..0000000 --- a/device_modbus/src/main/java/com/xr/clent/utils/ModbusRtuUtil.java +++ /dev/null @@ -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 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;iorg.springframework.boot spring-boot-starter-data-redis - - - - - - - - - - - - - - - org.apache.httpcomponents - httpclient - 4.5 - - - org.apache.httpcomponents - httpmime - 4.5 - - - org.apache.httpcomponents - httpcore - 4.4.1 - - - org.dom4j - dom4j - 2.1.3 + io.netty + netty-all + 4.1.65.Final @@ -141,13 +112,6 @@ **/* - - ${basedir}/src/main/resources - BOOT-INF/lib/ - - **/*.jar - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/DeviceUdpclentApplication.java b/device_udpclent/src/main/java/com/xr/device_udpclent/DeviceUdpclentApplication.java index 574f2ed..2e65a0c 100644 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/DeviceUdpclentApplication.java +++ b/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 { diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/BodyRequestConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/BodyRequestConfig.java deleted file mode 100644 index e7778dd..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/BodyRequestConfig.java +++ /dev/null @@ -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; - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/Const.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/Const.java deleted file mode 100644 index fc2a1f8..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/Const.java +++ /dev/null @@ -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\""; - - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/FormRequestConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/FormRequestConfig.java deleted file mode 100644 index 73c6386..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/FormRequestConfig.java +++ /dev/null @@ -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 formData = new HashMap<>(); - - private File file; - - /** - * 文件请求的name - */ - private String fileName; - - /** - * application/json - * text/xml - */ - private String type = "application/json"; -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/HttpResponseBean.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/HttpResponseBean.java deleted file mode 100644 index f7bf1bf..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/HttpResponseBean.java +++ /dev/null @@ -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
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; - } -} - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/KafkaConsumerConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/KafkaConsumerConfig.java deleted file mode 100644 index b4e1568..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/KafkaConsumerConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -//package com.xr.device_udpclent.common.config; -// -// -//import org.apache.kafka.clients.consumer.ConsumerConfig; -//import org.apache.kafka.common.serialization.StringDeserializer; -//import org.springframework.beans.factory.annotation.Value; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -//import org.springframework.kafka.annotation.EnableKafka; -//import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; -//import org.springframework.kafka.core.ConsumerFactory; -//import org.springframework.kafka.core.DefaultKafkaConsumerFactory; -// -//import java.util.HashMap; -//import java.util.Map; -// -//@Configuration -//@EnableKafka -//public class KafkaConsumerConfig { -// @Value("${spring.kafka.bootstrap-servers}") -// private String bootstrapServers; -// -// @Value("${spring.kafka.consumer.group-id}") -// private String groupId; -// -// @Bean -// public ConsumerFactory consumerFactory() { -// Map configProps = new HashMap<>(); -// configProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); -// configProps.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); -// configProps.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); -// configProps.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); -// return new DefaultKafkaConsumerFactory<>(configProps); -// } -// -// @Bean -// public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() { -// ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>(); -// factory.setConsumerFactory(consumerFactory()); -// return factory; -// } -//} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/KafkaProducerConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/KafkaProducerConfig.java deleted file mode 100644 index ed4eb44..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/KafkaProducerConfig.java +++ /dev/null @@ -1,37 +0,0 @@ -//package com.xr.device_udpclent.common.config; -// -//import org.apache.kafka.clients.producer.ProducerConfig; -//import org.apache.kafka.common.serialization.StringSerializer; -//import org.springframework.beans.factory.annotation.Value; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -//import org.springframework.kafka.annotation.EnableKafka; -//import org.springframework.kafka.core.DefaultKafkaProducerFactory; -//import org.springframework.kafka.core.KafkaTemplate; -//import org.springframework.kafka.core.ProducerFactory; -// -//import java.util.HashMap; -//import java.util.Map; -// -//@Configuration -//@EnableKafka -//public class KafkaProducerConfig { -// -// @Value("${spring.kafka.bootstrap-servers}") -// private String bootstrapServers; -// -// @Bean -// public ProducerFactory producerFactory() { -// Map configProps = new HashMap<>(); -// configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); -// configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); -// configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); -// return new DefaultKafkaProducerFactory<>(configProps); -// } -// -// @Bean -// public KafkaTemplate kafkaTemplate() { -// return new KafkaTemplate<>(producerFactory()); -// } -// -//} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/LoginConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/LoginConfig.java deleted file mode 100644 index a9b8dfe..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/LoginConfig.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.xr.device_udpclent.common.config; - -public class LoginConfig { - - public static String CODE_SUCCESS = "0000"; - public static String CODE_FAULE = "0010"; - public static String CODE_WRONG = "0020"; - public static String CAPTCHA_WRONG = "0030"; - public static String CODE_AUTH = "0040"; - public static String CODE_DATA_INCOMPLETE = "0060"; - public static String CODE_ABNORMAL = "0070"; - public static String CODE_NO_JURISDICTION="1102"; - public static String OUT_LOGIN="1103"; - public static String CODE_REPETITION="1104"; - public static String CODE_DELETACCOUNT="1106"; - public static String CODE_EXCEED="1105"; - - - public static String MSG_SUCCESS = "获取数据成功"; - public static String MSG_FAULE = "获取数据失败"; - public static String MSG_WRONG = "用户名或密码错误"; - public static String MSG_CAPTCHA_WRONG = "验证码错误"; - public static String MSG_AUTH = "token失效,请重新登录"; - public static String MSG_DATA_INCOMPLETE = "参数不完整"; - public static String MSG_NO_JURISDICTION="无此权限"; - public static String MSG_LOGIN="登出"; - public static String MSG_REPETITION="重复添加"; - public static String MSG_DELETACCOUNT="请勿删除此账号"; - public static String MSG_EXCEED="越界"; - public static String DEFAULT_PWD="123456"; - - - public static final int INVALID_VALUE = -1; - public static final int DEFAULT_VALUE = 0; - public static final int COUNT_VALUE = 100; - - public static final String SYSUSER_ROLE_ID="2"; - public static final String USER_ROLE_ID="1"; - - - public static final String TIMESTAMP = "time_stamp"; - public static final String CryptoKey="ReGlory"; - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/OnvifAuthBean.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/OnvifAuthBean.java deleted file mode 100644 index d25068d..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/OnvifAuthBean.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.xr.device_udpclent.common.config; - -import com.xr.device_udpclent.models.entity.OnvifBean; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@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; - } - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/getconfigvalue/StaticPropProxy.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/getconfigvalue/StaticPropProxy.java deleted file mode 100644 index c57f092..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/getconfigvalue/StaticPropProxy.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.xr.device_udpclent.common.config.getconfigvalue; - -import com.xr.device_udpclent.common.utils.StaticPropUtil; -import org.springframework.stereotype.Component; - -@Component -public class StaticPropProxy { - public StaticPropProxy(StaticProperties staticProperties){ - StaticPropUtil.initDingDingProp(staticProperties); - } -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/getconfigvalue/StaticProperties.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/getconfigvalue/StaticProperties.java deleted file mode 100644 index 49f6fe5..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/getconfigvalue/StaticProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.xr.device_udpclent.common.config.getconfigvalue; - -import lombok.Data; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -@Component -@Data -public class StaticProperties { - - @Value("${upLoad.path}") - private String path; - - @Value("${upLoad.url}") - private String url; - - @Value("${python.path}") - private String pythonPath; - - @Value("${python.modelPath}") - private String modelPath; - - @Value("${udp.server.host}") - private String udpHost; - - @Value("${udp.server.port}") - private Integer udpPort; - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/udp/UdbConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/udp/UdbConfig.java deleted file mode 100644 index 3ae5e55..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/udp/UdbConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.xr.device_udpclent.common.config.udp; - -import com.xr.device_udpclent.models.entity.MeterReadingRecord; -import lombok.Data; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Random; - -@Data -public class UdbConfig { - - //获取遥测报文 - public static String getTestMsg(MeterReadingRecord record){ - StringBuffer buffer=new StringBuffer(); - SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - buffer.append(new Date().getTime()+ new Random().nextInt(9000)+1000).append("\t"); - buffer.append("站序号").append("\t");//站序号 - buffer.append(record.getMeterId()).append("\t");//监控ID - buffer.append(record.getDataType()).append("\t");//默认为遥测 - buffer.append("在线监测").append("\t");//属性 - buffer.append(record.getReadingValue()).append("\t");//值描述 - buffer.append(sdf.format(new Date())); - return buffer.toString(); - } - - public static void main(String[] args) { - String record = getTestMsg(new MeterReadingRecord()); - String msgId = record.split("\t")[0]; - System.out.println(msgId); - } - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/udp/UdpClientConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/udp/UdpClientConfig.java deleted file mode 100644 index ffccd16..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/config/udp/UdpClientConfig.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.xr.device_udpclent.common.config.udp; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.xr.device_udpclent.common.utils.StaticPropUtil; -import com.xr.device_udpclent.models.entity.SendUdpLog; -import com.xr.device_udpclent.models.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.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() { - @Override - protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { - // 处理接收到的数据 - String data = msg.content().toString(CharsetUtil.UTF_8); - QueryWrapper queryWrapper=new QueryWrapper(); - queryWrapper.eq("message_id",data.split(":")[0]); - SendUdpLog sendUdbLog= sendUdpLogService.getOne(queryWrapper); - if(sendUdbLog!=null){ - sendUdbLog.setResTime(new Date()); - sendUdbLog.setResMsg(data); - } - 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); - } - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/AnalysisXml.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/AnalysisXml.java deleted file mode 100644 index 9dce134..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/AnalysisXml.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import com.xr.device_udpclent.models.entity.BallheadPT; -import net.logstash.logback.encoder.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 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 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 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 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("&", "&"); - 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"); - return String.valueOf(element.elements("Uri").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("&", "&"); - 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"); - return String.valueOf(element.elements("Uri").get(0).getData()); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static List getBallheadPTs(String resultStr){ - List ballheadPTS=new ArrayList<>(); - String xmlStr = StringEscapeUtils.unescapeXml(resultStr).replace("&", "&"); - SAXReader reader = new SAXReader(); - try { - Document document = reader.read(new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))); - Element root = document.getRootElement(); - List 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 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("&", "&"); - 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; - } - - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/CryptoUtil.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/CryptoUtil.java deleted file mode 100644 index 708a65a..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/CryptoUtil.java +++ /dev/null @@ -1,219 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import com.xr.device_udpclent.common.config.LoginConfig; -import sun.misc.BASE64Decoder; -import sun.misc.BASE64Encoder; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.spec.SecretKeySpec; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.SecureRandom; -import java.util.Date; -import java.util.Random; - -public class CryptoUtil { - - public static boolean isNullOrEmpty(String x) - { - return x == null || x.length() == 0; - } - - public static void main(String[] args) throws Exception { - String content = "123456"; - System.out.println("加密前:" + content); - System.out.println(new Date().getTime()); -// - String key = LoginConfig.CryptoKey; - System.out.println("加密密钥和解密密钥:" + key); - - String encrypt = aesEncrypt(content, key); - System.out.println("加密后:" + encrypt); -// String encrypt = "EAsRq3OjCwMHqXo/9yFc0A=="; - String decrypt = aesDecrypt("EReac0gCF7wAgh38nJfupg==", key); - System.out.println("解密后:" + decrypt); - } - - /** - * 将byte[]转为各种进制的字符串 - * - * @param bytes - * byte[] - * @param radix - * 可以转换进制的范围,从Character.MIN_RADIX到Character.MAX_RADIX,超出范围后变为10进制 - * @return 转换后的字符串 - */ - public static String binary(byte[] bytes, int radix) { - return new BigInteger(1, bytes).toString(radix);// 这里的1代表正数 - } - - /** - * base 64 encode - * - * @param bytes - * 待编码的byte[] - * @return 编码后的base 64 code - */ - public static String base64Encode(byte[] bytes) { - return new BASE64Encoder().encode(bytes); - } - - - /** - * base 64 decode - * - * @param base64Code - * 待解码的base 64 code - * @return 解码后的byte[] - * @throws Exception - */ - public static byte[] base64Decode(String base64Code) throws Exception { - return isNullOrEmpty(base64Code) ? null : new BASE64Decoder().decodeBuffer(base64Code); - } - - /** - * 获取byte[]的md5值 - * - * @param bytes - * byte[] - * @return md5 - * @throws Exception - */ - public static byte[] md5(byte[] bytes) throws Exception { - MessageDigest md = MessageDigest.getInstance("MD5"); - md.update(bytes); - - return md.digest(); - } - - /** - * 获取字符串md5值 - * - * @param msg - * @return md5 - * @throws Exception - */ - public static byte[] md5(String msg) throws Exception { - return isNullOrEmpty(msg) ? null : md5(msg.getBytes()); - } - - /** - * 结合base64实现md5加密 - * - * @param msg - * 待加密字符串 - * @return 获取md5后转为base64 - * @throws Exception - */ - public static String md5Encrypt(String msg) throws Exception { - return isNullOrEmpty(msg) ? null : base64Encode(md5(msg)); - } - - /** - * AES加密 - * - * @param content - * 待加密的内容 - * @param encryptKey - * 加密密钥 - * @return 加密后的byte[] - * @throws Exception - */ - public static byte[] aesEncryptToBytes(String content, String encryptKey) throws Exception { - KeyGenerator kgen = KeyGenerator.getInstance("AES"); - SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG" ); - secureRandom.setSeed(encryptKey.getBytes()); - kgen.init(128,secureRandom); -// kgen.init(128, new SecureRandom(encryptKey.getBytes())); - - Cipher cipher = Cipher.getInstance("AES"); - cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES")); - - return cipher.doFinal(content.getBytes("utf-8")); - } - - /** - * AES加密为base 64 code - * - * @param content - * 待加密的内容 - * @param encryptKey - * 加密密钥 - * @return 加密后的base 64 code - * @throws Exception - */ - public static String aesEncrypt(String content, String encryptKey) throws Exception { - return base64Encode(aesEncryptToBytes(content, encryptKey)); - } - - /** - * AES解密 - * - * @param encryptBytes - * 待解密的byte[] - * @param decryptKey - * 解密密钥 - * @return 解密后的String - * @throws Exception - */ - public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) throws Exception { - KeyGenerator kgen = KeyGenerator.getInstance("AES"); - - SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG" ); - secureRandom.setSeed(decryptKey.getBytes()); - kgen.init(128,secureRandom); -// kgen.init(128, new SecureRandom(decryptKey.getBytes())); - - Cipher cipher = Cipher.getInstance("AES"); - cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES")); - byte[] decryptBytes = cipher.doFinal(encryptBytes); - - return new String(decryptBytes); - } - - /** - * 将base 64 code AES解密 - * - * @param encryptStr - * 待解密的base 64 code - * @param decryptKey - * 解密密钥 - * @return 解密后的string - * @throws Exception - */ - public static String aesDecrypt(String encryptStr, String decryptKey) throws Exception { - return isNullOrEmpty(encryptStr) ? null : aesDecryptByBytes(base64Decode(encryptStr), decryptKey); - } - - /** - * 生成随即密码 - * - * @param pwd_len - * 生成的密码的总长度 - * @return 密码的字符串 - */ - public static String genRandomNum(int pwd_len) { - // 35是因为数组是从0开始的,26个字母+10个数字 - final int maxNum = 35; - int i; // 生成的随机数 - int count = 0; // 生成的密码的长度 - char[] str = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', '0', '1', '2', '3', '4', - '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L' }; - - StringBuffer pwd = new StringBuffer(""); - Random r = new Random(); - while (count < pwd_len) { - // 生成随机数,取绝对值,防止生成负数, - - i = Math.abs(r.nextInt(maxNum)); // 生成的数最大为36-1 - - if (i >= 0 && i < str.length) { - pwd.append(str[i]); - count++; - } - } - - return pwd.toString(); - } -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/CryptosUtils.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/CryptosUtils.java deleted file mode 100644 index 17710d3..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/CryptosUtils.java +++ /dev/null @@ -1,371 +0,0 @@ - package com.xr.device_udpclent.common.utils; - - import org.apache.commons.codec.binary.Base64; - import org.slf4j.Logger; - import org.slf4j.LoggerFactory; - - import javax.crypto.*; - import javax.crypto.spec.IvParameterSpec; - import javax.crypto.spec.SecretKeySpec; - import java.security.*; - import java.util.Arrays; - - - public class CryptosUtils - { -/* 36 */ private static final Logger logger = LoggerFactory.getLogger(CryptosUtils.class); - - private static final String AES = "AES"; - - private static final String AES_CBC = "AES/CBC/PKCS5Padding"; - - private static final String HMACSHA1 = "HmacSHA1"; - - private static final int DEFAULT_HMACSHA1_KEYSIZE = 160; - - private static final int DEFAULT_AES_KEYSIZE = 128; - private static final int DEFAULT_IVSIZE = 16; - public static final String KEY = "ZMTE_ZDP_KEY____"; - public static final String IV = "ZMTE_ZDP_IV_____"; -/* 50 */ private static SecureRandom random = new SecureRandom(); - - - - - - - public static byte[] hmacSha1(byte[] input, byte[] key) - { - try - { -/* 61 */ SecretKey secretKey = new SecretKeySpec(key, "HmacSHA1"); -/* 62 */ Mac mac = Mac.getInstance("HmacSHA1"); -/* 63 */ mac.init(secretKey); -/* 64 */ return mac.doFinal(input); - } catch (GeneralSecurityException e) { -/* 66 */ throw ExceptionUtil.unchecked(e); - } - } - - - - - - - - public static boolean isMacValid(byte[] expected, byte[] input, byte[] key) - { -/* 78 */ byte[] actual = hmacSha1(input, key); -/* 79 */ return Arrays.equals(expected, actual); - } - - - - public static byte[] generateHmacSha1Key() - { - try - { -/* 88 */ KeyGenerator keyGenerator = KeyGenerator.getInstance("HmacSHA1"); -/* 89 */ keyGenerator.init(160); -/* 90 */ SecretKey secretKey = keyGenerator.generateKey(); -/* 91 */ return secretKey.getEncoded(); - } catch (GeneralSecurityException e) { -/* 93 */ throw ExceptionUtil.unchecked(e); - } - } - - - - - - - - public static byte[] aesEncrypt(byte[] input, byte[] key) - { -/* 105 */ return aes(input, key, 1); - } - - - - - - - - public static byte[] aesEncrypt(byte[] input, byte[] key, byte[] iv) - { -/* 116 */ return aes(input, key, iv, 1); - } - - - - - - - public static String aesDecrypt(byte[] input, byte[] key) - { -/* 126 */ byte[] decryptResult = aes(input, key, 2); -/* 127 */ return new String(decryptResult); - } - - - - - - - - public static String aesDecrypt(byte[] input, byte[] key, byte[] iv) - { -/* 138 */ byte[] decryptResult = aes(input, key, iv, 2); -/* 139 */ return new String(decryptResult); - } - - - - - - - private static byte[] aes(byte[] input, byte[] key, int mode) - { - try - { -/* 151 */ SecretKey secretKey = new SecretKeySpec(key, "AES"); -/* 152 */ Cipher cipher = Cipher.getInstance("AES"); -/* 153 */ cipher.init(mode, secretKey); -/* 154 */ return cipher.doFinal(input); - } catch (GeneralSecurityException e) { -/* 156 */ throw ExceptionUtil.unchecked(e); - } - } - - - - - - - - private static byte[] aes(byte[] input, byte[] key, byte[] iv, int mode) - { - try - { -/* 170 */ SecretKey secretKey = new SecretKeySpec(key, "AES"); -/* 171 */ IvParameterSpec ivSpec = new IvParameterSpec(iv); -/* 172 */ Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); -/* 173 */ cipher.init(mode, secretKey, ivSpec); -/* 174 */ return cipher.doFinal(input); - } catch (GeneralSecurityException e) { -/* 176 */ throw ExceptionUtil.unchecked(e); - } - } - - - - public static byte[] generateAesKey() - { -/* 184 */ return generateAesKey(128); - } - - - public static byte[] generateAesKey(int keysize) - { - try - { -/* 192 */ KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); -/* 193 */ keyGenerator.init(keysize); -/* 194 */ SecretKey secretKey = keyGenerator.generateKey(); -/* 195 */ return secretKey.getEncoded(); - } catch (GeneralSecurityException e) { -/* 197 */ throw ExceptionUtil.unchecked(e); - } - } - - - - public static byte[] generateIV() - { -/* 205 */ byte[] bytes = new byte[16]; -/* 206 */ random.nextBytes(bytes); -/* 207 */ return bytes; - } - - - - - - - - - public static byte[] aesencrypt(byte[] content, byte[] key, boolean md5Key, byte[] iv) - { - try - { -/* 221 */ if (md5Key) { -/* 222 */ MessageDigest md = MessageDigest.getInstance("MD5"); -/* 223 */ key = md.digest(key); - } -/* 225 */ SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); -/* 226 */ Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding"); -/* 227 */ IvParameterSpec ivps = new IvParameterSpec(iv); -/* 228 */ cipher.init(1, skeySpec, ivps); -/* 229 */ return cipher.doFinal(content); - } catch (NoSuchAlgorithmException ex) { -/* 231 */ ex.getLocalizedMessage(); - } catch (NoSuchPaddingException ex) { - ex.getLocalizedMessage(); - } catch (InvalidKeyException ex) { -/* 235 */ ex.getLocalizedMessage(); - } catch (InvalidAlgorithmParameterException ex) { - ex.getLocalizedMessage(); - } catch (IllegalBlockSizeException ex) { -/* 239 */ ex.getLocalizedMessage(); - } catch (BadPaddingException ex) { -/* 241 */ ex.getLocalizedMessage(); - } -/* 243 */ return null; - } - - public static byte[] aesdecrypt(byte[] content, byte[] key, boolean md5Key, byte[] iv) - { - try { -/* 249 */ if (md5Key) { -/* 250 */ MessageDigest md = MessageDigest.getInstance("MD5"); -/* 251 */ key = md.digest(key); - } -/* 253 */ SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); -/* 254 */ Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding"); - IvParameterSpec ivps = new IvParameterSpec(iv); -/* 256 */ cipher.init(2, skeySpec, ivps); -/* 257 */ return cipher.doFinal(content); - } catch (NoSuchAlgorithmException ex) { -/* 259 */ ex.printStackTrace(); - } catch (NoSuchPaddingException ex) { -/* 261 */ ex.printStackTrace(); - } catch (InvalidKeyException ex) { -/* 263 */ ex.printStackTrace(); - } catch (InvalidAlgorithmParameterException ex) { -/* 265 */ ex.printStackTrace(); - } catch (IllegalBlockSizeException ex) { -/* 267 */ ex.printStackTrace(); - } catch (BadPaddingException ex) { -/* 269 */ ex.printStackTrace(); - } -/* 271 */ return null; - } - - public static String encrypt(String plain) throws Exception - { - try - { -/* 278 */ Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); -/* 279 */ int blockSize = cipher.getBlockSize(); - -/* 281 */ byte[] dataBytes = plain.getBytes(); -/* 282 */ int plaintextLength = dataBytes.length; -/* 283 */ if (plaintextLength % blockSize != 0) { -/* 284 */ plaintextLength += blockSize - plaintextLength % blockSize; - } - -/* 287 */ byte[] plaintext = new byte[plaintextLength]; -/* 288 */ System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length); - -/* 290 */ SecretKeySpec keyspec = new SecretKeySpec("ZMTE_ZDP_KEY____".getBytes(), "AES"); -/* 291 */ IvParameterSpec ivspec = new IvParameterSpec("ZMTE_ZDP_IV_____".getBytes()); - -/* 293 */ cipher.init(1, keyspec, ivspec); -/* 294 */ byte[] encrypted = cipher.doFinal(plaintext); - -/* 296 */ return Base64.encodeBase64String(encrypted); - } - catch (Exception e) { -/* 299 */ e.printStackTrace(); -/* 300 */ throw e; - } - } - - public static String encrypt(String plain, String key, String iv) throws Exception { - try { -/* 306 */ Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); -/* 307 */ int blockSize = cipher.getBlockSize(); - -/* 309 */ byte[] dataBytes = plain.getBytes(); -/* 310 */ int plaintextLength = dataBytes.length; -/* 311 */ if (plaintextLength % blockSize != 0) { -/* 312 */ plaintextLength += blockSize - plaintextLength % blockSize; - } - -/* 315 */ byte[] plaintext = new byte[plaintextLength]; -/* 316 */ System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length); - -/* 318 */ SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES"); -/* 319 */ IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes()); - -/* 321 */ cipher.init(1, keyspec, ivspec); -/* 322 */ byte[] encrypted = cipher.doFinal(plaintext); - -/* 324 */ return Base64.encodeBase64String(encrypted); - } - catch (Exception e) { -/* 327 */ e.printStackTrace(); -/* 328 */ throw e; - } - } - - public static String decrypt(String encrypt) throws Exception { - try { -/* 334 */ byte[] encrypted1 = Base64.decodeBase64(encrypt); - -/* 336 */ Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); -/* 337 */ SecretKeySpec keyspec = new SecretKeySpec("ZMTE_ZDP_KEY____".getBytes(), "AES"); -/* 338 */ IvParameterSpec ivspec = new IvParameterSpec("ZMTE_ZDP_IV_____".getBytes()); - -/* 340 */ cipher.init(2, keyspec, ivspec); - -/* 342 */ byte[] original = cipher.doFinal(encrypted1); - -/* 344 */ String originalString = new String(original); -/* 345 */ return originalString.trim(); - } catch (Exception e) { -/* 347 */ e.printStackTrace(); -/* 348 */ throw e; - } - } - - public static String decrypt(String encrypt, String key, String iv) throws Exception { - try { -/* 354 */ byte[] encrypted1 = Base64.decodeBase64(encrypt); - -/* 356 */ Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); -/* 357 */ SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES"); -/* 358 */ IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes()); - -/* 360 */ cipher.init(2, keyspec, ivspec); - -/* 362 */ byte[] original = cipher.doFinal(encrypted1); - -/* 364 */ String originalString = new String(original); -/* 365 */ return originalString.trim(); - } catch (Exception e) { -/* 367 */ e.printStackTrace(); -/* 368 */ throw e; - } - } - - - - - public static byte[] decode(byte[] bytes) - { -/* 377 */ return Base64.decodeBase64(bytes); - } - - - - - - - - public static String encode(byte[] bytes) - { -/* 388 */ return new String(Base64.encodeBase64(bytes)); - } - } - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/DigestsUtils.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/DigestsUtils.java deleted file mode 100644 index 3aba7e3..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/DigestsUtils.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.xr.device_udpclent.common.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(::) - * HA2 = MD5(:) - * response = MD5(HA1:::::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(); - } - -} - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/ExceptionUtil.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/ExceptionUtil.java deleted file mode 100644 index 78a073d..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/ExceptionUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import java.io.PrintWriter; -import java.io.StringWriter; - - -public class ExceptionUtil -{ - public static RuntimeException unchecked(Throwable ex) - { -/* 19 */ if ((ex instanceof RuntimeException)) { -/* 20 */ return (RuntimeException)ex; - } -/* 22 */ return new RuntimeException(ex); - } - - - - - public static String getStackTraceAsString(Throwable ex) - { -/* 30 */ StringWriter stringWriter = new StringWriter(); -/* 31 */ ex.printStackTrace(new PrintWriter(stringWriter)); -/* 32 */ return stringWriter.toString(); - } - - - - public static String getErrorMessageWithNestedException(Throwable ex) - { -/* 39 */ Throwable nestedException = ex.getCause(); -/* 40 */ return ex.getMessage() + " nested exception is " + nestedException -/* 41 */ .getClass().getName() + ":" + nestedException.getMessage(); - } - - - - public static Throwable getRootCause(Throwable ex) - { - Throwable cause; - -/* 50 */ while ((cause = ex.getCause()) != null) { -/* 51 */ ex = cause; - } -/* 53 */ return ex; - } - - - - public static boolean isCausedBy(Exception ex, Class... causeExceptionClasses) - { -/* 60 */ Throwable cause = ex; -/* 61 */ while (cause != null) { -/* 62 */ for (Class causeClass : causeExceptionClasses) { -/* 63 */ if (causeClass.isInstance(cause)) { -/* 64 */ return true; - } - } -/* 67 */ cause = cause.getCause(); - } -/* 69 */ return false; - } -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/FileUtil.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/FileUtil.java deleted file mode 100644 index 599bd11..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/FileUtil.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.xr.device_udpclent.common.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; - - } - - - - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/Files.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/Files.java deleted file mode 100644 index 135868d..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/Files.java +++ /dev/null @@ -1,314 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import org.apache.commons.io.FileUtils; -import org.springframework.web.multipart.MultipartFile; -import sun.misc.BASE64Encoder; - -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.util.Base64; - -public class Files { - - /** - * 根据文件路径获取文件字节流 - * @return - * filePath 文件路径 - * @throws IOException - */ - public static byte[] toByteArray(String filePath) throws IOException { - File f = new File(filePath); - if (!f.exists()) { - throw new FileNotFoundException("文件不存在"); - } - - ByteArrayOutputStream bos = new ByteArrayOutputStream((int) f.length()); - BufferedInputStream in = null; - try { - in = new BufferedInputStream(new FileInputStream(f)); - int buf_size = 1024; - byte[] buffer = new byte[buf_size]; - int len = 0; - while (-1 != (len = in.read(buffer, 0, buf_size))) { - bos.write(buffer, 0, len); - } - return bos.toByteArray(); - } catch (IOException e) { - e.printStackTrace(); - throw e; - } finally { - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - bos.close(); - } - } - public static File multipartFileToFile(MultipartFile file) throws Exception { - File toFile = null; - if (file.equals("") || file.getSize() <= 0) { - file = null; - } else { - InputStream ins = null; - ins = file.getInputStream(); - toFile = new File(file.getOriginalFilename()); - inputStreamToFile(ins, toFile); - ins.close(); - } - return toFile; - - } - - - - private static void inputStreamToFile(InputStream ins, File file) { - try { - OutputStream os = new FileOutputStream(file); - int bytesRead = 0; - byte[] buffer = new byte[8192]; - while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { - os.write(buffer, 0, bytesRead); - } - os.close(); - ins.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static BufferedImage urlByImage(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); - InputStream is2 = urlfile.openStream(); - BufferedImage uImg= ImageIO.read(is2); - return uImg; - } - - public static String TransformPhotoToBase64Data(String path){ - Base64.Encoder encoder= Base64.getEncoder(); //获取Base64编码器 - byte [] ImgContainer = null ; //数据集缓存器 - FileInputStream fileInputStream = null; //文件输入流 - try { - System.out.println(path); - File file=new File(path); - fileInputStream = new FileInputStream(file); //到指定路径寻找文件 - ImgContainer = new byte[fileInputStream.available()]; //设置图片字节数据缓冲区大小 - fileInputStream.read(ImgContainer); //将数据流中的图片数据读进缓冲区 - String Base64ImgData =encoder.encodeToString(ImgContainer); //将图片编码转换成Base64格式的数据集 - fileInputStream.close(); //关闭数据流 - return Base64ImgData; //将缓冲区数据转换成字符数据返回 - } catch (FileNotFoundException e) { - return "找不到指定文件!"; - } catch (IOException e) { - e.printStackTrace(); - } - return "null"; - } - - public static String getBase64String(MultipartFile multiPartFile) throws IOException { - String baseStr = null; - - //把MultipartFile转化为File - File file = new File(multiPartFile.getOriginalFilename()); - FileUtils.copyInputStreamToFile(multiPartFile.getInputStream(), file); - - /* System.out.println("文件名:"+file.getOriginalFilename( )); - System.out.println("文件类型:"+file.getContentType()); - System.out.println("文件大小: "+file.getSize( )); - String dateDir = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); - ClassPathResource PATHS = new ClassPathResource("static/files/"); - File paths=new File(PATHS.getPath()+file.getOriginalFilename()); - if (paths.getParentFile() != null && !paths.getParentFile().exists()) { - System.out.println("创建父路径"); - paths.getParentFile().mkdirs(); - } - com.xr.projsystem.common.utils.Base64Utils.decodeFile( - com.xr.projsystem.common.utils.Base64Utils.encode(file.getBytes()),paths); - mapData.put("url",serverConfig.getUrl()+paths.getPath().substring(paths.getPath().indexOf("files"))); - System.out.println(serverConfig.getUrl()+paths.getPath().substring(paths.getPath().indexOf("files")));*/ - try {//file转base64 - FileInputStream inputStream = new FileInputStream(file); - byte[] buffer = new byte[(int) file.length()]; - inputStream.read(buffer); - inputStream.close(); - baseStr = new BASE64Encoder().encode(buffer); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - //删除临时文件 - if (file.exists()) { - file.delete(); - } - baseStr = baseStr.replaceAll("\r\n", ""); - return baseStr; - } - - - public static String BufferedImageToBase64(BufferedImage bufferedImage) { - ByteArrayOutputStream baos = new ByteArrayOutputStream();//io流 - try { - ImageIO.write(bufferedImage, "png", baos);//写入流中 - } catch (IOException e) { - e.printStackTrace(); - } - byte[] bytes = baos.toByteArray();//转换成字节 - BASE64Encoder encoder = new BASE64Encoder(); - String png_base64 = encoder.encodeBuffer(bytes).trim();//转换成base64串 - png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n - System.out.println("值为:" + "data:image/jpg;base64," + png_base64); - return "data:image/jpg;base64," + png_base64; - } - - public static String ImageToBase64(BufferedImage bufferedImage) { - ByteArrayOutputStream baos = new ByteArrayOutputStream();//io流 - try { - ImageIO.write(bufferedImage, "png", baos);//写入流中 - } catch (IOException e) { - e.printStackTrace(); - } - byte[] bytes = baos.toByteArray();//转换成字节 - BASE64Encoder encoder = new BASE64Encoder(); - String png_base64 = encoder.encodeBuffer(bytes).trim();//转换成base64串 - png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n - return png_base64; - } - - /** *//** - * 旋转图片为指定角度 - * - * @param file - * 目标图像 - * @param degree - * 旋转角度 - * @return - */ - public static BufferedImage rotateImage(File file, - int degree) throws Exception{ -// if(degree<0){ -// degree=Math.abs(degree); -// }else{ -// degree=0-degree; -// } - BufferedImage bufferedimage = ImageIO.read(file); - int w= bufferedimage.getWidth();// 得到图片宽度。 - int h= bufferedimage.getHeight();// 得到图片高度。 - int type= bufferedimage.getColorModel().getTransparency();// 得到图片透明度。 - BufferedImage img;// 空的图片。 - Graphics2D graphics2d;// 空的画笔。 - (graphics2d= (img= new BufferedImage(w, h, type)) - .createGraphics()).setRenderingHint( - RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - graphics2d.rotate(Math.toRadians(degree),w/2,h/2);// 旋转,degree是整型,度数,比如垂直90度。 - graphics2d.drawImage(bufferedimage, 0, 0, null);// 从bufferedimagecopy图片至img,0,0是img的坐标。 - graphics2d.dispose(); - return img;// 返回复制好的图片,原图片依然没有变,没有旋转,下次还可以使用。 - } - - public static BufferedImage rotateImage(BufferedImage bufferedimage,int degree){ - int w= bufferedimage.getWidth();// 得到图片宽度。 - int h= bufferedimage.getHeight();// 得到图片高度。 - int type= bufferedimage.getColorModel().getTransparency();// 得到图片透明度。 - BufferedImage img;// 空的图片。 - Graphics2D graphics2d;// 空的画笔。 - (graphics2d= (img= new BufferedImage(w, h, type)) - .createGraphics()).setRenderingHint( - RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - graphics2d.rotate(Math.toRadians(degree), w / 2, h / 2);// 旋转,degree是整型,度数,比如垂直90度。 - graphics2d.drawImage(bufferedimage, 0, 0, null);// 从bufferedimagecopy图片至img,0,0是img的坐标。 - graphics2d.dispose(); - return img;// 返回复制好的图片,原图片依然没有变,没有旋转,下次还可以使用。 - } - - public static BufferedImage scaledImage(BufferedImage bufferedimage,Double scaled){ - int width =bufferedimage.getWidth(); - int height = bufferedimage.getHeight(); - return new BufferedImage(Double.valueOf(scaled*width).intValue(),Double.valueOf(scaled*height).intValue(),BufferedImage.TYPE_INT_RGB); - } - - public static byte[] bufferedImageToByte(BufferedImage bufferedImage) throws IOException{ - ByteArrayOutputStream os =new ByteArrayOutputStream(); - ImageIO.write(bufferedImage,"jpg",os); - return os.toByteArray(); - } - - - public static void savePathForImage(BufferedImage bufferedImage,String path){ - - File file=new File(path); - // 创建文件输出流 - try { - ImageIO.write(bufferedImage, "png", file); - } catch (IOException e) { - e.printStackTrace(); - } - - } - - public static String uploadImageForUrl(BufferedImage bufferedImage,String imgPath,String rqImg) throws IOException { - File file =new File(imgPath+rqImg); - if(!file.getParentFile().exists()){ - file.getParentFile().mkdirs(); - } - ImageIO.write(bufferedImage,"jpg",file); - rqImg=rqImg.replaceAll("\\\\","/"); - return StaticPropUtil.imageUrl+rqImg; - } - - public static String uploadImageForPath(BufferedImage bufferedImage,String imgPath,String rqImg) throws IOException { - File file =new File(imgPath+rqImg); - if(!file.getParentFile().exists()){ - file.getParentFile().mkdirs(); - } - ImageIO.write(bufferedImage,"jpg",file); - rqImg=(imgPath+rqImg).replace("\\","\\\\"); - return rqImg; - } - - - - - - - - - - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/HkComUtil.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/HkComUtil.java deleted file mode 100644 index 735b9f2..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/HkComUtil.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import com.xr.device_udpclent.common.config.OnvifAuthBean; -import com.xr.device_udpclent.models.entity.BallheadPT; -import com.xr.device_udpclent.models.entity.DeviceCamera; -import com.xr.device_udpclent.models.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 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.urlByImage(snapshotUrl,device.getAccount(),device.getPassword()); - } - return null; - } - - - - - - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/OnvifUtils.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/OnvifUtils.java deleted file mode 100644 index 428e81a..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/OnvifUtils.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import com.xr.device_udpclent.common.config.HttpResponseBean; -import com.xr.device_udpclent.common.config.OnvifAuthBean; -import com.xr.device_udpclent.models.entity.BallheadPT; -import com.xr.device_udpclent.models.entity.DigestBean; -import com.xr.device_udpclent.models.entity.OnvifBean; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.impl.auth.DigestScheme; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.springframework.core.io.ClassPathResource; -import org.springframework.util.StringUtils; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.List; - -import static com.xr.device_udpclent.common.config.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 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 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; - } -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/PythonExecutor.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/PythonExecutor.java deleted file mode 100644 index 00e43eb..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/PythonExecutor.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import cn.hutool.extra.spring.SpringUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.xr.device_udpclent.models.entity.MeterInitialization; -import com.xr.device_udpclent.models.service.MeterInitializationService; - -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 list = new ArrayList<>(); - String line; - // 读取输出 - while ((line = reader.readLine()) != null) { - list.add(line); - } - - // 等待进程执行完成 - int exitCode = process.waitFor(); - System.out.println("Exit Code: " + exitCode); - if (list.contains("success")) { - return true; - } - return false; - } - - /** - * 初始化算法 - * id 表计配置ID - * sfType 4 灯光 3 开关 5 液位计 - */ - public static boolean meterInit(Integer id, String sfType) throws Exception { - MeterInitializationService meterInitializationService = SpringUtil.getBean(MeterInitializationService.class); - QueryWrapper query = new QueryWrapper<>(); - query.eq("meter_id", id); - query.orderByAsc("serial"); - List list = meterInitializationService.list(query); - List 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> list1 = new ArrayList<>(); - List list2 = new ArrayList<>(); - list2.add(id); - List 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 list1 = new ArrayList<>(); - path.add(0, id + ""); - list1.add(ph); - code = "sr.initialize(" + Arrays.toString(list1.toArray()) + ")\n"; - } - if (sfType.equals("5")) { - List list1 = new ArrayList<>(); - path.add(0, id + ""); - list1.add(ph); - code = "ll.calculate_rgb_min_max(" + Arrays.toString(list1.toArray()) + ")\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])\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 list = new ArrayList<>(); - String line; - // 读取输出 - while ((line = reader.readLine()) != null) { - list.add(line); - } -// 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; - } - - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/RESTClient.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/RESTClient.java deleted file mode 100644 index 70fa448..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/RESTClient.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.xr.device_udpclent.common.utils; - -import com.xr.device_udpclent.common.config.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; - } - } - - - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/StaticPropUtil.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/StaticPropUtil.java deleted file mode 100644 index 02f23d7..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/StaticPropUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.xr.device_udpclent.common.utils; - - -import com.xr.device_udpclent.common.config.getconfigvalue.StaticProperties; -import org.springframework.beans.factory.annotation.Value; - -public class StaticPropUtil { - - public static String imagePath; - - public static String imageUrl; - - public static String pythonPath; - - public static String modelPath; - - 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(); - udpHost=dingProperties.getUdpHost(); - udpPort=dingProperties.getUdpPort(); - } - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/StringUtils.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/StringUtils.java deleted file mode 100644 index c2c9dd7..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/StringUtils.java +++ /dev/null @@ -1,367 +0,0 @@ - -package com.xr.device_udpclent.common.utils; - -import org.apache.commons.lang3.StringEscapeUtils; - -import java.io.UnsupportedEncodingException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author hhl - * @version $Id: StringUtils.java, v 0.1 2017年6月21日 上午10:12:00 hxq Exp $ - */ -public class StringUtils extends org.apache.commons.lang3.StringUtils { - private static final String doubleString = "^(([0-9]+\\.[0-9]{0,2})|([0-9]*[1-9][0-9]*))$"; - private static final String yearString = "^(19|20)\\d{2}$"; - private static String datePattern = "yyyy-MM-dd"; - private static final char SEPARATOR = '_'; - private static final String CHARSET_NAME = "UTF-8"; - - private static final String passwordString = "^(?:(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])).*$"; //验证密码 - - /** - * 判断输入的参数是否为空 - * - * @param param - * @return - */ - public static boolean isNullValue(String param) { - if (param == null || param.equals("") || param.equals("null") || param.equals("NULL")) { - return true; - } - return false; - } - - public static boolean isNotEmpty(List list) { - if (list == null || list.size() == 0) { - return false; - } - return true; - } - - public static boolean isNotEmpty(Object param) { - if (param == null || param.equals("") || param.equals("null") - || param.equals("undefined")) { - return false; - } - return true; - } - - /** - * long - * - * @param o - * @return - */ - public static boolean toLong(Object o) { - if (o == null || "".equals(o)) { - return false; - } - try { - Long.parseLong(o.toString()); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * long - * - * @param o - * @return - */ - public static Long dobTosLong(Object o) { - if (o == null || "".equals(o)) { - return null; - } - try { - double d = Double.parseDouble(o.toString()); - return new Double(d).longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * 判断是否是数字 - * - * @param str - * @return - */ - public static boolean isNumeric(String str) { - Pattern pattern = Pattern.compile(doubleString); - return pattern.matcher(str).matches(); - } - - public static boolean isDouble(String value) { - try { - Double.parseDouble(value); - return true; - } catch (NumberFormatException e) { - return false; - } - } - - /** - * int - * - * @param o - * @return - */ - public static int toInt(Object o) { - if (o == null || "".equals(o)) { - return 0; - } - try { - return Integer.parseInt(o.toString()); - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } - - /** - * 验证参数是否是日期格式 - * - * @param date - * @param pattern - * @return - * @throws Exception - */ - public static boolean dateFormat(String date, String pattern) { - SimpleDateFormat pdf = new SimpleDateFormat(pattern); - try { - if (!isNullValue(date)) { - pdf.parse(date); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 获取年份 - * - * @param date - * @return - */ - public static int getYear(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - return cal.get(Calendar.YEAR); - } - - /** - * 获取月份 - * - * @param date - * @return - */ - public static int getMonth(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - return cal.get(Calendar.MONTH) + 1; - } - - /** - * 判断年份有效性 - * - * @param dateStr - * @return - */ - public static boolean isvaldateYear(String dateStr) { - try { - Pattern pattern1 = Pattern.compile(yearString); - return pattern1.matcher(dateStr).matches(); - } catch (Exception e) { - return false; - } - - } - - /** - * 汉字和字符长度判断 - * - * @param s - * @return - */ - public static int length(String s) { - int length = 0; - for (int i = 0; i < s.length(); i++) { - int ascii = Character.codePointAt(s, i); - if (ascii >= 0 && ascii <= 255) - length++; - else - length += 3; - - } - return length; - - } - - /** - * 汉字和字符长度判断sql2008 - * - * @param s - * @return - */ - public static int lengthSql2008(String s) { - int length = 0; - for (int i = 0; i < s.length(); i++) { - int ascii = Character.codePointAt(s, i); - if (ascii >= 0 && ascii <= 255) - length++; - else - length += 2; - - } - return length; - - } - - /** - * 转换为字节数组 - * - * @param str - * @return - */ - public static byte[] getBytes(String str) { - if (str != null) { - try { - return str.getBytes(CHARSET_NAME); - } catch (UnsupportedEncodingException e) { - return null; - } - } else { - return null; - } - } - - /** - * 转换为字节数组 - * - * @param - * @return - */ - public static String toString(byte[] bytes) { - try { - return new String(bytes, CHARSET_NAME); - } catch (UnsupportedEncodingException e) { - return EMPTY; - } - } - - /** - * 是否包含字符串 - * - * @param str 验证字符串 - * @param strs 字符串组 - * @return 包含返回true - */ - public static boolean inString(String str, String... strs) { - if (str != null) { - for (String s : strs) { - if (str.equals(trim(s))) { - return true; - } - } - } - return false; - } - - public static boolean isvaldatePassword(String value) { - try { - if (value.length() <= 8) { - return false; - } - Pattern pattern1 = Pattern.compile(passwordString); - return pattern1.matcher(value).matches(); - } catch (NumberFormatException e) { - return false; - } - } - - /** - * 替换掉HTML标签方法 - */ - public static String replaceHtml(String html) { - if (isBlank(html)) { - return ""; - } - String regEx = "<.+?>"; - Pattern p = Pattern.compile(regEx); - Matcher m = p.matcher(html); - String s = m.replaceAll(""); - return s; - } - - /** - * 缩略字符串(不区分中英文字符) - * - * @param str 目标字符串 - * @param length 截取长度 - * @return - */ - public static String abbr(String str, int length) { - if (str == null) { - return ""; - } - try { - StringBuilder sb = new StringBuilder(); - int currentLength = 0; - for (char c : replaceHtml(StringEscapeUtils.unescapeHtml4(str)).toCharArray()) { - currentLength += String.valueOf(c).getBytes("GBK").length; - if (currentLength <= length - 3) { - sb.append(c); - } else { - sb.append("..."); - break; - } - } - return sb.toString(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return ""; - } - - public static int returnNotNullInt(Object obj){ - if(obj!=null && !obj.equals("")){ - return Integer.valueOf(obj.toString()); - } - return 0; - } - - public static float returnNotNullFloat(Object obj){ - if(obj!=null && !obj.equals("")){ - return Float.valueOf(obj.toString()); - } - return 0; - } - - public static void main(String[] args) { - String str = "2017-07-10"; - - // System.out.println(getYear(DateUtil.parseStr2Date(str, "yyyy-MM-dd"))); - // System.out.println(getMonth(DateUtil.parseStr2Date(str, "yyyy-MM-dd"))); - System.out.println(isNumeric("123456.08")); - } - - //2. 通过HashSet踢除重复元素 - - public static List removeDuplicate(List list) { - HashSet h = new HashSet(list); - list=new ArrayList(); - list.addAll(h); - return list; - } -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/controller/KafkaController.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/controller/KafkaController.java deleted file mode 100644 index 6727af2..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/controller/KafkaController.java +++ /dev/null @@ -1,27 +0,0 @@ -//package com.xr.device_udpclent.models.controller; -// -//import com.xr.device_udpclent.models.kafka.KafkaProducer; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.web.bind.annotation.PostMapping; -//import org.springframework.web.bind.annotation.RequestBody; -//import org.springframework.web.bind.annotation.RestController; -// -///** -// * @author suihao -// * @Title: KafkaController -// * @Description TODO -// * @date: 2023/03/03 17: -// * @version: V1.0 -// */ -//@RestController -//public class KafkaController { -// -// @Autowired -// private KafkaProducer kafkaProducer; -// -// @PostMapping("/messages") -// public void sendMessage(@RequestBody String message){ -// kafkaProducer.sendMessage(message, "ai-topic"); -// } -//} -// diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/DeviceCameraMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/DeviceCameraMapper.java deleted file mode 100644 index 3871dcc..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/DeviceCameraMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.DeviceCamera; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【device_camera】的数据库操作Mapper -* @createDate 2023-11-21 13:55:12 -* @Entity com.xr.device_udpclent.models.entity.DeviceCamera -*/ -@Mapper -public interface DeviceCameraMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/FocalLengthConfigMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/FocalLengthConfigMapper.java deleted file mode 100644 index d29be02..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/FocalLengthConfigMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.FocalLengthConfig; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【focal_length_config】的数据库操作Mapper -* @createDate 2023-11-10 14:47:58 -* @Entity com.xr.device_udpclent.models.entity.FocalLengthConfig -*/ -@Mapper -public interface FocalLengthConfigMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/Lds5000Mapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/Lds5000Mapper.java deleted file mode 100644 index b36568e..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/Lds5000Mapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.Lds5000; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【lds5000】的数据库操作Mapper -* @createDate 2023-11-10 14:48:42 -* @Entity com.xr.device_udpclent.models.entity.Lds5000 -*/ -@Mapper -public interface Lds5000Mapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterAbnormalRecordMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterAbnormalRecordMapper.java deleted file mode 100644 index 20cccfb..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterAbnormalRecordMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.MeterAbnormalRecord; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【meter_abnormal_record】的数据库操作Mapper -* @createDate 2023-11-10 14:49:01 -* @Entity com.xr.device_udpclent.models.entity.MeterAbnormalRecord -*/ -@Mapper -public interface MeterAbnormalRecordMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterConfigMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterConfigMapper.java deleted file mode 100644 index 681a603..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterConfigMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.MeterConfig; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【meter_config】的数据库操作Mapper -* @createDate 2023-11-10 14:49:19 -* @Entity com.xr.device_udpclent.models.entity.MeterConfig -*/ -@Mapper -public interface MeterConfigMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterGiveAlarmMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterGiveAlarmMapper.java deleted file mode 100644 index 248ce0c..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterGiveAlarmMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.MeterGiveAlarm; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【meter_give_alarm】的数据库操作Mapper -* @createDate 2023-11-10 14:49:47 -* @Entity com.xr.device_udpclent.models.entity.MeterGiveAlarm -*/ -@Mapper -public interface MeterGiveAlarmMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterInitializationMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterInitializationMapper.java deleted file mode 100644 index e359728..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterInitializationMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.MeterInitialization; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【meter_initialization(表计算法初始化)】的数据库操作Mapper -* @createDate 2023-11-21 14:40:23 -* @Entity com.xr.device_udpclent.models.entity.MeterInitialization -*/ -@Mapper -public interface MeterInitializationMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterReadingRecordMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterReadingRecordMapper.java deleted file mode 100644 index 577342f..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterReadingRecordMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.MeterReadingRecord; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** -* @author 范亚杰 -* @description 针对表【meter_reading_record】的数据库操作Mapper -* @createDate 2023-11-10 14:49:59 -* @Entity com.xr.device_udpclent.models.entity.MeterReadingRecord -*/ -@Mapper -public interface MeterReadingRecordMapper extends BaseMapper { - - List selectMaxReading(); - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterTypeMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterTypeMapper.java deleted file mode 100644 index 3823699..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/MeterTypeMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.entity.MeterType; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author 范亚杰 -* @description 针对表【meter_type】的数据库操作Mapper -* @createDate 2023-11-10 14:50:11 -* @Entity com.xr.device_udpclent.models.entity.MeterType -*/ -@Mapper -public interface MeterTypeMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/SendUdpLogMapper.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/SendUdpLogMapper.java deleted file mode 100644 index b6c3b33..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/dao/SendUdpLogMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.xr.device_udpclent.models.dao; - -import com.xr.device_udpclent.models.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:02:32 -* @Entity com.xr.device_udpclent.models.entity.SendUdbLog -*/ -@Mapper -public interface SendUdpLogMapper extends BaseMapper { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/BallheadPT.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/BallheadPT.java deleted file mode 100644 index c6b6025..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/BallheadPT.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.xr.device_udpclent.models.entity; - -import lombok.Data; - -@Data -public class BallheadPT { - private String id; - - private String name; - - private String x; - - private String y; - - private String z; - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/DeviceCamera.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/DeviceCamera.java deleted file mode 100644 index 9bbbb23..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/DeviceCamera.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.xr.device_udpclent.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 device_camera - */ -@TableName(value ="device_camera") -@Data -public class DeviceCamera implements Serializable { - /** - * 主键 - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * 摄像头编号 - */ - private String deviceNo; - - /** - * 类型(1 usb 2 mipi 3 球机 4 枪机) - */ - private String deviceType; - - /** - * IP - */ - private String deviceIp; - - /** - * 端口 - */ - private String devicePort; - - /** - * 账号 - */ - private String account; - - /** - * 密码 - */ - private String password; - - /** - * x轴 - */ - private String x; - - /** - * y轴 - */ - private String y; - - /** - * z轴 - */ - private String z; - - /** - * 摄像头型号 - */ - private String deviceModel; - - /** - * 安装位置 - */ - private String position; - - /** - * 品牌 - */ - private String brand; - - /** - * 备注 - */ - private String remarks; - - /** - * 状态(0未使用 1已使用) - */ - private String status; - - /** - * 创建人 - */ - private String createUser; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 修改人 - */ - private String updateUser; - - /** - * 修改时间 - */ - private LocalDateTime updateTime; - - /** - * 传输间隔 - */ - private Integer transmissionInterval; - - /** - * 对焦时间 - */ - private Integer warmup; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/DigestBean.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/DigestBean.java deleted file mode 100644 index 5259ec0..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/DigestBean.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.xr.device_udpclent.models.entity; - -import com.xr.device_udpclent.common.config.Const; -import com.xr.device_udpclent.common.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); - } - - -} - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/FocalLengthConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/FocalLengthConfig.java deleted file mode 100644 index b47ed94..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/FocalLengthConfig.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.xr.device_udpclent.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 focal_length_config - */ -@TableName(value ="focal_length_config") -@Data -public class FocalLengthConfig implements Serializable { - /** - * 主键 - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * 表计配置编号 - */ - private Integer configId; - - /** - * 焦距名称 - */ - private String focalName; - - /** - * 焦距tabs下标 - */ - private String focalIndex; - - /** - * 截图框宽 - */ - private Double copperWid; - - /** - * 截图框高 - */ - private Double copperHei; - - /** - * 截图框X坐标 - */ - private Double copperX; - - /** - * - */ - private Double copperX2; - - /** - * 截图框Y坐标 - */ - private Double copperY; - - /** - * - */ - private Double copperY2; - - /** - * 1指针表计,2数字表计,3状态类 - */ - private String configType; - - /** - * 指针最小值 - */ - private Double meterMin; - - /** - * 指针最大值 - */ - private Double meterMax; - - /** - * 旋转角度 - */ - private Integer rotate; - - /** - * 缩放倍数 - */ - private Double scale; - - /** - * 状态类状态数量 - */ - private Integer stateNum; - - /** - * 保存状态类多个状态的结果集 - */ - private String parameter; - - /** - * 解析得测试结果 - */ - private String result; - - /** - * 算法:0圆形表计1扇形表计 - */ - private Integer algorithm; - - /** - * 创建人 - */ - private String createUser; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 修改人 - */ - private String updateUser; - - /** - * 修改时间 - */ - private LocalDateTime updateTime; - - /** - * 焦距图片 - */ - private byte[] focalPicture; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/Lds5000.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/Lds5000.java deleted file mode 100644 index ee2b291..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/Lds5000.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.xr.device_udpclent.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; - - /** - * 1一体化电源 2摄像头 3串口 - */ - 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; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterAbnormalRecord.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterAbnormalRecord.java deleted file mode 100644 index 7545de3..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterAbnormalRecord.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.xr.device_udpclent.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 meter_abnormal_record - */ -@TableName(value ="meter_abnormal_record") -@Data -public class MeterAbnormalRecord implements Serializable { - /** - * 主键id - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * 报警阈值id - */ - private Integer alarmId; - - /** - * 表计读数表id - */ - private Integer readingId; - - /** - * 表计id - */ - private Integer meterId; - - /** - * 表计类型id - */ - private Integer meterTypeId; - - /** - * 表计类型名称 - */ - private String meterTypeName; - - /** - * 所属间隔 - */ - private String owningInterval; - - /** - * 读数时间 - */ - private LocalDateTime readingTime; - - /** - * 读数值 - */ - private String readingValue; - - /** - * 预警级别 3预警4报警 - */ - private Integer warningLevel; - - /** - * 异常简析 - */ - private String abnormalityAnalysis; - - /** - * 0 待处理 1 已处理 - */ - private Integer processingStatus; - - /** - * 创建人 - */ - private String createUser; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 修改人 - */ - private String updateUser; - - /** - * 修改时间 - */ - private LocalDateTime updateTime; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterConfig.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterConfig.java deleted file mode 100644 index 6c378d0..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterConfig.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.xr.device_udpclent.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 meter_config - */ -@TableName(value ="meter_config") -@Data -public class MeterConfig implements Serializable { - /** - * 主键 - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * ids5000表id - */ - private Integer ids5000Id; - - /** - * 间隔类型 1 分钟 2 小时 3 天 - */ - private Integer intervalType; - - /** - * 电压等级(1安全电压2低压3高压4超高压5特高压) - */ - private String voltageClass; - - /** - * 所属间隔 - */ - private String owningInterval; - - /** - * 识别间隔 - */ - private String identificationInterval; - - /** - * 所属设备 - */ - private String deviceName; - - /** - * y坐标 - */ - private Double locationY; - - /** - * x坐标 - */ - private Double locationX; - - /** - * 设备类型 - */ - private String deviceType; - - /** - * 表计编号 - */ - private String meterCode; - - /** - * 表计名称 - */ - private String meterName; - - /** - * 所属摄像头 - */ - private Integer cameraId; - - /** - * 告警最小值 - */ - private Double warningMax; - - /** - * 告警最大值 - */ - private Double warningMin; - - /** - * 表计类型配置编号 - */ - private Integer typeId; - - /** - * 状态(0停用1启用) - */ - private Integer status; - - /** - * 首次识别时间 - */ - private LocalDateTime firstTime; - - - /** - * 执行间隔时间 - */ - private Integer intervalTime; - - /** - * 焦距数量 - */ - private Integer focalNumber; - - /** - * 超参配置 - */ - private String parameterConfig; - - /** - * 备注 - */ - private String remarks; - - /** - * 61850读数模型 - */ - private String iec61850mx; - - /** - * 创建人 - */ - private String createUser; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 修改人 - */ - private String updateUser; - - /** - * 修改时间 - */ - private LocalDateTime updateTime; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterGiveAlarm.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterGiveAlarm.java deleted file mode 100644 index f9856ef..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterGiveAlarm.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.xr.device_udpclent.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 meter_give_alarm - */ -@TableName(value ="meter_give_alarm") -@Data -public class MeterGiveAlarm implements Serializable { - /** - * 主键 - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * 表计id - */ - private Integer meterId; - - /** - * 报警类型 1 区间 2 值变更 - */ - private Integer warningType; - - /** - * 预警最小值 - */ - private Double earlyWarningMin; - - /** - * 预警最大值 - */ - private Double earlyWarningMax; - - /** - * 正常最小值 - */ - private Double normalMin; - - /** - * 正常最大值 - */ - private Double normalMax; - - /** - * 警报名称 - */ - private String warningName; - - /** - * 警报最小值 - */ - private Double warningMin; - - /** - * 警报最大值 - */ - private Double warningMax; - - /** - * 状态(0停用1启用) - */ - private Integer status; - - /** - * 创建人 - */ - private String createUser; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 修改人 - */ - private String updateUser; - - /** - * 修改时间 - */ - private LocalDateTime updateTime; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterInitialization.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterInitialization.java deleted file mode 100644 index e6a6380..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterInitialization.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.xr.device_udpclent.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 lombok.Data; - -/** - * 表计算法初始化 - * @TableName meter_initialization - */ -@TableName(value ="meter_initialization") -@Data -public class MeterInitialization implements Serializable { - /** - * id - */ - @TableId - private Integer id; - - /** - * 请求图片路径 - */ - private String img; - - /** - * 盘符路径 - */ - private String imgAddress; - - /** - * 常量值 - */ - private String value; - - /** - * 表计id - */ - private Integer meterId; - - /** - * 序号(从0开始) - */ - private Integer serial; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterReadingRecord.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterReadingRecord.java deleted file mode 100644 index 0c4432f..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterReadingRecord.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.xr.device_udpclent.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 java.util.Date; - -import lombok.Data; - -/** - * - * @TableName meter_reading_record - */ -@TableName(value ="meter_reading_record") -@Data -public class MeterReadingRecord implements Serializable { - /** - * 主键id - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * 表计id - */ - private Integer meterId; - - /** - * 表计编号 - */ - private String meterCode; - - /** - * 表计类型id - */ - private Integer meterTypeId; - - /** - * 表计类型名称 - */ - private String meterTypeName; - - /** - * 所属间隔 - */ - private String owningInterval; - - /** - * 读数时间 - */ - private Date readingTime; - - /** - * 读数类型(1 AI 2 远传 3 转发-开关) - */ - private Integer readingType; - - /** - * 采集类型(0 遥控 1 遥信 2 遥测) - */ - private Integer dataType; - - /** - * 读数值 - */ - private String readingValue; - - /** - * 创建人 - */ - private String createUser; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改人 - */ - private String updateUser; - - /** - * 修改时间 - */ - private Date updateTime; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterType.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterType.java deleted file mode 100644 index 8b07984..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/MeterType.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.xr.device_udpclent.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 meter_type - */ -@TableName(value ="meter_type") -@Data -public class MeterType implements Serializable { - /** - * 主键 - */ - @TableId(type = IdType.AUTO) - private Integer id; - - /** - * 表计类型名称 - */ - private String meterType; - - /** - * 表计形状(0圆形指针1扇形指针2数字类表计3状态类表计) - */ - private String meterShape; - - /** - * 表计超参(对应的参数) - */ - private String typeDescription; - - /** - * 表计类型传输标识 - */ - private String typeIdentification; - - /** - * 备注 - */ - private String remarks; - - /** - * 读数单位 - */ - private String readingUnit; - - /** - * 表计类型别名 - */ - private String typeAlias; - - /** - * 0停用1启用 - */ - private String status; - - /** - * 创建人 - */ - private String createUser; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 修改人 - */ - private String updateUser; - - /** - * 修改时间 - */ - private LocalDateTime updateTime; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/OnvifBean.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/OnvifBean.java deleted file mode 100644 index 5d28d35..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/OnvifBean.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.xr.device_udpclent.models.entity; - -import com.xr.device_udpclent.common.config.Const; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@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; - } - - -} - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/OnvifCredentials.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/OnvifCredentials.java deleted file mode 100644 index fc7ebb0..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/OnvifCredentials.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.xr.device_udpclent.models.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; - } -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/SendUdpLog.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/SendUdpLog.java deleted file mode 100644 index 09c2c49..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/entity/SendUdpLog.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.xr.device_udpclent.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.util.Date; -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; - - /** - * 发送时间 - */ - private Date requestTime; - - /** - * 接收报文 - */ - private String resMsg; - - /** - * 返回时间 - */ - private Date resTime; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/kafka/KafkaConsumer.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/kafka/KafkaConsumer.java deleted file mode 100644 index 094c21d..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/kafka/KafkaConsumer.java +++ /dev/null @@ -1,29 +0,0 @@ -//package com.xr.device_udpclent.models.kafka; -// -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.cloud.stream.annotation.EnableBinding; -//import org.springframework.cloud.stream.annotation.StreamListener; -//import org.springframework.cloud.stream.messaging.Sink; -//import org.springframework.kafka.annotation.KafkaListener; -//import org.springframework.kafka.core.KafkaTemplate; -//import org.springframework.stereotype.Component; -//import org.springframework.stereotype.Service; -// -// -///** -// * @author suihao -// * 创建一个消费者,使用Spring Cloud的注解 `@EnableBinding` 标注,并指定要绑定的消息通道 -// * @Title: KafkaConsumer -// * @Description TODO -// * @date: 2023/03/03 17: -// * @version: V1.0 -// */ -//@Service -//public class KafkaConsumer { -// -// @KafkaListener(topics = "${kafka.topic}") -// public void receiveMessage(String message) { -// // 处理接收到的消息 -// System.out.println("Received message: " + message); -// } -//} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/kafka/KafkaProducer.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/kafka/KafkaProducer.java deleted file mode 100644 index 78248d7..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/kafka/KafkaProducer.java +++ /dev/null @@ -1,32 +0,0 @@ -//package com.xr.device_udpclent.models.kafka; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.cloud.stream.annotation.EnableBinding; -//import org.springframework.cloud.stream.messaging.Source; -//import org.springframework.integration.support.MessageBuilder; -//import org.springframework.kafka.core.KafkaTemplate; -//import org.springframework.messaging.MessageChannel; -//import org.springframework.scheduling.annotation.Scheduled; -//import org.springframework.stereotype.Component; -// -///** -// * @author suihao -// * 创建一个生产者,使用Spring Cloud的注解 `@EnableBinding` 标注,并指定要绑定的消息通 -// * @Title: KafkaProducer -// * @Description TODO -// * @date: 2023/03/03 17: -// * @version: V1.0 -// */ -//@Component -//@Slf4j -//@EnableBinding(Source.class) -//public class KafkaProducer { -// -// @Autowired -// private KafkaTemplate kafkaTemplate; -// -// public void sendMessage(String message, String topic) { -// kafkaTemplate.send(topic, message); -// } -//} - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/ImageDiscernScheduled.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/ImageDiscernScheduled.java deleted file mode 100644 index ac6d2ad..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/ImageDiscernScheduled.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.xr.device_udpclent.models.scheduled; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.xr.device_udpclent.common.utils.*; -import com.xr.device_udpclent.models.entity.*; -import com.xr.device_udpclent.models.service.*; -import lombok.RequiredArgsConstructor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -@Component -@RequiredArgsConstructor -public class ImageDiscernScheduled { - - - private final MeterConfigService meterConfigService; - - private final MeterTypeService meterTypeService; - - private final DeviceCameraService deviceCameraService; - - private final FocalLengthConfigService focalLengthConfigService; - - private final MeterReadingRecordService meterReadingRecordService; - - - private static Logger log= LoggerFactory.getLogger(ImageDiscernScheduled.class); - @Scheduled(cron = "0 0/3 * * * ?") - public void imageDiscernTask() throws Exception{ //定时拍摄网络摄像头,并且解析后存储到读数表 - try{ - QueryWrapper queryConfig=new QueryWrapper<>(); - queryConfig.eq("algorithm_type","3"); - queryConfig.eq("status",1); - queryConfig.eq("init_status","1"); - List meterConfigList=meterConfigService.list(queryConfig); - for (MeterConfig meter:meterConfigList){ - DeviceCamera device=deviceCameraService.getById(meter.getCameraId()); - BufferedImage bf= HkComUtil.getBole(device); - QueryWrapper query=new QueryWrapper<>(); - query.eq("config_id",meter.getId()); - MeterType type=meterTypeService.getById(meter.getTypeId()); - List focalList=focalLengthConfigService.list(query); - if(!focalList.isEmpty()){ - FocalLengthConfig focalLengthConfig=focalList.get(0); - String path=getAnalysis(focalLengthConfig,bf); - String value=PythonExecutor.readNumber(meter.getId(),path,type.getMeterShape()); - MeterReadingRecord readingRecord = getMeterReadingRecord(meter, value, type); - meterReadingRecordService.save(readingRecord); - } - } - }catch (Exception e){ - log.error(e.getMessage()); - } - } - - private static MeterReadingRecord getMeterReadingRecord(MeterConfig meter, String value, MeterType type) { - MeterReadingRecord readingRecord=new MeterReadingRecord(); - readingRecord.setMeterId(meter.getId()); - readingRecord.setReadingType(2); - readingRecord.setReadingTime(new Date()); - readingRecord.setCreateTime(new Date()); - readingRecord.setMeterCode(meter.getMeterCode()); - readingRecord.setReadingValue(value); - readingRecord.setMeterTypeId(type.getId()); - readingRecord.setMeterTypeName(type.getTypeDescription()); - readingRecord.setCreateUser("SYSTEM"); - return readingRecord; - } - - - //截取图片并保存为url - public String getAnalysis(FocalLengthConfig focal,BufferedImage pic) throws IOException { - Date date = new Date(); - SimpleDateFormat sfm = new SimpleDateFormat("yyyy-MM-dd"); - if(focal.getRotate()!=null && focal.getRotate()!=0){ - pic=Files.rotateImage(pic,focal.getRotate()); - } - int widthInt = (int) Math.round(focal.getCopperWid()); - int heightInt = (int) Math.round(focal.getCopperHei()); - double copperx = focal.getCopperX(); - double coppery = focal.getCopperY(); - BufferedImage pic2 = pic.getSubimage((int) copperx, (int) coppery, widthInt, heightInt); - //将截取的子图另行存储 - Image _img = pic2.getScaledInstance(widthInt, heightInt, Image.SCALE_DEFAULT); - BufferedImage image = new BufferedImage(widthInt, heightInt, BufferedImage.TYPE_INT_RGB); - Graphics2D graphics = image.createGraphics(); - graphics.drawImage(_img, 0, 0, null); - graphics.dispose(); - return Files.uploadImageForPath(image, StaticPropUtil.imagePath,sfm.format(date)+"\\\\"+date.getTime()+".jpg"); - } - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/UdpClentScheduled.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/UdpClentScheduled.java deleted file mode 100644 index a13934b..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/UdpClentScheduled.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.xr.device_udpclent.models.scheduled; - -import cn.hutool.extra.spring.SpringUtil; -import com.xr.device_udpclent.common.config.udp.UdbConfig; -import com.xr.device_udpclent.models.entity.MeterReadingRecord; -import com.xr.device_udpclent.models.service.MeterReadingRecordService; -import com.xr.device_udpclent.models.service.UdpClientService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.util.List; - - -@Component -public class UdpClentScheduled { - - @Autowired - private UdpClientService udpClientService; - - @Autowired - private MeterReadingRecordService meterReadingRecordService; - - - @Scheduled(cron = "0 0/3 * * * ?") - //定时发送监测数据 - public void udpTask(){ - if(meterReadingRecordService == null){ - meterReadingRecordService = SpringUtil.getBean(MeterReadingRecordService.class); - } - List list = meterReadingRecordService.selectMaxReading(); - for (MeterReadingRecord record:list){ - String writeValue = UdbConfig.getTestMsg(record); - udpClientService.sendData(writeValue); - } - } - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/DeviceCameraService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/DeviceCameraService.java deleted file mode 100644 index 7f19e43..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/DeviceCameraService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.DeviceCamera; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【device_camera】的数据库操作Service -* @createDate 2023-11-21 13:55:12 -*/ -public interface DeviceCameraService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/FocalLengthConfigService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/FocalLengthConfigService.java deleted file mode 100644 index 604d078..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/FocalLengthConfigService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.FocalLengthConfig; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【focal_length_config】的数据库操作Service -* @createDate 2023-11-10 14:47:58 -*/ -public interface FocalLengthConfigService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/Lds5000Service.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/Lds5000Service.java deleted file mode 100644 index 140ba80..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/Lds5000Service.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.Lds5000; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【lds5000】的数据库操作Service -* @createDate 2023-11-10 14:48:42 -*/ -public interface Lds5000Service extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterAbnormalRecordService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterAbnormalRecordService.java deleted file mode 100644 index 0ebeaab..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterAbnormalRecordService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.MeterAbnormalRecord; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【meter_abnormal_record】的数据库操作Service -* @createDate 2023-11-10 14:49:01 -*/ -public interface MeterAbnormalRecordService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterConfigService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterConfigService.java deleted file mode 100644 index 80df91d..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterConfigService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.MeterConfig; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【meter_config】的数据库操作Service -* @createDate 2023-11-10 14:49:19 -*/ -public interface MeterConfigService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterGiveAlarmService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterGiveAlarmService.java deleted file mode 100644 index bade9d3..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterGiveAlarmService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.MeterGiveAlarm; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【meter_give_alarm】的数据库操作Service -* @createDate 2023-11-10 14:49:47 -*/ -public interface MeterGiveAlarmService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterInitializationService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterInitializationService.java deleted file mode 100644 index c3feca9..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterInitializationService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.MeterInitialization; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【meter_initialization(表计算法初始化)】的数据库操作Service -* @createDate 2023-11-21 14:40:23 -*/ -public interface MeterInitializationService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterReadingRecordService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterReadingRecordService.java deleted file mode 100644 index 9f86ced..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterReadingRecordService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.MeterReadingRecord; -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.List; - -/** -* @author 范亚杰 -* @description 针对表【meter_reading_record】的数据库操作Service -* @createDate 2023-11-10 14:49:59 -*/ -public interface MeterReadingRecordService extends IService { - - List selectMaxReading(); - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterTypeService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterTypeService.java deleted file mode 100644 index 05d8206..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/MeterTypeService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.MeterType; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【meter_type】的数据库操作Service -* @createDate 2023-11-10 14:50:11 -*/ -public interface MeterTypeService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/SendUdpLogService.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/SendUdpLogService.java deleted file mode 100644 index 57cc10d..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/SendUdpLogService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xr.device_udpclent.models.service; - -import com.xr.device_udpclent.models.entity.SendUdpLog; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 范亚杰 -* @description 针对表【send_udb_log(udb消息日志表)】的数据库操作Service -* @createDate 2023-11-29 13:02:32 -*/ -public interface SendUdpLogService extends IService { - -} diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/DeviceCameraServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/DeviceCameraServiceImpl.java deleted file mode 100644 index 3170f88..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/DeviceCameraServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.DeviceCamera; -import com.xr.device_udpclent.models.service.DeviceCameraService; -import com.xr.device_udpclent.models.dao.DeviceCameraMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【device_camera】的数据库操作Service实现 -* @createDate 2023-11-21 13:55:12 -*/ -@Service -@DS("db2") -public class DeviceCameraServiceImpl extends ServiceImpl - implements DeviceCameraService{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/FocalLengthConfigServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/FocalLengthConfigServiceImpl.java deleted file mode 100644 index 2f9d313..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/FocalLengthConfigServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.FocalLengthConfig; -import com.xr.device_udpclent.models.service.FocalLengthConfigService; -import com.xr.device_udpclent.models.dao.FocalLengthConfigMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【focal_length_config】的数据库操作Service实现 -* @createDate 2023-11-10 14:47:58 -*/ -@Service -@DS("db2") -public class FocalLengthConfigServiceImpl extends ServiceImpl - implements FocalLengthConfigService{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/Lds5000ServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/Lds5000ServiceImpl.java deleted file mode 100644 index 26a33ff..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/Lds5000ServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.Lds5000; -import com.xr.device_udpclent.models.service.Lds5000Service; -import com.xr.device_udpclent.models.dao.Lds5000Mapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【lds5000】的数据库操作Service实现 -* @createDate 2023-11-10 14:48:42 -*/ -@Service -@DS("db2") -public class Lds5000ServiceImpl extends ServiceImpl - implements Lds5000Service{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterAbnormalRecordServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterAbnormalRecordServiceImpl.java deleted file mode 100644 index f5c15e8..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterAbnormalRecordServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.MeterAbnormalRecord; -import com.xr.device_udpclent.models.service.MeterAbnormalRecordService; -import com.xr.device_udpclent.models.dao.MeterAbnormalRecordMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【meter_abnormal_record】的数据库操作Service实现 -* @createDate 2023-11-10 14:49:01 -*/ -@Service -@DS("db2") -public class MeterAbnormalRecordServiceImpl extends ServiceImpl - implements MeterAbnormalRecordService{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterConfigServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterConfigServiceImpl.java deleted file mode 100644 index 2991339..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterConfigServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.MeterConfig; -import com.xr.device_udpclent.models.service.MeterConfigService; -import com.xr.device_udpclent.models.dao.MeterConfigMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【meter_config】的数据库操作Service实现 -* @createDate 2023-11-10 14:49:19 -*/ -@Service -@DS("db2") -public class MeterConfigServiceImpl extends ServiceImpl - implements MeterConfigService{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterGiveAlarmServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterGiveAlarmServiceImpl.java deleted file mode 100644 index 16a948e..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterGiveAlarmServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.MeterGiveAlarm; -import com.xr.device_udpclent.models.service.MeterGiveAlarmService; -import com.xr.device_udpclent.models.dao.MeterGiveAlarmMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【meter_give_alarm】的数据库操作Service实现 -* @createDate 2023-11-10 14:49:47 -*/ -@Service -@DS("db2") -public class MeterGiveAlarmServiceImpl extends ServiceImpl - implements MeterGiveAlarmService{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterInitializationServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterInitializationServiceImpl.java deleted file mode 100644 index aa2c064..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterInitializationServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.MeterInitialization; -import com.xr.device_udpclent.models.service.MeterInitializationService; -import com.xr.device_udpclent.models.dao.MeterInitializationMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【meter_initialization(表计算法初始化)】的数据库操作Service实现 -* @createDate 2023-11-21 14:40:23 -*/ -@Service -@DS("db2") -public class MeterInitializationServiceImpl extends ServiceImpl - implements MeterInitializationService{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterReadingRecordServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterReadingRecordServiceImpl.java deleted file mode 100644 index d233cc8..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterReadingRecordServiceImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.MeterReadingRecord; -import com.xr.device_udpclent.models.service.MeterReadingRecordService; -import com.xr.device_udpclent.models.dao.MeterReadingRecordMapper; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** -* @author 范亚杰 -* @description 针对表【meter_reading_record】的数据库操作Service实现 -* @createDate 2023-11-10 14:49:59 -*/ -@Service -@DS("db2") -public class MeterReadingRecordServiceImpl extends ServiceImpl implements MeterReadingRecordService{ - - public List selectMaxReading(){ - return this.baseMapper.selectMaxReading(); - } - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterTypeServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterTypeServiceImpl.java deleted file mode 100644 index 10c3137..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/MeterTypeServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.MeterType; -import com.xr.device_udpclent.models.service.MeterTypeService; -import com.xr.device_udpclent.models.dao.MeterTypeMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【meter_type】的数据库操作Service实现 -* @createDate 2023-11-10 14:50:11 -*/ -@Service -@DS("db2") -public class MeterTypeServiceImpl extends ServiceImpl - implements MeterTypeService{ - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/SendUdpLogServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/SendUdpLogServiceImpl.java deleted file mode 100644 index 2ae926a..0000000 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/SendUdpLogServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xr.device_udpclent.models.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.xr.device_udpclent.models.entity.SendUdpLog; -import com.xr.device_udpclent.models.service.SendUdpLogService; -import com.xr.device_udpclent.models.dao.SendUdpLogMapper; -import org.springframework.stereotype.Service; - -/** -* @author 范亚杰 -* @description 针对表【send_udb_log(udb消息日志表)】的数据库操作Service实现 -* @createDate 2023-11-29 13:02:32 -*/ -@Service -@DS("db2") -public class SendUdpLogServiceImpl extends ServiceImpl - implements SendUdpLogService { - -} - - - - diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/UdpClientServiceImpl.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/UdpClientServiceImpl.java index 9b4ac2e..8023167 100644 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/UdpClientServiceImpl.java +++ b/device_udpclent/src/main/java/com/xr/device_udpclent/models/service/impl/UdpClientServiceImpl.java @@ -1,7 +1,5 @@ package com.xr.device_udpclent.models.service.impl; -import com.xr.device_udpclent.models.entity.SendUdpLog; -import com.xr.device_udpclent.models.service.SendUdpLogService; import com.xr.device_udpclent.models.service.UdpClientService; import io.netty.buffer.Unpooled; import io.netty.channel.socket.DatagramChannel; @@ -11,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.net.InetSocketAddress; -import java.util.Date; @Service public class UdpClientServiceImpl implements UdpClientService { @@ -22,25 +19,13 @@ public class UdpClientServiceImpl implements UdpClientService { @Autowired private InetSocketAddress udpServerAddress; - @Autowired - private SendUdpLogService sendUdpLogService; - @Override public void sendData(String data) { - SendUdpLog sendUdbLog=new SendUdpLog(); - sendUdbLog.setRequestMsg(data); - sendUdbLog.setRequestTime(new Date()); - sendUdbLog.setMessageId(data.split("\t")[0]); try { udpChannel.writeAndFlush(new DatagramPacket( Unpooled.copiedBuffer(data, CharsetUtil.UTF_8), udpServerAddress)).sync(); - sendUdbLog.setRequestStatus("0"); } catch (Exception e) { - sendUdbLog.setRequestStatus("1"); - sendUdbLog.setResMsg(e.getMessage()); - sendUdbLog.setResTime(new Date()); e.printStackTrace(); } - sendUdpLogService.save(sendUdbLog); } } diff --git a/device_udpclent/src/main/resources/application-dev.yml b/device_udpclent/src/main/resources/application-dev.yml index 0e4a957..daf0f63 100644 --- a/device_udpclent/src/main/resources/application-dev.yml +++ b/device_udpclent/src/main/resources/application-dev.yml @@ -17,7 +17,13 @@ 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: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mysql://116.196.120.81:3306/modbusrtu?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false username: root password: 5ea47c0bdd7146ebbd53020eca@672307 #Hikari连接池配置 @@ -43,32 +49,20 @@ spring: timeout-seconds: 1000 config: enabled: false - stream: - kafka: - binder: - brokers: localhost:9092 #Kafka的消息中间件服务器 - zk-nodes: localhost:2181 #Zookeeper的节点,如果集群,后面加,号分隔 - auto-create-topics: false #如果设置为false,就不会自动创建Topic 有可能你Topic还没创建就直接调用了。 -# kafka: -# bootstrap-servers: localhost:9092 -# consumer: -# group-id: ai-consumer-group -#kafka: -# topic: ai-topic -# # redis 相关 -# redis: -# host: ${REDIS_URL:localhost} -# port: ${REDIS_PORT:6379} -# password: ${REDIS_PWD:111111} -# timeout: 10000 -# jedis: -# pool: -# max-active: 1000 -# max-wait: -1ms -# max-idle: 10 -# min-idle: 5 + # redis 相关 + redis: + host: ${REDIS_URL:localhost} + port: ${REDIS_PORT:6379} + password: ${REDIS_PWD:111111} + timeout: 10000 + jedis: + pool: + max-active: 1000 + max-wait: -1ms + max-idle: 10 + min-idle: 5 mybatis-plus: - mapper-locations: classpath:mapper/*Mapper.xml + mapper-locations: classpath:mappers/**/*Mapper.xml type-aliases-package: com.xr.device_udpclent # 在查询语句的是否,对Map或者是entity进行映射赋值的时候null也进行映射。默认false,不进行映射 configuration: @@ -90,12 +84,6 @@ udp: server: host: localhost port: 9300 -upLoad: - path: D:\\images\\images\\ - url: http://localhost:85/upload/ -python: - path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe - modelPath: D:\\smartGrid\\smartGrid\\models eureka: instance: instance-id: ${spring.cloud.client.ip-address}:${server.port} diff --git a/device_udpclent/src/main/resources/application-prod.yml b/device_udpclent/src/main/resources/application-prod.yml index bfe21b6..8d65063 100644 --- a/device_udpclent/src/main/resources/application-prod.yml +++ b/device_udpclent/src/main/resources/application-prod.yml @@ -17,7 +17,13 @@ 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 + db3: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + 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 #Hikari连接池配置 @@ -56,7 +62,7 @@ spring: max-idle: 10 min-idle: 5 mybatis-plus: - mapper-locations: classpath:mapper/*Mapper.xml + mapper-locations: classpath:mappers/*Mapper.xml type-aliases-package: com.xr.device_udpclent # 在查询语句的是否,对Map或者是entity进行映射赋值的时候null也进行映射。默认false,不进行映射 configuration: @@ -74,16 +80,7 @@ logging: boot: autoconfigure: logging: debug -udp: - server: - host: localhost - port: 9300 -python: - path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe - modelPath: D:\\smartGrid\\smartGrid\\models -upLoad: - path: D:\\images\\images\\ - url: http://localhost:85/upload/ + eureka: instance: instance-id: ${spring.cloud.client.ip-address}:${server.port} diff --git a/device_udpclent/src/main/resources/application.yml b/device_udpclent/src/main/resources/application.yml index 9297701..7f6d0a6 100644 --- a/device_udpclent/src/main/resources/application.yml +++ b/device_udpclent/src/main/resources/application.yml @@ -5,6 +5,19 @@ spring: #active: prod #生产环境 application: name: deviceUdpClent +mybatis-plus: + mapper-locations: classpath:mappers/*Mapper.xml + type-aliases-package: com.xr.udpclent + # 在查询语句的是否,对Map或者是entity进行映射赋值的时候null也进行映射。默认false,不进行映射 + configuration: + map-underscore-to-camel-case: true + call-setters-on-nulls: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + # 设置更新或者修改的时候的策略,不进行校验,否则如果是null则不会进行更新或者插入,当然在@TableField注解进行指定单个字段 + global-config: + db-config: + insert-strategy: ignored + update-strategy: ignored logging: org: springframework: diff --git a/device_udpclent/src/main/resources/digest/AbsoluteMove.wsdl b/device_udpclent/src/main/resources/digest/AbsoluteMove.wsdl deleted file mode 100644 index 7bb64b3..0000000 --- a/device_udpclent/src/main/resources/digest/AbsoluteMove.wsdl +++ /dev/null @@ -1,12 +0,0 @@ - - - - - %s - - - - - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GetDeviceInformation.wsdl b/device_udpclent/src/main/resources/digest/GetDeviceInformation.wsdl deleted file mode 100644 index 9b65996..0000000 --- a/device_udpclent/src/main/resources/digest/GetDeviceInformation.wsdl +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GetPTZ.wsdl b/device_udpclent/src/main/resources/digest/GetPTZ.wsdl deleted file mode 100644 index 5de3704..0000000 --- a/device_udpclent/src/main/resources/digest/GetPTZ.wsdl +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GetPresets.wsdl b/device_udpclent/src/main/resources/digest/GetPresets.wsdl deleted file mode 100644 index de30d8c..0000000 --- a/device_udpclent/src/main/resources/digest/GetPresets.wsdl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - %s - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GetProfiles.wsdl b/device_udpclent/src/main/resources/digest/GetProfiles.wsdl deleted file mode 100644 index 92dc2cd..0000000 --- a/device_udpclent/src/main/resources/digest/GetProfiles.wsdl +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GetSnapshotUrl.wsdl b/device_udpclent/src/main/resources/digest/GetSnapshotUrl.wsdl deleted file mode 100644 index 3b6f76a..0000000 --- a/device_udpclent/src/main/resources/digest/GetSnapshotUrl.wsdl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - %s - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GetStatus.wsdl b/device_udpclent/src/main/resources/digest/GetStatus.wsdl deleted file mode 100644 index 15f1e73..0000000 --- a/device_udpclent/src/main/resources/digest/GetStatus.wsdl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - %s - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GetStreamUri.wsdl b/device_udpclent/src/main/resources/digest/GetStreamUri.wsdl deleted file mode 100644 index b8fae91..0000000 --- a/device_udpclent/src/main/resources/digest/GetStreamUri.wsdl +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - %s - %s - %s - %s - - - - - - - - RTP-Unicast - - %s - - - %s - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/digest/GotoPreset.wsdl b/device_udpclent/src/main/resources/digest/GotoPreset.wsdl deleted file mode 100644 index 330014e..0000000 --- a/device_udpclent/src/main/resources/digest/GotoPreset.wsdl +++ /dev/null @@ -1,9 +0,0 @@ - - - - - %s - %s - - - \ No newline at end of file diff --git a/device_udpclent/src/main/resources/mapper/DeviceCameraMapper.xml b/device_udpclent/src/main/resources/mapper/DeviceCameraMapper.xml deleted file mode 100644 index d0a126f..0000000 --- a/device_udpclent/src/main/resources/mapper/DeviceCameraMapper.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id,device_no,device_type, - device_ip,device_port,account, - password,x,y, - z,device_model,position, - brand,remarks,status, - create_user,create_time,update_user, - update_time,transmission_interval,warmup - - diff --git a/device_udpclent/src/main/resources/mapper/FocalLengthConfigMapper.xml b/device_udpclent/src/main/resources/mapper/FocalLengthConfigMapper.xml deleted file mode 100644 index 367d19b..0000000 --- a/device_udpclent/src/main/resources/mapper/FocalLengthConfigMapper.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id,config_id,focal_name, - focal_index,copper_wid,copper_hei, - copper_x,copper_x2,copper_y, - copper_y2,config_type,meter_min, - meter_max,rotate,scale, - state_num,parameter,result, - algorithm,create_user,create_time, - update_user,update_time,focal_picture - - diff --git a/device_udpclent/src/main/resources/mapper/Lds5000Mapper.xml b/device_udpclent/src/main/resources/mapper/Lds5000Mapper.xml deleted file mode 100644 index d0e8863..0000000 --- a/device_udpclent/src/main/resources/mapper/Lds5000Mapper.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - id,clent_ip,lds_desc, - fc,type,node, - q,t,st_val, - f,create_time,update_time - - diff --git a/device_udpclent/src/main/resources/mapper/MeterAbnormalRecordMapper.xml b/device_udpclent/src/main/resources/mapper/MeterAbnormalRecordMapper.xml deleted file mode 100644 index 11d7d74..0000000 --- a/device_udpclent/src/main/resources/mapper/MeterAbnormalRecordMapper.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - id,alarm_id,reading_id, - meter_id,meter_type_id,meter_type_name, - owning_interval,reading_time,reading_value, - warning_level,abnormality_analysis,processing_status, - create_user,create_time,update_user, - update_time - - diff --git a/device_udpclent/src/main/resources/mapper/MeterConfigMapper.xml b/device_udpclent/src/main/resources/mapper/MeterConfigMapper.xml deleted file mode 100644 index 645c59b..0000000 --- a/device_udpclent/src/main/resources/mapper/MeterConfigMapper.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id,ids5000_id,interval_type, - voltage_class,owning_interval,identification_interval, - device_name,location_y,location_x, - device_type,meter_code,meter_name, - camera_id,warning_max,warning_min, - type_id,status,first_time, - interval_time,focal_number, - parameter_config,remarks,iec61850mx, - create_user,create_time,update_user, - update_time - - diff --git a/device_udpclent/src/main/resources/mapper/MeterGiveAlarmMapper.xml b/device_udpclent/src/main/resources/mapper/MeterGiveAlarmMapper.xml deleted file mode 100644 index d959388..0000000 --- a/device_udpclent/src/main/resources/mapper/MeterGiveAlarmMapper.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - id,meter_id,warning_type, - early_warning_min,early_warning_max,normal_min, - normal_max,warning_name,warning_min, - warning_max,status,create_user, - create_time,update_user,update_time - - diff --git a/device_udpclent/src/main/resources/mapper/MeterInitializationMapper.xml b/device_udpclent/src/main/resources/mapper/MeterInitializationMapper.xml deleted file mode 100644 index 7b433c4..0000000 --- a/device_udpclent/src/main/resources/mapper/MeterInitializationMapper.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - id,img,img_address, - value,meter_id,serial - - diff --git a/device_udpclent/src/main/resources/mapper/MeterReadingRecordMapper.xml b/device_udpclent/src/main/resources/mapper/MeterReadingRecordMapper.xml deleted file mode 100644 index 3ecbaf2..0000000 --- a/device_udpclent/src/main/resources/mapper/MeterReadingRecordMapper.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - id,meter_id,meter_code, - meter_type_id,meter_type_name,owning_interval, - reading_time,reading_type,data_type,reading_value, - create_user,create_time,update_user, - update_time - - - - diff --git a/device_udpclent/src/main/resources/mapper/MeterTypeMapper.xml b/device_udpclent/src/main/resources/mapper/MeterTypeMapper.xml deleted file mode 100644 index 1ad3fa4..0000000 --- a/device_udpclent/src/main/resources/mapper/MeterTypeMapper.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - id,meter_type,meter_shape, - type_description,type_identification,remarks, - reading_unit,type_alias,status, - create_user,create_time,update_user, - update_time - - diff --git a/device_udpclent/src/main/resources/mapper/SendUdpLogMapper.xml b/device_udpclent/src/main/resources/mapper/SendUdpLogMapper.xml deleted file mode 100644 index fc4f607..0000000 --- a/device_udpclent/src/main/resources/mapper/SendUdpLogMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - id,message_id,request_status, - request_msg,request_time,res_msg, - res_time - - diff --git a/device_udpserver/src/main/java/com/xr/device_udpserver/common/UdpServerHandler.java b/device_udpserver/src/main/java/com/xr/device_udpserver/common/UdpServerHandler.java index c28fcac..d68945b 100644 --- a/device_udpserver/src/main/java/com/xr/device_udpserver/common/UdpServerHandler.java +++ b/device_udpserver/src/main/java/com/xr/device_udpserver/common/UdpServerHandler.java @@ -23,10 +23,8 @@ public class UdpServerHandler extends SimpleChannelInboundHandler + 1.2.2.0-20200811 2.0.8.RELEASE Finchley.SR4 Cairo-SR7 + UTF-8 + 1.8 + 1.8 2.0.5 + 4.5.0 + 3.4.4 + 2.0.0 + 11.2.0.4.0-atlassian-hosted + 1.0 + 5.22.0 + 0.0.9 + 2.0.0 + 2.10.0 + 1.7 + 4.1.0 + 2.1.0 4.11 1.33 + 2.1.5 + 2.9.8 + 2.10.1 + + 3.11.9 + 2.4.1 + 2.12.2 + 2.8.4 + 2.12.9 6.0.0-GA 1.3.2 1.1.6 @@ -37,10 +62,12 @@ 9.1.5 1.6.1 0.0.17 - 1.18.12 - 4.1.42.Final - 3.9 - 2.10 + 3.4.1 + 2.8.5 + 2.9.9 + 2.5 + 3.0 + 3.0.0 @@ -157,7 +184,6 @@ org.projectlombok lombok - ${lombok.version} provided @@ -203,20 +229,61 @@ io.netty netty-all - ${netty.version} - - - org.apache.poi - poi - ${poi.version} + 4.1.42.Final + + + + + + + org.apache.poi poi-ooxml - ${poi.version} + 3.9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +