zhanghua
2023-11-02 46251c20b66bb1ca05058ae63a92a195e5543b90
优化
10个文件已修改
1个文件已添加
281 ■■■■■ 已修改文件
document/副本丽水市遂昌县智慧执法应用-资源开通表 -0228.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
ycl-common/src/main/java/com/ycl/service/oss/OssService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-common/src/main/java/com/ycl/service/oss/impl/OssServiceImpl.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/PlatformApplication.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/common/util/UtilNumber.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/controller/dingding/DingController.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/java/com/ycl/util/VideoUtil.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/main/resources/application-dev.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-platform/src/test/java/com/ycl/sccgplatform/Test1.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-smoke/src/main/java/com/ycl/smoke/utils/HttpUtil.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
document/¸±±¾ÀöË®ÊÐËì²ýÏØÖÇ»ÛÖ´·¨Ó¦ÓÃ-×ÊÔ´¿ªÍ¨±í -0228.xlsx
Binary files differ
ycl-common/src/main/java/com/ycl/service/oss/OssService.java
@@ -22,4 +22,5 @@
    String uploadImages(InputStream inputStream, String ext);
    String uploadVideo(MultipartFile file);
}
ycl-common/src/main/java/com/ycl/service/oss/impl/OssServiceImpl.java
@@ -101,6 +101,9 @@
        String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
        String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        System.out.println("准备上传--" + dtf2.format(LocalDateTime.now()));
        // åˆ›å»ºOSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        // ä¸Šä¼ æ–‡ä»¶æµ
@@ -109,32 +112,21 @@
            LocalDate date = LocalDate.now();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
            String fileName = "sczf/" + date.format(formatter) + RandomUtils.generateRandomInt(8) + "." + ext;
            System.out.println("文件地址:" + fileName);
            ObjectMetadata objectMetadata = new ObjectMetadata();
            objectMetadata.setContentType(getcontentType(ext));
            // è°ƒç”¨oss的方法实现长传
            // ç¬¬ä¸€ä¸ªå‚æ•° bucketName
            // ç¬¬äºŒä¸ªå‚æ•° ä¸Šä¼ åˆ°oss的文件路径和文件名称
            ossClient.putObject(bucketName, fileName, inputStream, objectMetadata);
            // å…³é—­OSSClient。
            ossClient.shutdown();
            // æŠŠä¸Šä¼ çš„æ–‡ä»¶è·¯å¾„返回 ï¼ˆæ‰‹åŠ¨æ‹¼æŽ¥ï¼‰
            // è¿™é‡Œè®¾ç½®å›¾ç‰‡æœ‰æ•ˆæ—¶é—´ æˆ‘设置了30å¹´
            Date expiration = new Date(System.currentTimeMillis() + (long) 946080000 * 1000);
            String url = ossClient.generatePresignedUrl(bucketName, fileName, expiration).toString();
            System.out.println("oss上传成功:" + url);
            // URL urlO = new URL(url);
            // HttpURLConnection conn = (HttpURLConnection) urlO.openConnection();
            // conn.setRequestMethod("GET");
            // conn.setConnectTimeout(10 * 1000);
            // conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
            //
            // InputStream inputStream2 = conn.getInputStream();// é€šè¿‡è¾“入流获取图片数据
            //
            // byte[] data = readInputStream(inputStream2);
            //
            // System.out.println("获取图片成功:" + url);
            System.out.println("开始上传--" + dtf2.format(LocalDateTime.now()));
            ossClient.putObject(bucketName, fileName, inputStream, objectMetadata);
            ossClient.shutdown();
            Date expiration = new Date(System.currentTimeMillis() + (long) 946080000 * 1000);
            String url = ossClient.generatePresignedUrl(bucketName, fileName, expiration).toString();
//            System.out.println("oss上传成功:" + url);
            System.out.println("上传完成--" + dtf2.format(LocalDateTime.now()));
            return url;
        } catch (Exception e) {
            System.out.println("oss异常:" + e.getMessage());
@@ -179,6 +171,7 @@
        }
    }
    public static String getcontentType(String FilenameExtension) {
        if (FilenameExtension.equalsIgnoreCase(".mp4")||FilenameExtension.equalsIgnoreCase(".mov")) {
            return "video/mp4";
ycl-platform/src/main/java/com/ycl/PlatformApplication.java
@@ -1,5 +1,6 @@
package com.ycl;
import com.ycl.util.VideoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -39,6 +40,8 @@
                env.getProperty("server.servlet.context-path"),
                "127.0.0.1",
                env.getProperty("server.port"));
    }
}
ycl-platform/src/main/java/com/ycl/common/util/UtilNumber.java
@@ -289,6 +289,9 @@
     */
    public String createCaseCode() {
        String ymd = getYMD();
        double num = Math.random();
        int myRandInt = (int)(num*100+1);
//        Integer number = myRandInt;
        Integer number = generatedCodeMapper.createNumber(ymd, "case");
        String numberStr = RandomUtils.formatSign(number, 4);
        String year = String.valueOf(LocalDateTime.now().getYear());
ycl-platform/src/main/java/com/ycl/controller/dingding/DingController.java
@@ -193,15 +193,15 @@
    @PostMapping("/oss/sign")
    public CommonResult ossSign(@RequestBody OssFileDto dto) {
        log.info("接收到file");
        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        if (StringUtils.isNullOrEmpty(dto.getMediaId()) || StringUtils.isNullOrEmpty(dto.getExtension())) {
            return CommonResult.failed("参数不能为空!");
        }
        ExecutableClient executableClient = DdTest.getExecutableClient();
        CloseableHttpResponse response = null;
        OSS ossClient = null;
        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        System.out.println("开始获取--" + dtf2.format(LocalDateTime.now()));
        try {
@@ -217,15 +217,9 @@
            HttpEntity entity = response.getEntity();
            InputStream is = entity.getContent();
            System.out.println("获取完成--" + dtf2.format(LocalDateTime.now()));
            DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
//            MultipartFile file = getMultipartFile(is, fileName);
            String strDate2 = dtf.format(LocalDateTime.now());
            String fileName = strDate2 + RandomUtils.generateRandomInt(4) + "." + dto.getExtension();
            MultipartFile file = getMultipartFile(is, fileName);
            String url = ossService.uploadImages(file);
            String url = ossService.uploadImages(is,dto.getExtension());
            return CommonResult.success(url);
        } catch (Exception e) {
            e.printStackTrace();
ycl-platform/src/main/java/com/ycl/util/VideoUtil.java
@@ -207,6 +207,7 @@
        jsonBody.put("streamType", 0);
        jsonBody.put("protocol", "hls");
        jsonBody.put("transmode", 0);
        jsonBody.put("expand","transcode=1&videotype=h264");
        String body = jsonBody.toString();
        //参数根据接口实际情况设置
        HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, query, null, "application/json", head);
ycl-platform/src/main/resources/application-dev.yml
@@ -75,10 +75,10 @@
aliyun:
  oss:
    endpoint: https://oss-cn-zhangjiakou.aliyuncs.com
    endpoint: https://oss-accelerate.aliyuncs.com
    keyId: LTAIDlTWjHW0IVyW
    keySecret: 6fO78NmgyF49TK5GWFAzXuSAexl9PL
    bucketName: hcjs-mte-internal
    bucketName: xshlivelesson
#专有钉钉参数
zzding :
ycl-platform/src/test/java/com/ycl/sccgplatform/Test1.java
@@ -1,6 +1,7 @@
package com.ycl.sccgplatform;
import com.alibaba.fastjson.JSONObject;
import com.ycl.common.util.UtilNumber;
import com.ycl.dto.video.Camera;
import com.ycl.dto.video.HttpResponseResult;
import com.ycl.dto.video.PageResult;
@@ -24,73 +25,15 @@
    @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 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());
        }
        System.out.println(utilNumber.createShopCode());
        System.out.println(utilNumber.createCaseCode());
    }
//    @Test
ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java
@@ -199,8 +199,8 @@
    @Scheduled(cron = "0 */1 * * * ?")   // æ¯5分钟执行
    public void listDataInTime() {
        DataIntimeParamDto paramDto = DataIntimeParamDto.builder().build();
        // {"StartAt":0,"Size":20,"Typ":2,"SortBy":"status","SortMode":"asc","Param":{"StatusOfRecord":"NORMAL"}}:
        paramDto.setSize(200);
        // {"StartAt":0,"Size":20,"Typ":2,"SortBy":"status","SortMode":"asc","Param":{"StatusOfRecord":"NORMAL"}}
        paramDto.setSize(20);
        paramDto.setStartAt(0);
        paramDto.setTyp(2);
        paramDto.setSortBy("status");
ycl-smoke/src/main/java/com/ycl/smoke/utils/HttpUtil.java
New file
@@ -0,0 +1,145 @@
package com.ycl.smoke.utils;
import com.ycl.service.redis.RedisService;
import com.ycl.utils.redis.RedisKey;
import org.apache.http.*;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class HttpUtil {
    private static final CloseableHttpClient httpclient = HttpClients.createDefault();
    public static String doGet(String urlPath, Map<String, Object> params)
            throws Exception {
        StringBuilder sb = new StringBuilder(urlPath);
        if (params != null && !params.isEmpty()) { // è¯´æ˜Žæœ‰å‚æ•°
            sb.append("?");
            Set<Map.Entry<String, Object>> set = params.entrySet();
            for (Map.Entry<String, Object> entry : set) { // éåކmap里面的参数
                String key = entry.getKey();
                String value = "";
                if (null != entry.getValue()) {
                    value = entry.getValue().toString();
                    // è½¬ç 
                    value = URLEncoder.encode(value, "UTF-8");
                }
                sb.append(key).append("=").append(value).append("&");
            }
            sb.deleteCharAt(sb.length() - 1); // åˆ é™¤æœ€åŽä¸€ä¸ª&
        }
        // System.out.println(sb.toString());
        URL url = new URL(sb.toString());
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setConnectTimeout(5000); // 5s超时
        conn.setRequestMethod("GET");
        if (conn.getResponseCode() == HttpStatus.SC_OK) {// HttpStatus.SC_OK ==
            // 200
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    conn.getInputStream()));
            StringBuilder sbs = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                sbs.append(line);
            }
            // JSONObject jsonObject = new JSONObject(sbs.toString());
            return sbs.toString();
        }
        return null;
    }
    /**
     * å‘送HttpPost请求,参数为map
     * @param url
     * @param map
     * @return
     */
    public static String sendPost(String url, Map<String, Object> map) {
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
        }
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
        HttpPost httppost = new HttpPost(url);
        httppost.setEntity(entity);
        CloseableHttpResponse response = null;
        try {
            response = httpclient.execute(httppost);
        } catch (IOException e) {
            e.printStackTrace();
        }
        HttpEntity entity1 = response.getEntity();
        String result = null;
        try {
            result = EntityUtils.toString(entity1);
        } catch (ParseException | IOException e) {
            e.printStackTrace();
        }
        return result;
    }
    public static String HttpPostWithJson(String url, String json,String token) {
        String returnValue = "这是默认返回值,接口调用失败";
        CloseableHttpClient httpClient = HttpClients.createDefault();
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        try{
            //第一步:创建HttpClient对象
            httpClient = HttpClients.createDefault();
            //第二步:创建httpPost对象
            HttpPost httpPost = new HttpPost(url);
            //第三步:给httpPost设置JSON格式的参数
            StringEntity requestEntity = new StringEntity(json,"utf-8");
            requestEntity.setContentEncoding("UTF-8");
            httpPost.setHeader("Content-type", "application/json");
            httpPost.setHeader("Auth",token);
            httpPost.setEntity(requestEntity);
            //第四步:发送HttpPost请求,获取返回值
            returnValue = httpClient.execute(httpPost,responseHandler); //调接口获取返回值时,必须用此方法
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        //第五步:处理返回值
        return returnValue;
    }
}