傅行帆 6 years ago
parent
commit
f06dfc88fa

+ 373
- 341
.idea/workspace.xml
File diff suppressed because it is too large
View File


+ 9
- 7
src/main/java/com/huiju/welcome/hardware/libs/APIUtil.java View File

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

+ 4
- 2
src/main/java/com/huiju/welcome/hardware/service/HikService.java View File

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

+ 1
- 1
src/main/java/com/huiju/welcome/hardware/service/Monitor.java View File

32
 
32
 
33
             if (!lastResult && netOk) {
33
             if (!lastResult && netOk) {
34
                 while (true) {
34
                 while (true) {
35
-                    boolean success = hikService.initDevice();
35
+                    boolean success = hikService.init();
36
                     if (success) break;
36
                     if (success) break;
37
 
37
 
38
                     try {
38
                     try {

+ 1
- 0
src/main/java/com/huiju/welcome/hardware/service/PersonDetect.java View File

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

+ 1
- 1
src/main/resources/application.properties View File

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