zhanghua
2023-09-05 1c732150ad5e8b21efff07ecd923c4ff8fda60c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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.mapper.unlawful.UnlawfulMapper;
import com.ycl.service.oss.OssService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
import javax.annotation.Resource;
import javax.xml.bind.DatatypeConverter;
import java.io.*;
import java.util.List;
import java.util.UUID;
 
@SpringBootTest
public class Test1 {
 
    @Autowired
    private OssService ossService;
 
    @Resource
    private UnlawfulMapper unlawfuldao;
 
    @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 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());
        }
    }
 
//    @Test
//    void test1(){
//        List<StatusDto> statusData = unlawfuldao.getStatusData(null, null, 23);
//        System.out.println(statusData);
//    }
 
    @Test
    void test2() {
        double v = Double.parseDouble("1.0");
        double v1 = Double.parseDouble("3.0");
        System.out.println(v / v1);
    }
 
    @Test
    void test3() {
        System.out.println("sczf/" + String.valueOf(UUID.randomUUID()));
    }
 
    @Test
    void test4() throws Exception {
        String extension = "jpg";
 
        File file = new File("src/main/resources/file.txt");
        FileInputStream fis = new FileInputStream(file);
        InputStreamReader isr = new InputStreamReader(fis);
        BufferedReader br = new BufferedReader(isr);
 
        String PicData = br.readLine();
        byte[] data = DatatypeConverter.parseBase64Binary(PicData);
        InputStream inputStream = new ByteArrayInputStream(data);
        String s = ossService.uploadImages(inputStream, extension);
        System.out.println(s);
 
        br.close();
        isr.close();
        fis.close();
    }
}