From 6ab0ec5ade792e91ba90018c0b7f822abb1db5b2 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期三, 06 十二月 2023 11:29:51 +0800
Subject: [PATCH] 增加超脑报警事件
---
src/main/java/com/ard/utils/sdk/hiksdk/service/impl/FMSGCallBack.java | 529 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 385 insertions(+), 144 deletions(-)
diff --git a/src/main/java/com/ard/utils/sdk/hiksdk/service/impl/FMSGCallBack.java b/src/main/java/com/ard/utils/sdk/hiksdk/service/impl/FMSGCallBack.java
index 3283dbf..a5a8575 100644
--- a/src/main/java/com/ard/utils/sdk/hiksdk/service/impl/FMSGCallBack.java
+++ b/src/main/java/com/ard/utils/sdk/hiksdk/service/impl/FMSGCallBack.java
@@ -15,6 +15,7 @@
import com.ard.utils.mqtt.MqttProducer;
import com.ard.utils.util.IdUtils;
import com.sun.jna.Pointer;
+import javafx.scene.Camera;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
@@ -65,19 +66,20 @@
if (camera == null && ardEquipExternal == null) {
return false;
}
- CameraEventInfo info;
+ CameraEventInfo cameraEventInfo;
+ SuperBrainEventInfo superBrainEventInfo;
+ String alarmName = "";//鎶ヨ鍚嶇О
String alarmTime;//浜嬩欢鏃堕棿
String alarmType = "";//鎶ヨ绫诲瀷
String picUrl = "";//浜嬩欢鍥剧墖
- String facePicUrl = "";//浜鸿劯鍥剧墖
+ String facePicUrl = "";//浜鸿劯鎶撴媿鍥剧墖
+ String faceLibUrl = "";//浜鸿劯搴撳浘鐗�
+ int dwPicDataLen;//鍥剧墖鏁版嵁闀垮害
//lCommand鏄紶鐨勬姤璀︾被鍨�
log.debug("銆�" + sDeviceIP + ":" + wLinkPort + "銆戞姤璀︿簨浠剁被鍨�:lCommand:" + Integer.toHexString(lCommand));
switch (lCommand) {
case COMM_ALARM_V30:
- log.debug("绉诲姩渚︽祴鎶ヨ淇℃伅涓婃姤");
- if (camera == null) {
- return false;
- }
+ log.debug("绉诲姩渚︽祴淇℃伅涓婃姤");
//region 绉诲姩渚︽祴銆佽棰戜涪澶便�侀伄鎸°�両O淇″彿閲忕瓑鎶ヨ淇℃伅(V3.0浠ヤ笂鐗堟湰鏀寔鐨勮澶�)
HCNetSDK.NET_DVR_ALARMINFO_V30 netDvrAlarminfoV30 = new HCNetSDK.NET_DVR_ALARMINFO_V30();
netDvrAlarminfoV30.write();
@@ -86,28 +88,17 @@
netDvrAlarminfoV30.read();
switch (netDvrAlarminfoV30.dwAlarmType) {
case 3:
- info = new CameraEventInfo();
- info.setAlarmName("绉诲姩渚︽祴");
- info.setAlarmTime(fmt.format(new Date()));
- info.setCameraName(camera.getName());
- info.setCameraId(camera.getId());
- info.setCameraIp(camera.getIp());
- info.setCameraPort(camera.getPort());
- info.setCameraType(camera.getGdType());
- info.setCameraChannel(Integer.valueOf(netDvrAlarminfoV30.byChannel[0]));
- info.setLongitude(camera.getLongitude());
- info.setLatitude(camera.getLatitude());
- info.setAlarmType("绉诲姩渚︽祴");
- //鍥剧墖瀛樺叆minio
- picUrl = snapPicture(info);
- info.setPicUrl(picUrl);
- publishMqtt(info, "camera");
+ if (camera != null) {
+ cameraEventHandler(camera, "绉诲姩渚︽祴", "绉诲姩渚︽祴鎶ヨ", fmt.format(new Date()), "");
+ }
break;
}
//endregion
break;
+ case COMM_VCA_ALARM:
+ log.debug("鏅鸿兘妫�娴嬮�氱敤淇℃伅涓婃姤(鏆備笉瑙f瀽)");
case COMM_ALARM_RULE:
- log.debug("寮傚父琛屼负璇嗗埆淇℃伅鎶ヨ淇℃伅涓婃姤");
+ log.debug("寮傚父琛屼负璇嗗埆淇℃伅涓婃姤");
//region 寮傚父琛屼负璇嗗埆淇℃伅
HCNetSDK.NET_VCA_RULE_ALARM strVcaAlarm = new HCNetSDK.NET_VCA_RULE_ALARM();
strVcaAlarm.write();
@@ -117,74 +108,108 @@
Integer ruleID = Integer.valueOf(strVcaAlarm.struRuleInfo.byRuleID);
alarmTime = DateUtils.parseTime(strVcaAlarm.dwAbsTime);//浜嬩欢鏃堕棿
Integer channel = Integer.valueOf(strVcaAlarm.struDevInfo.byChannel);//閫氶亾
- info = new CameraEventInfo();
- info.setAlarmName("浜哄憳琛屼负鍒嗘瀽");
- info.setAlarmTime(alarmTime);
- info.setCameraName(camera.getName());
- info.setCameraId(camera.getId());
- info.setCameraIp(camera.getIp());
- info.setCameraPort(camera.getPort());
- info.setCameraType(camera.getGdType());
- info.setCameraChannel(channel);
- info.setLongitude(camera.getLongitude());
- info.setLatitude(camera.getLatitude());
- info.setRuleId(ruleID);
switch (strVcaAlarm.struRuleInfo.wEventTypeEx) {
case 1: //region绌胯秺璀︽垝闈� (瓒婄晫渚︽祴)
- info.setAlarmType("瓒婄晫渚︽祴鎶ヨ");
- strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_TRAVERSE_PLANE.class);
- //鍥剧墖瀛樺叆minio
- picUrl = snapPicture(info);
- info.setPicUrl(picUrl);
- publishMqtt(info, "camera");
+ alarmType = "瓒婄晫渚︽祴鎶ヨ";
//endregion
break;
-// case 2: //region 鐩爣杩涘叆鍖哄煙
-// info.setAlarmType("鐩爣杩涘叆鍖哄煙鎶ヨ");
-// strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class);
-// //endregion
-// break;
-// case 3: //region 鐩爣绂诲紑鍖哄煙
-// info.setAlarmType("鐩爣绂诲紑鍖哄煙鎶ヨ");
-// strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class);
-// //endregion
-// break;
+ case 2: //region 鐩爣杩涘叆鍖哄煙
+ alarmType = "鐩爣杩涘叆鍖哄煙鎶ヨ";
+ //endregion
+ break;
+ case 3: //region 鐩爣绂诲紑鍖哄煙
+ alarmType = "鐩爣绂诲紑鍖哄煙鎶ヨ";
+ //strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class);
+ //endregion
+ break;
case 4: //region 鍛ㄧ晫鍏ヤ镜
- info.setAlarmType("鍛ㄧ晫鍏ヤ镜鎶ヨ");
- strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_INTRUSION.class);
- //鍥剧墖瀛樺叆minio
- picUrl = snapPicture(info);
- info.setPicUrl(picUrl);
- publishMqtt(info, "camera");
+ alarmType = "鍛ㄧ晫鍏ヤ镜鎶ヨ";
//endregion
break;
-// case 5: //region 寰樺緤
-// info.setAlarmType("寰樺緤浜嬩欢鎶ヨ");
-// //endregion
-// break;
-// case 8: //region 蹇�熺Щ鍔�(濂旇窇)
-// info.setAlarmType("蹇�熺Щ鍔�(濂旇窇)浜嬩欢鎶ヨ");
-// //endregion
-// break;
-// case 13: //region 鐗╁搧閬楃暀浜嬩欢
-// info.setAlarmType("鐗╁搧閬楃暀浜嬩欢鎶ヨ");
-// //endregion
-// break;
-// case 14: //region 鐗╁搧鎷垮彇浜嬩欢
-// info.setAlarmType("鐗╁搧鎷垮彇浜嬩欢浜嬩欢鎶ヨ");
-// //endregion
-// break;
-// case 20: //region 鍊掑湴妫�娴�
-// info.setAlarmType("鍊掑湴浜嬩欢瑙﹀彂");
-// //endregion
-// break;
-// case 44: //region 鐜╂墜鏈�
-// info.setAlarmType("鐜╂墜鏈烘姤璀︿簨浠�");
-// //endregion
-// break;
+ case 5: //region 寰樺緤
+ alarmType = "寰樺緤浜嬩欢鎶ヨ";
+ //endregion
+ break;
+ case 8: //region 蹇�熺Щ鍔�(濂旇窇)
+ alarmType = "蹇�熺Щ鍔ㄦ姤璀�";
+ //endregion
+ break;
+ case 9: //region 浜哄憳鑱氶泦鎶ヨ
+ alarmType = "浜哄憳鑱氶泦鎶ヨ";
+ //endregion
+ break;
+ case 13: //region 鐗╁搧閬楃暀浜嬩欢
+ alarmType = "鐗╁搧閬楃暀浜嬩欢鎶ヨ";
+ //endregion
+ break;
+ case 14: //region 鐗╁搧鎷垮彇浜嬩欢
+ alarmType = "鐗╁搧鎷垮彇浜嬩欢鎶ヨ";
+ //endregion
+ break;
+ case 15: //region 绂诲矖浜嬩欢
+ strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_LEAVE_POSITION.class);
+ int byMode = strVcaAlarm.struRuleInfo.uEventParam.struLeavePos.byMode;
+ switch (byMode) {
+ case 0:
+ alarmType = "绂诲矖浜嬩欢鎶ヨ";
+ break;
+ case 1:
+ alarmType = "鐫″矖浜嬩欢鎶ヨ";
+ break;
+ }
+ //endregion
+ break;
+ case 20: //region 鍊掑湴妫�娴�
+ alarmType = "鍊掑湴妫�娴嬩簨浠舵姤璀�";
+ //endregion
+ break;
+ case 35: //region 鍊掑湴妫�娴�
+ alarmType = "浜烘暟鍙樺寲浜嬩欢鎶ヨ";
+ //endregion
+ break;
+ case 41: //region 婊炵暀妫�娴�
+ alarmType = "婊炵暀妫�娴嬩簨浠舵姤璀�";
+ //endregion
+ break;
+ case 44: //region 鐜╂墜鏈�
+ alarmType = "鐜╂墜鏈轰簨浠舵姤璀�";
+ //endregion
+ break;
default:
log.debug("鏈煡寮傚父琛屼负浜嬩欢绫诲瀷:" + strVcaAlarm.struRuleInfo.wEventTypeEx);
break;
+ }
+ //鍥剧墖鎺ユ敹
+ int byPicType = strVcaAlarm.byPicType;
+ dwPicDataLen = strVcaAlarm.dwPicDataLen;
+ int byPicTransType = strVcaAlarm.byPicTransType;
+ if (dwPicDataLen > 0 && strVcaAlarm.pImage != null && byPicTransType == 0) {
+ //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ long offset = 0;
+ ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, dwPicDataLen);
+ byte[] bytes = new byte[dwPicDataLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ InputStream input = new ByteArrayInputStream(bytes);
+ try {
+ String bucketName = "pic";
+ String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg";
+ boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG");
+ if (uploadObject) {
+ picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName);
+ //log.debug("涓婁紶鏂囦欢鎴愬姛!" + picUrl);
+ }
+ } catch (Exception e) {
+ log.error("寮傚父琛屼负璇嗗埆淇℃伅鎶ヨ淇℃伅涓婃姤鍥剧墖淇濆瓨澶辫触" + e.getMessage());
+ }
+ }
+ if (camera != null) {
+ camera.setChannel(channel);
+ cameraEventHandler(camera, alarmName, alarmType, alarmTime, picUrl);
+ }
+ if (ardEquipExternal != null) {
+ alarmName = "寮傚父琛屼负璇嗗埆";
+ superBrainEventHandler(ardEquipExternal, channel, alarmName, alarmType, alarmTime, picUrl, "");
}
//endregion
break;
@@ -249,7 +274,7 @@
log.error("浜鸿劯鎶撴媿鎶ヨ淇℃伅鍥剧墖淇濆瓨澶辫触" + e.getMessage());
}
}
- log.debug("銆愪汉鑴告姄鎷嶆姤璀︿俊鎭��: alarmTime:" + alarmTime + " picUrl:" + picUrl + " facePicType:" + facePicTyp + " facePicUrl:" + facePicUrl);
+ //log.debug("銆愪汉鑴告姄鎷嶆姤璀︿俊鎭��: alarmTime:" + alarmTime + " picUrl:" + picUrl + " facePicType:" + facePicTyp + " facePicUrl:" + facePicUrl);
FaceSnapEventInfo faceSnapEventInfo = new FaceSnapEventInfo();
faceSnapEventInfo.setAlarmTime(alarmTime);
faceSnapEventInfo.setPicUrl(picUrl);
@@ -260,27 +285,17 @@
log.debug("浜鸿劯姣斿鎶ヨ淇℃伅");
//region 浜鸿劯姣斿鎶ヨ淇℃伅
HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM struFaceMatchAlarm = new HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM();
+ struFaceMatchAlarm.byPicTransType = 0;
struFaceMatchAlarm.write();
Pointer fmaInfo = struFaceMatchAlarm.getPointer();
fmaInfo.write(0, pAlarmInfo.getByteArray(0, struFaceMatchAlarm.size()), 0, struFaceMatchAlarm.size());
struFaceMatchAlarm.read();
alarmTime = DateUtils.parseTime(struFaceMatchAlarm.struSnapInfo.dwAbsTime);//鎶ヨ鏃堕棿
-
int byMatchPicNum = struFaceMatchAlarm.byMatchPicNum;//鍖归厤鍥剧墖鏁伴噺
- String picTransType = "";
- switch (struFaceMatchAlarm.byPicTransType) {
- case 0:
- picTransType = "浜岃繘鍒跺浘鐗�";
- break;
- case 1:
- picTransType = "URL璺緞鍥剧墖";
- break;
- }
String contrastStatus = "";
switch (struFaceMatchAlarm.byContrastStatus) {
case 1:
contrastStatus = "姣斿鎴愬姛";
-
break;
case 2:
contrastStatus = "姣斿澶辫触";
@@ -289,42 +304,157 @@
contrastStatus = "鏈煡";
break;
}
+ String BlockType = "";
switch (struFaceMatchAlarm.struBlockListInfo.struBlockListInfo.byType) {
case 1:
- alarmType = "闄岀敓浜烘姤璀�";
+ BlockType = "闄岀敓浜烘姤璀�";
break;
case 2:
- alarmType = "浜鸿劯姣斿鎶ヨ";
+ BlockType = "浜鸿劯姣斿鎶ヨ";
break;
default:
- alarmType = "鏈煡";
+ BlockType = "鏈煡";
break;
}
- if (struFaceMatchAlarm.dwSnapPicLen > 0 && struFaceMatchAlarm.pSnapPicBuffer != null && struFaceMatchAlarm.byPicTransType == 0) {
- //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ //浜鸿劯姣斿鎶ヨ鍥剧墖淇濆瓨锛屽浘鐗囨牸寮忎簩杩涘埗
+ if ((struFaceMatchAlarm.dwSnapPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 0)) {
+ SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
+ String newName = sf.format(new Date());
+ FileOutputStream fout;
+ try {
+ String filename = "../pic/" + newName + "_pSnapPicBuffer" + ".jpg";
+ fout = new FileOutputStream(filename);
+ //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ long offset = 0;
+ ByteBuffer buffers = struFaceMatchAlarm.pSnapPicBuffer.getByteBuffer(offset, struFaceMatchAlarm.dwSnapPicLen);
+ byte[] bytes = new byte[struFaceMatchAlarm.dwSnapPicLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ fout.write(bytes);
+ fout.close();
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if ((struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen > 0) && (struFaceMatchAlarm.byPicTransType == 0)) {
+ SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
+ String newName = sf.format(new Date());
+ FileOutputStream fout;
+ try {
+ String filename = "../pic/" + newName + "_struSnapInfo_pBuffer1" + ".jpg";
+ fout = new FileOutputStream(filename);
+ //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ long offset = 0;
+ ByteBuffer buffers = struFaceMatchAlarm.struSnapInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen);
+ byte[] bytes = new byte[struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ fout.write(bytes);
+ fout.close();
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if ((struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 0)) {
+ SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
+ String newName = sf.format(new Date());
+ FileOutputStream fout;
+ try {
+ String filename = "../pic/" + newName + "_fSimilarity_" + struFaceMatchAlarm.fSimilarity + "_struBlackListInfo_pBuffer1" + ".jpg";
+ fout = new FileOutputStream(filename);
+ //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ long offset = 0;
+ ByteBuffer buffers = struFaceMatchAlarm.struBlockListInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen);
+ byte[] bytes = new byte[struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ fout.write(bytes);
+ fout.close();
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ //浜鸿劯姣斿鎶ヨ鍥剧墖淇濆瓨锛屽浘鐗囨牸寮廢RL鏍煎紡
+ if ((struFaceMatchAlarm.dwSnapPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 1)) {
+
long offset = 0;
ByteBuffer buffers = struFaceMatchAlarm.pSnapPicBuffer.getByteBuffer(offset, struFaceMatchAlarm.dwSnapPicLen);
byte[] bytes = new byte[struFaceMatchAlarm.dwSnapPicLen];
buffers.rewind();
buffers.get(bytes);
- InputStream input = new ByteArrayInputStream(bytes);
- try {
- String bucketName = "pic";
- String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg";
- boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG");
- if (uploadObject) {
- picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName);
- //log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
- }
- } catch (Exception e) {
- log.error("浜鸿劯鎶撴媿鎶ヨ淇℃伅鍥剧墖淇濆瓨澶辫触" + e.getMessage());
- }
+ picUrl = new String(bytes);
+ //log.debug("鎶撴媿鍥綰RL锛�" + picUrl);
}
- if (struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen > 0 && struFaceMatchAlarm.struBlockListInfo.pBuffer1 != null) {
- //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ if ((struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen > 0) && (struFaceMatchAlarm.byPicTransType == 1)) {
+
+ long offset = 0;
+ ByteBuffer buffers = struFaceMatchAlarm.struSnapInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen);
+ byte[] bytes = new byte[struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ facePicUrl = new String(bytes);
+ //System.out.println("鎶撴媿浜鸿劯瀛愬浘URL锛�" + SnapPicUrl);
+ }
+ if ((struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 1)) {
+
long offset = 0;
ByteBuffer buffers = struFaceMatchAlarm.struBlockListInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen);
byte[] bytes = new byte[struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ faceLibUrl = new String(bytes);
+ //System.out.println("浜鸿劯搴撲汉鑴稿浘鐨刄RL锛�" + SnapPicUrl);
+ }
+ if (ardEquipExternal != null) {
+ alarmName = "浜鸿劯姣斿妫�娴�";
+ alarmType = contrastStatus + "[" + BlockType + "]";
+ superBrainEventHandler(ardEquipExternal, 0, alarmName, alarmType, alarmTime, picUrl, facePicUrl);
+ }
+ //endregion
+ break;
+ case COMM_UPLOAD_AIOP_VIDEO:
+ log.debug("AI寮�鏀惧钩鍙版帴鍏ヨ棰戞娴嬫姤璀︿笂浼�");
+ //region AI寮�鏀惧钩鍙版帴鍏ヨ棰戞娴�
+ HCNetSDK.NET_AIOP_VIDEO_HEAD struAIOPVideo = new HCNetSDK.NET_AIOP_VIDEO_HEAD();
+ struAIOPVideo.write();
+ Pointer pAIOPVideo = struAIOPVideo.getPointer();
+ pAIOPVideo.write(0, pAlarmInfo.getByteArray(0, struAIOPVideo.size()), 0, struAIOPVideo.size());
+ struAIOPVideo.read();
+ log.debug("瑙嗛浠诲姟ID" + new String(struAIOPVideo.szTaskID).trim());
+ log.debug("閫氶亾鍙凤細" + struAIOPVideo.dwChannel);
+ String szMPID = new String(struAIOPVideo.szMPID).trim();//妫�娴嬫ā鍨嬪寘ID
+ log.debug("妫�娴嬫ā鍨嬪寘ID" + szMPID);
+ alarmTime = String.format("%04d", struAIOPVideo.struTime.wYear) + "-" +
+ String.format("%02d", struAIOPVideo.struTime.wMonth) + "-" +
+ String.format("%02d", struAIOPVideo.struTime.wDay) + " " +
+ String.format("%02d", struAIOPVideo.struTime.wHour) + ":" +
+ String.format("%02d", struAIOPVideo.struTime.wMinute) + ":" +
+ String.format("%02d", struAIOPVideo.struTime.wSecond) + "." +
+ String.format("%03d", struAIOPVideo.struTime.wMilliSec);
+ alarmName = "AI寮�鏀惧钩鍙版帴鍏ヨ棰戞娴�";
+ switch (szMPID) {
+ case "H930_MODEL_SPD":
+ alarmType = "鎶界儫鎵撶數璇�";
+ break;
+ }
+ //鍥剧墖鏁版嵁淇濆瓨
+ if (struAIOPVideo.dwPictureSize > 0) {
+ //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ long offset = 0;
+ ByteBuffer buffers = struAIOPVideo.pBufferPicture.getByteBuffer(offset, struAIOPVideo.dwPictureSize);
+ byte[] bytes = new byte[struAIOPVideo.dwPictureSize];
buffers.rewind();
buffers.get(bytes);
InputStream input = new ByteArrayInputStream(bytes);
@@ -334,34 +464,19 @@
boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG");
if (uploadObject) {
picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName);
- //log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
+ //log.debug("涓婁紶鏂囦欢鎴愬姛!" + picUrl);
}
} catch (Exception e) {
- log.error("浜鸿劯鎶撴媿鎶ヨ淇℃伅鍥剧墖淇濆瓨澶辫触" + e.getMessage());
+ log.error("AI寮�鏀惧钩鍙版帴鍏ヨ棰戞娴嬫姤璀︿笂浼犱笂鎶ュ浘鐗囦繚瀛樺け璐�" + e.getMessage());
}
}
- String sAlarmType = "";
- try {
- sAlarmType = "浜鸿劯榛戝悕鍗曟瘮瀵规姤璀︼紝鐩歌瘑搴︼細" + struFaceMatchAlarm.fSimilarity + "锛岄粦鍚嶅崟濮撳悕锛�" +
- new String(struFaceMatchAlarm.struBlockListInfo.struBlockListInfo.struAttribute.byName, "GBK").trim() + "锛岄粦鍚嶅崟璇佷欢淇℃伅锛�" +
- new String(struFaceMatchAlarm.struBlockListInfo.struBlockListInfo.struAttribute.byCertificateNumber).trim();
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
+ if (ardEquipExternal != null) {
+ superBrainEventHandler(ardEquipExternal, struAIOPVideo.dwChannel, alarmName, alarmType, alarmTime, picUrl, "");
}
- log.debug(sAlarmType);
- log.debug("銆愪汉鑴告瘮瀵规姤璀︿俊鎭��:" + " 姣斿缁撴灉:" + contrastStatus + " 姣斿绫诲瀷:" + alarmType + " 鎶ヨ鏃堕棿:" + alarmTime + " 鍖归厤鍥剧墖鏁伴噺锛�" + byMatchPicNum + " 鍥剧墖绫诲瀷锛�" + picTransType + " 姣斿鍥剧墖:" + picUrl);
- FaceMatchEventInfo faceMatchEventInfo = new FaceMatchEventInfo();
- faceMatchEventInfo.setAlarmTime(alarmTime);
- faceMatchEventInfo.setStatus(contrastStatus);
- faceMatchEventInfo.setAlarmType(alarmType);
- publishMqtt(faceMatchEventInfo, "faceMatch");
//endregion
break;
- case COMM_UPLOAD_AIOP_VIDEO:
- log.debug("璁惧鏀寔AI寮�鏀惧钩鍙版帴鍏ワ紝涓婁紶瑙嗛妫�娴嬫暟鎹�(鏆備笉瑙f瀽)");
- break;
case COMM_ISAPI_ALARM:
- log.debug("瀹夊叏甯芥娴嬫姤璀︿俊鎭�");
+ log.debug("瀹夊叏甯芥娴嬫姤璀︿俊鎭笂鎶�");
//region 瀹夊叏甯芥娴嬫姤璀︿俊鎭�
HCNetSDK.NET_DVR_ALARM_ISAPI_INFO struEventISAPI = new HCNetSDK.NET_DVR_ALARM_ISAPI_INFO();
struEventISAPI.write();
@@ -371,22 +486,53 @@
int dwAlarmDataLen = struEventISAPI.dwAlarmDataLen;
int byDataType = struEventISAPI.byDataType;
int byPicturesNumber = struEventISAPI.byPicturesNumber;
-
//澶勭悊瀹夊叏甯芥娴嬩笂浼犵殑鐓х墖鏁版嵁
- HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA struPicData = new HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA();
- struPicData.write();
- Pointer pPicData = struPicData.getPointer();
- pPicData.write(0, struEventISAPI.pPicPackData.getByteArray(0, struPicData.size()), 0,
- struPicData.size());
- struPicData.read();
- log.debug("妫�娴嬪埌瀹夊叏甯戒簨浠�");
+ Pointer pPicPackData = struEventISAPI.pPicPackData;
+ if (pPicPackData != null) {
+ HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA struPicData = new HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA();
+ struPicData.write();
+ if (struPicData.size() > 0) {
+ Pointer pPicData = struPicData.getPointer();
+ pPicData.write(0, pPicPackData.getByteArray(0, struPicData.size()), 0, struPicData.size());
+ struPicData.read();
+ int dwPicLen = struPicData.dwPicLen;
+ pPicData = struPicData.pPicData;
+ if (dwPicLen > 0 && pPicData != null) {
+ //灏嗗瓧鑺傚啓鍏ユ枃浠�
+ long offset = 0;
+ ByteBuffer buffers = pPicData.getByteBuffer(offset, dwPicLen);
+ byte[] bytes = new byte[dwPicLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ InputStream input = new ByteArrayInputStream(bytes);
+ try {
+ String bucketName = "pic";
+ String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg";
+ boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG");
+ if (uploadObject) {
+ picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName);
+ //log.debug("涓婁紶鏂囦欢鎴愬姛!" + picUrl);
+ }
+ } catch (Exception e) {
+ log.error("寮傚父琛屼负璇嗗埆淇℃伅鎶ヨ淇℃伅涓婃姤鍥剧墖淇濆瓨澶辫触" + e.getMessage());
+ }
+ }
+
+ }
+ }
+ if (ardEquipExternal != null) {
+ alarmName = "瀹夊叏甯芥娴�";
+ alarmType = "瀹夊叏甯戒簨浠舵姤璀�";
+ alarmTime = fmt.format(new Date());
+ superBrainEventHandler(ardEquipExternal, 0, alarmName, alarmType, alarmTime, picUrl, "");
+ }
//endregion
break;
case COMM_GISINFO_UPLOAD:
log.debug("GPS鎶ヨ淇℃伅涓婃姤(鏆備笉瑙f瀽)");
break;
case COMM_ALARMHOST_CID_ALARM:
- log.debug("鎶ヨ涓绘満CID鎶ュ憡鎶ヨ涓婃姤");
+ log.debug("鎶ヨ涓绘満CID鎶ュ憡淇℃伅涓婃姤");
//region 鎶ヨ涓绘満鎶ヨ澶勭悊
HCNetSDK.NET_DVR_CID_ALARM netDvrCidAlarm = new HCNetSDK.NET_DVR_CID_ALARM();
netDvrCidAlarm.write();
@@ -464,7 +610,7 @@
//endregion
break;
case HCNetSDK.COMM_ALARM_ACS:
- log.debug("闂ㄧ涓绘満鎶ヨ涓婃姤");
+ log.debug("闂ㄧ涓绘満淇℃伅涓婃姤");
//region 闂ㄧ涓绘満鎶ヨ澶勭悊
HCNetSDK.NET_DVR_ACS_ALARM_INFO strACSInfo = new HCNetSDK.NET_DVR_ACS_ALARM_INFO();
strACSInfo.write();
@@ -495,7 +641,7 @@
alarmTime = DateUtils.convertDate(parseAlarmTime(strACSInfo.struTime), "yyyy-M-d H:m:s");
//浜嬩欢鍥剧墖澶勭悊
- int dwPicDataLen = strACSInfo.dwPicDataLen;
+ dwPicDataLen = strACSInfo.dwPicDataLen;
if (dwPicDataLen > 0) {
try {
//灏嗗瓧鑺傚啓鍏ユ枃浠�
@@ -571,12 +717,107 @@
publishMqtt(accessControlHostEventInfo, "accessControl");
//endregion
break;
+ case COMM_FIREDETECTION_ALARM: //鐏偣妫�娴嬫姤璀�
+ log.debug("鐏偣妫�娴嬩俊鎭笂鎶�");
+ //region 鐏偣妫�娴嬫姤璀�
+ HCNetSDK.NET_DVR_FIREDETECTION_ALARM struFireDecAlarm = new HCNetSDK.NET_DVR_FIREDETECTION_ALARM();
+ struFireDecAlarm.write();
+ Pointer pFireDecAlarm = struFireDecAlarm.getPointer();
+ pFireDecAlarm.write(0, pAlarmInfo.getByteArray(0, struFireDecAlarm.size()), 0, struFireDecAlarm.size());
+ struFireDecAlarm.read();
+ String sFireDecAlarmInfo = "缁濆鏃堕棿锛�" + struFireDecAlarm.dwAbsTime + ",鎶ヨ瀛愮被鍨嬶細" + struFireDecAlarm.byAlarmSubType + ",鐏偣鏈�楂樻俯搴� :" +
+ struFireDecAlarm.wFireMaxTemperature + ",鐏偣鐩爣璺濈锛�" + struFireDecAlarm.wTargetDistance;
+ System.out.println(sFireDecAlarmInfo);
+ //鍥剧墖淇濆瓨
+ if ((struFireDecAlarm.dwPicDataLen > 0) && (struFireDecAlarm.byPicTransType == 0)) {
+ long offset = 0;
+ ByteBuffer buffers = struFireDecAlarm.pBuffer.getByteBuffer(offset, struFireDecAlarm.dwPicDataLen);
+ byte[] bytes = new byte[struFireDecAlarm.dwPicDataLen];
+ buffers.rewind();
+ buffers.get(bytes);
+ InputStream input = new ByteArrayInputStream(bytes);
+ try {
+ String bucketName = "pic";
+ String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg";
+ boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG");
+ if (uploadObject) {
+ picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName);
+ //log.debug("涓婁紶鏂囦欢鎴愬姛!" + picUrl);
+ }
+ } catch (Exception e) {
+ log.error("鐏偣妫�娴嬩簨浠舵姤璀︿笂鎶ョ儹鎴愬儚鍥剧墖淇濆瓨澶辫触" + e.getMessage());
+ }
+
+ }
+ if (ardEquipExternal != null) {
+ alarmName = "鐏劙妫�娴嬩俊鎭笂鎶�";
+ alarmType = "鐏劙妫�娴嬩簨浠舵姤璀�";
+ int dwVisibleChannel = struFireDecAlarm.dwVisibleChannel;
+ alarmTime = DateUtils.parseTime(struFireDecAlarm.dwAbsTime);//鎶ヨ鏃堕棿
+ superBrainEventHandler(ardEquipExternal, dwVisibleChannel, alarmName, alarmType, alarmTime, picUrl, "");
+ }
+ //endregion
+ break;
+ case COMM_ITS_PLATE_RESULT://浜ら�氭姄鎷嶇殑缁堢鍥剧墖涓婁紶
+ log.debug("浜ら�氭姄鎷嶇殑缁堢鍥剧墖涓婃姤(鏆備笉瑙f瀽)");
+ break;
default:
log.debug("鏈煡鎶ヨ浜嬩欢绫诲瀷:lCommand:" + Integer.toHexString(lCommand));
break;
}
return true;
+ }
+
+
+ /**
+ * 鐩告満浜嬩欢澶勭悊
+ * 鍒樿嫃涔�
+ * 2023/12/5 12:56:47
+ */
+ public void cameraEventHandler(ArdCameras camera, String alarmName, String alarmType, String alarmTime, String picUrl) {
+
+ CameraEventInfo cameraEventInfo = new CameraEventInfo();
+ cameraEventInfo.setAlarmName(alarmName);
+ cameraEventInfo.setAlarmTime(alarmTime);
+ cameraEventInfo.setCameraName(camera.getName());
+ cameraEventInfo.setCameraId(camera.getId());
+ cameraEventInfo.setCameraIp(camera.getIp());
+ cameraEventInfo.setCameraPort(camera.getPort());
+ cameraEventInfo.setCameraType(camera.getGdType());
+ cameraEventInfo.setCameraChannel(camera.getChannel());
+ cameraEventInfo.setLongitude(camera.getLongitude());
+ cameraEventInfo.setLatitude(camera.getLatitude());
+ cameraEventInfo.setAlarmType(alarmType);
+ //鍥剧墖瀛樺叆minio
+ if (picUrl.equals("")) {
+ picUrl = snapPicture(cameraEventInfo);
+ }
+ cameraEventInfo.setPicUrl(picUrl);
+ log.debug("澶勭悊閫氱敤鍏夌數浜嬩欢鎶ヨ:銆怤ame銆�" + alarmName + "銆怲ype銆�" + alarmType + "銆怲ime銆�" + alarmTime + "銆怐evice銆�" + camera.getName() + "銆怳rl銆�" + picUrl);
+ publishMqtt(cameraEventInfo, "camera");
+ }
+
+ /**
+ * 瓒呰剳浜嬩欢澶勭悊
+ * 鍒樿嫃涔�
+ * 2023/12/5 12:56:47
+ */
+ public void superBrainEventHandler(ArdEquipExternal superBrainDevice, Integer chanNo, String alarmName, String alarmType, String alarmTime, String picUrl, String faceUrl) {
+
+ SuperBrainEventInfo superBrainEventInfo = new SuperBrainEventInfo();
+ superBrainEventInfo.setAlarmName(alarmName);
+ superBrainEventInfo.setAlarmType(alarmType);
+ superBrainEventInfo.setAlarmTime(alarmTime);
+ superBrainEventInfo.setDeviceId(superBrainDevice.getId());
+ superBrainEventInfo.setDeviceName(superBrainDevice.getName());
+ superBrainEventInfo.setChanNo(chanNo);
+ superBrainEventInfo.setLongitude(superBrainDevice.getLongitude());
+ superBrainEventInfo.setLatitude(superBrainDevice.getLatitude());
+ superBrainEventInfo.setPicUrl(picUrl);
+ superBrainEventInfo.setFaceUrl(faceUrl);
+ log.debug("澶勭悊閫氳秴鑴戜簨浠舵姤璀�:銆怤ame銆�" + alarmName + "銆怲ype銆�" + alarmType + "銆怲ime銆�" + alarmTime + "銆怐evice銆�" + superBrainDevice.getName() + "銆怳rl銆�" + picUrl + "銆恌aceUrl銆�" + faceUrl );
+ publishMqtt(superBrainEventInfo, "superBrain");
}
/**
@@ -604,7 +845,6 @@
.filter(camera -> camera.getIp().equals(ip) && camera.getPort() == port)
.findFirst();
}
-
/**
* 鐩告満鎴浘
@@ -689,4 +929,5 @@
int bySecond = netDvrTimeEx.dwSecond;
return wYear + "-" + byMonth + "-" + byDay + " " + byHour + ":" + byMinute + ":" + bySecond;
}
+
}
--
Gitblit v1.9.3