Browse Source

修改外部包

523096025 2 years ago
parent
commit
9905758ca4

+ 40 - 32
huimv-admin/pom.xml

@@ -85,48 +85,51 @@
             <artifactId>mybatis-plus-generator</artifactId>
             <version>3.2.0</version>
         </dependency>
-        <!--       引用外部包-->
         <dependency>
-            <groupId>Ice</groupId>
-            <artifactId>Ice</artifactId>
-            <version>1.0</version>
-            <scope>system</scope>
-            <systemPath>${basedir}/lib/httpcore-4.4.3.jar</systemPath>
+            <groupId>com.hkvs</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.4</version>
         </dependency>
         <dependency>
-            <groupId>Ice1</groupId>
-            <artifactId>Ice1</artifactId>
-            <version>1.0</version>
-            <scope>system</scope>
-            <systemPath>${basedir}/lib/Digests.jar</systemPath>
+            <groupId>com.hkvs</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.0.1</version>
         </dependency>
         <dependency>
-            <groupId>Ice2</groupId>
-            <artifactId>Ice2</artifactId>
-            <version>1.0</version>
-            <scope>system</scope>
-            <systemPath>${basedir}/lib/HttpClientSSLUtils.jar</systemPath>
+            <groupId>com.hkvs</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.1</version>
         </dependency>
-
-        <!--暂时不用nacos-->
-     <!--   <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-            <version>2021.1</version>
+        <dependency>
+            <groupId>com.hkvs</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.hkvs</groupId>
+            <artifactId>Digests.jar</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.hkvs</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.8</version>
         </dependency>
         <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
-            <version>2021.1</version>
+            <groupId>com.hkvs</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.1</version>
         </dependency>
-        &lt;!&ndash;alibaba&ndash;&gt;
         <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-alibaba-dependencies</artifactId>
-            <version>2021.1</version>
-            <type>pom</type>
-            <scope>import</scope>
-        </dependency>-->
+            <groupId>com.hkvs</groupId>
+            <artifactId>HttpClientSSLUtils</artifactId>
+            <version>1.0</version>
+        </dependency>  <dependency>
+        <groupId>com.hkvs</groupId>
+        <artifactId>httpcore</artifactId>
+        <version>4.4.3</version>
+    </dependency>
+
 
 </dependencies>
     <build>
@@ -134,6 +137,11 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+<!--                <configuration>-->
+<!--                    <includeSystemScope>true</includeSystemScope>-->
+<!--                    <skip>true</skip>-->
+<!--                    <mainClass>HuimvAdminApplication</mainClass>-->
+<!--                </configuration>-->
             </plugin>
             <!--在这里修改版本-->
             <plugin>

+ 141 - 0
huimv-admin/src/main/java/com/huimv/admin/common/utils/Digests.java

@@ -0,0 +1,141 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.huimv.admin.common.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+import java.security.SecureRandom;
+import org.apache.commons.lang3.Validate;
+
+public class Digests {
+    private static final String SHA1 = "SHA-1";
+    private static final String MD5 = "MD5";
+    private static SecureRandom random = new SecureRandom();
+
+    public Digests() {
+    }
+
+    public static byte[] md5(byte[] input) {
+        return digest(input, "MD5", (byte[])null, 1);
+    }
+
+    public static byte[] md5(byte[] input, int iterations) {
+        return digest(input, "MD5", (byte[])null, iterations);
+    }
+
+    public static byte[] sha1(byte[] input) {
+        return digest(input, "SHA-1", (byte[])null, 1);
+    }
+
+    public static byte[] sha1(byte[] input, byte[] salt) {
+        return digest(input, "SHA-1", salt, 1);
+    }
+
+    public static byte[] sha1(byte[] input, byte[] salt, int iterations) {
+        return digest(input, "SHA-1", salt, iterations);
+    }
+
+    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 var7) {
+            throw new RuntimeException(var7);
+        }
+    }
+
+    public static byte[] generateSalt(int numBytes) {
+        Validate.isTrue(numBytes > 0, "numBytes argument must be a positive integer (1 or larger)", (long)numBytes);
+        byte[] bytes = new byte[numBytes];
+        random.nextBytes(bytes);
+        return bytes;
+    }
+
+    public static byte[] md5(InputStream input) throws IOException {
+        return digest(input, "MD5");
+    }
+
+    public static byte[] sha1(InputStream input) throws IOException {
+        return digest(input, "SHA-1");
+    }
+
+    private static byte[] digest(InputStream input, String algorithm) throws IOException {
+        try {
+            MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
+            int bufferLength = 8192;
+            byte[] buffer = new byte[bufferLength];
+
+            for(int read = input.read(buffer, 0, bufferLength); read > -1; read = input.read(buffer, 0, bufferLength)) {
+                messageDigest.update(buffer, 0, read);
+            }
+
+            return messageDigest.digest();
+        } catch (GeneralSecurityException var6) {
+            throw new RuntimeException(var6);
+        }
+    }
+
+    public static final String md5(String s) {
+        char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+        try {
+            MessageDigest mdTemp = MessageDigest.getInstance("MD5");
+
+            try {
+                mdTemp.update(s.getBytes("UTF-8"));
+            } catch (UnsupportedEncodingException var9) {
+                mdTemp.update(s.getBytes());
+            }
+
+            byte[] md = mdTemp.digest();
+            int j = md.length;
+            char[] str = new char[j * 2];
+            int k = 0;
+
+            for(int i = 0; i < j; ++i) {
+                byte byte0 = md[i];
+                str[k++] = hexDigits[byte0 >>> 4 & 15];
+                str[k++] = hexDigits[byte0 & 15];
+            }
+
+            return (new String(str)).toUpperCase();
+        } catch (Exception var10) {
+            return null;
+        }
+    }
+
+    public static final String buildToken(String url, String paramJson, String secret) {
+        String tempUrl = null;
+        if (url.contains("https://")) {
+            tempUrl = url.substring("https://".length());
+        } else {
+            tempUrl = url.substring("http://".length());
+        }
+
+        int index = tempUrl.indexOf("/");
+        String URI = tempUrl.substring(index);
+        String[] ss = URI.split("\\?");
+        return ss.length > 1 ? md5(ss[0] + ss[1] + secret) : md5(ss[0] + paramJson + secret);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(md5("abc"));
+    }
+}

+ 162 - 0
huimv-admin/src/main/java/com/huimv/admin/common/utils/HttpClientSSLUtils.java

@@ -0,0 +1,162 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.huimv.admin.common.utils;
+
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.Map;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.config.RequestConfig.Builder;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+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.ssl.SSLContextBuilder;
+
+public class HttpClientSSLUtils {
+    private static HttpClient client = null;
+    protected static final Integer DEFAULT_CONNECTION_TIME_OUT = 100000;
+    protected static final Integer DEFAULT_SOCKET_TIME_OUT = 200000;
+    protected static final String DEFAULT_CHAR_SET = "UTF-8";
+
+    public HttpClientSSLUtils() {
+    }
+
+    public static String doPost(String url, String jsonText) throws Exception {
+        HttpClient client = null;
+        HttpPost post = new HttpPost(url);
+
+        String var6;
+        try {
+            if (jsonText != null && !jsonText.isEmpty()) {
+                StringEntity entity = new StringEntity(jsonText, ContentType.APPLICATION_JSON);
+                post.setEntity(entity);
+            }
+
+            Builder customReqConf = RequestConfig.custom();
+            customReqConf.setConnectTimeout(DEFAULT_CONNECTION_TIME_OUT);
+            customReqConf.setSocketTimeout(DEFAULT_CONNECTION_TIME_OUT);
+            post.setConfig(customReqConf.build());
+            HttpResponse res = null;
+            if (url.startsWith("https")) {
+                client = createSSLInsecureClient();
+                res = ((HttpClient)client).execute(post);
+            } else {
+                client = HttpClientSSLUtils.client;
+                res = ((HttpClient)client).execute(post);
+            }
+
+            var6 = IOUtils.toString(res.getEntity().getContent(), "UTF-8");
+        } finally {
+            post.releaseConnection();
+            if (url.startsWith("https") && client != null && client instanceof CloseableHttpClient) {
+                ((CloseableHttpClient)client).close();
+            }
+
+        }
+
+        return var6;
+    }
+
+    public static String doGet(String url) throws Exception {
+        HttpClient client = null;
+        HttpGet get = new HttpGet(url);
+        String result = "";
+
+        try {
+            Builder customReqConf = RequestConfig.custom();
+            customReqConf.setConnectTimeout(DEFAULT_CONNECTION_TIME_OUT);
+            customReqConf.setSocketTimeout(DEFAULT_CONNECTION_TIME_OUT);
+            get.setConfig(customReqConf.build());
+            HttpResponse res = null;
+            if (url.startsWith("https")) {
+                client = createSSLInsecureClient();
+                res = ((HttpClient)client).execute(get);
+            } else {
+                client = HttpClientSSLUtils.client;
+                res = ((HttpClient)client).execute(get);
+            }
+
+            result = IOUtils.toString(res.getEntity().getContent(), "UTF-8");
+        } finally {
+            get.releaseConnection();
+            if (url.startsWith("https") && client != null && client instanceof CloseableHttpClient) {
+                ((CloseableHttpClient)client).close();
+            }
+
+        }
+
+        return result;
+    }
+
+    private static CloseableHttpClient createSSLInsecureClient() throws GeneralSecurityException {
+        try {
+            SSLContext sslContext = (new SSLContextBuilder()).loadTrustMaterial((KeyStore)null, new TrustStrategy() {
+                public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+                    return true;
+                }
+            }).build();
+            SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new HostnameVerifier() {
+                public boolean verify(String hostname, SSLSession session) {
+                    return true;
+                }
+            });
+            return HttpClients.custom().setSSLSocketFactory(sslsf).build();
+        } catch (GeneralSecurityException var2) {
+            throw var2;
+        }
+    }
+
+//    public static void main(String[] args) {
+//        String url = "https://10.33.39.8/webapi/service/base/getPlatAuthSubSystemList";
+//        String params = "appkey=f8524632&time=" + System.currentTimeMillis() + "&pageNo=1&pageSize=10";
+//        String urlString = url + "?" + params + "&token=" + Digests.buildToken(url + "?" + params, (String)null, "0a5a6558a06546088da645b5f9248a3a");
+//
+//        try {
+//            String output = new String(doGet(urlString));
+//            System.out.println(output);
+//        } catch (Exception var7) {
+//            var7.printStackTrace();
+//        }
+//
+//        url = "https://10.20.134.21/webapi/service/base/addPlatCard";
+//        Map<String, Object> map = new HashMap();
+//        map.put("appkey", "f8524632");
+//        map.put("time", System.currentTimeMillis());
+//        map.put("startCardNo", "16000");
+//        map.put("endCardNo", "16010");
+////        params = JsonUtils.object2Json(map);
+//        url = url + "?token=" + Digests.buildToken(url + "?" + params, (String)null, "0a5a6558a06546088da645b5f9248a3a");
+//
+//        try {
+//            System.out.println(doPost(url, params));
+//        } catch (Exception var6) {
+//            var6.printStackTrace();
+//        }
+//
+//    }
+
+    static {
+        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
+        cm.setMaxTotal(128);
+        cm.setDefaultMaxPerRoute(128);
+        client = HttpClients.custom().setConnectionManager(cm).build();
+    }
+}

+ 2 - 2
huimv-admin/src/main/java/com/huimv/admin/controller/CameraHKVSSync.java

@@ -4,7 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.hikvision.cms.api.common.util.Digests;
-import com.hikvision.cms.api.common.util.HttpClientSSLUtils;
+import com.huimv.admin.common.utils.HttpClientSSLUtils;
 import com.huimv.admin.common.utils.Result;
 import com.huimv.admin.entity.hkwsdto.*;
 import com.huimv.admin.service.ICameraAreaService;
@@ -163,7 +163,7 @@ public class CameraHKVSSync {
         //根据中心UUID分页获取下级区
 //        System.out.println(testGetRegionsByUnitUuid(1048576));
         //获取监控点
-//        System.out.println(testGetCameras());
+        System.out.println(testGetCameras());
 //        /***https方式调用***/
 //        System.out.println(testGetDefaultUserUUID_Https());
 //        System.out.println(testGetCameras_Https());

+ 8 - 1
huimv-admin/src/main/java/com/huimv/admin/service/impl/CameraBaseServiceImpl.java

@@ -53,6 +53,12 @@ public class CameraBaseServiceImpl extends ServiceImpl<CameraBaseMapper, CameraB
         Integer farmId = cameraListVo.getFarmId();
         Integer onLineStatus = cameraListVo.getOnLineStatus();
         QueryWrapper<CameraBase> wrapper = new QueryWrapper<>();
+        if (null == current ) {
+            current =1;
+        }
+        if (null ==size) {
+            size =10;
+        }
         if (farmId != null) {
             wrapper.eq("farm_id", farmId);
         }
@@ -73,7 +79,8 @@ public class CameraBaseServiceImpl extends ServiceImpl<CameraBaseMapper, CameraB
             wrapper.orderByAsc("sort");
         }
         wrapper.orderByDesc("id");
-        return new Result(ResultCode.SUCCESS, page(new Page<>(current, size), wrapper));
+        Page<CameraBase> page = page(new Page<CameraBase>(current, size), wrapper);
+        return new Result(ResultCode.SUCCESS, page);
     }
 
     @Override

+ 22 - 16
huimv-admin/src/main/java/com/huimv/admin/timer/CarmeraTimer.java

@@ -6,8 +6,8 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.hikvision.cms.api.common.util.Digests;
-import com.hikvision.cms.api.common.util.HttpClientSSLUtils;
+import com.huimv.admin.common.utils.Digests;
+import com.huimv.admin.common.utils.HttpClientSSLUtils;
 import com.huimv.admin.entity.EnvData;
 import com.huimv.admin.entity.EnvDevice;
 import com.huimv.admin.entity.EnvWarningInfo;
@@ -27,7 +27,6 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
-import javax.sound.midi.Soundbank;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -127,6 +126,13 @@ public class CarmeraTimer {
                     return;
                 }
                 ShackDatasDto shackDatasDto = JSONUtil.toBean(shishiBody, ShackDatasDto.class);
+                String onLine = shackDatasDto.getData().getOnLine();
+                if ("N".equals(onLine)){
+                    envDevice.setDeviceStatus(0);
+                }else {
+                    envDevice.setDeviceStatus(1);
+                }
+                envDeviceService.updateById(envDevice);
                 List<ShackDatasSensor> sensorDatas = shackDatasDto.getData().getSensorDatas();
                 EnvData envData = new EnvData();
                 for (ShackDatasSensor sensorData : sensorDatas) {
@@ -249,25 +255,25 @@ public class CarmeraTimer {
 
     public static void main(String[] args) throws Exception {
         Map<String, Object> map = new HashMap<String, Object>();
-        String s = HttpClientSSLUtils.doPost("https://yzwlw.loongk.com/mobile/login?username=江西增鑫&password=21218cca77804d2ba1922c33e0151105",JSON.toJSONString(map));
+        String s = HttpClientSSLUtils.doPost("https://yzwlw.loongk.com/mobile/loginO?username=江西增鑫&password=21218cca77804d2ba1922c33e0151105",JSON.toJSONString(map));
         LoginDto loginDto = JSONUtil.toBean(s, LoginDto.class);
         DataToken token = loginDto.getData().getToken();
         String encode = Base64.encode(token.getUserId() + "_" + token.getToken());
 
         //获取配置
-        Map<String, Object> map2 = new HashMap<String, Object>();
-        HttpHeaders headers = new HttpHeaders();
-        headers.add("Authorization",encode);
-        HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
-        RestTemplate restTemplate = new RestTemplate();
-
-        ResponseEntity<String> exchangePeizhi = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackConfig/"+"2c92083a83f8673701854cde3f6203bb", HttpMethod.GET, requestEntity, String.class);
-        System.out.println("peizhi"+exchangePeizhi.getBody());
-
-        ResponseEntity<String> exchangeShishi = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackDatas/"+"2c92083a83f8673701854cde3f6203bb", HttpMethod.GET, requestEntity, String.class);
-        System.out.println("shishi"+exchangeShishi.getBody());
+//        Map<String, Object> map2 = new HashMap<String, Object>();
+//        HttpHeaders headers = new HttpHeaders();
+//        headers.add("Authorization",encode);
+//        HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
+//        RestTemplate restTemplate = new RestTemplate();
+//
+//        ResponseEntity<String> exchangePeizhi = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackConfig/"+"2c92083a83f8673701854cde3f6203bb", HttpMethod.GET, requestEntity, String.class);
+//        System.out.println("peizhi"+exchangePeizhi.getBody());
+//
+//        ResponseEntity<String> exchangeShishi = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackDatas/"+"2c92083a83f8673701854cde3f6203bb", HttpMethod.GET, requestEntity, String.class);
+//        System.out.println("shishi"+exchangeShishi.getBody());
 
-        System.out.println(s);
+//        System.out.println(s);
     }
 
 

huimv-admin/src/main/resources/mapper/CameraAreaMapper.xml → huimv-admin/src/main/resources/com/huimv/admin/mapper/CameraAreaMapper.xml


huimv-admin/src/main/resources/mapper/CameraBaseMapper.xml → huimv-admin/src/main/resources/com/huimv/admin/mapper/CameraBaseMapper.xml


huimv-admin/src/main/resources/mapper/CameraBrandMapper.xml → huimv-admin/src/main/resources/com/huimv/admin/mapper/CameraBrandMapper.xml


huimv-admin/src/main/resources/mapper/CameraFunctionAreaMapper.xml → huimv-admin/src/main/resources/com/huimv/admin/mapper/CameraFunctionAreaMapper.xml


huimv-admin/src/main/resources/mapper/CameraFunctionMapper.xml → huimv-admin/src/main/resources/com/huimv/admin/mapper/CameraFunctionMapper.xml