瀏覽代碼

集成minio

hanqingsong 3 月之前
父節點
當前提交
c82017c65b

+ 22 - 0
pom.xml

@@ -25,6 +25,7 @@
25 25
         <lombok.versin>1.18.22</lombok.versin>
26 26
         <spring-cloud.version>Hoxton.SR12</spring-cloud.version>
27 27
         <jna.version>3.0.9</jna.version>
28
+        <minio.version>8.5.2</minio.version>
28 29
     </properties>
29 30
     <dependencies>
30 31
         <!-- lombok -->
@@ -51,6 +52,27 @@
51 52
             <version>${jna.version}</version>
52 53
         </dependency>
53 54
         <dependency>
55
+            <groupId>io.minio</groupId>
56
+            <artifactId>minio</artifactId>
57
+            <version>${minio.version}</version>
58
+            <exclusions>
59
+                <exclusion>
60
+                    <artifactId>okhttp</artifactId>
61
+                    <groupId>com.squareup.okhttp3</groupId>
62
+                </exclusion>
63
+            </exclusions>
64
+        </dependency>
65
+        <dependency>
66
+            <groupId>com.squareup.okhttp3</groupId>
67
+            <artifactId>okhttp</artifactId>
68
+            <version>4.10.0</version>
69
+        </dependency>
70
+        <dependency>
71
+            <groupId>cn.hutool</groupId>
72
+            <artifactId>hutool-all</artifactId>
73
+            <version>5.8.12</version>
74
+        </dependency>
75
+        <dependency>
54 76
             <groupId>org.springframework.boot</groupId>
55 77
             <artifactId>spring-boot-starter-web</artifactId>
56 78
         </dependency>

+ 3 - 0
src/main/java/com/unis/alarm/Alarm.java

@@ -2,6 +2,9 @@ package com.unis.alarm;
2 2
 
3 3
 import com.sun.jna.Native;
4 4
 import com.sun.jna.Pointer;
5
+import com.unis.common.FMSGCallBack;
6
+import com.unis.common.FMSGCallBack_V31;
7
+import com.unis.common.HCNetSDK;
5 8
 import com.unis.common.osSelect;
6 9
 import com.unis.config.AddressModel;
7 10
 import lombok.extern.slf4j.Slf4j;

+ 115 - 244
src/main/java/com/unis/alarm/AlarmDataParse.java

@@ -1,12 +1,15 @@
1 1
 package com.unis.alarm;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.sun.jna.Pointer;
5
+import com.unis.common.HCNetSDK;
6
+import com.unis.common.NetDVRAlarmerConvert;
4 7
 import lombok.extern.slf4j.Slf4j;
8
+import org.springframework.beans.BeanUtils;
5 9
 
6 10
 import java.io.FileNotFoundException;
7 11
 import java.io.FileOutputStream;
8 12
 import java.io.IOException;
9
-import java.io.UnsupportedEncodingException;
10 13
 import java.nio.ByteBuffer;
11 14
 import java.text.SimpleDateFormat;
12 15
 import java.util.Date;
@@ -20,18 +23,119 @@ import java.util.Date;
20 23
 public class AlarmDataParse {
21 24
 
22 25
     public static void alarmDataHandle(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) {
23
-        log.info("报警事件类型lCommand int: {}", lCommand);
24
-        log.info("报警事件类型lCommand int: {}", "0x" + lCommand);
26
+//        log.info("报警事件类型lCommand int: {}", lCommand);
25 27
 
26
-        /*String hexString = Integer.toHexString(lCommand);
27
-        log.info("报警事件类型lCommand Hex: {}", hexString);*/
28
+        String hexString = Integer.toHexString(lCommand);
29
+        log.info("报警事件类型lCommand Hex: {}", hexString);
28 30
 
29 31
         String sTime;
30 32
         String MonitoringSiteID;
31 33
         String pic = System.getProperty("user.dir") + "/pic/";
32
-        log.info("pic: {}", pic);
34
+//        log.info("pic: {}", pic);
35
+//        log.info("int---> {}", HCNetSDK.COMM_UPLOAD_AIOP_POLLING_SNAP);
36
+
37
+        // bye封装对象转换
38
+        NetDVRAlarmerConvert convert = new NetDVRAlarmerConvert();
39
+        BeanUtils.copyProperties(pAlarmer, convert);
40
+
41
+        // byMacAddr
42
+        convert.setByMacAddr(new String(pAlarmer.getByMacAddr()).trim());
43
+        // byRes2
44
+        convert.setByRes2(new String(pAlarmer.getByRes2()).trim());
45
+        // sDeviceIP
46
+        convert.setSDeviceIP(new String(pAlarmer.getSDeviceIP()).trim());
47
+        // sDeviceName
48
+        convert.setSDeviceName(new String(pAlarmer.getSDeviceName()).trim());
49
+        // sSerialNumber
50
+        convert.setSSerialNumber(new String(pAlarmer.getSSerialNumber()).trim());
51
+        // sSocketIP
52
+        convert.setSSocketIP(new String(pAlarmer.getSSocketIP()).trim());
53
+        log.info("convert: {}", JSON.toJSONString(convert));
54
+
33 55
         //lCommand是传的报警类型
34 56
         switch (lCommand) {
57
+            //AI开放平台接入轮询抓图检测报警信息(抽烟打电话)
58
+            case HCNetSDK.COMM_UPLOAD_AIOP_POLLING_SNAP:
59
+                log.info("抽烟打电话");
60
+                HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD strAiopPollingPic = new HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD();
61
+                strAiopPollingPic.write();
62
+                Pointer pAiopPollingPic = strAiopPollingPic.getPointer();
63
+                pAiopPollingPic.write(0, pAlarmInfo.getByteArray(0, strAiopPollingPic.size()), 0, strAiopPollingPic.size());
64
+                strAiopPollingPic.read();
65
+                log.info("通道号: {}", strAiopPollingPic.dwChannel);
66
+                log.info("轮询抓图任务ID: {}", new String(strAiopPollingPic.szTaskID));
67
+                String strPollingPicTime = "" + String.format("%04d", strAiopPollingPic.struTime.wYear) +
68
+                        String.format("%02d", strAiopPollingPic.struTime.wMonth) +
69
+                        String.format("%02d", strAiopPollingPic.struTime.wDay) +
70
+                        String.format("%02d", strAiopPollingPic.struTime.wHour) +
71
+                        String.format("%02d", strAiopPollingPic.struTime.wMinute) +
72
+                        String.format("%02d", strAiopPollingPic.struTime.wSecond) +
73
+                        String.format("%03d", strAiopPollingPic.struTime.wMilliSec);
74
+                //AIOPData数据保存
75
+                if (strAiopPollingPic.dwAIOPDataSize > 0) {
76
+                    FileOutputStream fout;
77
+                    try {
78
+                        String filename = pic + new String(pAlarmer.sDeviceIP).trim() +
79
+                                "_" + strPollingPicTime + "_PollingPicData.json";
80
+                        fout = new FileOutputStream(filename);
81
+                        //将字节写入文件
82
+                        long offset = 0;
83
+                        ByteBuffer buffers = strAiopPollingPic.pBufferAIOPData.getByteBuffer(offset, strAiopPollingPic.dwAIOPDataSize);
84
+                        byte[] bytes = new byte[strAiopPollingPic.dwAIOPDataSize];
85
+                        buffers.rewind();
86
+                        buffers.get(bytes);
87
+                        fout.write(bytes);
88
+                        fout.close();
89
+                    } catch (FileNotFoundException e) {
90
+                        // TODO Auto-generated catch block
91
+                        e.printStackTrace();
92
+                    } catch (IOException e) {
93
+                        // TODO Auto-generated catch block
94
+                        e.printStackTrace();
95
+                    }
96
+                }
97
+                // 轮询抓图图片保存
98
+                if (strAiopPollingPic.dwPictureSize > 0) {
99
+                    FileOutputStream fout;
100
+                    try {
101
+                        String filename = pic + new String(pAlarmer.sDeviceIP).trim() +
102
+                                "_" + strPollingPicTime + "_PollingPic.jpg";
103
+                        fout = new FileOutputStream(filename);
104
+                        //将字节写入文件
105
+                        long offset = 0;
106
+                        ByteBuffer buffers = strAiopPollingPic.pBufferPicture.getByteBuffer(offset, strAiopPollingPic.dwPictureSize);
107
+                        byte[] bytes = new byte[strAiopPollingPic.dwPictureSize];
108
+                        buffers.rewind();
109
+                        buffers.get(bytes);
110
+                        fout.write(bytes);
111
+                        fout.close();
112
+                    } catch (FileNotFoundException e) {
113
+                        // TODO Auto-generated catch block
114
+                        e.printStackTrace();
115
+                    } catch (IOException e) {
116
+                        // TODO Auto-generated catch block
117
+                        e.printStackTrace();
118
+                    }
119
+                }
120
+                break;
121
+            case HCNetSDK.COMM_ALARM_V30:  //移动侦测、视频丢失、遮挡、IO信号量等报警信息(V3.0以上版本支持的设备)
122
+                HCNetSDK.NET_DVR_ALARMINFO_V30 struAlarmInfo = new HCNetSDK.NET_DVR_ALARMINFO_V30();
123
+                struAlarmInfo.write();
124
+                Pointer pAlarmInfo_V30 = struAlarmInfo.getPointer();
125
+                pAlarmInfo_V30.write(0, pAlarmInfo.getByteArray(0, struAlarmInfo.size()), 0, struAlarmInfo.size());
126
+                struAlarmInfo.read();
127
+                log.info("报警类型V30: {}", struAlarmInfo.dwAlarmType); // 3-移动侦测
128
+                break;
129
+            case HCNetSDK.COMM_ALARM_V40: //移动侦测、视频丢失、遮挡、IO信号量等报警信息,报警数据为可变长
130
+                HCNetSDK.NET_DVR_ALARMINFO_V40 struAlarmInfoV40 = new HCNetSDK.NET_DVR_ALARMINFO_V40();
131
+                struAlarmInfoV40.write();
132
+                Pointer pAlarmInfoV40 = struAlarmInfoV40.getPointer();
133
+                pAlarmInfoV40.write(0, pAlarmInfo.getByteArray(0, struAlarmInfoV40.size()), 0, struAlarmInfoV40.size());
134
+                struAlarmInfoV40.read();
135
+                log.info("报警类型V40: {}", struAlarmInfoV40.struAlarmFixedHeader.dwAlarmType); // 3-移动侦测
136
+                break;
137
+
138
+            // -------------------------------------------------------------------------
35 139
             //行为分析信息
36 140
             case HCNetSDK.COMM_ALARM_RULE:
37 141
                 HCNetSDK.NET_VCA_RULE_ALARM strVcaAlarm = new HCNetSDK.NET_VCA_RULE_ALARM();
@@ -39,7 +143,7 @@ public class AlarmDataParse {
39 143
                 Pointer pVCAInfo = strVcaAlarm.getPointer();
40 144
                 pVCAInfo.write(0, pAlarmInfo.getByteArray(0, strVcaAlarm.size()), 0, strVcaAlarm.size());
41 145
                 strVcaAlarm.read();
42
-
146
+                log.info("行为分析信息case: {}", strVcaAlarm.struRuleInfo.wEventTypeEx);
43 147
                 switch (strVcaAlarm.struRuleInfo.wEventTypeEx) {
44 148
                     case 1: //穿越警戒面 (越界侦测)
45 149
                         System.out.println("越界侦测报警发生");
@@ -80,7 +184,7 @@ public class AlarmDataParse {
80 184
                             String newName = sf.format(new Date());
81 185
                             FileOutputStream fout;
82 186
                             try {
83
-                                String filename = "../pic/" + newName + "_TargetEnter" + ".jpg";
187
+                                String filename = pic + newName + "_TargetEnter" + ".jpg";
84 188
                                 fout = new FileOutputStream(filename);
85 189
                                 //将字节写入文件
86 190
                                 long offset = 0;
@@ -168,7 +272,7 @@ public class AlarmDataParse {
168 272
                             String newName = sf.format(new Date());
169 273
                             FileOutputStream fout;
170 274
                             try {
171
-                                String filename = "../pic/" + newName + "VCA_LEAVE_POSITION_" + ".jpg";
275
+                                String filename = pic + newName + "VCA_LEAVE_POSITION_" + ".jpg";
172 276
                                 fout = new FileOutputStream(filename);
173 277
                                 //将字节写入文件
174 278
                                 long offset = 0;
@@ -189,34 +293,6 @@ public class AlarmDataParse {
189 293
                     case 20: //倒地检测
190 294
                         System.out.println("倒地事件触发");
191 295
                         break;
192
-                    case 44: //玩手机
193
-
194
-                        System.out.println("玩手机报警发生");
195
-                        //图片保存
196
-                        if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) {
197
-                            SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
198
-                            String newName = sf.format(new Date());
199
-                            FileOutputStream fout;
200
-                            try {
201
-                                String filename = "../pic/" + newName + "PLAY_CELLPHONE_" + ".jpg";
202
-                                fout = new FileOutputStream(filename);
203
-                                //将字节写入文件
204
-                                long offset = 0;
205
-                                ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen);
206
-                                byte[] bytes = new byte[strVcaAlarm.dwPicDataLen];
207
-                                buffers.rewind();
208
-                                buffers.get(bytes);
209
-                                fout.write(bytes);
210
-                                fout.close();
211
-                            } catch (FileNotFoundException e) {
212
-                                // TODO Auto-generated catch block
213
-                                e.printStackTrace();
214
-                            } catch (IOException e) {
215
-                                // TODO Auto-generated catch block
216
-                                e.printStackTrace();
217
-                            }
218
-                        }
219
-                        break;
220 296
                     case 45: //持续检测
221 297
                         System.out.println("持续检测事件触发");
222 298
                     default:
@@ -224,210 +300,6 @@ public class AlarmDataParse {
224 300
                         break;
225 301
                 }
226 302
                 break;
227
-            case HCNetSDK.COMM_UPLOAD_FACESNAP_RESULT: //实时人脸抓拍上传
228
-                System.out.println("UPLOAD_FACESNAP_Alarm");
229
-                HCNetSDK.NET_VCA_FACESNAP_RESULT strFaceSnapInfo = new HCNetSDK.NET_VCA_FACESNAP_RESULT();
230
-                strFaceSnapInfo.write();
231
-                Pointer pFaceSnapInfo = strFaceSnapInfo.getPointer();
232
-                pFaceSnapInfo.write(0, pAlarmInfo.getByteArray(0, strFaceSnapInfo.size()), 0, strFaceSnapInfo.size());
233
-                strFaceSnapInfo.read();
234
-
235
-                //事件时间
236
-                int dwYear = (strFaceSnapInfo.dwAbsTime >> 26) + 2000;
237
-                int dwMonth = (strFaceSnapInfo.dwAbsTime >> 22) & 15;
238
-                int dwDay = (strFaceSnapInfo.dwAbsTime >> 17) & 31;
239
-                int dwHour = (strFaceSnapInfo.dwAbsTime >> 12) & 31;
240
-                int dwMinute = (strFaceSnapInfo.dwAbsTime >> 6) & 63;
241
-                int dwSecond = (strFaceSnapInfo.dwAbsTime >> 0) & 63;
242
-
243
-                String strAbsTime = "" + String.format("%04d", dwYear) +
244
-                        String.format("%02d", dwMonth) +
245
-                        String.format("%02d", dwDay) +
246
-                        String.format("%02d", dwHour) +
247
-                        String.format("%02d", dwMinute) +
248
-                        String.format("%02d", dwSecond);
249
-
250
-                //人脸属性信息
251
-                String sFaceAlarmInfo = "Abs时间:" + strAbsTime + ",年龄:" + strFaceSnapInfo.struFeature.byAge +
252
-                        ",性别:" + strFaceSnapInfo.struFeature.bySex + ",是否戴口罩:" +
253
-                        strFaceSnapInfo.struFeature.byMask + ",是否微笑:" + strFaceSnapInfo.struFeature.bySmile;
254
-                System.out.println("人脸信息:" + sFaceAlarmInfo);
255
-
256
-                //人脸测温信息
257
-                if (strFaceSnapInfo.byAddInfo == 1) {
258
-                    HCNetSDK.NET_VCA_FACESNAP_ADDINFO strAddInfo = new HCNetSDK.NET_VCA_FACESNAP_ADDINFO();
259
-                    strAddInfo.write();
260
-                    Pointer pAddInfo = strAddInfo.getPointer();
261
-                    pAddInfo.write(0, strFaceSnapInfo.pAddInfoBuffer.getByteArray(0, strAddInfo.size()), 0, strAddInfo.size());
262
-                    strAddInfo.read();
263
-
264
-                    String sTemperatureInfo = "测温是否开启:" + strAddInfo.byFaceSnapThermometryEnabled + "人脸温度:" + strAddInfo.fFaceTemperature + "温度是否异常"
265
-                            + strAddInfo.byIsAbnomalTemperature + "报警温度阈值:" + strAddInfo.fAlarmTemperature;
266
-                    System.out.println("人脸温度信息:" + sTemperatureInfo);
267
-
268
-                }
269
-
270
-                try {
271
-                    SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
272
-                    String time = df.format(new Date());// new Date()为获取当前系统时间
273
-
274
-                    //人脸图片写文件
275
-                    FileOutputStream small = new FileOutputStream("../pic/" + time + "small.jpg");
276
-                    FileOutputStream big = new FileOutputStream("../pic/" + time + "big.jpg");
277
-                    try {
278
-                        small.write(strFaceSnapInfo.pBuffer1.getByteArray(0, strFaceSnapInfo.dwFacePicLen), 0, strFaceSnapInfo.dwFacePicLen);
279
-                        small.close();
280
-                    } catch (IOException ex) {
281
-                        ex.printStackTrace();
282
-                    }
283
-                    try {
284
-                        big.write(strFaceSnapInfo.pBuffer2.getByteArray(0, strFaceSnapInfo.dwBackgroundPicLen), 0, strFaceSnapInfo.dwBackgroundPicLen);
285
-                        big.close();
286
-                    } catch (IOException ex) {
287
-                        ex.printStackTrace();
288
-                    }
289
-
290
-                } catch (FileNotFoundException ex) {
291
-                    ex.printStackTrace();
292
-                }
293
-                break;
294
-            case HCNetSDK.COMM_ALARM_V30:  //移动侦测、视频丢失、遮挡、IO信号量等报警信息(V3.0以上版本支持的设备)
295
-                HCNetSDK.NET_DVR_ALARMINFO_V30 struAlarmInfo = new HCNetSDK.NET_DVR_ALARMINFO_V30();
296
-                struAlarmInfo.write();
297
-                Pointer pAlarmInfo_V30 = struAlarmInfo.getPointer();
298
-                pAlarmInfo_V30.write(0, pAlarmInfo.getByteArray(0, struAlarmInfo.size()), 0, struAlarmInfo.size());
299
-                struAlarmInfo.read();
300
-                System.out.println("报警类型:" + struAlarmInfo.dwAlarmType);  // 3-移动侦测
301
-                break;
302
-            case HCNetSDK.COMM_ALARM_V40: //移动侦测、视频丢失、遮挡、IO信号量等报警信息,报警数据为可变长
303
-                HCNetSDK.NET_DVR_ALARMINFO_V40 struAlarmInfoV40 = new HCNetSDK.NET_DVR_ALARMINFO_V40();
304
-                struAlarmInfoV40.write();
305
-                Pointer pAlarmInfoV40 = struAlarmInfoV40.getPointer();
306
-                pAlarmInfoV40.write(0, pAlarmInfo.getByteArray(0, struAlarmInfoV40.size()), 0, struAlarmInfoV40.size());
307
-                struAlarmInfoV40.read();
308
-                System.out.println("报警类型:" + struAlarmInfoV40.struAlarmFixedHeader.dwAlarmType); //3-移动侦测
309
-                break;
310
-            case HCNetSDK.COMM_THERMOMETRY_ALARM:  //温度报警信息
311
-                HCNetSDK.NET_DVR_THERMOMETRY_ALARM struTemInfo = new HCNetSDK.NET_DVR_THERMOMETRY_ALARM();
312
-                struTemInfo.write();
313
-                Pointer pTemInfo = struTemInfo.getPointer();
314
-                pTemInfo.write(0, pAlarmInfo.getByteArray(0, struTemInfo.size()), 0, struTemInfo.size());
315
-                struTemInfo.read();
316
-                String sThermAlarmInfo = "规则ID:" + struTemInfo.byRuleID + "预置点号:" + struTemInfo.wPresetNo + "报警等级:" + struTemInfo.byAlarmLevel + "报警类型:" +
317
-                        struTemInfo.byAlarmType + "当前温度:" + struTemInfo.fCurrTemperature;
318
-                System.out.println(sThermAlarmInfo);
319
-                //可见光图片保存
320
-                if ((struTemInfo.dwPicLen > 0) && (struTemInfo.byPicTransType == 0)) {
321
-                    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
322
-                    String newName = sf.format(new Date());
323
-                    FileOutputStream fout;
324
-
325
-                    try {
326
-                        String filename = "../pic/" + newName + "_" + struTemInfo.fCurrTemperature + ".jpg";
327
-                        fout = new FileOutputStream(filename);
328
-                        //将字节写入文件
329
-                        long offset = 0;
330
-                        ByteBuffer buffers = struTemInfo.pPicBuff.getByteBuffer(offset, struTemInfo.dwPicLen);
331
-                        byte[] bytes = new byte[struTemInfo.dwPicLen];
332
-                        buffers.rewind();
333
-                        buffers.get(bytes);
334
-                        fout.write(bytes);
335
-                        fout.close();
336
-                    } catch (FileNotFoundException e) {
337
-                        // TODO Auto-generated catch block
338
-                        e.printStackTrace();
339
-                    } catch (IOException e) {
340
-                        // TODO Auto-generated catch block
341
-                        e.printStackTrace();
342
-                    }
343
-                }
344
-
345
-                if ((struTemInfo.dwThermalPicLen > 0) && (struTemInfo.byPicTransType == 0)) {
346
-                    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
347
-                    String newName = sf.format(new Date());
348
-                    FileOutputStream fout;
349
-
350
-                    try {
351
-                        String filename = "../pic/" + newName + "_" + "_ThermalPiC" + ".jpg";
352
-                        fout = new FileOutputStream(filename);
353
-                        //将字节写入文件
354
-                        long offset = 0;
355
-                        ByteBuffer buffers = struTemInfo.pThermalPicBuff.getByteBuffer(offset, struTemInfo.dwThermalPicLen);
356
-                        byte[] bytes = new byte[struTemInfo.dwThermalPicLen];
357
-                        buffers.rewind();
358
-                        buffers.get(bytes);
359
-                        fout.write(bytes);
360
-                        fout.close();
361
-                    } catch (FileNotFoundException e) {
362
-                        // TODO Auto-generated catch block
363
-                        e.printStackTrace();
364
-                    } catch (IOException e) {
365
-                        // TODO Auto-generated catch block
366
-                        e.printStackTrace();
367
-                    }
368
-
369
-                }
370
-                break;
371
-            case HCNetSDK.COMM_THERMOMETRY_DIFF_ALARM: //温差检测报警
372
-                HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM strThermDiffAlarm = new HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM();
373
-                strThermDiffAlarm.write();
374
-                Pointer pTemDiffInfo = strThermDiffAlarm.getPointer();
375
-                pTemDiffInfo.write(0, pAlarmInfo.getByteArray(0, strThermDiffAlarm.size()), 0, strThermDiffAlarm.size());
376
-                strThermDiffAlarm.read();
377
-                String sThremDiffInfo = "通道号:" + strThermDiffAlarm.dwChannel + ",报警规则:" + strThermDiffAlarm.byAlarmRule + ",当前温差:" + strThermDiffAlarm.fCurTemperatureDiff;
378
-                System.out.println(sThremDiffInfo);
379
-                //可见光图片保存
380
-                if ((strThermDiffAlarm.dwPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) {
381
-                    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
382
-                    String newName = sf.format(new Date());
383
-                    FileOutputStream fout;
384
-
385
-                    try {
386
-                        String filename = "../pic/" + newName + "_" + strThermDiffAlarm.fCurTemperatureDiff + ".jpg";
387
-                        fout = new FileOutputStream(filename);
388
-                        //将字节写入文件
389
-                        long offset = 0;
390
-                        ByteBuffer buffers = strThermDiffAlarm.pPicBuff.getByteBuffer(offset, strThermDiffAlarm.dwPicLen);
391
-                        byte[] bytes = new byte[strThermDiffAlarm.dwPicLen];
392
-                        buffers.rewind();
393
-                        buffers.get(bytes);
394
-                        fout.write(bytes);
395
-                        fout.close();
396
-                    } catch (FileNotFoundException e) {
397
-                        // TODO Auto-generated catch block
398
-                        e.printStackTrace();
399
-                    } catch (IOException e) {
400
-                        // TODO Auto-generated catch block
401
-                        e.printStackTrace();
402
-                    }
403
-                }
404
-                //热成像图片保存
405
-                if ((strThermDiffAlarm.dwThermalPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) {
406
-                    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
407
-                    String newName = sf.format(new Date());
408
-                    FileOutputStream fout;
409
-
410
-                    try {
411
-                        String filename = "../pic/" + newName + "_" + "_ThermalDiffPiC" + ".jpg";
412
-                        fout = new FileOutputStream(filename);
413
-                        //将字节写入文件
414
-                        long offset = 0;
415
-                        ByteBuffer buffers = strThermDiffAlarm.pThermalPicBuff.getByteBuffer(offset, strThermDiffAlarm.dwThermalPicLen);
416
-                        byte[] bytes = new byte[strThermDiffAlarm.dwThermalPicLen];
417
-                        buffers.rewind();
418
-                        buffers.get(bytes);
419
-                        fout.write(bytes);
420
-                        fout.close();
421
-                    } catch (FileNotFoundException e) {
422
-                        // TODO Auto-generated catch block
423
-                        e.printStackTrace();
424
-                    } catch (IOException e) {
425
-                        // TODO Auto-generated catch block
426
-                        e.printStackTrace();
427
-                    }
428
-
429
-                }
430
-                break;
431 303
 
432 304
             case HCNetSDK.COMM_FIREDETECTION_ALARM://烟火检测
433 305
                 HCNetSDK.NET_DVR_FIREDETECTION_ALARM struFireDecAlarm = new HCNetSDK.NET_DVR_FIREDETECTION_ALARM();
@@ -445,7 +317,7 @@ public class AlarmDataParse {
445 317
                     FileOutputStream fout;
446 318
 
447 319
                     try {
448
-                        String filename = "../pic/" + newName + "_FireDecAlarm" + ".jpg";
320
+                        String filename = pic + newName + "_FireDecAlarm" + ".jpg";
449 321
                         fout = new FileOutputStream(filename);
450 322
                         //将字节写入文件
451 323
                         long offset = 0;
@@ -470,7 +342,7 @@ public class AlarmDataParse {
470 342
                     FileOutputStream fout;
471 343
 
472 344
                     try {
473
-                        String filename = "../pic/" + newName + "_" + "_ThermalFireAlarm" + ".jpg";
345
+                        String filename = pic + newName + "_" + "_ThermalFireAlarm" + ".jpg";
474 346
                         fout = new FileOutputStream(filename);
475 347
                         //将字节写入文件
476 348
                         long offset = 0;
@@ -487,7 +359,6 @@ public class AlarmDataParse {
487 359
                         // TODO Auto-generated catch block
488 360
                         e.printStackTrace();
489 361
                     }
490
-
491 362
                 }
492 363
                 break;
493 364
             default:

File diff suppressed because it is too large
+ 0 - 10677
src/main/java/com/unis/alarm/HCNetSDK.java


+ 1 - 1
src/main/java/com/unis/alarm/CommonUtil.java

@@ -1,6 +1,6 @@
1 1
 
2 2
 
3
-package com.unis.alarm;
3
+package com.unis.common;
4 4
 
5 5
 /**
6 6
  * @author

+ 3 - 1
src/main/java/com/unis/alarm/FMSGCallBack.java

@@ -1,6 +1,8 @@
1
-package com.unis.alarm;
1
+package com.unis.common;
2 2
 
3 3
 import com.sun.jna.Pointer;
4
+import com.unis.alarm.AlarmDataParse;
5
+import com.unis.common.HCNetSDK;
4 6
 
5 7
 
6 8
 /**

+ 3 - 1
src/main/java/com/unis/alarm/FMSGCallBack_V31.java

@@ -1,7 +1,9 @@
1 1
 
2
-package com.unis.alarm;
2
+package com.unis.common;
3 3
 
4 4
 import com.sun.jna.Pointer;
5
+import com.unis.alarm.AlarmDataParse;
6
+import com.unis.common.HCNetSDK;
5 7
 
6 8
 
7 9
 public class FMSGCallBack_V31 implements HCNetSDK.FMSGCallBack_V31 {

File diff suppressed because it is too large
+ 736 - 84
src/main/java/com/unis/common/HCNetSDK.java


+ 2 - 1
src/main/java/com/unis/common/NetDVRAlarmerConvert.java

@@ -1,5 +1,6 @@
1 1
 package com.unis.common;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import lombok.Data;
4 5
 
5 6
 /**
@@ -25,7 +26,7 @@ public class NetDVRAlarmerConvert {
25 26
     private Byte byVersionValid;
26 27
     private Byte dwDeviceVersion;
27 28
     private Integer lUserID;
28
-    private Object pointer;
29
+    private JSONObject pointer;
29 30
     private String sDeviceIP;
30 31
     private String sDeviceName;
31 32
     private String sSerialNumber;

+ 197 - 0
src/main/java/com/unis/config/DevFileMinIoUtil.java

@@ -0,0 +1,197 @@
1
+/*
2
+ * Copyright [2022] [https://www.xiaonuo.vip]
3
+ *
4
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
5
+ *
6
+ * 1.请不要删除和修改根目录下的LICENSE文件。
7
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
8
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
9
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
10
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
11
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
12
+ */
13
+package com.unis.config;
14
+
15
+import cn.hutool.core.io.IoUtil;
16
+import cn.hutool.core.util.StrUtil;
17
+import cn.hutool.json.JSONArray;
18
+import cn.hutool.json.JSONObject;
19
+import cn.hutool.json.JSONUtil;
20
+import com.unis.enums.DevFileBucketAuthEnum;
21
+import io.minio.MinioClient;
22
+import io.minio.PutObjectArgs;
23
+import io.minio.SetBucketPolicyArgs;
24
+import lombok.extern.slf4j.Slf4j;
25
+import org.springframework.beans.factory.annotation.Autowired;
26
+import org.springframework.stereotype.Component;
27
+import org.springframework.web.multipart.MultipartFile;
28
+
29
+import javax.activation.MimetypesFileTypeMap;
30
+import java.io.IOException;
31
+import java.io.InputStream;
32
+
33
+/**
34
+ * MINIO文件工具类
35
+ * 参考文档:http://docs.minio.org.cn/docs/master/java-client-quickstart-guide
36
+ *
37
+ * @author xuyuxiang
38
+ * @date 2022/1/2 18:13
39
+ */
40
+@Slf4j
41
+@Component
42
+public class DevFileMinIoUtil {
43
+    private static MinioClient client;
44
+    private static MinIoProperties minIoProperties;
45
+
46
+    @Autowired
47
+    public DevFileMinIoUtil(MinIoProperties minIoProperties) {
48
+        this.minIoProperties = minIoProperties;
49
+    }
50
+
51
+    /**
52
+     * 初始化操作的客户端
53
+     *
54
+     * @author xuyuxiang
55
+     * @date 2022/1/5 23:24
56
+     */
57
+    private static void initClient() {
58
+        String endpoint = minIoProperties.getEndpoint();
59
+        String accessKey = minIoProperties.getAccessKey();
60
+        String secretKey = minIoProperties.getSecretKey();
61
+        client = MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
62
+    }
63
+
64
+    /**
65
+     * 获取默认存储桶名称
66
+     *
67
+     * @author xuyuxiang
68
+     * @date 2022/6/22 18:05
69
+     **/
70
+    public static String getDefaultBucketName() {
71
+        initClient();
72
+        return minIoProperties.getBucketName();
73
+
74
+    }
75
+
76
+
77
+    /**
78
+     * 存储文件,返回外网地址
79
+     *
80
+     * @param bucketName    桶名称
81
+     * @param key           唯一标示id,例如a.txt, doc/a.txt
82
+     * @param multipartFile 文件
83
+     * @author xuyuxiang
84
+     * @date 2022/1/5 23:45
85
+     */
86
+    public static String storageFileWithReturnUrl(String bucketName, String key, MultipartFile multipartFile) {
87
+        storageFile(bucketName, key, multipartFile);
88
+        setFileAcl(bucketName, key, DevFileBucketAuthEnum.PUBLIC_READ);
89
+        return getFileAuthUrl(bucketName, key);
90
+    }
91
+
92
+
93
+    /**
94
+     * 获取文件的下载地址(永久的,文件必须为公有读),生成外网地址
95
+     *
96
+     * @param bucketName 文件桶
97
+     * @param key        唯一标示id,例如a.txt, doc/a.txt
98
+     * @author xuyuxiang
99
+     * @date 2022/1/5 23:24
100
+     */
101
+    public static String getFileAuthUrl(String bucketName, String key) {
102
+        initClient();
103
+        return minIoProperties.getEndpoint() + StrUtil.SLASH + bucketName + StrUtil.SLASH + key;
104
+
105
+    }
106
+
107
+    /**
108
+     * 存储文件,不返回地址
109
+     *
110
+     * @param bucketName    桶名称
111
+     * @param key           唯一标示id,例如a.txt, doc/a.txt
112
+     * @param multipartFile 文件
113
+     * @author xuyuxiang
114
+     * @date 2022/1/5 23:45
115
+     */
116
+    public static void storageFile(String bucketName, String key, MultipartFile multipartFile) {
117
+        InputStream inputStream = null;
118
+        try {
119
+            inputStream = multipartFile.getInputStream();
120
+        } catch (IOException e) {
121
+
122
+        }
123
+        storageFile(bucketName, key, inputStream);
124
+    }
125
+
126
+    /**
127
+     * 设置文件访问权限管理
128
+     *
129
+     * @param bucketName            桶名称
130
+     * @param key                   唯一标示id,例如a.txt, doc/a.txt
131
+     * @param devFileBucketAuthEnum 文件权限
132
+     * @author xuyuxiang
133
+     * @date 2022/1/5 23:24
134
+     */
135
+    public static void setFileAcl(String bucketName, String key, DevFileBucketAuthEnum devFileBucketAuthEnum) {
136
+        try {
137
+            JSONObject configObject = JSONUtil.createObj().set("Version", "2012-10-17");
138
+            JSONArray statementArray = JSONUtil.createArray();
139
+            JSONArray actionArray = JSONUtil.createArray();
140
+            if (devFileBucketAuthEnum.equals(DevFileBucketAuthEnum.PUBLIC_READ)) {
141
+                actionArray.put("s3:GetObject");
142
+            }
143
+            if (devFileBucketAuthEnum.equals(DevFileBucketAuthEnum.PUBLIC_READ_WRITE)) {
144
+                actionArray.put("s3:GetObject");
145
+                actionArray.put("s3:PutObject");
146
+            }
147
+            JSONObject statementObject = JSONUtil.createObj();
148
+            statementObject.set("Effect", "Allow").set("Principal", JSONUtil.createObj().set("AWS", JSONUtil.createArray().put("*")))
149
+                    .set("Action", actionArray).set("Resource", JSONUtil.createArray().put("arn:aws:s3:::" + bucketName + "/*"));
150
+            statementArray.put(statementObject);
151
+            configObject.set("Statement", statementArray);
152
+            String config = JSONUtil.toJsonStr(configObject);
153
+            SetBucketPolicyArgs setBucketPolicyArgs = SetBucketPolicyArgs.builder().bucket(bucketName).config(config).build();
154
+            client.setBucketPolicy(setBucketPolicyArgs);
155
+        } catch (Exception e) {
156
+
157
+        }
158
+    }
159
+
160
+    /**
161
+     * 存储文件,不返回地址
162
+     *
163
+     * @param bucketName  桶名称
164
+     * @param key         唯一标示id,例如a.txt, doc/a.txt
165
+     * @param inputStream 文件流
166
+     * @author xuyuxiang
167
+     * @date 2022/1/5 23:24
168
+     */
169
+    public static void storageFile(String bucketName, String key, InputStream inputStream) {
170
+        try {
171
+            initClient();
172
+            PutObjectArgs putObjectArgs = PutObjectArgs.builder().bucket(bucketName).object(key)
173
+                    .contentType(getFileContentType(key)).stream(inputStream, inputStream.available(), -1).build();
174
+            client.putObject(putObjectArgs);
175
+        } catch (Exception e) {
176
+
177
+        } finally {
178
+            IoUtil.close(inputStream);
179
+        }
180
+    }
181
+
182
+    /**
183
+     * 根据文件名获取ContentType
184
+     *
185
+     * @author xuyuxiang
186
+     * @date 2022/1/6 11:27
187
+     **/
188
+    private static String getFileContentType(String key) {
189
+        // 根据文件名获取contentType
190
+        String contentType = "application/octet-stream";
191
+        if (key.contains(".")) {
192
+            contentType = MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(key);
193
+        }
194
+        return contentType;
195
+    }
196
+
197
+}

+ 35 - 0
src/main/java/com/unis/config/MinIoProperties.java

@@ -0,0 +1,35 @@
1
+package com.unis.config;
2
+
3
+import cn.hutool.json.JSONArray;
4
+import cn.hutool.json.JSONObject;
5
+import cn.hutool.json.JSONUtil;
6
+import com.unis.enums.DevFileBucketAuthEnum;
7
+import io.minio.MinioClient;
8
+import io.minio.SetBucketPolicyArgs;
9
+import lombok.Data;
10
+import org.springframework.beans.factory.annotation.Value;
11
+import org.springframework.context.annotation.Bean;
12
+import org.springframework.context.annotation.Configuration;
13
+
14
+/**
15
+ * @author qingsong.han
16
+ * @description: minio 基础信息配置
17
+ * @create 2024-08-02 15:30
18
+ */
19
+@Data
20
+@Configuration
21
+public class MinIoProperties {
22
+
23
+    @Value("${minio.endpoint}")
24
+    private String endpoint;
25
+
26
+    @Value("${minio.access-key}")
27
+    private String accessKey;
28
+
29
+    @Value("${minio.secret-key}")
30
+    private String secretKey;
31
+
32
+    @Value("${minio.bucket-name}")
33
+    private String bucketName;
34
+
35
+}

+ 38 - 0
src/main/java/com/unis/enums/DevFileBucketAuthEnum.java

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright [2022] [https://www.xiaonuo.vip]
3
+ *
4
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
5
+ *
6
+ * 1.请不要删除和修改根目录下的LICENSE文件。
7
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
8
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
9
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
10
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
11
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
12
+ */
13
+package com.unis.enums;
14
+
15
+/**
16
+ * 文件存储桶的权限策略枚举
17
+ *
18
+ * @author xuyuxiang
19
+ * @date 2022/1/5 23:29
20
+ */
21
+public enum DevFileBucketAuthEnum {
22
+
23
+    /**
24
+     * 私有的(仅有 owner 可以读写)
25
+     */
26
+    PRIVATE,
27
+
28
+    /**
29
+     * 公有读,私有写( owner 可以读写, 其他客户可以读)
30
+     */
31
+    PUBLIC_READ,
32
+
33
+    /**
34
+     * 公共读写(即所有人都可以读写,慎用)
35
+     */
36
+    PUBLIC_READ_WRITE
37
+
38
+}

+ 43 - 0
src/main/java/com/unis/enums/DevFileEngineTypeEnum.java

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright [2022] [https://www.xiaonuo.vip]
3
+ *
4
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
5
+ *
6
+ * 1.请不要删除和修改根目录下的LICENSE文件。
7
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
8
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
9
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
10
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
11
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
12
+ */
13
+package com.unis.enums;
14
+
15
+import lombok.Getter;
16
+
17
+/**
18
+ * 文件存储引擎类型枚举
19
+ *
20
+ * @author xuyuxiang
21
+ * @date 2022/6/16 16:14
22
+ **/
23
+@Getter
24
+public enum DevFileEngineTypeEnum {
25
+
26
+    /** 本地 */
27
+    LOCAL("LOCAL"),
28
+
29
+    /** 阿里云 */
30
+    ALIYUN("ALIYUN"),
31
+
32
+    /** 腾讯云 */
33
+    TENCENT("TENCENT"),
34
+
35
+    /** MINIO */
36
+    MINIO("MINIO");
37
+
38
+    private final String value;
39
+
40
+    DevFileEngineTypeEnum(String value) {
41
+        this.value = value;
42
+    }
43
+}

+ 0 - 75
src/main/java/com/unis/face/Alarm.java

@@ -1,75 +0,0 @@
1
-package com.unis.face;
2
-
3
-import com.sun.jna.Pointer;
4
-import com.unis.common.HCNetSDK;
5
-import lombok.extern.slf4j.Slf4j;
6
-
7
-/**
8
- * 报警布防/监听功能模块:功能:报警布防/监听实时接受设备的人脸比对报警事件,回调函数中获取的报警类型(lCommand)为COMM_SNAP_MATCH_ALARM,报警信息(pAlarmInfo)对应结构体:NET_VCA_FACESNAP_MATCH_ALARM。
9
- * fSimilarity相似度大于0表示人脸比对成功,可以获取人脸库相关数据;fSimilarity相似度为0,需要通过NET_VCA_BLACKLIST_INFO结构体里面的byType类型判断,值为1表示陌生人模式,值为2表示人脸比对失败。
10
- */
11
-@Slf4j
12
-public class Alarm {
13
-
14
-    public static HCNetSDK.FMSGCallBack_V31 fMSFCallBack_V31 = null;
15
-
16
-    /**
17
-     * 报警布防 (布防和监听选其一)
18
-     *
19
-     * @param lUserID 用户登录句柄
20
-     */
21
-    public static void SetAlarm(int lUserID) {
22
-        //尚未布防,需要布防
23
-        if (FaceMain.lAlarmHandle < 0) {
24
-
25
-            //设置报警回调函数,一个程序进程只需要而且只能调用一次,对接多台设备,可以SDK初始化之后就调用该接口设置报警回调函数
26
-            if (fMSFCallBack_V31 == null) {
27
-                fMSFCallBack_V31 = new FMSGCallBack_V31();
28
-                Pointer pUser = null;
29
-                if (!FaceMain.hCNetSDK.NET_DVR_SetDVRMessageCallBack_V31(fMSFCallBack_V31, pUser)) {
30
-                    log.error("设置回调函数失败!");
31
-                } else {
32
-                    log.info("设置回调函数成功!");
33
-                }
34
-            }
35
-
36
-            //报警布防参数设置
37
-            HCNetSDK.NET_DVR_SETUPALARM_PARAM m_strAlarmInfo = new HCNetSDK.NET_DVR_SETUPALARM_PARAM();
38
-            m_strAlarmInfo.dwSize = m_strAlarmInfo.size();
39
-            m_strAlarmInfo.byLevel = 1;  //布防等级
40
-            m_strAlarmInfo.byAlarmInfoType = 1;   // 智能交通报警信息上传类型:0- 老报警信息(NET_DVR_PLATE_RESULT),1- 新报警信息(NET_ITS_PLATE_RESULT)
41
-            m_strAlarmInfo.byDeployType = 1;   //布防类型 0:客户端布防 1:实时布防
42
-            m_strAlarmInfo.write();
43
-            FaceMain.lAlarmHandle = FaceMain.hCNetSDK.NET_DVR_SetupAlarmChan_V41(lUserID, m_strAlarmInfo);
44
-            log.info("lAlarmHandle: {}", FaceMain.lAlarmHandle);
45
-            if (FaceMain.lAlarmHandle == -1) {
46
-                log.error("布防失败,错误码为: {}", FaceMain.hCNetSDK.NET_DVR_GetLastError());
47
-            } else {
48
-                log.info("布防成功");
49
-            }
50
-        }
51
-    }
52
-
53
-    /**
54
-     * 报警监听
55
-     * <p>
56
-     * 注意: 设置监听前需要现在本机pc配置端口
57
-     * 具体步骤:库文件ClientDemo->登录设备->配置->网络参数配置->配置告警管理主机地址、告警管理主机端口(需要与NET_DVR_StartListen_V30接口中对应)
58
-     */
59
-    public void StartListen() {
60
-        if (fMSFCallBack_V31 == null) {
61
-            fMSFCallBack_V31 = new FMSGCallBack_V31();
62
-        }
63
-        /**
64
-         * 这里NET_DVR_StartListen_V30接口中的ip和端口需要和配置的ip和端口对应
65
-         * NET_DVR_StartListen_V30中传入的IP和端口是服务器或者测试PC的IP地址和端口,不是设备的IP和端口!!!
66
-         */
67
-        FaceMain.lListenHandle = FaceMain.hCNetSDK.NET_DVR_StartListen_V30("10.17.36.14", (short) 7201, fMSFCallBack_V31, null);
68
-        if (FaceMain.lListenHandle == -1) {
69
-            log.error("监听失败: {}", FaceMain.hCNetSDK.NET_DVR_GetLastError());
70
-        } else {
71
-            log.info("监听成功");
72
-        }
73
-    }
74
-
75
-}

+ 0 - 215
src/main/java/com/unis/face/FMSGCallBack_V31.java

@@ -1,215 +0,0 @@
1
-package com.unis.face;
2
-
3
-import com.alibaba.fastjson.JSON;
4
-import com.sun.jna.Pointer;
5
-import com.unis.common.HCNetSDK;
6
-/*import com.unissoft.pushMsg.AlarmDSService;
7
-import com.unissoft.pushMsg.AlarmDSServiceImpl;*/
8
-import com.unis.common.NetDVRAlarmerConvert;
9
-import com.unis.utils.BinaryConversionUtil;
10
-import com.unis.video.VideoMok;
11
-import lombok.extern.slf4j.Slf4j;
12
-import org.springframework.beans.BeanUtils;
13
-
14
-import java.io.FileOutputStream;
15
-import java.io.IOException;
16
-import java.nio.ByteBuffer;
17
-import java.text.SimpleDateFormat;
18
-import java.util.Date;
19
-
20
-/**
21
- * 人脸比对报警接收回调函数
22
- */
23
-@Slf4j
24
-public class FMSGCallBack_V31 implements HCNetSDK.FMSGCallBack_V31 {
25
-    // this class call jna native callback,so is not spring manage class
26
-    /*private AlarmDSService alarmDSService = new AlarmDSServiceImpl();*/
27
-    //相机一般只有一个通道号,热成像相机有2个通道号,通道号为1或1,2
28
-    static int iChannelNo = 1;
29
-
30
-    //报警信息回调函数
31
-    public boolean invoke(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) {
32
-        AlarmDataHandle(lCommand, pAlarmer, pAlarmInfo, dwBufLen, pUser);
33
-        return true;
34
-    }
35
-
36
-    public void AlarmDataHandle(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) {
37
-        log.info("报警事件发生,进入回调");
38
-        log.info("lCommand: {}", lCommand);
39
-        log.info("pAlarmer: {}", JSON.toJSONString(pAlarmer));
40
-        log.info("pAlarmInfo: {}", JSON.toJSONString(pAlarmInfo));
41
-        log.info("dwBufLen: {}", dwBufLen);
42
-        log.info("pUser: {}", JSON.toJSONString(pUser));
43
-        /*log.info(
44
-                "lCommand {} -> pAlarmer {} -> pAlarmInfo {} -> dwBufLen {} -> pUser {}",
45
-                lCommand, JSON.toJSONString(pAlarmer), JSON.toJSONString(pAlarmInfo),dwBufLen,JSON.toJSONString(pUser)
46
-        );*/
47
-        // bye封装对象转换
48
-        NetDVRAlarmerConvert convert = new NetDVRAlarmerConvert();
49
-        BeanUtils.copyProperties(pAlarmer, convert);
50
-
51
-        // byMacAddr
52
-        convert.setByMacAddr(new String(pAlarmer.getByMacAddr()));
53
-        // byRes2
54
-        convert.setByRes2(new String(pAlarmer.getByRes2()));
55
-        // sDeviceIP
56
-        convert.setSDeviceIP(new String(pAlarmer.getSDeviceIP()));
57
-        // sDeviceName
58
-        convert.setSDeviceName(new String(pAlarmer.getSDeviceName()));
59
-        // sSerialNumber
60
-        convert.setSSerialNumber(new String(pAlarmer.getSSerialNumber()));
61
-        // sSocketIP
62
-        convert.setSSocketIP(new String(pAlarmer.getSSocketIP()));
63
-        log.info("convert: {}", convert);
64
-
65
-        // 抓图
66
-        VideoMok.RealPlay(convert.getLUserID(), iChannelNo);
67
-        VideoMok.getPicbyPlayCtrl();
68
-
69
-        /*String hexString = Integer.toHexString(lCommand);
70
-        log.info("报警类型 hexString {}", hexString);*/
71
-        switch (lCommand) {
72
-            case HCNetSDK.COMM_ALARM_RULE://行为分析信息上传
73
-                HCNetSDK.NET_VCA_RULE_ALARM ruleAlarm = new HCNetSDK.NET_VCA_RULE_ALARM();
74
-                ruleAlarm.write();
75
-                Pointer ruleAlarmPointer = ruleAlarm.getPointer();
76
-                ruleAlarmPointer.write(0, pAlarmInfo.getByteArray(0, ruleAlarm.size()), 0, ruleAlarm.size());
77
-                ruleAlarm.read();
78
-                log.info("Alarm type in the NET_VCA_RULE_ALARM ---------->: {}", JSON.toJSONString(ruleAlarm));
79
-//                alarmDSService.pushLCommand(lCommand);
80
-                break;
81
-            case HCNetSDK.COMM_SNAP_MATCH_ALARM:
82
-                //人脸黑名单比对报警
83
-                log.info("SNAP_MATCH_ALARM");
84
-                HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM strFaceSnapMatch = new HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM();
85
-                strFaceSnapMatch.write();
86
-                Pointer pFaceSnapMatch = strFaceSnapMatch.getPointer();
87
-                pFaceSnapMatch.write(0, pAlarmInfo.getByteArray(0, strFaceSnapMatch.size()), 0, strFaceSnapMatch.size());
88
-                strFaceSnapMatch.read();
89
-                //比对结果
90
-                log.info("比对结果: {}", strFaceSnapMatch.byContrastStatus == 1 ? "比对成功" : "比对失败");
91
-                //人脸库ID
92
-                if (strFaceSnapMatch.struBlockListInfo.dwFDIDLen > 0) {
93
-                    long offset1 = 0;
94
-                    ByteBuffer buffers1 = strFaceSnapMatch.struBlockListInfo.pFDID.getByteBuffer(offset1, strFaceSnapMatch.struBlockListInfo.dwFDIDLen);
95
-                    byte[] bytes1 = new byte[strFaceSnapMatch.struBlockListInfo.dwFDIDLen];
96
-                    buffers1.get(bytes1);
97
-                    log.info("人脸库ID: {}", new String(bytes1));
98
-                }
99
-                //人脸库图片ID
100
-                if (strFaceSnapMatch.struBlockListInfo.dwPIDLen > 0) {
101
-                    long offset2 = 0;
102
-                    ByteBuffer buffers2 = strFaceSnapMatch.struBlockListInfo.pPID.getByteBuffer(offset2, strFaceSnapMatch.struBlockListInfo.dwPIDLen);
103
-                    byte[] bytes2 = new byte[strFaceSnapMatch.struBlockListInfo.dwPIDLen];
104
-                    buffers2.get(bytes2);
105
-                    log.info("图片ID: {}", new String(bytes2));
106
-                }
107
-                //保存抓拍人脸图,图片数据传输方式: 0- 二进制
108
-                if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) {
109
-                    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
110
-                    String newName = sf.format(new Date());
111
-                    FileOutputStream fout;
112
-                    try {
113
-                        String filename = ".//pic//" + newName + "_pSnapPicBuffer" + ".jpg";
114
-                        fout = new FileOutputStream(filename);
115
-                        //将字节写入文件
116
-                        long offset = 0;
117
-                        ByteBuffer buffers = strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(offset, strFaceSnapMatch.dwSnapPicLen);
118
-                        byte[] bytes = new byte[strFaceSnapMatch.dwSnapPicLen];
119
-                        buffers.rewind();
120
-                        buffers.get(bytes);
121
-                        fout.write(bytes);
122
-                        fout.close();
123
-                    } catch (IOException e) {
124
-                        // TODO Auto-generated catch block
125
-                        e.printStackTrace();
126
-                    }
127
-                }
128
-                //保存抓拍人脸图URL,图片数据传输方式: 1- URL 注:超脑设备人脸比对报警图片一般按照URL上传,根据URL去下载设备中存储的图片,认证方式选择:摘要认证
129
-                if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) {
130
-                    long offset = 0;
131
-                    ByteBuffer buffers = strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(offset, strFaceSnapMatch.dwSnapPicLen);
132
-                    byte[] bytes = new byte[strFaceSnapMatch.dwSnapPicLen];
133
-                    buffers.rewind();
134
-                    buffers.get(bytes);
135
-                    log.info("人脸抓拍图片 URL: {}", new String(bytes));
136
-                }
137
-                if ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) {
138
-                    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
139
-                    String newName = sf.format(new Date());
140
-                    FileOutputStream fout;
141
-                    try {
142
-                        String filename = ".//pic//" + newName + "_struSnapInfo_pBuffer1" + ".jpg";
143
-                        fout = new FileOutputStream(filename);
144
-                        //将字节写入文件
145
-                        long offset = 0;
146
-                        ByteBuffer buffers = strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen);
147
-                        byte[] bytes = new byte[strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen];
148
-                        buffers.rewind();
149
-                        buffers.get(bytes);
150
-                        fout.write(bytes);
151
-                        fout.close();
152
-                    } catch (IOException e) {
153
-                        // TODO Auto-generated catch block
154
-                        e.printStackTrace();
155
-                    }
156
-                }
157
-                if ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) {
158
-                    long offset = 0;
159
-                    ByteBuffer buffers = strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen);
160
-                    byte[] bytes = new byte[strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen];
161
-                    buffers.rewind();
162
-                    buffers.get(bytes);
163
-                    log.info("人脸抓拍图片1 URL: {}", new String(bytes));
164
-                }
165
-                //保存人脸库图片,图片数据传输方式: 0- 二进制
166
-                if ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) {
167
-                    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
168
-                    String newName = sf.format(new Date());
169
-                    FileOutputStream fout;
170
-                    try {
171
-                        String filename = ".//pic//" + newName + "_fSimilarity_" + strFaceSnapMatch.fSimilarity + "_struBlackListInfo_pBuffer1" + ".jpg";
172
-                        fout = new FileOutputStream(filename);
173
-                        //将字节写入文件
174
-                        long offset = 0;
175
-                        ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen);
176
-                        byte[] bytes = new byte[strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen];
177
-                        buffers.rewind();
178
-                        buffers.get(bytes);
179
-                        fout.write(bytes);
180
-                        fout.close();
181
-                    } catch (IOException e) {
182
-                        // TODO Auto-generated catch block
183
-                        e.printStackTrace();
184
-                    }
185
-                }
186
-                //保存人脸库图片,图片数据传输方式: 1-URL
187
-                if ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) {
188
-                    long offset = 0;
189
-                    ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen);
190
-                    byte[] bytes = new byte[strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen];
191
-                    buffers.rewind();
192
-                    buffers.get(bytes);
193
-                    log.info("人脸库图片 URL: {}", new String(bytes));
194
-                }
195
-                //抓拍库附加信息数据指针,附加信息的XML文本中包含人脸温度数据
196
-                if (strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen > 0) {
197
-                    long offset = 0;
198
-                    ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.struBlockListInfo.pFCAdditionInfoBuffer.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen);
199
-                    byte[] bytes = new byte[strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen];
200
-                    buffers.rewind();
201
-                    buffers.get(bytes);
202
-                    log.info("抓拍库附加信息: {}", new String(bytes));
203
-                }
204
-//                alarmDSService.pushLCommand(lCommand);
205
-                break;
206
-            default:
207
-                // TODO 单报警设备 目前不需要 sAlarmType alarmNow
208
-                log.info("Alarm type in the FMSGCallBack_V31 ->int: {}", lCommand);
209
-                log.info("Alarm type in the FMSGCallBack_V31 ->HEX: {}", BinaryConversionUtil.toHex(lCommand));
210
-//                alarmDSService.pushLCommand(lCommand);
211
-                break;
212
-        }
213
-    }
214
-
215
-}

+ 0 - 187
src/main/java/com/unis/face/FaceMain.java

@@ -1,187 +0,0 @@
1
-package com.unis.face;
2
-
3
-import com.sun.jna.Native;
4
-import com.unis.common.HCNetSDK;
5
-import com.unis.common.osSelect;
6
-import com.unis.config.AddressModel;
7
-import lombok.extern.slf4j.Slf4j;
8
-import org.springframework.boot.ApplicationArguments;
9
-import org.springframework.boot.ApplicationRunner;
10
-import org.springframework.core.annotation.Order;
11
-import org.springframework.stereotype.Component;
12
-
13
-import javax.annotation.Resource;
14
-import java.io.BufferedReader;
15
-import java.io.IOException;
16
-import java.io.InputStreamReader;
17
-
18
-/**
19
- * @author qingsong.han
20
- * @description:
21
- * @create 2024-07-31 9:29
22
- */
23
-@Slf4j
24
-// 启动加载注解
25
-//@Component
26
-@Order(1)
27
-public class FaceMain implements ApplicationRunner {
28
-
29
-    static HCNetSDK hCNetSDK = null;
30
-    static int lUserID = -1;//用户句柄
31
-    static int lAlarmHandle = -1; //布防句柄
32
-    static int lListenHandle = -1; //监听句柄
33
-
34
-    // 设备连接信息
35
-    @Resource
36
-    private AddressModel addressModel;
37
-
38
-    /*
39
-     * 获取配置
40
-     */
41
-    private void mainMethod() {
42
-        log.info("FaceMain mainMethod===========================================================init thread");
43
-        try {
44
-            if (hCNetSDK == null) {
45
-                if (!CreateSDKInstance()) {
46
-                    log.error("Load SDK fail");
47
-                    return;
48
-                }
49
-            }
50
-            //linux系统建议调用以下接口加载组件库
51
-            if (osSelect.isLinux()) {
52
-                HCNetSDK.BYTE_ARRAY ptrByteArray1 = new HCNetSDK.BYTE_ARRAY(256);
53
-                HCNetSDK.BYTE_ARRAY ptrByteArray2 = new HCNetSDK.BYTE_ARRAY(256);
54
-                //这里是库的绝对路径,请根据实际情况修改,注意改路径必须有访问权限
55
-                String strPath1 = System.getProperty("user.dir") + "/lib/libcrypto.so.1.1";
56
-                String strPath2 = System.getProperty("user.dir") + "/lib/libssl.so.1.1";
57
-
58
-                System.arraycopy(strPath1.getBytes(), 0, ptrByteArray1.byValue, 0, strPath1.length());
59
-                ptrByteArray1.write();
60
-                hCNetSDK.NET_DVR_SetSDKInitCfg(3, ptrByteArray1.getPointer());
61
-
62
-                System.arraycopy(strPath2.getBytes(), 0, ptrByteArray2.byValue, 0, strPath2.length());
63
-                ptrByteArray2.write();
64
-                hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArray2.getPointer());
65
-
66
-                String strPathCom = System.getProperty("user.dir") + "/lib";
67
-                HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH();
68
-                System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length());
69
-                struComPath.write();
70
-                hCNetSDK.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer());
71
-            }
72
-
73
-            //初始化
74
-            hCNetSDK.NET_DVR_Init();
75
-
76
-            //加载日志
77
-            hCNetSDK.NET_DVR_SetLogToFile(3, "..//sdklog", false);
78
-
79
-            //登录设备,每一台设备分别登录; 登录句柄是唯一的,可以区分设备
80
-            HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
81
-            HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
82
-
83
-            String m_sDeviceIP = addressModel.getDeviceIP();//设备ip地址
84
-            m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
85
-            System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
86
-
87
-            String m_sUsername = addressModel.getUserName();//设备用户名
88
-            m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
89
-            System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
90
-
91
-            String m_sPassword = addressModel.getPassword();//设备密码
92
-            m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
93
-            System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
94
-
95
-            m_strLoginInfo.wPort = 8000;
96
-            m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
97
-            m_strLoginInfo.byLoginMode = 0;  //登录模式:0- SDK私有协议,1- ISAPI协议
98
-            m_strLoginInfo.write();
99
-
100
-            lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
101
-            if (lUserID == -1) {
102
-                log.error("登录失败,错误码为: {}", hCNetSDK.NET_DVR_GetLastError());
103
-            } else {
104
-                log.info("{} 设备登录成功!设备序列号: {}", m_sDeviceIP, new String(m_strDeviceInfo.struDeviceV30.sSerialNumber).trim());
105
-                m_strDeviceInfo.read();
106
-            }
107
-
108
-            //报警布防实时接收人脸比对的结果信息,也可以单独参考“2-报警布防监听”这个Demo示例
109
-            Alarm.SetAlarm(lUserID);
110
-
111
-            // TODO 暂停状态 需要测试改造
112
-            while (true) {
113
-                //这里加入控制台输入控制,是为了保持连接状态,当输入Y表示布防结束
114
-                log.info("请选择是否撤出布防(Y/N):");
115
-                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
116
-                String str = bufferedReader.readLine();
117
-                if (str.toUpperCase().equals("Y")) {
118
-                    break;
119
-                }
120
-            }
121
-            Thread.sleep(3000);
122
-
123
-            //退出之前判断布防监听状态,并做撤防和停止监听操作
124
-            if (lAlarmHandle >= 0) {
125
-                if (!hCNetSDK.NET_DVR_CloseAlarmChan_V30(lAlarmHandle)) {
126
-                    log.error("撤防失败,错误码: {}", hCNetSDK.NET_DVR_GetLastError());
127
-                } else {
128
-                    log.info("撤防成功!!!");
129
-                }
130
-            }
131
-            if (lListenHandle >= 0) {
132
-                if (!hCNetSDK.NET_DVR_StopListen_V30(lListenHandle)) {
133
-                    log.error("取消监听失败,错误码:{}", hCNetSDK.NET_DVR_GetLastError());
134
-                } else {
135
-                    log.info("停止监听成功!!!");
136
-                }
137
-            }
138
-
139
-            //注销登录,程序退出时调用;程序同时对接多台设备时,每一台设备分别调用一次接口,传入不同的登录句柄
140
-            if (lUserID >= 0) {
141
-                hCNetSDK.NET_DVR_Logout(lUserID);
142
-            }
143
-
144
-            //SDK反初始化,释放资源,程序退出时调用
145
-            boolean b = hCNetSDK.NET_DVR_Cleanup();
146
-            if (b)
147
-                log.info("释放资源,程序退出!");
148
-        } catch (InterruptedException e) {
149
-            e.printStackTrace();
150
-        } catch (IOException e) {
151
-            e.printStackTrace();
152
-        }
153
-    }
154
-
155
-    /**
156
-     * 根据不同操作系统选择不同的库文件和库路径
157
-     *
158
-     * @return
159
-     */
160
-    private boolean CreateSDKInstance() {
161
-        if (hCNetSDK == null) {
162
-            synchronized (HCNetSDK.class) {
163
-                String strDllPath = "";
164
-                try {
165
-//                    System.setProperty("jna.debug_load", "true");
166
-                    if (osSelect.isWindows())
167
-                        //win系统加载库路径
168
-                        strDllPath = System.getProperty("user.dir") + "\\lib\\HCNetSDK.dll";
169
-                    else if (osSelect.isLinux())
170
-                        //Linux系统加载库路径
171
-                        strDllPath = System.getProperty("user.dir") + "/lib/libhcnetsdk.so";
172
-                    hCNetSDK = (HCNetSDK) Native.loadLibrary(strDllPath, HCNetSDK.class);
173
-                } catch (Exception ex) {
174
-                    log.error("loadLibrary: {} Error: {}", strDllPath, ex.getMessage());
175
-                    return false;
176
-                }
177
-            }
178
-        }
179
-        return true;
180
-    }
181
-
182
-    @Override
183
-    public void run(ApplicationArguments args) throws Exception {
184
-        // after behind for application run,because implements ApplicationRunner
185
-        this.mainMethod();
186
-    }
187
-}

+ 90 - 0
src/main/java/com/unis/fileUpload/DevFileService.java

@@ -0,0 +1,90 @@
1
+/*
2
+ * Copyright [2022] [https://www.xiaonuo.vip]
3
+ *
4
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
5
+ *
6
+ * 1.请不要删除和修改根目录下的LICENSE文件。
7
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
8
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
9
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
10
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
11
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
12
+ */
13
+package com.unis.fileUpload;
14
+
15
+import cn.hutool.core.convert.Convert;
16
+import cn.hutool.core.date.DateUtil;
17
+import cn.hutool.core.img.ImgUtil;
18
+import cn.hutool.core.io.FileUtil;
19
+import cn.hutool.core.util.NumberUtil;
20
+import cn.hutool.core.util.ObjectUtil;
21
+import cn.hutool.core.util.StrUtil;
22
+import com.unis.config.DevFileMinIoUtil;
23
+import com.unis.enums.DevFileEngineTypeEnum;
24
+import org.springframework.stereotype.Service;
25
+import org.springframework.web.multipart.MultipartFile;
26
+
27
+import java.math.BigDecimal;
28
+import java.util.UUID;
29
+
30
+
31
+/**
32
+ * 文件Service接口
33
+ *
34
+ * @author xuyuxiang
35
+ * @date 2022/2/23 18:27
36
+ **/
37
+public interface DevFileService {
38
+
39
+    /**
40
+     * MultipartFile文件上传,返回文件Url
41
+     *
42
+     * @author xuyuxiang
43
+     * @date 2022/4/22 15:53
44
+     **/
45
+    String uploadReturnUrl(MultipartFile file);
46
+
47
+    @Service
48
+    class DevFileServiceImpl implements DevFileService {
49
+
50
+        @Override
51
+        public String uploadReturnUrl(MultipartFile file) {
52
+            return this.storageFile(file);
53
+        }
54
+
55
+        /**
56
+         * 存储文件
57
+         *
58
+         * @author xuyuxiang
59
+         * @date 2022/6/16 16:24
60
+         **/
61
+        private String storageFile(MultipartFile file) {
62
+            // 生成id
63
+            String fileId = UUID.randomUUID().toString();
64
+            return DevFileMinIoUtil.storageFileWithReturnUrl(DevFileMinIoUtil.getDefaultBucketName(), genFileKey(fileId, file), file);
65
+        }
66
+
67
+        @SuppressWarnings("all")
68
+        public String genFileKey(String fileId, MultipartFile file) {
69
+
70
+            // 获取文件原始名称
71
+            String originalFileName = file.getOriginalFilename();
72
+
73
+            // 获取文件后缀
74
+            String fileSuffix = FileUtil.getSuffix(originalFileName);
75
+
76
+            // 生成文件的对象名称,格式如:1377109572375810050.docx
77
+            String fileObjectName = fileId + StrUtil.DOT + fileSuffix;
78
+
79
+            // 获取日期文件夹,格式如,2021/10/11/
80
+            String dateFolderPath = DateUtil.thisYear() + StrUtil.SLASH +
81
+                    (DateUtil.thisMonth() + 1) + StrUtil.SLASH +
82
+                    DateUtil.thisDayOfMonth() + StrUtil.SLASH;
83
+
84
+            // 返回
85
+            return dateFolderPath + fileObjectName;
86
+        }
87
+
88
+    }
89
+
90
+}

+ 54 - 0
src/main/java/com/unis/test/DevFileController.java

@@ -0,0 +1,54 @@
1
+/*
2
+ * Copyright [2022] [https://www.xiaonuo.vip]
3
+ *
4
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
5
+ *
6
+ * 1.请不要删除和修改根目录下的LICENSE文件。
7
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
8
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
9
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
10
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
11
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
12
+ */
13
+package com.unis.test;
14
+
15
+import com.unis.enums.DevFileEngineTypeEnum;
16
+import com.unis.fileUpload.DevFileService;
17
+import org.springframework.web.bind.annotation.PostMapping;
18
+import org.springframework.web.bind.annotation.RequestMapping;
19
+import org.springframework.web.bind.annotation.RequestPart;
20
+import org.springframework.web.bind.annotation.RestController;
21
+import org.springframework.web.multipart.MultipartFile;
22
+
23
+import javax.annotation.Resource;
24
+
25
+
26
+/**
27
+ * 文件控制器
28
+ *
29
+ * @author xuyuxiang
30
+ * @date 2022/2/23 18:26
31
+ **/
32
+@RestController
33
+@RequestMapping("/file")
34
+public class DevFileController {
35
+
36
+    @Resource
37
+    private DevFileService devFileService;
38
+
39
+
40
+    /**
41
+     * MINIO文件上传,返回文件Url
42
+     *
43
+     * @author xuyuxiang
44
+     * @date 2021/10/13 14:01
45
+     **/
46
+    // 上传MINIO文件返回url
47
+    @PostMapping("/uploadMinIoReturnUrl")
48
+    public String uploadMinIoReturnUrl(@RequestPart("file") MultipartFile file) {
49
+        return devFileService.uploadReturnUrl(file);
50
+    }
51
+
52
+
53
+
54
+}

+ 0 - 213
src/main/java/com/unis/video/Clinet.java

@@ -1,213 +0,0 @@
1
-package com.unis.video;
2
-
3
-import com.sun.jna.Native;
4
-import com.sun.jna.Pointer;
5
-import com.unis.common.HCNetSDK;
6
-import com.unis.common.osSelect;
7
-
8
-import java.util.Timer;
9
-
10
-/**
11
- * @author qingsong.han
12
- * @description:
13
- * @create 2024-08-01 10:35
14
- */
15
-public class Clinet {
16
-    int iErr = 0;
17
-    static HCNetSDK hCNetSDK = null;
18
-    static PlayCtrl playControl = null;
19
-    static int lUserID = 0;//用户句柄
20
-    static int lAlarmHandle = -1;//报警布防句柄
21
-    static int lListenHandle = -1;//报警监听句柄
22
-
23
-    static boolean bSaveHandle = false;
24
-    Timer Playbacktimer;//回放用定时器
25
-
26
-    static FExceptionCallBack_Imp fExceptionCallBack;
27
-    static int FlowHandle;
28
-
29
-    static class FExceptionCallBack_Imp implements HCNetSDK.FExceptionCallBack {
30
-        public void invoke(int dwType, int lUserID, int lHandle, Pointer pUser) {
31
-            System.out.println("异常事件类型:" + dwType);
32
-            return;
33
-        }
34
-    }
35
-
36
-    public static void main(String[] args) throws InterruptedException {
37
-
38
-        if (hCNetSDK == null && playControl == null) {
39
-            if (!CreateSDKInstance()) {
40
-                System.out.println("Load SDK fail");
41
-                return;
42
-            }
43
-            if (!CreatePlayInstance()) {
44
-                System.out.println("Load PlayCtrl fail");
45
-                return;
46
-            }
47
-        }
48
-        //linux系统建议调用以下接口加载组件库
49
-        if (osSelect.isLinux()) {
50
-            HCNetSDK.BYTE_ARRAY ptrByteArray1 = new HCNetSDK.BYTE_ARRAY(256);
51
-            HCNetSDK.BYTE_ARRAY ptrByteArray2 = new HCNetSDK.BYTE_ARRAY(256);
52
-            //这里是库的绝对路径,请根据实际情况修改,注意改路径必须有访问权限
53
-            /*String strPath1 = "/home/hik/LinuxSDK/libcrypto.so.1.1";
54
-            String strPath2 = "/home/hik/LinuxSDK/libssl.so.1.1";*/
55
-            String strPath1 = System.getProperty("user.dir") + "\\lib\\libcrypto.so.1.1";
56
-            String strPath2 = System.getProperty("user.dir") + "\\lib\\libssl.so.1.1";
57
-
58
-            System.arraycopy(strPath1.getBytes(), 0, ptrByteArray1.byValue, 0, strPath1.length());
59
-            ptrByteArray1.write();
60
-            hCNetSDK.NET_DVR_SetSDKInitCfg(3, ptrByteArray1.getPointer());
61
-
62
-            System.arraycopy(strPath2.getBytes(), 0, ptrByteArray2.byValue, 0, strPath2.length());
63
-            ptrByteArray2.write();
64
-            hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArray2.getPointer());
65
-
66
-            String strPathCom = System.getProperty("user.dir") + "\\lib\\";
67
-            HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH();
68
-            System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length());
69
-            struComPath.write();
70
-            hCNetSDK.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer());
71
-        }
72
-
73
-        //SDK初始化,一个程序只需要调用一次
74
-        boolean initSuc = hCNetSDK.NET_DVR_Init();
75
-
76
-        if (initSuc != true) {
77
-            System.out.println("初始化失败");
78
-        }
79
-
80
-        //异常消息回调
81
-        if (fExceptionCallBack == null) {
82
-            fExceptionCallBack = new FExceptionCallBack_Imp();
83
-        }
84
-
85
-        Pointer pUser = null;
86
-        if (!hCNetSDK.NET_DVR_SetExceptionCallBack_V30(0, 0, fExceptionCallBack, pUser)) {
87
-            return;
88
-        }
89
-        System.out.println("设置异常消息回调成功");
90
-
91
-        //启动SDK写日志
92
-        hCNetSDK.NET_DVR_SetLogToFile(3, "..\\sdkLog\\", false);
93
-
94
-        //登录设备,每一台设备分别登录; 登录句柄是唯一的,可以区分设备
95
-        HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
96
-        HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
97
-
98
-        String m_sDeviceIP = "10.7.11.161";//设备ip地址
99
-        m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
100
-        System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
101
-
102
-        String m_sUsername = "admin";//设备用户名
103
-        m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
104
-        System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
105
-
106
-        String m_sPassword = "Aa870618";//设备密码
107
-        m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
108
-        System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
109
-
110
-        m_strLoginInfo.wPort = 8000; //SDK端口
111
-        m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
112
-        m_strLoginInfo.write();
113
-
114
-        lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
115
-        if (lUserID == -1) {
116
-            System.out.println("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
117
-        } else {
118
-            System.out.println(m_sDeviceIP + ":设备登录成功! " + "设备序列号:" + new String(m_strDeviceInfo.struDeviceV30.sSerialNumber).trim());
119
-            m_strDeviceInfo.read();
120
-        }
121
-        //相机一般只有一个通道号,热成像相机有2个通道号,通道号为1或1,2
122
-        int lDChannel = 1;
123
-        //byStartDChan为IP通道起始通道号, 预览回放NVR的IP通道时需要根据起始通道号进行取值
124
-        if ((int) m_strDeviceInfo.struDeviceV30.byStartDChan == 1 && (int) m_strDeviceInfo.struDeviceV30.byStartDChan == 33) {
125
-            //byStartDChan为IP通道起始通道号, 预览回放NVR的IP通道时需要根据起始通道号进行取值,NVR起始通道号一般是33或者1开始
126
-            lDChannel = (int) m_strDeviceInfo.struDeviceV30.byStartDChan;
127
-        }
128
-        System.out.println("预览通道号: " + lDChannel);
129
-
130
-        //注释掉的代码也可以参考,去掉注释可以运行
131
-        //VideoDemo.getIPChannelInfo(lUserID); //获取IP通道
132
-
133
-//        VideoDemo.RealPlay(lUserID,lDChannel);
134
-
135
-        //按时间回放和下载
136
-        new VideoMok().PlayBackBytime(lUserID);
137
-//        new VideoDemo().DowmloadRecordByTime(lUserID); //按时间下载录像
138
-        //按时间回放和下载录像,需要等待回放和下载完成后调用注销和释放接口
139
-/*        while (true)
140
-        {
141
-
142
-        }*/
143
-
144
-        //按录像文件回放和下载
145
-//        VideoDemo.DownloadRecordByFile(lUserID, 1);//录像文件查找下载
146
-//        VideoDemo.playBackByfile(lUserID);
147
-        Thread.sleep(3000);
148
-
149
-        //退出程序时调用,每一台设备分别注销
150
-        if (hCNetSDK.NET_DVR_Logout(lUserID)) {
151
-            System.out.println("注销成功");
152
-        }
153
-
154
-        //SDK反初始化,释放资源,只需要退出时调用一次
155
-        hCNetSDK.NET_DVR_Cleanup();
156
-        return;
157
-
158
-    }
159
-
160
-    /**
161
-     * 动态库加载
162
-     *
163
-     * @return
164
-     */
165
-    private static boolean CreateSDKInstance() {
166
-        if (hCNetSDK == null) {
167
-            synchronized (HCNetSDK.class) {
168
-                String strDllPath = "";
169
-                try {
170
-                    if (osSelect.isWindows())
171
-                        //win系统加载库路径
172
-                        strDllPath = System.getProperty("user.dir") + "\\lib\\HCNetSDK.dll";
173
-
174
-                    else if (osSelect.isLinux())
175
-                        //Linux系统加载库路径
176
-                        strDllPath = "/home/hik/LinuxSDK/libhcnetsdk.so";
177
-                    hCNetSDK = (HCNetSDK) Native.loadLibrary(strDllPath, HCNetSDK.class);
178
-                } catch (Exception ex) {
179
-                    System.out.println("loadLibrary: " + strDllPath + " Error: " + ex.getMessage());
180
-                    return false;
181
-                }
182
-            }
183
-        }
184
-        return true;
185
-    }
186
-
187
-    /**
188
-     * 播放库加载
189
-     *
190
-     * @return
191
-     */
192
-    private static boolean CreatePlayInstance() {
193
-        if (playControl == null) {
194
-            synchronized (PlayCtrl.class) {
195
-                String strPlayPath = "";
196
-                try {
197
-                    if (osSelect.isWindows())
198
-                        //win系统加载库路径
199
-                        strPlayPath = System.getProperty("user.dir") + "\\lib\\PlayCtrl.dll";
200
-                    else if (osSelect.isLinux())
201
-                        //Linux系统加载库路径
202
-                        strPlayPath = "/home/hik/LinuxSDK/libPlayCtrl.so";
203
-                    playControl = (PlayCtrl) Native.loadLibrary(strPlayPath, PlayCtrl.class);
204
-
205
-                } catch (Exception ex) {
206
-                    System.out.println("loadLibrary: " + strPlayPath + " Error: " + ex.getMessage());
207
-                    return false;
208
-                }
209
-            }
210
-        }
211
-        return true;
212
-    }
213
-}

+ 0 - 59
src/main/java/com/unis/video/PlayCtrl.java

@@ -1,59 +0,0 @@
1
-package com.unis.video;
2
-
3
-import com.sun.jna.Callback;
4
-import com.sun.jna.Library;
5
-import com.sun.jna.Pointer;
6
-import com.sun.jna.Structure;
7
-import com.sun.jna.examples.win32.W32API;
8
-import com.sun.jna.ptr.ByteByReference;
9
-import com.sun.jna.ptr.IntByReference;
10
-
11
-/**
12
- * @author qingsong.han
13
- * @description:
14
- * @create 2024-08-01 10:44
15
- */
16
-//播放库函数声明,PlayCtrl.dll
17
-public interface PlayCtrl extends Library {
18
-
19
-    public static final int STREAME_REALTIME = 0;
20
-    public static final int STREAME_FILE = 1;
21
-
22
-    boolean PlayM4_GetPort(IntByReference nPort);
23
-
24
-    boolean PlayM4_OpenStream(int nPort, ByteByReference pFileHeadBuf, int nSize, int nBufPoolSize);
25
-
26
-    boolean PlayM4_InputData(int nPort, ByteByReference pBuf, int nSize);
27
-
28
-    boolean PlayM4_CloseStream(int nPort);
29
-
30
-    boolean PlayM4_SetStreamOpenMode(int nPort, int nMode);
31
-
32
-    boolean PlayM4_Play(int nPort, W32API.HWND hWnd);
33
-
34
-    boolean PlayM4_Stop(int nPort);
35
-
36
-    boolean PlayM4_SetSecretKey(int nPort, int lKeyType, String pSecretKey, int lKeyLen);
37
-
38
-    boolean PlayM4_GetPictureSize(int nPort, IntByReference pWidth, IntByReference pHeight);
39
-
40
-    boolean PlayM4_GetJPEG(int nPort, Pointer pBitmap, int nBufSize, IntByReference pBmpSize);
41
-
42
-    int PlayM4_GetLastError(int nPort);
43
-
44
-    boolean PlayM4_SetDecCallBackExMend(int nPort, DecCallBack decCBFun, Pointer pDest, int nDestSize, int nUser);
45
-
46
-    public static interface DecCallBack extends Callback {
47
-        void invoke(int nPort, Pointer pBuf, int nSize, FRAME_INFO pFrameInfo, int nReserved1, int nReserved2);
48
-    }
49
-
50
-    public class FRAME_INFO extends Structure {
51
-        public int nWidth;                   /* 画面宽,单位像素。如果是音频数据,则为音频声道数 */
52
-        public int nHeight;                     /* 画面高,单位像素。如果是音频数据,则为样位率 */
53
-        public int nStamp;                           /* 时标信息,单位毫秒 */
54
-        public int nType;                            /* 数据类型,T_AUDIO16, T_RGB32, T_YV12 */
55
-        public int nFrameRate;                /* 编码时产生的图像帧率,如果是音频数据则为采样率 */
56
-        public int dwFrameNum;                      /* 帧号 */
57
-    }
58
-
59
-}

+ 0 - 716
src/main/java/com/unis/video/VideoMok.java

@@ -1,716 +0,0 @@
1
-package com.unis.video;
2
-
3
-import com.sun.jna.Pointer;
4
-import com.sun.jna.ptr.ByteByReference;
5
-import com.sun.jna.ptr.IntByReference;
6
-import com.unis.common.HCNetSDK;
7
-
8
-import java.io.*;
9
-import java.nio.ByteBuffer;
10
-import java.text.SimpleDateFormat;
11
-import java.util.Date;
12
-import java.util.Timer;
13
-
14
-import static com.unis.video.Clinet.hCNetSDK;
15
-import static com.unis.video.Clinet.playControl;
16
-
17
-/**
18
- * @author qingsong.han
19
- * @description: 视频取流预览,下载,抓图mok
20
- * @create 2024-08-01 10:30
21
- */
22
-public class VideoMok {
23
-    Timer Downloadtimer;//下载用定时器
24
-    Timer Playbacktimer;//回放用定时器
25
-    static FRealDataCallBack fRealDataCallBack;//预览回调函数实现
26
-    static fPlayEScallback fPlayescallback; //裸码流回调函数
27
-    static playDataCallBack playBackCallBack; //回放码流回调
28
-    static int lPlay = -1;  //预览句柄
29
-    int m_lLoadHandle;
30
-    int iPlayBack; //回放句柄
31
-    static File file;
32
-    static FileOutputStream outputStream;
33
-    static IntByReference m_lPort = new IntByReference(-1);
34
-    static String resultFileName = "..\\Download" + new String("returnFile" + ".h264");
35
-    static FileOutputStream fileOutputStream = null;
36
-    static int fileLenth = 0;
37
-
38
-    public static void RealPlay(int userID, int iChannelNo) {
39
-        if (userID == -1) {
40
-            System.out.println("请先注册");
41
-            return;
42
-        }
43
-        HCNetSDK.NET_DVR_PREVIEWINFO strClientInfo = new HCNetSDK.NET_DVR_PREVIEWINFO();
44
-        strClientInfo.read();
45
-        strClientInfo.hPlayWnd = 0;  //窗口句柄,从回调取流不显示一般设置为空
46
-        strClientInfo.lChannel = iChannelNo;  //通道号
47
-        strClientInfo.dwStreamType = 0; //0-主码流,1-子码流,2-三码流,3-虚拟码流,以此类推
48
-        strClientInfo.dwLinkMode = 0; //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4- RTP/RTSP,5- RTP/HTTP,6- HRUDP(可靠传输) ,7- RTSP/HTTPS,8- NPQ
49
-        strClientInfo.bBlocked = 1;
50
-        strClientInfo.write();
51
-
52
-        //回调函数定义必须是全局的
53
-        if (fRealDataCallBack == null) {
54
-            fRealDataCallBack = new FRealDataCallBack();
55
-        }
56
-
57
-        //开启预览
58
-        lPlay = hCNetSDK.NET_DVR_RealPlay_V40(userID, strClientInfo, fRealDataCallBack, null);
59
-        if (lPlay == -1) {
60
-            int iErr = hCNetSDK.NET_DVR_GetLastError();
61
-            System.out.println("取流失败" + iErr);
62
-            return;
63
-        }
64
-        System.out.println("取流成功");
65
-
66
-        //设置裸码流回调函数
67
-//        if (fPlayescallback==null)
68
-//        {
69
-//            fPlayescallback=new fPlayEScallback();
70
-//        }
71
-//        boolean setcallback=hCNetSDK.NET_DVR_SetESRealPlayCallBack(lPlay,fPlayescallback,null);
72
-//        if (setcallback==false)
73
-//        {
74
-//            System.out.println("设置裸码流回调失败,错误码:"+hCNetSDK.NET_DVR_GetLastError());
75
-//        }
76
-
77
-//        try {
78
-//            Thread.sleep(3000);
79
-//        } catch (InterruptedException e) {
80
-//            e.printStackTrace();
81
-//        }
82
-
83
-        //取流解码过程中播放库从解码码流中抓图
84
-//        getPicbyPlayCtrl();
85
-
86
-        /**
87
-         * 预览一段时间;如果要一直取流预览,需要保证程序一直运行
88
-         */
89
-        try {
90
-            Thread.sleep(30000);
91
-        } catch (InterruptedException e) {
92
-            // TODO Auto-generated catch block
93
-            e.printStackTrace();
94
-        }
95
-
96
-        if (lPlay >= 0) {
97
-            if (hCNetSDK.NET_DVR_StopRealPlay(lPlay)) {
98
-                System.out.println("停止预览成功");
99
-                return;
100
-            }
101
-        }
102
-    }
103
-
104
-    //播放库抓图
105
-    public static void getPicbyPlayCtrl() {
106
-
107
-        IntByReference pWidth = new IntByReference(0);
108
-        IntByReference pHieght = new IntByReference(0);
109
-        boolean bFlag = playControl.PlayM4_GetPictureSize(m_lPort.getValue(), pWidth, pHieght);
110
-        if (!bFlag) {
111
-            System.out.println("获取失败:" + playControl.PlayM4_GetLastError(m_lPort.getValue()));
112
-        }
113
-        System.out.println(pWidth.getValue());
114
-        System.out.println(pHieght.getValue());
115
-        IntByReference RealPicSize = new IntByReference(0);
116
-        int picsize = pWidth.getValue() * pHieght.getValue() * 5;
117
-        HCNetSDK.BYTE_ARRAY picByte = new HCNetSDK.BYTE_ARRAY(picsize);
118
-        picByte.write();
119
-        Pointer pByte = picByte.getPointer();
120
-        boolean b_GetPic = playControl.PlayM4_GetJPEG(m_lPort.getValue(), pByte, picsize, RealPicSize);
121
-        if (!b_GetPic) {
122
-            System.out.println("抓图失败:" + playControl.PlayM4_GetLastError(m_lPort.getValue()));
123
-        }
124
-        picByte.read();
125
-        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
126
-        String newName = sf.format(new Date());
127
-        FileOutputStream fout = null;
128
-        try {
129
-
130
-            fout = new FileOutputStream(System.getProperty("user.dir") + "//pic//" + newName + ".jpg");
131
-            //将字节写入文件
132
-            long offset = 0;
133
-            ByteBuffer buffers = pByte.getByteBuffer(offset, RealPicSize.getValue());
134
-            byte[] bytes = new byte[RealPicSize.getValue()];
135
-            buffers.rewind();
136
-            buffers.get(bytes);
137
-            fout.write(bytes);
138
-            fout.close();
139
-        } catch (FileNotFoundException e) {
140
-            // TODO Auto-generated catch block
141
-            e.printStackTrace();
142
-        } catch (IOException e) {
143
-            // TODO Auto-generated catch block
144
-            e.printStackTrace();
145
-        }
146
-        System.out.println("抓图成功!");
147
-
148
-    }
149
-
150
-
151
-    /**
152
-     * 按时间回放获取码流数据
153
-     *
154
-     * @param userID
155
-     */
156
-
157
-    public void PlayBackBytime(int userID) {
158
-        file = new File(System.getProperty("user.dir") + "\\Download\\Videodatabytime.mp4");  //保存回调函数的音频数据
159
-
160
-        if (!file.exists()) {
161
-            try {
162
-                file.createNewFile();
163
-            } catch (Exception e) {
164
-                e.printStackTrace();
165
-            }
166
-        }
167
-        try {
168
-            outputStream = new FileOutputStream(file);
169
-        } catch (FileNotFoundException e) {
170
-            // TODO Auto-generated catch block
171
-            e.printStackTrace();
172
-        }
173
-        HCNetSDK.NET_DVR_VOD_PARA net_dvr_vod_para = new HCNetSDK.NET_DVR_VOD_PARA();
174
-        net_dvr_vod_para.dwSize = net_dvr_vod_para.size();
175
-        net_dvr_vod_para.struIDInfo.dwChannel = 1; //通道号
176
-        net_dvr_vod_para.struBeginTime.dwYear = 2024;
177
-        net_dvr_vod_para.struBeginTime.dwMonth = 8;
178
-        net_dvr_vod_para.struBeginTime.dwDay = 1;
179
-        net_dvr_vod_para.struBeginTime.dwHour = 14;
180
-        net_dvr_vod_para.struBeginTime.dwMinute = 00;
181
-        net_dvr_vod_para.struBeginTime.dwSecond = 00;
182
-        //停止时间
183
-        net_dvr_vod_para.struEndTime.dwYear = 2024;
184
-        net_dvr_vod_para.struEndTime.dwMonth = 8;
185
-        net_dvr_vod_para.struEndTime.dwDay = 1;
186
-        net_dvr_vod_para.struEndTime.dwHour = 14;
187
-        net_dvr_vod_para.struEndTime.dwMinute = 05;
188
-        net_dvr_vod_para.struEndTime.dwSecond = 00;
189
-        net_dvr_vod_para.hWnd = null; // 回放的窗口句柄,若置为空,SDK仍能收到码流数据,但不解码显示
190
-        net_dvr_vod_para.write();
191
-
192
-        int iPlayBack = hCNetSDK.NET_DVR_PlayBackByTime_V40(userID, net_dvr_vod_para);
193
-        if (iPlayBack <= -1) {
194
-            System.out.println("按时间回放失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
195
-            return;
196
-        }
197
-
198
-        //开启取流
199
-        boolean bCrtl = hCNetSDK.NET_DVR_PlayBackControl(iPlayBack, HCNetSDK.NET_DVR_PLAYSTART, 0, null);
200
-        if (playBackCallBack == null) {
201
-            playBackCallBack = new playDataCallBack();
202
-        }
203
-        boolean bRet = hCNetSDK.NET_DVR_SetPlayDataCallBack_V40(iPlayBack, playBackCallBack, Pointer.NULL);
204
-        //开始计时器
205
-        Playbacktimer = new Timer();//新建定时器
206
-        Playbacktimer.schedule(new PlaybackTask(), 0, 5000);//0秒后开始响应函数
207
-        return;
208
-    }
209
-
210
-
211
-    public static void playBackByfile(int userID) {
212
-        file = new File(System.getProperty("user.dir") + "\\Download\\Videodatabyfile.mp4");  //保存回调函数的音频数据
213
-
214
-        if (!file.exists()) {
215
-            try {
216
-                file.createNewFile();
217
-            } catch (Exception e) {
218
-                e.printStackTrace();
219
-            }
220
-        }
221
-        try {
222
-            outputStream = new FileOutputStream(file);
223
-        } catch (FileNotFoundException e) {
224
-            // TODO Auto-generated catch block
225
-            e.printStackTrace();
226
-        }
227
-        String strFileName = "";
228
-        HCNetSDK.NET_DVR_FILECOND_V40 struFileCond = new HCNetSDK.NET_DVR_FILECOND_V40();
229
-        struFileCond.read();
230
-        struFileCond.lChannel = 1; //通道号 NVR设备路数小于32路的起始通道号从33开始,依次增加
231
-        struFileCond.byFindType = 0;  //录象文件类型 0=定时录像
232
-        //起始时间
233
-        struFileCond.struStartTime.dwYear = 2022;
234
-        struFileCond.struStartTime.dwMonth = 4;
235
-        struFileCond.struStartTime.dwDay = 17;
236
-        struFileCond.struStartTime.dwHour = 10;
237
-        struFileCond.struStartTime.dwMinute = 00;
238
-        struFileCond.struStartTime.dwSecond = 00;
239
-        //停止时间
240
-        struFileCond.struStopTime.dwYear = 2022;
241
-        struFileCond.struStopTime.dwMonth = 4;
242
-        struFileCond.struStopTime.dwDay = 17;
243
-        struFileCond.struStopTime.dwHour = 10;
244
-        struFileCond.struStopTime.dwMinute = 10;
245
-        struFileCond.struStopTime.dwSecond = 0;
246
-        struFileCond.write();
247
-        int FindFileHandle = hCNetSDK.NET_DVR_FindFile_V40(userID, struFileCond);
248
-        if (FindFileHandle <= -1) {
249
-            System.out.println("查找建立失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
250
-        }
251
-
252
-        while (true) {
253
-            HCNetSDK.NET_DVR_FINDDATA_V40 struFindData = new HCNetSDK.NET_DVR_FINDDATA_V40();
254
-
255
-            long State = hCNetSDK.NET_DVR_FindNextFile_V40(FindFileHandle, struFindData);
256
-            if (State <= -1) {
257
-
258
-                System.out.println("查找失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
259
-                return;
260
-
261
-            } else if (State == 1000)  //获取文件信息成功
262
-            {
263
-                struFindData.read();
264
-                try {
265
-                    strFileName = new String(struFindData.sFileName, "UTF-8").trim();
266
-                    System.out.println("文件名称:" + strFileName);
267
-                    System.out.println("文件大小:" + struFindData.dwFileSize);
268
-                } catch (UnsupportedEncodingException e) {
269
-                    e.printStackTrace();
270
-                }
271
-                System.out.println("获取文件成功");
272
-                break;
273
-
274
-            } else if (State == 1001) //未查找到文件
275
-            {
276
-                System.out.println("未查找到文件");
277
-                break;
278
-
279
-            } else if (State == 1002) //正在查找请等待
280
-            {
281
-                System.out.println("正在查找,请等待");
282
-                continue;
283
-
284
-            } else if (State == 1003) //没有更多的文件,查找结束
285
-            {
286
-                System.out.println("没有更多的文件,查找结束");
287
-                break;
288
-
289
-            } else if (State == 1004) //查找文件时异常
290
-            {
291
-
292
-                System.out.println("没有更多的文件,查找结束");
293
-                break;
294
-
295
-            } else if (State == 1005) //查找文件超时
296
-            {
297
-
298
-                System.out.println("没有更多的文件,查找结束");
299
-                break;
300
-
301
-            }
302
-
303
-        }
304
-        boolean b_CloseHandle = hCNetSDK.NET_DVR_FindClose_V30(FindFileHandle);
305
-        if (!b_CloseHandle) {
306
-            System.out.println("关闭失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
307
-            return;
308
-        }
309
-
310
-        int lPlayByFileHandle = hCNetSDK.NET_DVR_PlayBackByName(userID, strFileName, null);
311
-        if (lPlayByFileHandle <= -1) {
312
-            System.out.println("按文件回放失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
313
-            return;
314
-        }
315
-        IntByReference intP1 = new IntByReference(0);
316
-        IntByReference intInlen = new IntByReference(0);
317
-        boolean b_PlayBackStart = hCNetSDK.NET_DVR_PlayBackControl_V40(lPlayByFileHandle, HCNetSDK.NET_DVR_PLAYSTART, intP1.getPointer(), 4, Pointer.NULL, intInlen);
318
-        if (!b_PlayBackStart) {
319
-            System.out.println("开始播放失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
320
-            return;
321
-        }
322
-        if (playBackCallBack == null) {
323
-            playBackCallBack = new playDataCallBack();
324
-        }
325
-        boolean bRet = hCNetSDK.NET_DVR_SetPlayDataCallBack_V40(lPlayByFileHandle, playBackCallBack, Pointer.NULL);
326
-        while (true) {
327
-            int Pos = hCNetSDK.NET_DVR_GetDownloadPos(lPlayByFileHandle);
328
-            if (Pos != 100) {
329
-                System.out.println("回放进度:" + Pos);
330
-
331
-                try {
332
-                    Thread.sleep(1000);
333
-                } catch (InterruptedException e) {
334
-                    // TODO Auto-generated catch block
335
-                    e.printStackTrace();
336
-                }
337
-                continue;
338
-            } else {
339
-                break;
340
-            }
341
-        }
342
-        boolean b_Stop = hCNetSDK.NET_DVR_StopPlayBack(lPlayByFileHandle);
343
-        if (!b_Stop) {
344
-            System.out.println("停止回放失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
345
-            return;
346
-        }
347
-        System.out.println("回放成功");
348
-        return;
349
-
350
-
351
-    }
352
-
353
-
354
-    //按文件下载录像(设置转成3GP格式)
355
-    public static void DownloadRecordByFile(int userID, int iChannelNo) {
356
-        String strFileName = "";
357
-        HCNetSDK.NET_DVR_FILECOND_V40 struFileCond = new HCNetSDK.NET_DVR_FILECOND_V40();
358
-        struFileCond.read();
359
-        struFileCond.lChannel = 1; //通道号 NVR设备路数小于32路的起始通道号从33开始,依次增加
360
-        struFileCond.dwFileType = 0Xff;
361
-        struFileCond.byFindType = 0;
362
-        //起始时间
363
-        struFileCond.struStartTime.dwYear = 2022;
364
-        struFileCond.struStartTime.dwMonth = 7;
365
-        struFileCond.struStartTime.dwDay = 5;
366
-        struFileCond.struStartTime.dwHour = 12;
367
-        struFileCond.struStartTime.dwMinute = 00;
368
-        struFileCond.struStartTime.dwSecond = 00;
369
-        //停止时间
370
-        struFileCond.struStopTime.dwYear = 2022;
371
-        struFileCond.struStopTime.dwMonth = 7;
372
-        struFileCond.struStopTime.dwDay = 5;
373
-        struFileCond.struStopTime.dwHour = 12;
374
-        struFileCond.struStopTime.dwMinute = 10;
375
-        struFileCond.struStopTime.dwSecond = 00;
376
-        struFileCond.write();
377
-        int FindFileHandle = hCNetSDK.NET_DVR_FindFile_V40(userID, struFileCond);
378
-        if (FindFileHandle <= -1) {
379
-            System.out.println("查找建立失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
380
-        }
381
-
382
-        while (true) {
383
-            HCNetSDK.NET_DVR_FINDDATA_V40 struFindData = new HCNetSDK.NET_DVR_FINDDATA_V40();
384
-
385
-            long State = hCNetSDK.NET_DVR_FindNextFile_V40(FindFileHandle, struFindData);
386
-            if (State <= -1) {
387
-
388
-                System.out.println("查找失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
389
-                return;
390
-
391
-            } else if (State == 1000)  //获取文件信息成功
392
-            {
393
-                struFindData.read();
394
-                try {
395
-                    strFileName = new String(struFindData.sFileName, "UTF-8").trim();
396
-                    System.out.println("文件名称:" + strFileName);
397
-                    System.out.println("文件大小:" + struFindData.dwFileSize);
398
-                } catch (UnsupportedEncodingException e) {
399
-                    e.printStackTrace();
400
-                }
401
-                System.out.println("获取文件成功");
402
-                break;
403
-
404
-            } else if (State == 1001) //未查找到文件
405
-            {
406
-                System.out.println("未查找到文件");
407
-                break;
408
-
409
-            } else if (State == 1002) //正在查找请等待
410
-            {
411
-                System.out.println("正在查找,请等待");
412
-                continue;
413
-
414
-            } else if (State == 1003) //没有更多的文件,查找结束
415
-            {
416
-                System.out.println("没有更多的文件,查找结束");
417
-                break;
418
-
419
-            } else if (State == 1004) //查找文件时异常
420
-            {
421
-
422
-                System.out.println("没有更多的文件,查找结束");
423
-                break;
424
-
425
-            } else if (State == 1005) //查找文件超时
426
-            {
427
-
428
-                System.out.println("没有更多的文件,查找结束");
429
-                break;
430
-
431
-            }
432
-
433
-        }
434
-        boolean b_CloseHandle = hCNetSDK.NET_DVR_FindClose_V30(FindFileHandle);
435
-        if (!b_CloseHandle) {
436
-            System.out.println("关闭失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
437
-            return;
438
-        }
439
-
440
-        //按文件下载录像
441
-        String SaveDir = ".\\Download\\test.mp4";
442
-
443
-        int FileName = hCNetSDK.NET_DVR_GetFileByName(userID, strFileName, SaveDir.getBytes());
444
-        if (FileName <= -1) {
445
-            System.out.println("下载录像失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
446
-            return;
447
-        }
448
-        //转码3GP命令
449
-        IntByReference intP = new IntByReference(5);
450
-        IntByReference intInlen1 = new IntByReference(0);
451
-        boolean b_PlayBack = hCNetSDK.NET_DVR_PlayBackControl_V40(FileName, 32, intP.getPointer(), 4, Pointer.NULL, intInlen1);
452
-        if (!b_PlayBack) {
453
-            System.out.println("转封装失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
454
-            return;
455
-        }
456
-
457
-        IntByReference intP1 = new IntByReference(0);
458
-        IntByReference intInlen = new IntByReference(0);
459
-        boolean b_PlayBackStart = hCNetSDK.NET_DVR_PlayBackControl_V40(FileName, HCNetSDK.NET_DVR_PLAYSTART, intP1.getPointer(), 4, Pointer.NULL, intInlen);
460
-        if (!b_PlayBackStart) {
461
-            System.out.println("开始播放失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
462
-            return;
463
-        }
464
-
465
-/*        IntByReference intP=new IntByReference(30*1024);
466
-        IntByReference intInlen1=new IntByReference(0);
467
-        boolean b_PlayBack=hCNetSDK.NET_DVR_PlayBackControl_V40(FileName,24,intP.getPointer(),4, Pointer.NULL,intInlen1);
468
-        if (!b_PlayBack) {
469
-            System.out.println("设置下载速度失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
470
-            return;
471
-        }*/
472
-        while (true) {
473
-            int Pos = hCNetSDK.NET_DVR_GetDownloadPos(FileName);
474
-            if (Pos != 100) {
475
-                System.out.println("下载进度:" + Pos);
476
-
477
-                try {
478
-                    Thread.sleep(1000);
479
-                } catch (InterruptedException e) {
480
-                    // TODO Auto-generated catch block
481
-                    e.printStackTrace();
482
-                }
483
-                continue;
484
-            } else {
485
-                break;
486
-            }
487
-        }
488
-        boolean b_Stop = hCNetSDK.NET_DVR_StopGetFile(FileName);
489
-        if (!b_Stop) {
490
-            System.out.println("停止下载失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
491
-            return;
492
-        }
493
-        System.out.println("下载成功");
494
-        return;
495
-    }
496
-
497
-    //按时间下载录像(不支持转码3GP格式)
498
-    public void DowmloadRecordByTime(int userID) {
499
-        HCNetSDK.NET_DVR_PLAYCOND net_dvr_playcond = new HCNetSDK.NET_DVR_PLAYCOND();
500
-        net_dvr_playcond.read();
501
-        net_dvr_playcond.dwChannel = 1; //通道号 NVR设备路数小于32路的起始通道号从33开始,依次增加
502
-        //开始时间
503
-        net_dvr_playcond.struStartTime.dwYear = 2022;
504
-        net_dvr_playcond.struStartTime.dwMonth = 4;
505
-        net_dvr_playcond.struStartTime.dwDay = 17;
506
-        net_dvr_playcond.struStartTime.dwHour = 10;
507
-        net_dvr_playcond.struStartTime.dwMinute = 00;
508
-        net_dvr_playcond.struStartTime.dwSecond = 00;
509
-        //停止时间
510
-        net_dvr_playcond.struStopTime.dwYear = 2022;
511
-        net_dvr_playcond.struStopTime.dwMonth = 4;
512
-        net_dvr_playcond.struStopTime.dwDay = 17;
513
-        net_dvr_playcond.struStopTime.dwHour = 10;
514
-        net_dvr_playcond.struStopTime.dwMinute = 10;
515
-        net_dvr_playcond.struStopTime.dwSecond = 00;
516
-        net_dvr_playcond.write();
517
-        String sFileName = ".\\Download\\" + System.currentTimeMillis() + ".mp4";
518
-        System.out.println(sFileName);
519
-        m_lLoadHandle = hCNetSDK.NET_DVR_GetFileByTime_V40(userID, sFileName, net_dvr_playcond);
520
-        if (m_lLoadHandle >= 0) {
521
-            hCNetSDK.NET_DVR_PlayBackControl(m_lLoadHandle, HCNetSDK.NET_DVR_PLAYSTART, 0, null);
522
-/*            IntByReference intP=new IntByReference(5*8*1024);
523
-            IntByReference intInlen=new IntByReference(0);
524
-            boolean b_PlayBack=ClientDemo.hCNetSDK.NET_DVR_PlayBackControl_V40(m_lLoadHandle,24,intP.getPointer(),4,Pointer.NULL,intInlen);
525
-            if (!b_PlayBack) {
526
-                System.out.println("设置下载速度失败,错误码为" + ClientDemo.hCNetSDK.NET_DVR_GetLastError());
527
-                return;
528
-            }*/
529
-            Date nowTime = new Date(System.currentTimeMillis());
530
-            SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
531
-            System.out.println("开始下载时间:" + sdFormatter.format(nowTime));
532
-            Downloadtimer = new Timer();//新建定时器
533
-            Downloadtimer.schedule(new DownloadTask(), 0, 5000);//0秒后开始响应函数
534
-        } else {
535
-            System.out.println("按时间下载失败");
536
-            System.out.println("laste error " + hCNetSDK.NET_DVR_GetLastError());
537
-            return;
538
-        }
539
-    }
540
-
541
-    /*************************************************
542
-     类:      DownloadTask
543
-     类描述:  下载定时器响应函数
544
-     *************************************************/
545
-    class DownloadTask extends java.util.TimerTask {
546
-        //定时器函数
547
-        @Override
548
-        public void run() {
549
-            IntByReference nPos = new IntByReference(0);
550
-            hCNetSDK.NET_DVR_PlayBackControl(m_lLoadHandle, HCNetSDK.NET_DVR_PLAYGETPOS, 0, nPos);
551
-            if (nPos.getValue() > 100) {
552
-                m_lLoadHandle = -1;
553
-                Downloadtimer.cancel();
554
-                System.out.println("由于网络原因或DVR忙,下载异常终止!");
555
-            }
556
-            if (nPos.getValue() == 100) {
557
-                Date nowTime = new Date(System.currentTimeMillis());
558
-                SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
559
-                System.out.println("结束下载时间:" + sdFormatter.format(nowTime));
560
-                m_lLoadHandle = -1;
561
-                Downloadtimer.cancel();
562
-                System.out.println("按时间下载结束!");
563
-            }
564
-        }
565
-    }
566
-
567
-
568
-    class PlaybackTask extends java.util.TimerTask {
569
-        //定时器函数
570
-        @Override
571
-        public void run() {
572
-            System.out.println("定时器触发");
573
-            IntByReference nPos = new IntByReference(0);
574
-            System.out.println("ceshi");
575
-
576
-            System.out.println("iPlayBack" + iPlayBack);
577
-            boolean bret = hCNetSDK.NET_DVR_PlayBackControl(iPlayBack, HCNetSDK.NET_DVR_PLAYGETPOS, 0, nPos);
578
-            if (bret) {
579
-                System.out.println("回放进度" + nPos.getValue());
580
-            } else {
581
-                System.out.println("获取回放进度失败");
582
-            }
583
-
584
-            if (nPos.getValue() > 100) {
585
-
586
-                hCNetSDK.NET_DVR_StopPlayBack(iPlayBack);
587
-                if (outputStream != null) {
588
-                    try {
589
-                        outputStream.close();
590
-                    } catch (IOException e) {
591
-                        // TODO Auto-generated catch block
592
-                        e.printStackTrace();
593
-                    }
594
-                }
595
-                System.out.println("由于网络原因或DVR忙,回放异常终止!");
596
-            }
597
-            if (nPos.getValue() == 100) {
598
-                hCNetSDK.NET_DVR_StopPlayBack(iPlayBack);
599
-                if (outputStream != null) {
600
-                    try {
601
-                        outputStream.close();
602
-                    } catch (IOException e) {
603
-                        // TODO Auto-generated catch block
604
-                        e.printStackTrace();
605
-                    }
606
-                }
607
-                System.out.println("按时间回放结束");
608
-            }
609
-        }
610
-
611
-
612
-    }
613
-
614
-
615
-    //获取IP通道
616
-    public static void getIPChannelInfo(int userID) {
617
-        IntByReference ibrBytesReturned = new IntByReference(0);//获取IP接入配置参数
618
-        HCNetSDK.NET_DVR_IPPARACFG_V40 m_strIpparaCfg = new HCNetSDK.NET_DVR_IPPARACFG_V40();
619
-        m_strIpparaCfg.write();
620
-        //lpIpParaConfig 接收数据的缓冲指针
621
-        Pointer lpIpParaConfig = m_strIpparaCfg.getPointer();
622
-        boolean bRet = hCNetSDK.NET_DVR_GetDVRConfig(userID, HCNetSDK.NET_DVR_GET_IPPARACFG_V40, 0, lpIpParaConfig, m_strIpparaCfg.size(), ibrBytesReturned);
623
-        m_strIpparaCfg.read();
624
-        System.out.println("起始数字通道号:" + m_strIpparaCfg.dwStartDChan);
625
-
626
-        for (int iChannum = 0; iChannum < m_strIpparaCfg.dwDChanNum; iChannum++) {
627
-            int channum = iChannum + m_strIpparaCfg.dwStartDChan;
628
-            m_strIpparaCfg.struStreamMode[iChannum].read();
629
-            if (m_strIpparaCfg.struStreamMode[iChannum].byGetStreamType == 0) {
630
-                m_strIpparaCfg.struStreamMode[iChannum].uGetStream.setType(HCNetSDK.NET_DVR_IPCHANINFO.class);
631
-                m_strIpparaCfg.struStreamMode[iChannum].uGetStream.struChanInfo.read();
632
-                if (m_strIpparaCfg.struStreamMode[iChannum].uGetStream.struChanInfo.byEnable == 1) {
633
-                    System.out.println("IP通道" + channum + "在线");
634
-                } else {
635
-                    System.out.println("IP通道" + channum + "不在线");
636
-                }
637
-            }
638
-        }
639
-    }
640
-
641
-    static class fPlayEScallback implements HCNetSDK.FPlayESCallBack {
642
-        public void invoke(int lPreviewHandle, HCNetSDK.NET_DVR_PACKET_INFO_EX pstruPackInfo, Pointer pUser) {
643
-            System.out.println("进入码流回调");
644
-            System.out.println(pstruPackInfo.dwPacketSize);
645
-//            try {
646
-//                fileLenth += pstruPackInfo.dwPacketSize;
647
-//                fileOutputStream = new FileOutputStream(resultFileName,true);
648
-//                //将字节写入文件
649
-//                ByteBuffer buffers = pstruPackInfo.pPacketBuffer.getByteBuffer(0, pstruPackInfo.dwPacketSize);
650
-//                byte[] bytes = new byte[pstruPackInfo.dwPacketSize];
651
-//                buffers.rewind();
652
-//                buffers.get(bytes);
653
-//                fileOutputStream.write(bytes);
654
-//            } catch (FileNotFoundException e) {
655
-//                e.printStackTrace();
656
-//            } catch (IOException e) {
657
-//                e.printStackTrace();
658
-//            }
659
-        }
660
-    }
661
-
662
-    static class playDataCallBack implements HCNetSDK.FPlayDataCallBack {
663
-        public void invoke(int lPlayHandle, int dwDataType, Pointer pBuffer, int dwBufSize, int dwUser) {
664
-            System.out.println("回放码流回调...");
665
-            //将设备发送过来的回放码流数据写入文件
666
-            long offset = 0;
667
-            ByteBuffer buffers = pBuffer.getByteBuffer(offset, dwBufSize);
668
-            byte[] bytes = new byte[dwBufSize];
669
-            buffers.rewind();
670
-            buffers.get(bytes);
671
-            try {
672
-                outputStream.write(bytes);
673
-            } catch (IOException e) {
674
-                e.printStackTrace();
675
-            }
676
-        }
677
-    }
678
-
679
-    static class FRealDataCallBack implements HCNetSDK.FRealDataCallBack_V30 {
680
-        //预览回调
681
-        public void invoke(int lRealHandle, int dwDataType, ByteByReference pBuffer, int dwBufSize, Pointer pUser) {
682
-            System.out.println("码流数据回调...dwBufSize=" + dwBufSize);
683
-            //播放库解码
684
-            switch (dwDataType) {
685
-                case HCNetSDK.NET_DVR_SYSHEAD: //系统头
686
-                    if (!playControl.PlayM4_GetPort(m_lPort)) //获取播放库未使用的通道号
687
-                    {
688
-                        break;
689
-                    }
690
-                    if (dwBufSize > 0) {
691
-                        if (!playControl.PlayM4_SetStreamOpenMode(m_lPort.getValue(), PlayCtrl.STREAME_REALTIME))  //设置实时流播放模式
692
-                        {
693
-                            break;
694
-                        }
695
-                        if (!playControl.PlayM4_OpenStream(m_lPort.getValue(), pBuffer, dwBufSize, 1024 * 1024)) //打开流接口
696
-                        {
697
-                            break;
698
-                        }
699
-                        if (!playControl.PlayM4_Play(m_lPort.getValue(), null)) //播放开始
700
-                        {
701
-                            break;
702
-                        }
703
-
704
-                    }
705
-                case HCNetSDK.NET_DVR_STREAMDATA:   //码流数据
706
-                    if ((dwBufSize > 0) && (m_lPort.getValue() != -1)) {
707
-                        if (!playControl.PlayM4_InputData(m_lPort.getValue(), pBuffer, dwBufSize))  //输入流数据
708
-                        {
709
-                            break;
710
-                        }
711
-                    }
712
-            }
713
-        }
714
-    }
715
-
716
-}

+ 6 - 1
src/main/resources/application-dev.yml

@@ -14,4 +14,9 @@ exceptionAlarm:
14 14
 # 只支持post
15 15
 address:
16 16
   # 推送异常闯入/入侵信息地址
17
-  pushToIntrusion: http://localhost:8077/pushIntrusion
17
+  pushToIntrusion: http://localhost:8077/pushIntrusion
18
+minio:
19
+  endpoint: http://172.16.0.36:15772
20
+  access-key: 4vFQhyfxcwcqAXHPOV57
21
+  secret-key: 3kB9RIsEqXuHMG6FDDp4f299LACEwztgybwYTAmg
22
+  bucket-name: province-qinghai

+ 6 - 1
src/main/resources/application-prod.yml

@@ -14,4 +14,9 @@ exceptionAlarm:
14 14
 # 只支持post
15 15
 address:
16 16
   # 推送异常闯入/入侵信息地址
17
-  pushToIntrusion: http://23.99.21.201:59882/pushIntrusion
17
+  pushToIntrusion: http://23.99.21.201:59882/pushIntrusion
18
+minio:
19
+  endpoint: http://172.18.93.234:15772
20
+  access-key: ubj8S4OuD5hPNq7tzHeD
21
+  secret-key: TwyyMuHgYlZFFW5q20BVPeowfwgOrCipdyEwi52u
22
+  bucket-name: province-qinghai

+ 7 - 3
src/main/resources/application.yml

@@ -5,9 +5,13 @@ server:
5 5
 spring:
6 6
   application:
7 7
     name: video-super-brain
8
+  # dev: 开发环境,prod: 生产环境(线上)
9
+  profiles:
10
+    active: dev
8 11
   jackson:
9 12
     date-format: yyyy-MM-dd HH:mm:ss
10 13
     time-zone: GMT+8
11
-  # dev: 开发环境,prod: 生产环境(线上)
12
-  profiles:
13
-    active: dev
14
+  servlet:
15
+    multipart:
16
+      max-file-size: 100MB
17
+      max-request-size: 100MB