Browse Source

初始化

yangyue 1 year ago
commit
8407a5a0a1

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 106 - 0
pom.xml

@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.1.3.RELEASE</version>
+        <relativePath/>
+    </parent>
+    <groupId>cn.com.taiji</groupId>
+    <artifactId>data-service</artifactId>
+    <version>1.0</version>
+    <name>data-service</name>
+    <description>DataService project for Spring Boot</description>
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <scope>runtime</scope>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+            <version>1.18.20</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>cn.com.taiji</groupId>
+            <artifactId>apione-http-client</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/src/main/resources/lib/apione-http-client-1.0.0-SNAPSHOT.jar</systemPath>
+        </dependency>
+
+        <!-- 海康SDK -->
+        <dependency>
+            <groupId>com.hikvision.ga</groupId>
+            <artifactId>artemis-http-client</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.75</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.6.6</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>utf-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <!--fork:设置True,否则可能devtools不会起作用-->
+                    <fork>true</fork>
+                    <!-- 指定该Main Class为全局的唯一入口 -->
+                    <mainClass>cn.com.taiji.dataService.DataServiceApplication</mainClass>
+                    <layout>ZIP</layout>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+    </build>
+
+</project>

+ 13 - 0
src/main/java/cn/com/taiji/dataService/DataServiceApplication.java

@@ -0,0 +1,13 @@
+package cn.com.taiji.dataService;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DataServiceApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DataServiceApplication.class, args);
+    }
+
+}

+ 30 - 0
src/main/java/cn/com/taiji/dataService/cotroller/TestController.java

@@ -0,0 +1,30 @@
+package cn.com.taiji.dataService.cotroller;
+
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+
+@RestController
+public class TestController {
+
+    public static void main(String[] args) throws ParseException {
+        //闰年的情况
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
+        Date date = sdf.parse("2023-03-30 05");
+        DateTime targetTime = DateUtil.offsetMonth(date,-1);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(targetTime);
+        calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
+        // calendar.add(Calendar.MONTH,1);
+        Date d2 = calendar.getTime();
+        System.out.println(sdf.format(targetTime)+"加一月:"+sdf.format(d2));
+
+    }
+}

+ 42 - 0
src/main/java/cn/com/taiji/dataService/cotroller/test006.java

@@ -0,0 +1,42 @@
+package cn.com.taiji.dataService.cotroller;
+
+import cn.com.digitalhainan.apione.sdk.ContentBody;
+import cn.com.digitalhainan.apione.sdk.HttpCaller;
+import cn.com.digitalhainan.apione.sdk.HttpParameters;
+import cn.com.digitalhainan.apione.sdk.HttpReturn;
+
+public class test006 {
+    public static void main(String[] args) {
+
+        //换成自己的ak、sk
+        String ak = "替换AK";
+        String sk = "替换SK";
+        String api = "替换API";
+
+        String region = "接口请求区域 INTRA(政务外网),INTER(政务互联网),PUBLIC(公网)";
+
+        String requestUrl = "https://api-one.digitalhainan.com.cn/apione";
+
+        //传参格式,根据不同的参数格式以不同的方式传参。
+        String contentJson = "{\"idNo\":\"460*****15\",\"name\":\"*****\"}";
+        ContentBody contentBody = new ContentBody(contentJson);
+
+        //拼装业务信息
+        HttpParameters parameters = HttpParameters.builder()
+                .api(api)
+                .region(region)
+                // 如果有query参数需要设置
+                //.queryParamsMap(query)
+                // 如果有path参数需要设置
+                //.path(path)
+                .accessKey(ak)
+                .secretKey(sk)
+                .contentBody(contentBody)
+                .requestUrl(requestUrl)
+                .build();
+
+        // 请求服务接口,获取response
+        HttpReturn call = HttpCaller.getInstance().call(parameters);
+        System.out.println(call);
+    }
+}

+ 43 - 0
src/main/java/cn/com/taiji/dataService/model/ProviewFetchingVO.java

@@ -0,0 +1,43 @@
+package cn.com.taiji.dataService.model;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Description
+ *
+ * @Author  yangyue
+ * @Date 2021/11/18
+ */
+@Data
+public class ProviewFetchingVO implements Serializable {
+
+
+
+    /**
+     * 监控点编号(通用唯一识别码UUID)
+     */
+    private String  cameraIndexCode;
+
+    /**
+     * 码流类型(0-主码流,1-子码流),未填默认为主码流
+     */
+
+    private Integer streamType;
+
+    /**
+     * 协议类型(rtsp-rtsp协议,rtmp-rtmp协议,hls-hLS协议),未填写为rtsp协议
+     */
+    private String  protocol;
+
+    /**
+     * 协议类型( 0-udp,1-tcp),默认为tcp,在protocol设置为rtsp或者rtmp时有效
+     */
+    private Integer transmode;
+
+    /**
+     * 拓展字段(标准协议取流不需要扩展字段信息 )
+     */
+    private String expand;
+}

+ 20 - 0
src/main/java/cn/com/taiji/dataService/service/IProviewFetchingService.java

@@ -0,0 +1,20 @@
+// package cn.com.taiji.dataService.service;
+//
+//
+// import cn.com.taiji.dataService.model.ProviewFetchingVO;
+//
+// /**
+//  * @Description
+//  *
+//  * @Author  yangyue
+//  * @Date 2021/11/18
+//  */
+// public interface IProviewFetchingService {
+//     /**
+//      * 海康视频流地址
+//      * @param pre 海康入参
+//      * @return String
+//      */
+//     String httpsPost(ProviewFetchingVO pre);
+//
+// }

+ 48 - 0
src/main/java/cn/com/taiji/dataService/service/impl/PerviewFetchingServiceImpl.java

@@ -0,0 +1,48 @@
+// package cn.com.taiji.dataService.service.impl;
+//
+//
+// import cn.com.taiji.dataService.model.ProviewFetchingVO;
+// import cn.com.taiji.dataService.service.IProviewFetchingService;
+// import com.alibaba.fastjson.JSON;
+// import com.alibaba.fastjson.JSONObject;
+// import com.hikvision.artemis.sdk.ArtemisHttpUtil;
+// import com.hikvision.artemis.sdk.config.ArtemisConfig;
+// import lombok.extern.slf4j.Slf4j;
+// import org.springframework.stereotype.Service;
+//
+// import java.util.HashMap;
+// import java.util.Map;
+//
+// /**
+//  * @Description
+//  *
+//  * @Author  yangyue
+//  * @Date 2021/11/18
+//  */
+// @Service
+// @Slf4j
+// public class PerviewFetchingServiceImpl implements IProviewFetchingService {
+//
+//     @Override
+//     public String httpsPost(ProviewFetchingVO pre) {
+//
+//         ArtemisConfig.host="74.10.28.97:443";
+//         ArtemisConfig.appKey="26491753";
+//         ArtemisConfig.appSecret="nSWbgqChFBSdGPSnb59i";
+//         final String artemispath = "/artemis";
+//         final String previewurlsapi = artemispath + "/api/video/v1/cameras/previewURLs";
+//
+//         Map<String, String> path = new HashMap<String, String>(2) {
+//             {
+//                 put("https://", previewurlsapi);//根据现场环境部署确认是http还是https
+//             }
+//         };
+//         String contentType = "application/json";
+//         String body = JSON.toJSONString(pre);
+//         // post请求application/json类型参数
+//         String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
+//         log.info(result);
+//         JSONObject jsonObject = JSONObject.parseObject(result);
+//         return jsonObject.getJSONObject("data").getString("url");
+//     }
+// }

+ 76 - 0
src/main/java/cn/com/taiji/dataService/utils/AESUtils.java

@@ -0,0 +1,76 @@
+package cn.com.taiji.dataService.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.util.Base64;
+
+/**
+ * Created by Kevin on 2018/6/21.
+ */
+public class AESUtils {
+
+    static String iv = "d22b0a851e014f7b";
+
+    private final static Logger logger = LoggerFactory.getLogger(AESUtils.class);
+
+    private final static Base64.Encoder encoder = Base64.getEncoder();
+    private final static Base64.Decoder decoder = Base64.getDecoder();
+
+    private static final String defaultCharset = "UTF-8";
+    private static final String KEY_AES = "AES";
+    public static final String KEY = "8192553d3db81630";
+
+    /**
+     * 加密
+     *
+     * @param data 需要加密的内容
+     * @param key  加密密码
+     * @return
+     */
+    public static String encrypt(String data, String key) {
+        return doAES(data, key, iv.getBytes(), Cipher.ENCRYPT_MODE);
+    }
+
+    /**
+     * 解密
+     *
+     * @param data 待解密内容
+     * @param key  解密密钥
+     * @return
+     */
+    public static String decrypt(String data, String key) {
+        return doAES(data, key, iv.getBytes(), Cipher.DECRYPT_MODE);
+    }
+
+    public static String doAES(String data, String secretKey, byte[] iv, int mode) {
+
+        try {
+            boolean encrypt = mode == Cipher.ENCRYPT_MODE;
+            byte[] content;
+            //true 加密内容 false 解密内容
+            if (encrypt) {
+                content = data.getBytes(defaultCharset);
+            } else {
+                content = decoder.decode(data);
+            }
+
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            SecretKeySpec skeySpec = new SecretKeySpec(secretKey.getBytes(), KEY_AES);
+            cipher.init(mode, skeySpec, new IvParameterSpec(iv));
+            byte[] result = cipher.doFinal(content);
+            if (encrypt) {
+                return new String(encoder.encode(result));
+            } else {
+                return new String(result, defaultCharset);
+            }
+        } catch (Exception e) {
+            logger.error("aes error:", e);
+        }
+        return null;
+    }
+}
+

+ 2 - 0
src/main/resources/application.yml

@@ -0,0 +1,2 @@
+server:
+  port: 9000

BIN
src/main/resources/lib/apione-http-client-1.0.0-SNAPSHOT.jar