瀏覽代碼

Merge remote-tracking branch 'origin/master'

lchao 4 月之前
父節點
當前提交
499e327aa4

+ 6 - 1
qmjszx-admin/src/main/resources/application.yml

@@ -146,7 +146,7 @@ rsa:
   publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIdmTeQdUyYK2a5ivPXdYArOgDMDKu6ob7YPlaC6R1/XxjHhGaSIucYGrzO+JhCFNkhgHxmc4POpyFq+PFdLuNMCAwEAAQ==
   # 私钥
   privateKey: MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAh2ZN5B1TJgrZrmK89d1gCs6AMwMq7qhvtg+VoLpHX9fGMeEZpIi5xgavM74mEIU2SGAfGZzg86nIWr48V0u40wIDAQABAkBbgNXu7ap9sSN/aJcPCXaYlwmob+GZvBcS0OFr57fImsxTEzWg/OJWxcbHk7Li31AbHjwqQmVtUxk2wQ6GawthAiEAve5+CCaUHV3BIH7LhzU7MsPAr6IIx25t1NkNNg+dn3kCIQC2f7XtdTOVRtPUwO7QhwC0fX/wJu53pR01p55tqmgLqwIgYzUHr8o243/tOMQCG4W6fjGxnAvO+hy8UcluFSbi9kECIQCAK4NOyPA4V6zwD6vpgdcJ69YNiJoUJz8zboxCwtodzwIgNUN6uuiVJuZmBJDm+9AIY7Ury+ajGRZJ7l1FIBbxMPY=
-# 微信支付配置
+
 # 微信支付配置 notifyUrl:微信支付异步回调地址
 wx:
   pay:
@@ -158,6 +158,11 @@ wx:
     privateKeyPath: #证书认证是生成文件
     merchantserialNumber: #证书序列号
 
+# 海康获取直播视频流配置
+hik:
+  appKey: "28356728"
+  appSecret: "C3K889wQUgVlSj1BMay6"
+  host: "218.62.80.146:1443"
 
 
 

+ 7 - 0
qmjszx-business/pom.xml

@@ -80,6 +80,13 @@
             <version>2.5.0</version>
         </dependency>
 
+        <!--海康-->
+        <dependency>
+            <groupId>com.hikvision.ga</groupId>
+            <artifactId>artemis-http-client</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 48 - 0
qmjszx-business/src/main/java/beilv/hik/controller/HiKController.java

@@ -0,0 +1,48 @@
+package beilv.hik.controller;
+
+import beilv.common.core.domain.AjaxResult;
+import beilv.hik.controller.utils.GetCameraPreviewURL;
+import beilv.hik.controller.utils.GetCameras;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+
+@RestController
+@RequestMapping("/app-api/hik")
+public class HiKController {
+
+    @Value("${hik.appKey}")
+    private String appKey;
+    @Value("${hik.appSecret}")
+    private String appSecret;
+    @Value("${hik.host}")
+    private String host;
+
+
+    /**
+     * 根据userId查询用户积分流水列表
+     */
+    @GetMapping("/getCameraPreviewURL")
+    @ResponseBody
+    public AjaxResult getCameraPreviewURL() {
+        List<String> urlList = new ArrayList<>();
+        List<Map<String, Object>> cameras = GetCameras.getCameras(host, appKey, appSecret);
+        if (!CollectionUtils.isEmpty(cameras)) {
+            for (Map<String, Object> map : cameras) {
+                String url = GetCameraPreviewURL.getCameraPreviewURL(host, appKey, appSecret, map.get("cameraIndexCode").toString());
+                urlList.add(url);
+            }
+        }
+        return AjaxResult.success(urlList);
+    }
+
+
+}

+ 46 - 0
qmjszx-business/src/main/java/beilv/hik/controller/utils/GetCameraPreviewURL.java

@@ -0,0 +1,46 @@
+package beilv.hik.controller.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.hikvision.artemis.sdk.ArtemisHttpUtil;
+import com.hikvision.artemis.sdk.config.ArtemisConfig;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 获取监控点预览取流URLv2
+ */
+public class GetCameraPreviewURL {
+
+    public static String getCameraPreviewURL(String host, String appKey, String appSecret, String cameraIndexCode) {
+        String url = null;
+        ArtemisConfig.host = host; // 平台的ip端口
+        ArtemisConfig.appKey = appKey;  // 密钥appkey
+        ArtemisConfig.appSecret = appSecret;// 密钥appSecret
+        final String ARTEMIS_PATH = "/artemis";
+        final String previewURLsApi = ARTEMIS_PATH + "/api/video/v1/cameras/previewURLs";
+        Map<String, String> path = new HashMap<String, String>(2) {
+            {
+                put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
+            }
+        };
+        String contentType = "application/json";
+        JSONObject jsonBody = new JSONObject();
+        jsonBody.put("cameraIndexCode", cameraIndexCode);
+        jsonBody.put("streamType", 0);
+        jsonBody.put("protocol", "ws");
+        jsonBody.put("transmode", 1);
+        jsonBody.put("expand", "streamform=ps");
+        String body = jsonBody.toJSONString();
+        JSONObject json = JSONObject.parseObject(ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null));// post请求application/json类型参数
+        if (json.get("code").equals("0")) {
+            url = JSONObject.parseObject(json.get("data").toString()).get("url").toString();
+        }
+        return url;
+    }
+
+    public static void main(String[] args) {
+        String result = getCameraPreviewURL("218.62.80.146:1443", "28356728", "C3K889wQUgVlSj1BMay6", "fd98e88146904ceba1e30081e61b47f9");
+        System.out.println("result结果示例: " + result);
+    }
+}

+ 60 - 0
qmjszx-business/src/main/java/beilv/hik/controller/utils/GetCameras.java

@@ -0,0 +1,60 @@
+package beilv.hik.controller.utils;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.hikvision.artemis.sdk.ArtemisHttpUtil;
+import com.hikvision.artemis.sdk.config.ArtemisConfig;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 分页获取监控点资源
+ */
+@Slf4j
+public class GetCameras {
+
+    public static List<Map<String, Object>> getCameras(String host, String appKey, String appSecret) {
+        List<Map<String, Object>> list = new ArrayList<>();
+
+        ArtemisConfig.host = host; // 平台的ip端口
+        ArtemisConfig.appKey = appKey;  // 密钥appkey
+        ArtemisConfig.appSecret = appSecret;// 密钥appSecret
+
+        final String ARTEMIS_PATH = "/artemis";
+        final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
+        Map<String, String> path = new HashMap<String, String>(2) {
+            {
+                put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
+            }
+        };
+        String contentType = "application/json";
+        JSONObject jsonBody = new JSONObject();
+        jsonBody.put("pageNo", 1);
+        jsonBody.put("pageSize", 2);
+        String body = jsonBody.toJSONString();
+        JSONObject json = JSONObject.parseObject(ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null));// post请求application/json类型参数
+        if (json.get("code").equals("0")) {
+            JSONArray jsonArray = JSONObject.parseArray(JSONObject.parseObject(json.get("data").toString()).get("list").toString());
+            ObjectMapper objectMapper = new ObjectMapper();
+            try {
+                list = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<Map<String, Object>>>() {
+                });
+            } catch (JsonProcessingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return list;
+    }
+
+    public static void main(String[] args) {
+        List<Map<String, Object>> result = getCameras("218.62.80.146:1443", "28356728", "C3K889wQUgVlSj1BMay6");
+        System.out.println("result结果示例: " + result);
+    }
+}

+ 0 - 16
qmjszx-business/src/main/java/beilv/hk/controller/HKController.java

@@ -1,16 +0,0 @@
-package beilv.hk.controller;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class HKController {
-
-
-
-
-
-
-
-
-
-}

+ 1 - 3
qmjszx-business/src/main/java/beilv/userbill/service/impl/SysUserBillServiceImpl.java

@@ -147,14 +147,12 @@ public class SysUserBillServiceImpl implements ISysUserBillService {
 
     @Override
     public int exchange(SysMemberDTO dto) {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        Date date = new Date();
         SysMember sysMember = sysMemberMapper.selectSysMemberById(dto.getId());
         if (sysMember.getIntegral().compareTo(dto.getIntegral()) < 0) {
             throw new RuntimeException("积分不足");
         }
         BigDecimal surplusIntegral = sysMember.getIntegral().subtract(dto.getIntegral());
-        expend(dto.getId(), "会员兑换", dto.getIntegral(), surplusIntegral, sdf.format(date) + "消耗" + dto.getIntegral() + "积分," + "兑换" + dto.getGiftName() + "成功");
+        expend(dto.getId(), "会员兑换", dto.getIntegral(), surplusIntegral, "本次消耗" + dto.getIntegral() + "积分," + "兑换" + dto.getGiftName() + "成功");
         sysMember.setIntegral(surplusIntegral);
         return sysMemberMapper.updateSysMember(sysMember);
     }