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();
|
}
|
}
|