傅行帆 6 anos atrás
pai
commit
f06dfc88fa

+ 373
- 341
.idea/workspace.xml
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 9
- 7
src/main/java/com/huiju/welcome/hardware/libs/APIUtil.java Ver arquivo

@@ -74,11 +74,11 @@ public class APIUtil {
74 74
     }
75 75
 
76 76
     public static Headers buildHeaders(Map<String, String> headers) {
77
-        if (null == headers) return null;
78
-
79 77
         Headers.Builder builder = new Headers.Builder();
80
-        for (Map.Entry<String, String> entry: headers.entrySet()) {
81
-            builder.add(entry.getKey(), entry.getValue());
78
+        if (null != headers) {
79
+            for (Map.Entry<String, String> entry: headers.entrySet()) {
80
+                builder.add(entry.getKey(), entry.getValue());
81
+            }
82 82
         }
83 83
         return builder.build();
84 84
     }
@@ -119,7 +119,9 @@ public class APIUtil {
119 119
                 } else if (fieldValue instanceof FileInputStream) {
120 120
                     buildFileInputStream(builder, (FileInputStream) fieldValue, fieldName);
121 121
                 } else if (fieldValue instanceof ByteBuffer) {
122
-                    buildFileBytes(builder, ((ByteBuffer) fieldValue).array(), fieldName);
122
+                    byte[] array = new byte[((ByteBuffer) fieldValue).remaining()];
123
+                    ((ByteBuffer) fieldValue).get(array);
124
+                    buildFileBytes(builder, array, fieldName);
123 125
                 } else if (fieldValue instanceof Array) {
124 126
                     for (int i = 0; i < Array.getLength(fieldValue); i ++) {
125 127
                         Object item = Array.get(fieldValue, i);
@@ -161,7 +163,7 @@ public class APIUtil {
161 163
 
162 164
             MediaType tp = MediaType.get("application/octet-stream");
163 165
             RequestBody body = RequestBody.create(tp, content);
164
-            builder.addFormDataPart(field, "未知文件", body);
166
+            builder.addFormDataPart(field, "未知文件.jpg", body);
165 167
         } catch (IOException e) {
166 168
             e.printStackTrace();
167 169
             log.error("转换 form-data 数据 到 body 失败: " + e.getMessage());
@@ -171,7 +173,7 @@ public class APIUtil {
171 173
     private static void buildFileBytes(MultipartBody.Builder builder, byte[] content, String field) {
172 174
         MediaType tp = MediaType.get("application/octet-stream");
173 175
         RequestBody body = RequestBody.create(tp, content);
174
-        builder.addFormDataPart(field, "未知文件", body);
176
+        builder.addFormDataPart(field, "未知文件.jpg", body);
175 177
     }
176 178
 
177 179
     private static String getSearchString(Map<String, String> query) {

+ 4
- 2
src/main/java/com/huiju/welcome/hardware/service/HikService.java Ver arquivo

@@ -54,7 +54,7 @@ public class HikService {
54 54
     HCNetSDK.FMSGCallBack_V31 fmsgCallBack;
55 55
 
56 56
     public boolean init() {
57
-        String deviceIP = Configer.pick("device.id");
57
+        String deviceIP = Configer.pick("device.ip");
58 58
 
59 59
         if (!Ping.attemp(deviceIP)) {
60 60
             log.error("设备未上线...");
@@ -65,6 +65,7 @@ public class HikService {
65 65
         if (!setDeviceCallback()) return false;
66 66
         if (!loginDevice()) return false;
67 67
         if (!setDeviceAlarm()) return false;
68
+        if (!setDeviceOnline()) return false;
68 69
 
69 70
         return true;
70 71
     }
@@ -108,7 +109,7 @@ public class HikService {
108 109
         HCNetSDK.NET_DVR_DEVICEINFO_V30 device = new HCNetSDK.NET_DVR_DEVICEINFO_V30();
109 110
 
110 111
         user = hcNetSDK.NET_DVR_Login_V30(
111
-                Configer.pick("device.id"),
112
+                Configer.pick("device.ip"),
112 113
                 (short) Integer.valueOf(Configer.pick("device.port")).intValue(),
113 114
                 Configer.pick("device.loginUser"),
114 115
                 Configer.pick("device.password"),
@@ -341,6 +342,7 @@ public class HikService {
341 342
         query.put("port", Configer.pick("device.port"));
342 343
         query.put("username", Configer.pick("device.loginUser"));
343 344
         query.put("password", Configer.pick("device.password"));
345
+        query.put("status", "1");
344 346
         query.put("api", Configer.pick("api.current") + ":" + Configer.pick("server.port"));
345 347
 
346 348
         try {

+ 1
- 1
src/main/java/com/huiju/welcome/hardware/service/Monitor.java Ver arquivo

@@ -32,7 +32,7 @@ public class Monitor extends Thread {
32 32
 
33 33
             if (!lastResult && netOk) {
34 34
                 while (true) {
35
-                    boolean success = hikService.initDevice();
35
+                    boolean success = hikService.init();
36 36
                     if (success) break;
37 37
 
38 38
                     try {

+ 1
- 0
src/main/java/com/huiju/welcome/hardware/service/PersonDetect.java Ver arquivo

@@ -48,6 +48,7 @@ public class PersonDetect implements HCNetSDK.FMSGCallBack_V31 {
48 48
     }
49 49
 
50 50
     // 海康回调
51
+    @Override
51 52
     public boolean invoke(NativeLong lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) {
52 53
         // 回调类型
53 54
         switch (lCommand.intValue()){

+ 1
- 1
src/main/resources/application.properties Ver arquivo

@@ -7,7 +7,7 @@ device.id=98
7 7
 device.name=测试摄像头
8 8
 device.loginUser=admin
9 9
 device.password=huiju999
10
-device.ip=192.168.0.98
10
+device.ip=192.168.0.99
11 11
 device.port=8000
12 12
 # 1-人脸识别相机,  2-车辆识别相机
13 13
 device.type=1