zhanghua
2024-09-05 8ba8e90f1e44f0ffc0f59ac9a13c8ca113b55b8c
ycl-platform/src/test/java/com/ycl/sccgplatform/Test1.java
@@ -1,11 +1,14 @@
package com.ycl.sccgplatform;
import com.alibaba.fastjson.JSONObject;
import com.ycl.dto.video.Camera;
import com.ycl.dto.video.HttpResponseResult;
import com.ycl.dto.video.PageResult;
import com.ycl.common.util.UtilNumber;
import com.ycl.entity.dingding.DingUserInfo;
import com.ycl.entity.user.UmsAdmin;
import com.ycl.mapper.unlawful.UnlawfulMapper;
import com.ycl.service.oss.OssService;
import com.ycl.util.dahua.alarm.AlarmDataCB;
import com.ycl.util.dahua.lib.module.LoginModule;
import com.ycl.util.dahua.module.AlarmListenModule;
import net.coobird.thumbnailator.Thumbnails;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -13,8 +16,9 @@
import javax.annotation.Resource;
import javax.xml.bind.DatatypeConverter;
import java.io.*;
import java.util.List;
import java.util.UUID;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
@SpringBootTest
public class Test1 {
@@ -24,72 +28,31 @@
    @Resource
    private UnlawfulMapper unlawfuldao;
    @Autowired
    UtilNumber utilNumber;
    @Test
    void test() {
//        List<CategoryDto> data = unlawfuldao.getDataByType(0, 5,"2022-12-14 17:19:01", "2022-12-14 17:19:03");
//        System.out.println(data);
        String url = "http://test.xshcs.com/10%E6%9C%88%E6%8E%92%E6%9C%9F.jpg";
        try {
            HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
            connection.setReadTimeout(5000);
            connection.setConnectTimeout(5000);
            connection.setRequestMethod("GET");
            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                InputStream in = connection.getInputStream();
                ByteArrayOutputStream outs = new ByteArrayOutputStream();
                Thumbnails.of(in).scale(0.6).outputQuality(1).toOutputStream(outs);
                InputStream ins = new ByteArrayInputStream(outs.toByteArray());
                String picData = ossService.uploadImages(ins, ".png");
                System.out.println(picData);
            }
        } catch (IOException e) {
            System.out.println("获取网络图片出现异常,图片路径为:" + url);
        String msg = "{\n" +
                "    \"code\": \"0\",\n" +
                "    \"msg\": \"success\",\n" +
                "    \"data\": {\n" +
                "        \"total\": 1,\n" +
                "        \"pageSize\": 20,\n" +
                "        \"pageNo\": 1,\n" +
                "        \"list\": [\n" +
                "            {\n" +
                "                \"cameraIndexCode\": \"90ad77d8057c43dab140b77361606927\",\n" +
                "                \"gbIndexCode\": \"12000000051210000000\",\n" +
                "                \"name\": \"Camera_01\",\n" +
                "                \"deviceIndexCode\": \"f5da3e320bcb483da6bef4b3f86de779\",\n" +
                "                \"longitude\": \"120.216123284763\",\n" +
                "                \"latitude\": \"30.21168569675452\",\n" +
                "                \"altitude\": \"88\",\n" +
                "                \"pixel\": 1,\n" +
                "                \"cameraType\": 1,\n" +
                "                \"cameraTypeName\": \"半球\",\n" +
                "                \"installPlace\": \"街道\",\n" +
                "                \"matrixCode\": \"2076c586b0a94a6ba639b44eda9e76e9\",\n" +
                "                \"chanNum\": 1,\n" +
                "                \"viewshed\": \"{\\\"horizontalValue\\\":\\\"13.80000\\\",\\\"azimuth\\\":\\\"109.23000\\\",\\\"visibleRadius\\\":\\\"48.00000\\\"}\",\n" +
                "                \"capabilitySet\": \"@event_face@\",\n" +
                "                \"capabilitySetName\": \"人脸采集能力\",\n" +
                "                \"intelligentSet\": \"@face@\",\n" +
                "                \"intelligentSetName\": \"人脸结构化能力\",\n" +
                "                \"recordLocation\": \"0\",\n" +
                "                \"recordLocationName\": \"中心存储\",\n" +
                "                \"ptzController\": 1,\n" +
                "                \"ptzControllerName\": \"DVR\",\n" +
                "                \"deviceResourceType\": \"ENCODE_DEVICE\",\n" +
                "                \"deviceResourceTypeName\": \"编码设备\",\n" +
                "                \"channelType\": \"digital\",\n" +
                "                \"channelTypeName\": \"数字通道\",\n" +
                "                \"transType\": 0,\n" +
                "                \"transTypeName\": \"UDP\",\n" +
                "                \"updateTime\": \"2021-06-15T00:00:00.000+08:00\",\n" +
                "                \"unitIndexCode\": \"083b2031c1db4f368f015fe2562e0012\",\n" +
                "                \"treatyType\": \"20005\",\n" +
                "                \"treatyTypeName\": \"ONVIF\",\n" +
                "                \"createTime\": \"2021-06-15T00:00:00.000+08:00\",\n" +
                "                \"status\": 0,\n" +
                "                \"statusName\": \"不在线\"\n" +
                "            }\n" +
                "        ]\n" +
                "    }\n" +
                "}\n";
        HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(msg, HttpResponseResult.class);
        if ("0".equals(responseResult.getCode())) {
            JSONObject jsonObject = responseResult.getData();
            String strList = jsonObject.getString("list");
            Integer total = Integer.parseInt(jsonObject.getString("total"));
            Integer pageSize = Integer.parseInt(jsonObject.getString("pageSize"));
            Integer pageNo = Integer.parseInt(jsonObject.getString("pageNo"));
            List<Camera> ls = JSONObject.parseArray(strList, Camera.class);
            PageResult<Camera> pageResult = new PageResult<>(total, pageSize, pageNo, ls);
            System.out.println(ls.size());
            e.printStackTrace();
        }
    }
@@ -130,4 +93,18 @@
        isr.close();
        fis.close();
    }
    @Test
    void alarmTest() {
        AlarmDataCB cbMessage = new AlarmDataCB();
        String m_strIp = "192.168.202.123";
        int m_nPort = 37777;
        String m_strUser = "admin";
        String m_strPassword = "scdx@123";
        LoginModule.login(m_strIp, m_nPort, m_strUser, m_strPassword);
        AlarmListenModule.startListen(cbMessage);
        System.out.println(cbMessage.data);
    }
}