diff --git a/pom.xml b/pom.xml index 3217db3..3ba8954 100644 --- a/pom.xml +++ b/pom.xml @@ -110,11 +110,11 @@ - - com.sun.jna - jna - 3.0.9 - + + + + + com.sun.jna @@ -122,11 +122,11 @@ 1.0 - - - - - + + net.java.dev.jna + jna + 3.4.0 + diff --git a/src/main/java/com/shxy/xyhkcamera/alarm/AlarmDataParse.java b/src/main/java/com/shxy/xyhkcamera/alarm/AlarmDataParse.java index 1c5a63a..e70c710 100644 --- a/src/main/java/com/shxy/xyhkcamera/alarm/AlarmDataParse.java +++ b/src/main/java/com/shxy/xyhkcamera/alarm/AlarmDataParse.java @@ -1,1555 +1,1555 @@ -package com.shxy.xyhkcamera.alarm; - -import com.shxy.xyhkcamera.hk.HCNetSDK; -import com.sun.jna.Pointer; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * @author jiangxin - * @create 2022-08-15-18:04 - */ -public class AlarmDataParse { - - public static void alarmDataHandle(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) { - System.out.println("报警事件类型: lCommand:" + Integer.toHexString(lCommand)); - String sTime; - String MonitoringSiteID; - HCNetSDK.BYTE_ARRAY byte_array1 = new HCNetSDK.BYTE_ARRAY(25); - byte_array1.write(); - Pointer pbyte_array1 = byte_array1.getPointer(); - pbyte_array1.write(0, pUser.getByteArray(0, byte_array1.size()), 0, byte_array1.size()); - byte_array1.read(); - System.out.println(new String(byte_array1.byValue).trim()); - //lCommand是传的报警类型 - switch (lCommand) { - case HCNetSDK.COMM_ITS_PLATE_RESULT://交通抓拍结果(新报警信息) - HCNetSDK.NET_ITS_PLATE_RESULT strItsPlateResult = new HCNetSDK.NET_ITS_PLATE_RESULT(); - strItsPlateResult.write(); - Pointer pItsPlateInfo = strItsPlateResult.getPointer(); - pItsPlateInfo.write(0, pAlarmInfo.getByteArray(0, strItsPlateResult.size()), 0, strItsPlateResult.size()); - strItsPlateResult.read(); - try { - String sLicense = new String(strItsPlateResult.struPlateInfo.sLicense, "GBK"); - byte VehicleType = strItsPlateResult.byVehicleType; //0-其他车辆,1-小型车,2-大型车,3- 行人触发,4- 二轮车触发,5- 三轮车触发,6- 机动车触发 - MonitoringSiteID = new String(strItsPlateResult.byMonitoringSiteID); - System.out.println("车牌号:" + sLicense + ":车辆类型:" + VehicleType + ":布防点编号:" + MonitoringSiteID); - } catch (UnsupportedEncodingException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - /** - * 报警图片保存,车牌,车辆图片 - */ - for (int i = 0; i < strItsPlateResult.dwPicNum; i++) { - if (strItsPlateResult.struPicInfo[i].dwDataLen > 0) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "_type[" + strItsPlateResult.struPicInfo[i].byType + "]_ItsPlate.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strItsPlateResult.struPicInfo[i].pBuffer.getByteBuffer(offset, strItsPlateResult.struPicInfo[i].dwDataLen); - byte[] bytes = new byte[strItsPlateResult.struPicInfo[i].dwDataLen]; - 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(); - } - } - } - break; - case HCNetSDK.COMM_ALARM_TFS: //道路违章取证报警 - HCNetSDK.NET_DVR_TFS_ALARM strTfsAlarm = new HCNetSDK.NET_DVR_TFS_ALARM(); - strTfsAlarm.write(); - Pointer pTfsAlarm = strTfsAlarm.getPointer(); - pTfsAlarm.write(0, pAlarmInfo.getByteArray(0, strTfsAlarm.size()), 0, strTfsAlarm.size()); - strTfsAlarm.read(); - sTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTfsAlarm.dwAbsTime); //报警绝对时间 - int IllegalType = strTfsAlarm.dwIllegalType; // 违章类型 - MonitoringSiteID = strTfsAlarm.byMonitoringSiteID.toString(); //布防点编号 - // 车牌信息 - try { - String PlateInfo = "车牌号:" + new String(strTfsAlarm.struPlateInfo.sLicense, "GBK"); - System.out.println("【道路违章取证报警】时间:" + sTime + "违章类型:" + IllegalType + "车牌信息:" + PlateInfo); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - //报警图片信息 - for (int i = 0; i < strTfsAlarm.dwPicNum; i++) { - if (strTfsAlarm.struPicInfo[i].dwDataLen > 0) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "_type[" + strTfsAlarm.struPicInfo[i].byType + "]_TfsPlate.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strTfsAlarm.struPicInfo[i].pBuffer.getByteBuffer(offset, strTfsAlarm.struPicInfo[i].dwDataLen); - byte[] bytes = new byte[strTfsAlarm.struPicInfo[i].dwDataLen]; - 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(); - } - } - } - break; - case HCNetSDK.COMM_ALARM_AID_V41: //道路事件检测 - HCNetSDK.NET_DVR_AID_ALARM_V41 strAIDAlarmV41 = new HCNetSDK.NET_DVR_AID_ALARM_V41(); - strAIDAlarmV41.write(); - Pointer pstrAIDAlarmV41 = strAIDAlarmV41.getPointer(); - pstrAIDAlarmV41.write(0, pAlarmInfo.getByteArray(0, strAIDAlarmV41.size()), 0, strAIDAlarmV41.size()); - strAIDAlarmV41.read(); - sTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strAIDAlarmV41.dwAbsTime); //报警触发绝对时间 - MonitoringSiteID = strAIDAlarmV41.byMonitoringSiteID.toString(); //布防点编号 - int AIDType = strAIDAlarmV41.struAIDInfo.dwAIDType; // 交通事件类型 - int AIDTypeEx = strAIDAlarmV41.struAIDInfo.dwAIDTypeEx; //交通事件类型扩展 - System.out.println("【道路事件检测】" + "时间:" + sTime + "布防点:" + MonitoringSiteID + "交通事件类型:" + AIDType + "交通事件类型扩展:" + AIDTypeEx); - //报警图片信息 - if (strAIDAlarmV41.dwPicDataLen > 0 && strAIDAlarmV41.pImage != null) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "_AIDalarm.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strAIDAlarmV41.pImage.getByteBuffer(offset, strAIDAlarmV41.dwPicDataLen); - byte[] bytes = new byte[strAIDAlarmV41.dwPicDataLen]; - 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(); - } - } - break; - case HCNetSDK.COMM_ALARM_TPS_V41://交通数据统计的报警 - HCNetSDK.NET_DVR_TPS_ALARM_V41 strTPSalarmV41 = new HCNetSDK.NET_DVR_TPS_ALARM_V41(); - strTPSalarmV41.write(); - Pointer pstrTPSalarmV41 = strTPSalarmV41.getPointer(); - pstrTPSalarmV41.write(0, pAlarmInfo.getByteArray(0, strTPSalarmV41.size()), 0, strTPSalarmV41.size()); - strTPSalarmV41.read(); - sTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTPSalarmV41.dwAbsTime); - MonitoringSiteID = strTPSalarmV41.byMonitoringSiteID.toString(); //布防点编号 - String StartTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTPSalarmV41.dwStartTime); //开始统计时间; - String StopTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTPSalarmV41.dwStopTime); //结束统计时间; - System.out.println("【交通数据统计】" + "时间:" + sTime + "布防点编号:" + MonitoringSiteID + "开始统计时间:" + StartTime + "结束统计时间:" + StopTime); - //车道统计参数信息 - for (int i = 0; i <= HCNetSDK.MAX_TPS_RULE; i++) { - byte LaneNo = strTPSalarmV41.struTPSInfo.struLaneParam[i].byLaneNo; //车道号 - byte TrafficState = strTPSalarmV41.struTPSInfo.struLaneParam[i].byTrafficState; //车道状态 0-无效,1-畅通,2-拥挤,3-堵塞 - int TpsType = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwTpsType; //数据变化类型标志,表示当前上传的统计参数中,哪些数据有效,按位区分 - int LaneVolume = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwLaneVolume; //车道流量 - int LaneVelocity = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwLaneVelocity; //车道平均速度 - float SpaceOccupyRation = strTPSalarmV41.struTPSInfo.struLaneParam[i].fSpaceOccupyRation; //车道占有率,百分比计算(空间上,车辆长度与布防路段总长度的比值) - System.out.println("车道号:" + LaneNo + "车道状态:" + TrafficState + "车道流量:" + LaneVolume + "车道占有率:" + SpaceOccupyRation + "\n"); - } - break; - case HCNetSDK.COMM_ALARM_TPS_REAL_TIME: //实时过车数据数据 - HCNetSDK.NET_DVR_TPS_REAL_TIME_INFO netDvrTpsParam = new HCNetSDK.NET_DVR_TPS_REAL_TIME_INFO(); - netDvrTpsParam.write(); - Pointer pItsParkVehicle = netDvrTpsParam.getPointer(); - pItsParkVehicle.write(0, pAlarmInfo.getByteArray(0, netDvrTpsParam.size()), 0, netDvrTpsParam.size()); - netDvrTpsParam.read(); - String struTime = "" + String.format("%04d", netDvrTpsParam.struTime.wYear) + - String.format("%02d", netDvrTpsParam.struTime.byMonth) + - String.format("%02d", netDvrTpsParam.struTime.byDay) + - String.format("%02d", netDvrTpsParam.struTime.byDay) + - String.format("%02d", netDvrTpsParam.struTime.byHour) + - String.format("%02d", netDvrTpsParam.struTime.byMinute) + - String.format("%02d", netDvrTpsParam.struTime.bySecond); - Short wDeviceID = new Short(netDvrTpsParam.struTPSRealTimeInfo.wDeviceID);//设备ID - int channel = netDvrTpsParam.dwChan; //触发报警通道号 - String byLane = new String(String.valueOf(netDvrTpsParam.struTPSRealTimeInfo.byLane)).trim();// 对应车道号 - String bySpeed = new String(String.valueOf(netDvrTpsParam.struTPSRealTimeInfo.bySpeed)).trim();// 对应车速(KM/H) - int dwDownwardFlow = netDvrTpsParam.struTPSRealTimeInfo.dwDownwardFlow;//当前车道 从上到下车流量 - int dwUpwardFlow = netDvrTpsParam.struTPSRealTimeInfo.dwUpwardFlow; //当前车道 从下到上车流量 - System.out.println("通道号:" + channel + "; 时间:" + struTime + ";对应车道号:" + byLane + ";当前车道 从上到下车流量:" + dwDownwardFlow + ";dwUpwardFlow:" + dwUpwardFlow); - break; - - case HCNetSDK.COMM_ALARM_TPS_STATISTICS: //统计过车数据 - HCNetSDK.NET_DVR_TPS_STATISTICS_INFO netDvrTpsStatisticsInfo = new HCNetSDK.NET_DVR_TPS_STATISTICS_INFO(); - netDvrTpsStatisticsInfo.write(); - Pointer pTpsVehicle = netDvrTpsStatisticsInfo.getPointer(); - pTpsVehicle.write(0, pAlarmInfo.getByteArray(0, netDvrTpsStatisticsInfo.size()), 0, netDvrTpsStatisticsInfo.size()); - netDvrTpsStatisticsInfo.read(); - int Tpschannel = netDvrTpsStatisticsInfo.dwChan; //触发报警通道号 - //统计开始时间 - String struStartTime = "" + String.format("%04d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.wYear) + - String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byMonth) + - String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byDay) + - String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byDay) + - String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byHour) + - String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byMinute) + - String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.bySecond); - byte TotalLaneNum = netDvrTpsStatisticsInfo.struTPSStatisticsInfo.byTotalLaneNum; //有效车道总数 - System.out.println("通道号:" + Tpschannel + "; 开始统计时间:" + struStartTime + "有效车道总数:" + TotalLaneNum); - break; - case HCNetSDK.COMM_ITS_PARK_VEHICLE: //停车场数据上传 - HCNetSDK.NET_ITS_PARK_VEHICLE strParkVehicle = new HCNetSDK.NET_ITS_PARK_VEHICLE(); - strParkVehicle.write(); - Pointer pstrParkVehicle = strParkVehicle.getPointer(); - pstrParkVehicle.write(0, pAlarmInfo.getByteArray(0, strParkVehicle.size()), 0, strParkVehicle.size()); - strParkVehicle.read(); - try { - byte ParkError = strParkVehicle.byParkError; //停车异常:0- 正常,1- 异常 - String ParkingNo = new String(strParkVehicle.byParkingNo, "UTF-8"); //车位编号 - byte LocationStatus = strParkVehicle.byLocationStatus; //车位车辆状态 0- 无车,1- 有车 - MonitoringSiteID = strParkVehicle.byMonitoringSiteID.toString(); - String plateNo = new String(strParkVehicle.struPlateInfo.sLicense, "GBK"); //车牌号 - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - //报警图片信息 - for (int i = 0; i < strParkVehicle.dwPicNum; i++) { - if (strParkVehicle.struPicInfo[i].dwDataLen > 0) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "_ParkVehicle.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strParkVehicle.struPicInfo[i].pBuffer.getByteBuffer(offset, strParkVehicle.struPicInfo[i].dwDataLen); - byte[] bytes = new byte[strParkVehicle.struPicInfo[i].dwDataLen]; - 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(); - } - } - } - break; - case HCNetSDK.COMM_ALARMHOST_CID_ALARM://报警主机CID报告报警上传 - HCNetSDK.NET_DVR_CID_ALARM strCIDalarm = new HCNetSDK.NET_DVR_CID_ALARM(); - strCIDalarm.write(); - Pointer pstrCIDalarm = strCIDalarm.getPointer(); - pstrCIDalarm.write(0, pAlarmInfo.getByteArray(0, strCIDalarm.size()), 0, strCIDalarm.size()); - strCIDalarm.read(); - try { - String TriggerTime = "" + String.format("%04d", strCIDalarm.struTriggerTime.wYear) + - String.format("%02d", strCIDalarm.struTriggerTime.byMonth) + - String.format("%02d", strCIDalarm.struTriggerTime.byDay) + - String.format("%02d", strCIDalarm.struTriggerTime.byDay) + - String.format("%02d", strCIDalarm.struTriggerTime.byHour) + - String.format("%02d", strCIDalarm.struTriggerTime.byMinute) + - String.format("%02d", strCIDalarm.struTriggerTime.bySecond); //触发报警时间 - String sCIDCode = new String(strCIDalarm.sCIDCode, "GBK"); //CID事件号 - String sCIDDescribe = new String(strCIDalarm.sCIDDescribe, "GBK"); //CID事件名 - byte bySubSysNo = strCIDalarm.bySubSysNo; //子系统号 - if (strCIDalarm.wDefenceNo != 0xff) - { - System.out.println("防区号:"+Integer.sum(strCIDalarm.wDefenceNo,1)); - } - System.out.println("【CID事件】" + "触发时间:" + TriggerTime + "CID事件号:" + sCIDCode + "CID事件名:" + sCIDDescribe + "子系统号:" + - bySubSysNo); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - break; - case HCNetSDK.COMM_IPC_AUXALARM_RESULT: //PIR报警、无线报警、呼救报警信息 - System.out.println("PIR报警、无线报警、呼救报警触发"); - break; - case HCNetSDK.COMM_ISAPI_ALARM: //ISAPI协议报警信息 - HCNetSDK.NET_DVR_ALARM_ISAPI_INFO struEventISAPI = new HCNetSDK.NET_DVR_ALARM_ISAPI_INFO(); - struEventISAPI.write(); - Pointer pEventISAPI = struEventISAPI.getPointer(); - pEventISAPI.write(0, pAlarmInfo.getByteArray(0, struEventISAPI.size()), 0, struEventISAPI.size()); - struEventISAPI.read(); - String sAlarmInfo = new String(pAlarmer.sDeviceIP).trim(); - //报警数据类型:0- invalid,1- xml,2- json - sAlarmInfo = "报警设备IP:" + sAlarmInfo + ":ISAPI协议报警信息, 数据格式:" + struEventISAPI.byDataType + - ", 图片个数:" + struEventISAPI.byPicturesNumber; - System.out.println(sAlarmInfo); - SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMddHHmmss"); - String curTime1 = sf1.format(new Date()); - //报警数据打印 - HCNetSDK.BYTE_ARRAY m_strISAPIData = new HCNetSDK.BYTE_ARRAY(struEventISAPI.dwAlarmDataLen); - m_strISAPIData.write(); - Pointer pPlateInfo = m_strISAPIData.getPointer(); - pPlateInfo.write(0, struEventISAPI.pAlarmData.getByteArray(0, m_strISAPIData.size()), 0, m_strISAPIData.size()); - m_strISAPIData.read(); - System.out.println(new String(m_strISAPIData.byValue).trim() +"\n"); -/* - FileOutputStream foutdata; - try { - String jsonfilename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + curTime1 + "_ISAPI_Alarm_" + ".json"; - foutdata = new FileOutputStream(jsonfilename); - //将字节写入文件 - ByteBuffer jsonbuffers = struEventISAPI.pAlarmData.getByteBuffer(0, struEventISAPI.dwAlarmDataLen); - byte[] jsonbytes = new byte[struEventISAPI.dwAlarmDataLen]; - jsonbuffers.rewind(); - jsonbuffers.get(jsonbytes); - foutdata.write(jsonbytes); - foutdata.close(); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ - //图片数据保存 - for (int i = 0; i < struEventISAPI.byPicturesNumber; i++) { - 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(i * struPicData.size(), struPicData.size()), 0, struPicData.size()); - struPicData.read(); - - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + curTime1 + - "_ISAPIPic_" + i + "_" + new String(struPicData.szFilename).trim() + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struPicData.pPicData.getByteBuffer(offset, struPicData.dwPicLen); - byte[] bytes = new byte[struPicData.dwPicLen]; - 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(); - } - } - break; - case HCNetSDK.COMM_VCA_ALARM: // 智能检测通用报警(Json或者XML数据结构) - sAlarmInfo = new String(pAlarmer.sDeviceIP); - //报警数据类型:0- invalid,1- xml,2- json - sAlarmInfo = "报警设备IP:" + sAlarmInfo; - System.out.println(sAlarmInfo); - - SimpleDateFormat sf0 = new SimpleDateFormat("yyyyMMddHHmmss"); - String curTime0 = sf0.format(new Date()); - FileOutputStream Data; - String jsonfile = "../pic" + new String(pAlarmer.sDeviceIP).trim() + curTime0 + "_VCA_ALARM_" + ".json"; - try { - Data = new FileOutputStream(jsonfile); - //将字节写入文件 - ByteBuffer dataBuffer = pAlarmInfo.getByteBuffer(0, dwBufLen); - byte[] dataByte = new byte[dwBufLen]; - dataBuffer.rewind(); - dataBuffer.get(dataByte); - Data.write(dataByte); - Data.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - break; - - //异常行为检测信息 - case HCNetSDK.COMM_ALARM_RULE: - HCNetSDK.NET_VCA_RULE_ALARM strVcaAlarm = new HCNetSDK.NET_VCA_RULE_ALARM(); - strVcaAlarm.write(); - Pointer pVCAInfo = strVcaAlarm.getPointer(); - pVCAInfo.write(0, pAlarmInfo.getByteArray(0, strVcaAlarm.size()), 0, strVcaAlarm.size()); - strVcaAlarm.read(); - - switch (strVcaAlarm.struRuleInfo.wEventTypeEx) { - case 1: //穿越警戒面 (越界侦测) - System.out.println("越界侦测报警发生"); - strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_TRAVERSE_PLANE.class); - System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struTraversePlane.byDetectionTarget); //检测目标,0表示所有目标(表示不锁定检测目标,所有目标都将进行检测),其他取值按位表示不同的检测目标:0x01-人,0x02-车 - //图片保存 - if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "VCA_TRAVERSE_PLANE" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); - byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; - 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(); - } - } - break; - case 2: //目标进入区域 - System.out.println("目标进入区域报警发生"); - strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); - System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struArea.byDetectionTarget); - //图片保存 - if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "_TargetEnter" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); - byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; - 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(); - } - } - break; - case 3: //目标离开区域 - System.out.println("目标离开区域报警触发"); - strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); - System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struArea.byDetectionTarget); - //图片保存 - if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "_TargetLeave" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); - byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; - 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(); - } - } - break; - case 4: //周界入侵 - System.out.println("周界入侵报警发生"); - strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_INTRUSION.class); - System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struIntrusion.byDetectionTarget); - //图片保存 - if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "VCA_INTRUSION" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); - byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; - 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(); - } - } - break; - case 5: //徘徊 - System.out.println("徘徊事件触发"); - - break; - case 8: //快速移动(奔跑), - System.out.println("快速移动(奔跑)事件触发"); - break; - case 15: - System.out.println("事件触发"); - strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_LEAVE_POSITION.class); - System.out.println(strVcaAlarm.struRuleInfo.uEventParam.struLeavePos.byOnPosition); - //图片保存 - if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "VCA_LEAVE_POSITION_" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); - byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; - 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(); - } - } - case 20: //倒地检测 - System.out.println("倒地事件触发"); - break; - case 44: //玩手机 - - System.out.println("玩手机报警发生"); - //图片保存 - if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "PLAY_CELLPHONE_" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); - byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; - 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(); - } - } - break; - case 45: //持续检测 - System.out.println("持续检测事件触发"); - default: - System.out.println("行为事件类型:" + strVcaAlarm.struRuleInfo.wEventTypeEx); - break; - } - break; - case HCNetSDK.COMM_ALARM_ACS: //门禁主机报警信息 - HCNetSDK.NET_DVR_ACS_ALARM_INFO strACSInfo = new HCNetSDK.NET_DVR_ACS_ALARM_INFO(); - strACSInfo.write(); - Pointer pACSInfo = strACSInfo.getPointer(); - pACSInfo.write(0, pAlarmInfo.getByteArray(0, strACSInfo.size()), 0, strACSInfo.size()); - strACSInfo.read(); - /**门禁事件的详细信息解析,通过主次类型的可以判断当前的具体门禁类型,例如(主类型:0X5 次类型:0x4b 表示人脸认证通过, - 主类型:0X5 次类型:0x4c 表示人脸认证失败)*/ - System.out.println("【门禁主机报警信息】卡号:" + new String(strACSInfo.struAcsEventInfo.byCardNo).trim() + ",卡类型:" + - strACSInfo.struAcsEventInfo.byCardType + ",报警主类型:" + Integer.toHexString(strACSInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strACSInfo.dwMinor)); - System.out.println("工号1:" + strACSInfo.struAcsEventInfo.dwEmployeeNo); - //温度信息(如果设备支持测温功能,人脸温度信息从NET_DVR_ACS_EVENT_INFO_EXTEND_V20结构体获取) - if (strACSInfo.byAcsEventInfoExtendV20 == 1) { - HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20 strAcsInfoExV20 = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20(); - strAcsInfoExV20.write(); - Pointer pAcsInfoExV20 = strAcsInfoExV20.getPointer(); - pAcsInfoExV20.write(0, strACSInfo.pAcsEventInfoExtendV20.getByteArray(0, strAcsInfoExV20.size()), 0, strAcsInfoExV20.size()); - strAcsInfoExV20.read(); - System.out.println("实时温度值:" + strAcsInfoExV20.fCurrTemperature); - } - //考勤状态 - if (strACSInfo.byAcsEventInfoExtend == 1) { - HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND strAcsInfoEx = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND(); - strAcsInfoEx.write(); - Pointer pAcsInfoEx = strAcsInfoEx.getPointer(); - pAcsInfoEx.write(0, strACSInfo.pAcsEventInfoExtend.getByteArray(0, strAcsInfoEx.size()), 0, strAcsInfoEx.size()); - strAcsInfoEx.read(); - System.out.println("考勤状态:" + strAcsInfoEx.byAttendanceStatus); - System.out.println("工号2:" + new String(strAcsInfoEx.byEmployeeNo).trim()); - } - - /** - * 报警时间 - */ - String year = Integer.toString(strACSInfo.struTime.dwYear); - String SwipeTime = year + strACSInfo.struTime.dwMonth + strACSInfo.struTime.dwDay + strACSInfo.struTime.dwHour + strACSInfo.struTime.dwMinute + - strACSInfo.struTime.dwSecond; - if (strACSInfo.dwPicDataLen > 0) { +//package com.shxy.xyhkcamera.alarm; +// +//import com.shxy.xyhkcamera.hk.HCNetSDK; +//import com.sun.jna.Pointer; +// +//import java.io.FileNotFoundException; +//import java.io.FileOutputStream; +//import java.io.IOException; +//import java.io.UnsupportedEncodingException; +//import java.nio.ByteBuffer; +//import java.text.SimpleDateFormat; +//import java.util.Date; +// +///** +// * @author jiangxin +// * @create 2022-08-15-18:04 +// */ +//public class AlarmDataParse { +// +// public static void alarmDataHandle(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) { +// System.out.println("报警事件类型: lCommand:" + Integer.toHexString(lCommand)); +// String sTime; +// String MonitoringSiteID; +// HCNetSDK.BYTE_ARRAY byte_array1 = new HCNetSDK.BYTE_ARRAY(25); +// byte_array1.write(); +// Pointer pbyte_array1 = byte_array1.getPointer(); +// pbyte_array1.write(0, pUser.getByteArray(0, byte_array1.size()), 0, byte_array1.size()); +// byte_array1.read(); +// System.out.println(new String(byte_array1.byValue).trim()); +// //lCommand是传的报警类型 +// switch (lCommand) { +// case HCNetSDK.COMM_ITS_PLATE_RESULT://交通抓拍结果(新报警信息) +// HCNetSDK.NET_ITS_PLATE_RESULT strItsPlateResult = new HCNetSDK.NET_ITS_PLATE_RESULT(); +// strItsPlateResult.write(); +// Pointer pItsPlateInfo = strItsPlateResult.getPointer(); +// pItsPlateInfo.write(0, pAlarmInfo.getByteArray(0, strItsPlateResult.size()), 0, strItsPlateResult.size()); +// strItsPlateResult.read(); +// try { +// String sLicense = new String(strItsPlateResult.struPlateInfo.sLicense, "GBK"); +// byte VehicleType = strItsPlateResult.byVehicleType; //0-其他车辆,1-小型车,2-大型车,3- 行人触发,4- 二轮车触发,5- 三轮车触发,6- 机动车触发 +// MonitoringSiteID = new String(strItsPlateResult.byMonitoringSiteID); +// System.out.println("车牌号:" + sLicense + ":车辆类型:" + VehicleType + ":布防点编号:" + MonitoringSiteID); +// } catch (UnsupportedEncodingException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// /** +// * 报警图片保存,车牌,车辆图片 +// */ +// for (int i = 0; i < strItsPlateResult.dwPicNum; i++) { +// if (strItsPlateResult.struPicInfo[i].dwDataLen > 0) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_type[" + strItsPlateResult.struPicInfo[i].byType + "]_ItsPlate.jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strItsPlateResult.struPicInfo[i].pBuffer.getByteBuffer(offset, strItsPlateResult.struPicInfo[i].dwDataLen); +// byte[] bytes = new byte[strItsPlateResult.struPicInfo[i].dwDataLen]; +// 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(); +// } +// } +// } +// break; +// case HCNetSDK.COMM_ALARM_TFS: //道路违章取证报警 +// HCNetSDK.NET_DVR_TFS_ALARM strTfsAlarm = new HCNetSDK.NET_DVR_TFS_ALARM(); +// strTfsAlarm.write(); +// Pointer pTfsAlarm = strTfsAlarm.getPointer(); +// pTfsAlarm.write(0, pAlarmInfo.getByteArray(0, strTfsAlarm.size()), 0, strTfsAlarm.size()); +// strTfsAlarm.read(); +// sTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTfsAlarm.dwAbsTime); //报警绝对时间 +// int IllegalType = strTfsAlarm.dwIllegalType; // 违章类型 +// MonitoringSiteID = strTfsAlarm.byMonitoringSiteID.toString(); //布防点编号 +// // 车牌信息 +// try { +// String PlateInfo = "车牌号:" + new String(strTfsAlarm.struPlateInfo.sLicense, "GBK"); +// System.out.println("【道路违章取证报警】时间:" + sTime + "违章类型:" + IllegalType + "车牌信息:" + PlateInfo); +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } +// //报警图片信息 +// for (int i = 0; i < strTfsAlarm.dwPicNum; i++) { +// if (strTfsAlarm.struPicInfo[i].dwDataLen > 0) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_type[" + strTfsAlarm.struPicInfo[i].byType + "]_TfsPlate.jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strTfsAlarm.struPicInfo[i].pBuffer.getByteBuffer(offset, strTfsAlarm.struPicInfo[i].dwDataLen); +// byte[] bytes = new byte[strTfsAlarm.struPicInfo[i].dwDataLen]; +// 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(); +// } +// } +// } +// break; +// case HCNetSDK.COMM_ALARM_AID_V41: //道路事件检测 +// HCNetSDK.NET_DVR_AID_ALARM_V41 strAIDAlarmV41 = new HCNetSDK.NET_DVR_AID_ALARM_V41(); +// strAIDAlarmV41.write(); +// Pointer pstrAIDAlarmV41 = strAIDAlarmV41.getPointer(); +// pstrAIDAlarmV41.write(0, pAlarmInfo.getByteArray(0, strAIDAlarmV41.size()), 0, strAIDAlarmV41.size()); +// strAIDAlarmV41.read(); +// sTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strAIDAlarmV41.dwAbsTime); //报警触发绝对时间 +// MonitoringSiteID = strAIDAlarmV41.byMonitoringSiteID.toString(); //布防点编号 +// int AIDType = strAIDAlarmV41.struAIDInfo.dwAIDType; // 交通事件类型 +// int AIDTypeEx = strAIDAlarmV41.struAIDInfo.dwAIDTypeEx; //交通事件类型扩展 +// System.out.println("【道路事件检测】" + "时间:" + sTime + "布防点:" + MonitoringSiteID + "交通事件类型:" + AIDType + "交通事件类型扩展:" + AIDTypeEx); +// //报警图片信息 +// if (strAIDAlarmV41.dwPicDataLen > 0 && strAIDAlarmV41.pImage != null) { // SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); // String newName = sf.format(new Date()); - FileOutputStream fout; - try { - /** - * 人脸保存路径 - */ - String filename = "../pic/" + SwipeTime + "_ACS_Event_" + new String(strACSInfo.struAcsEventInfo.byCardNo).trim() + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strACSInfo.pPicData.getByteBuffer(offset, strACSInfo.dwPicDataLen); - byte[] bytes = new byte[strACSInfo.dwPicDataLen]; - 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(); - } - } - break; - - case HCNetSDK.COMM_ID_INFO_ALARM: //身份证信息 - HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM strIDCardInfo = new HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM(); - strIDCardInfo.write(); - Pointer pIDCardInfo = strIDCardInfo.getPointer(); - pIDCardInfo.write(0, pAlarmInfo.getByteArray(0, strIDCardInfo.size()), 0, strIDCardInfo.size()); - strIDCardInfo.read(); - System.out.println("报警主类型:" + Integer.toHexString(strIDCardInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strIDCardInfo.dwMinor)); - /** - * 身份证信息 - */ - String IDnum = new String(strIDCardInfo.struIDCardCfg.byIDNum).trim(); - System.out.println("【身份证信息】:身份证号码:" + IDnum + ",姓名:" + - new String(strIDCardInfo.struIDCardCfg.byName).trim() + ",住址:" + new String(strIDCardInfo.struIDCardCfg.byAddr)); - - /** - * 报警时间 - */ - String year1 = Integer.toString(strIDCardInfo.struSwipeTime.wYear); - String SwipeTime1 = year1 + strIDCardInfo.struSwipeTime.byMonth + strIDCardInfo.struSwipeTime.byDay + strIDCardInfo.struSwipeTime.byHour + strIDCardInfo.struSwipeTime.byMinute + - strIDCardInfo.struSwipeTime.bySecond; - /** - * 保存图片 - */ - //身份证图片 - if (strIDCardInfo.dwPicDataLen > 0 || strIDCardInfo.pPicData != null) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_AIDalarm.jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strAIDAlarmV41.pImage.getByteBuffer(offset, strAIDAlarmV41.dwPicDataLen); +// byte[] bytes = new byte[strAIDAlarmV41.dwPicDataLen]; +// 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(); +// } +// } +// break; +// case HCNetSDK.COMM_ALARM_TPS_V41://交通数据统计的报警 +// HCNetSDK.NET_DVR_TPS_ALARM_V41 strTPSalarmV41 = new HCNetSDK.NET_DVR_TPS_ALARM_V41(); +// strTPSalarmV41.write(); +// Pointer pstrTPSalarmV41 = strTPSalarmV41.getPointer(); +// pstrTPSalarmV41.write(0, pAlarmInfo.getByteArray(0, strTPSalarmV41.size()), 0, strTPSalarmV41.size()); +// strTPSalarmV41.read(); +// sTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTPSalarmV41.dwAbsTime); +// MonitoringSiteID = strTPSalarmV41.byMonitoringSiteID.toString(); //布防点编号 +// String StartTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTPSalarmV41.dwStartTime); //开始统计时间; +// String StopTime = com.shxy.xyhkcamera.utils.CommonUtil.parseTime(strTPSalarmV41.dwStopTime); //结束统计时间; +// System.out.println("【交通数据统计】" + "时间:" + sTime + "布防点编号:" + MonitoringSiteID + "开始统计时间:" + StartTime + "结束统计时间:" + StopTime); +// //车道统计参数信息 +// for (int i = 0; i <= HCNetSDK.MAX_TPS_RULE; i++) { +// byte LaneNo = strTPSalarmV41.struTPSInfo.struLaneParam[i].byLaneNo; //车道号 +// byte TrafficState = strTPSalarmV41.struTPSInfo.struLaneParam[i].byTrafficState; //车道状态 0-无效,1-畅通,2-拥挤,3-堵塞 +// int TpsType = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwTpsType; //数据变化类型标志,表示当前上传的统计参数中,哪些数据有效,按位区分 +// int LaneVolume = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwLaneVolume; //车道流量 +// int LaneVelocity = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwLaneVelocity; //车道平均速度 +// float SpaceOccupyRation = strTPSalarmV41.struTPSInfo.struLaneParam[i].fSpaceOccupyRation; //车道占有率,百分比计算(空间上,车辆长度与布防路段总长度的比值) +// System.out.println("车道号:" + LaneNo + "车道状态:" + TrafficState + "车道流量:" + LaneVolume + "车道占有率:" + SpaceOccupyRation + "\n"); +// } +// break; +// case HCNetSDK.COMM_ALARM_TPS_REAL_TIME: //实时过车数据数据 +// HCNetSDK.NET_DVR_TPS_REAL_TIME_INFO netDvrTpsParam = new HCNetSDK.NET_DVR_TPS_REAL_TIME_INFO(); +// netDvrTpsParam.write(); +// Pointer pItsParkVehicle = netDvrTpsParam.getPointer(); +// pItsParkVehicle.write(0, pAlarmInfo.getByteArray(0, netDvrTpsParam.size()), 0, netDvrTpsParam.size()); +// netDvrTpsParam.read(); +// String struTime = "" + String.format("%04d", netDvrTpsParam.struTime.wYear) + +// String.format("%02d", netDvrTpsParam.struTime.byMonth) + +// String.format("%02d", netDvrTpsParam.struTime.byDay) + +// String.format("%02d", netDvrTpsParam.struTime.byDay) + +// String.format("%02d", netDvrTpsParam.struTime.byHour) + +// String.format("%02d", netDvrTpsParam.struTime.byMinute) + +// String.format("%02d", netDvrTpsParam.struTime.bySecond); +// Short wDeviceID = new Short(netDvrTpsParam.struTPSRealTimeInfo.wDeviceID);//设备ID +// int channel = netDvrTpsParam.dwChan; //触发报警通道号 +// String byLane = new String(String.valueOf(netDvrTpsParam.struTPSRealTimeInfo.byLane)).trim();// 对应车道号 +// String bySpeed = new String(String.valueOf(netDvrTpsParam.struTPSRealTimeInfo.bySpeed)).trim();// 对应车速(KM/H) +// int dwDownwardFlow = netDvrTpsParam.struTPSRealTimeInfo.dwDownwardFlow;//当前车道 从上到下车流量 +// int dwUpwardFlow = netDvrTpsParam.struTPSRealTimeInfo.dwUpwardFlow; //当前车道 从下到上车流量 +// System.out.println("通道号:" + channel + "; 时间:" + struTime + ";对应车道号:" + byLane + ";当前车道 从上到下车流量:" + dwDownwardFlow + ";dwUpwardFlow:" + dwUpwardFlow); +// break; +// +// case HCNetSDK.COMM_ALARM_TPS_STATISTICS: //统计过车数据 +// HCNetSDK.NET_DVR_TPS_STATISTICS_INFO netDvrTpsStatisticsInfo = new HCNetSDK.NET_DVR_TPS_STATISTICS_INFO(); +// netDvrTpsStatisticsInfo.write(); +// Pointer pTpsVehicle = netDvrTpsStatisticsInfo.getPointer(); +// pTpsVehicle.write(0, pAlarmInfo.getByteArray(0, netDvrTpsStatisticsInfo.size()), 0, netDvrTpsStatisticsInfo.size()); +// netDvrTpsStatisticsInfo.read(); +// int Tpschannel = netDvrTpsStatisticsInfo.dwChan; //触发报警通道号 +// //统计开始时间 +// String struStartTime = "" + String.format("%04d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.wYear) + +// String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byMonth) + +// String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byDay) + +// String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byDay) + +// String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byHour) + +// String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byMinute) + +// String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.bySecond); +// byte TotalLaneNum = netDvrTpsStatisticsInfo.struTPSStatisticsInfo.byTotalLaneNum; //有效车道总数 +// System.out.println("通道号:" + Tpschannel + "; 开始统计时间:" + struStartTime + "有效车道总数:" + TotalLaneNum); +// break; +// case HCNetSDK.COMM_ITS_PARK_VEHICLE: //停车场数据上传 +// HCNetSDK.NET_ITS_PARK_VEHICLE strParkVehicle = new HCNetSDK.NET_ITS_PARK_VEHICLE(); +// strParkVehicle.write(); +// Pointer pstrParkVehicle = strParkVehicle.getPointer(); +// pstrParkVehicle.write(0, pAlarmInfo.getByteArray(0, strParkVehicle.size()), 0, strParkVehicle.size()); +// strParkVehicle.read(); +// try { +// byte ParkError = strParkVehicle.byParkError; //停车异常:0- 正常,1- 异常 +// String ParkingNo = new String(strParkVehicle.byParkingNo, "UTF-8"); //车位编号 +// byte LocationStatus = strParkVehicle.byLocationStatus; //车位车辆状态 0- 无车,1- 有车 +// MonitoringSiteID = strParkVehicle.byMonitoringSiteID.toString(); +// String plateNo = new String(strParkVehicle.struPlateInfo.sLicense, "GBK"); //车牌号 +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } +// //报警图片信息 +// for (int i = 0; i < strParkVehicle.dwPicNum; i++) { +// if (strParkVehicle.struPicInfo[i].dwDataLen > 0) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_ParkVehicle.jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strParkVehicle.struPicInfo[i].pBuffer.getByteBuffer(offset, strParkVehicle.struPicInfo[i].dwDataLen); +// byte[] bytes = new byte[strParkVehicle.struPicInfo[i].dwDataLen]; +// 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(); +// } +// } +// } +// break; +// case HCNetSDK.COMM_ALARMHOST_CID_ALARM://报警主机CID报告报警上传 +// HCNetSDK.NET_DVR_CID_ALARM strCIDalarm = new HCNetSDK.NET_DVR_CID_ALARM(); +// strCIDalarm.write(); +// Pointer pstrCIDalarm = strCIDalarm.getPointer(); +// pstrCIDalarm.write(0, pAlarmInfo.getByteArray(0, strCIDalarm.size()), 0, strCIDalarm.size()); +// strCIDalarm.read(); +// try { +// String TriggerTime = "" + String.format("%04d", strCIDalarm.struTriggerTime.wYear) + +// String.format("%02d", strCIDalarm.struTriggerTime.byMonth) + +// String.format("%02d", strCIDalarm.struTriggerTime.byDay) + +// String.format("%02d", strCIDalarm.struTriggerTime.byDay) + +// String.format("%02d", strCIDalarm.struTriggerTime.byHour) + +// String.format("%02d", strCIDalarm.struTriggerTime.byMinute) + +// String.format("%02d", strCIDalarm.struTriggerTime.bySecond); //触发报警时间 +// String sCIDCode = new String(strCIDalarm.sCIDCode, "GBK"); //CID事件号 +// String sCIDDescribe = new String(strCIDalarm.sCIDDescribe, "GBK"); //CID事件名 +// byte bySubSysNo = strCIDalarm.bySubSysNo; //子系统号 +// if (strCIDalarm.wDefenceNo != 0xff) +// { +// System.out.println("防区号:"+Integer.sum(strCIDalarm.wDefenceNo,1)); +// } +// System.out.println("【CID事件】" + "触发时间:" + TriggerTime + "CID事件号:" + sCIDCode + "CID事件名:" + sCIDDescribe + "子系统号:" + +// bySubSysNo); +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } +// break; +// case HCNetSDK.COMM_IPC_AUXALARM_RESULT: //PIR报警、无线报警、呼救报警信息 +// System.out.println("PIR报警、无线报警、呼救报警触发"); +// break; +// case HCNetSDK.COMM_ISAPI_ALARM: //ISAPI协议报警信息 +// HCNetSDK.NET_DVR_ALARM_ISAPI_INFO struEventISAPI = new HCNetSDK.NET_DVR_ALARM_ISAPI_INFO(); +// struEventISAPI.write(); +// Pointer pEventISAPI = struEventISAPI.getPointer(); +// pEventISAPI.write(0, pAlarmInfo.getByteArray(0, struEventISAPI.size()), 0, struEventISAPI.size()); +// struEventISAPI.read(); +// String sAlarmInfo = new String(pAlarmer.sDeviceIP).trim(); +// //报警数据类型:0- invalid,1- xml,2- json +// sAlarmInfo = "报警设备IP:" + sAlarmInfo + ":ISAPI协议报警信息, 数据格式:" + struEventISAPI.byDataType + +// ", 图片个数:" + struEventISAPI.byPicturesNumber; +// System.out.println(sAlarmInfo); +// SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMddHHmmss"); +// String curTime1 = sf1.format(new Date()); +// //报警数据打印 +// HCNetSDK.BYTE_ARRAY m_strISAPIData = new HCNetSDK.BYTE_ARRAY(struEventISAPI.dwAlarmDataLen); +// m_strISAPIData.write(); +// Pointer pPlateInfo = m_strISAPIData.getPointer(); +// pPlateInfo.write(0, struEventISAPI.pAlarmData.getByteArray(0, m_strISAPIData.size()), 0, m_strISAPIData.size()); +// m_strISAPIData.read(); +// System.out.println(new String(m_strISAPIData.byValue).trim() +"\n"); +///* +// FileOutputStream foutdata; +// try { +// String jsonfilename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + curTime1 + "_ISAPI_Alarm_" + ".json"; +// foutdata = new FileOutputStream(jsonfilename); +// //将字节写入文件 +// ByteBuffer jsonbuffers = struEventISAPI.pAlarmData.getByteBuffer(0, struEventISAPI.dwAlarmDataLen); +// byte[] jsonbytes = new byte[struEventISAPI.dwAlarmDataLen]; +// jsonbuffers.rewind(); +// jsonbuffers.get(jsonbytes); +// foutdata.write(jsonbytes); +// foutdata.close(); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// }*/ +// //图片数据保存 +// for (int i = 0; i < struEventISAPI.byPicturesNumber; i++) { +// 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(i * struPicData.size(), struPicData.size()), 0, struPicData.size()); +// struPicData.read(); +// +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + curTime1 + +// "_ISAPIPic_" + i + "_" + new String(struPicData.szFilename).trim() + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struPicData.pPicData.getByteBuffer(offset, struPicData.dwPicLen); +// byte[] bytes = new byte[struPicData.dwPicLen]; +// 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(); +// } +// } +// break; +// case HCNetSDK.COMM_VCA_ALARM: // 智能检测通用报警(Json或者XML数据结构) +// sAlarmInfo = new String(pAlarmer.sDeviceIP); +// //报警数据类型:0- invalid,1- xml,2- json +// sAlarmInfo = "报警设备IP:" + sAlarmInfo; +// System.out.println(sAlarmInfo); +// +// SimpleDateFormat sf0 = new SimpleDateFormat("yyyyMMddHHmmss"); +// String curTime0 = sf0.format(new Date()); +// FileOutputStream Data; +// String jsonfile = "../pic" + new String(pAlarmer.sDeviceIP).trim() + curTime0 + "_VCA_ALARM_" + ".json"; +// try { +// Data = new FileOutputStream(jsonfile); +// //将字节写入文件 +// ByteBuffer dataBuffer = pAlarmInfo.getByteBuffer(0, dwBufLen); +// byte[] dataByte = new byte[dwBufLen]; +// dataBuffer.rewind(); +// dataBuffer.get(dataByte); +// Data.write(dataByte); +// Data.close(); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// break; +// +// //异常行为检测信息 +// case HCNetSDK.COMM_ALARM_RULE: +// HCNetSDK.NET_VCA_RULE_ALARM strVcaAlarm = new HCNetSDK.NET_VCA_RULE_ALARM(); +// strVcaAlarm.write(); +// Pointer pVCAInfo = strVcaAlarm.getPointer(); +// pVCAInfo.write(0, pAlarmInfo.getByteArray(0, strVcaAlarm.size()), 0, strVcaAlarm.size()); +// strVcaAlarm.read(); +// +// switch (strVcaAlarm.struRuleInfo.wEventTypeEx) { +// case 1: //穿越警戒面 (越界侦测) +// System.out.println("越界侦测报警发生"); +// strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_TRAVERSE_PLANE.class); +// System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struTraversePlane.byDetectionTarget); //检测目标,0表示所有目标(表示不锁定检测目标,所有目标都将进行检测),其他取值按位表示不同的检测目标:0x01-人,0x02-车 +// //图片保存 +// if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "VCA_TRAVERSE_PLANE" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); +// byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; +// 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(); +// } +// } +// break; +// case 2: //目标进入区域 +// System.out.println("目标进入区域报警发生"); +// strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); +// System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struArea.byDetectionTarget); +// //图片保存 +// if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_TargetEnter" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); +// byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; +// 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(); +// } +// } +// break; +// case 3: //目标离开区域 +// System.out.println("目标离开区域报警触发"); +// strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); +// System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struArea.byDetectionTarget); +// //图片保存 +// if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_TargetLeave" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); +// byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; +// 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(); +// } +// } +// break; +// case 4: //周界入侵 +// System.out.println("周界入侵报警发生"); +// strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_INTRUSION.class); +// System.out.println("检测目标:"+strVcaAlarm.struRuleInfo.uEventParam.struIntrusion.byDetectionTarget); +// //图片保存 +// if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "VCA_INTRUSION" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); +// byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; +// 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(); +// } +// } +// break; +// case 5: //徘徊 +// System.out.println("徘徊事件触发"); +// +// break; +// case 8: //快速移动(奔跑), +// System.out.println("快速移动(奔跑)事件触发"); +// break; +// case 15: +// System.out.println("事件触发"); +// strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_LEAVE_POSITION.class); +// System.out.println(strVcaAlarm.struRuleInfo.uEventParam.struLeavePos.byOnPosition); +// //图片保存 +// if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "VCA_LEAVE_POSITION_" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); +// byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; +// 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(); +// } +// } +// case 20: //倒地检测 +// System.out.println("倒地事件触发"); +// break; +// case 44: //玩手机 +// +// System.out.println("玩手机报警发生"); +// //图片保存 +// if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "PLAY_CELLPHONE_" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, strVcaAlarm.dwPicDataLen); +// byte[] bytes = new byte[strVcaAlarm.dwPicDataLen]; +// 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(); +// } +// } +// break; +// case 45: //持续检测 +// System.out.println("持续检测事件触发"); +// default: +// System.out.println("行为事件类型:" + strVcaAlarm.struRuleInfo.wEventTypeEx); +// break; +// } +// break; +// case HCNetSDK.COMM_ALARM_ACS: //门禁主机报警信息 +// HCNetSDK.NET_DVR_ACS_ALARM_INFO strACSInfo = new HCNetSDK.NET_DVR_ACS_ALARM_INFO(); +// strACSInfo.write(); +// Pointer pACSInfo = strACSInfo.getPointer(); +// pACSInfo.write(0, pAlarmInfo.getByteArray(0, strACSInfo.size()), 0, strACSInfo.size()); +// strACSInfo.read(); +// /**门禁事件的详细信息解析,通过主次类型的可以判断当前的具体门禁类型,例如(主类型:0X5 次类型:0x4b 表示人脸认证通过, +// 主类型:0X5 次类型:0x4c 表示人脸认证失败)*/ +// System.out.println("【门禁主机报警信息】卡号:" + new String(strACSInfo.struAcsEventInfo.byCardNo).trim() + ",卡类型:" + +// strACSInfo.struAcsEventInfo.byCardType + ",报警主类型:" + Integer.toHexString(strACSInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strACSInfo.dwMinor)); +// System.out.println("工号1:" + strACSInfo.struAcsEventInfo.dwEmployeeNo); +// //温度信息(如果设备支持测温功能,人脸温度信息从NET_DVR_ACS_EVENT_INFO_EXTEND_V20结构体获取) +// if (strACSInfo.byAcsEventInfoExtendV20 == 1) { +// HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20 strAcsInfoExV20 = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20(); +// strAcsInfoExV20.write(); +// Pointer pAcsInfoExV20 = strAcsInfoExV20.getPointer(); +// pAcsInfoExV20.write(0, strACSInfo.pAcsEventInfoExtendV20.getByteArray(0, strAcsInfoExV20.size()), 0, strAcsInfoExV20.size()); +// strAcsInfoExV20.read(); +// System.out.println("实时温度值:" + strAcsInfoExV20.fCurrTemperature); +// } +// //考勤状态 +// if (strACSInfo.byAcsEventInfoExtend == 1) { +// HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND strAcsInfoEx = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND(); +// strAcsInfoEx.write(); +// Pointer pAcsInfoEx = strAcsInfoEx.getPointer(); +// pAcsInfoEx.write(0, strACSInfo.pAcsEventInfoExtend.getByteArray(0, strAcsInfoEx.size()), 0, strAcsInfoEx.size()); +// strAcsInfoEx.read(); +// System.out.println("考勤状态:" + strAcsInfoEx.byAttendanceStatus); +// System.out.println("工号2:" + new String(strAcsInfoEx.byEmployeeNo).trim()); +// } +// +// /** +// * 报警时间 +// */ +// String year = Integer.toString(strACSInfo.struTime.dwYear); +// String SwipeTime = year + strACSInfo.struTime.dwMonth + strACSInfo.struTime.dwDay + strACSInfo.struTime.dwHour + strACSInfo.struTime.dwMinute + +// strACSInfo.struTime.dwSecond; +// if (strACSInfo.dwPicDataLen > 0) { +//// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +//// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// /** +// * 人脸保存路径 +// */ +// String filename = "../pic/" + SwipeTime + "_ACS_Event_" + new String(strACSInfo.struAcsEventInfo.byCardNo).trim() + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strACSInfo.pPicData.getByteBuffer(offset, strACSInfo.dwPicDataLen); +// byte[] bytes = new byte[strACSInfo.dwPicDataLen]; +// 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(); +// } +// } +// break; +// +// case HCNetSDK.COMM_ID_INFO_ALARM: //身份证信息 +// HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM strIDCardInfo = new HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM(); +// strIDCardInfo.write(); +// Pointer pIDCardInfo = strIDCardInfo.getPointer(); +// pIDCardInfo.write(0, pAlarmInfo.getByteArray(0, strIDCardInfo.size()), 0, strIDCardInfo.size()); +// strIDCardInfo.read(); +// System.out.println("报警主类型:" + Integer.toHexString(strIDCardInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strIDCardInfo.dwMinor)); +// /** +// * 身份证信息 +// */ +// String IDnum = new String(strIDCardInfo.struIDCardCfg.byIDNum).trim(); +// System.out.println("【身份证信息】:身份证号码:" + IDnum + ",姓名:" + +// new String(strIDCardInfo.struIDCardCfg.byName).trim() + ",住址:" + new String(strIDCardInfo.struIDCardCfg.byAddr)); +// +// /** +// * 报警时间 +// */ +// String year1 = Integer.toString(strIDCardInfo.struSwipeTime.wYear); +// String SwipeTime1 = year1 + strIDCardInfo.struSwipeTime.byMonth + strIDCardInfo.struSwipeTime.byDay + strIDCardInfo.struSwipeTime.byHour + strIDCardInfo.struSwipeTime.byMinute + +// strIDCardInfo.struSwipeTime.bySecond; +// /** +// * 保存图片 +// */ +// //身份证图片 +// if (strIDCardInfo.dwPicDataLen > 0 || strIDCardInfo.pPicData != null) { +//// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +//// String nowtime = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + SwipeTime1 + "_" + IDnum + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strIDCardInfo.pPicData.getByteBuffer(offset, strIDCardInfo.dwPicDataLen); +// byte[] bytes = new byte[strIDCardInfo.dwPicDataLen]; +// 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 (strIDCardInfo.dwCapturePicDataLen > 0 || strIDCardInfo.pCapturePicData != null) { +//// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +//// String nowtime = sf.format(new Date()); +// FileOutputStream fout; +// try { +// /** +// * 人脸图片保存路径 +// */ +// String filename = "../pic/" + SwipeTime1 + "_CapturePic_" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strIDCardInfo.pCapturePicData.getByteBuffer(offset, strIDCardInfo.dwCapturePicDataLen); +// byte[] bytes = new byte[strIDCardInfo.dwCapturePicDataLen]; +// 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(); +// } +// } +// break; +// +// case HCNetSDK.COMM_ALARM_VIDEO_INTERCOM: //可视对讲报警信息 +// System.out.println("可视对讲报警触发"); +// HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM strVideoIntercomAlarm = new HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM(); +// strVideoIntercomAlarm.write(); +// Pointer pVideoIntercomAlarm = strVideoIntercomAlarm.getPointer(); +// pVideoIntercomAlarm.write(0, pAlarmInfo.getByteArray(0, strVideoIntercomAlarm.size()), 0, strVideoIntercomAlarm.size()); +// strVideoIntercomAlarm.read(); +// System.out.println("byAlarmType:" + strVideoIntercomAlarm.byAlarmType); +// +// if (strVideoIntercomAlarm.byAlarmType == 1) { +// strVideoIntercomAlarm.uAlarmInfo.setType(HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM_INFO_UNION.class); +// strVideoIntercomAlarm.uAlarmInfo.read(); +// System.out.println("byZoneType :" + strVideoIntercomAlarm.uAlarmInfo.struZoneAlarm.byZoneType); +// } +// +// break; +// case HCNetSDK.COMM_UPLOAD_VIDEO_INTERCOM_EVENT: //可视对讲事件记录信息 +// System.out.println("可视对讲事件记录报警触发"); +// HCNetSDK.NET_DVR_VIDEO_INTERCOM_EVENT strVideoIntercomEvent = new HCNetSDK.NET_DVR_VIDEO_INTERCOM_EVENT(); +// strVideoIntercomEvent.write(); +// Pointer pVideoIntercomEvent = strVideoIntercomEvent.getPointer(); +// pVideoIntercomEvent.write(0, pAlarmInfo.getByteArray(0, strVideoIntercomEvent.size()), 0, strVideoIntercomEvent.size()); +// strVideoIntercomEvent.read(); +// System.out.println("byEventType:" + strVideoIntercomEvent.byEventType); +// +// if (strVideoIntercomEvent.byEventType == 1) { +// strVideoIntercomEvent.uEventInfo.setType(HCNetSDK.NET_DVR_UNLOCK_RECORD_INFO.class); +// strVideoIntercomEvent.uEventInfo.read(); +// System.out.println("byUnlockType:" + strVideoIntercomEvent.uEventInfo.struUnlockRecord.byUnlockType +// + ",byControlSrc:" + new String(strVideoIntercomEvent.uEventInfo.struUnlockRecord.byControlSrc).trim()); +// } +// break; +// case HCNetSDK.COMM_UPLOAD_FACESNAP_RESULT: //实时特征抓拍上传 +// System.out.println("UPLOAD_FACESNAP_Alarm"); +// HCNetSDK.NET_VCA_FACESNAP_RESULT strFaceSnapInfo = new HCNetSDK.NET_VCA_FACESNAP_RESULT(); +// strFaceSnapInfo.write(); +// Pointer pFaceSnapInfo = strFaceSnapInfo.getPointer(); +// pFaceSnapInfo.write(0, pAlarmInfo.getByteArray(0, strFaceSnapInfo.size()), 0, strFaceSnapInfo.size()); +// strFaceSnapInfo.read(); +// +// //事件时间 +// int dwYear = (strFaceSnapInfo.dwAbsTime >> 26) + 2000; +// int dwMonth = (strFaceSnapInfo.dwAbsTime >> 22) & 15; +// int dwDay = (strFaceSnapInfo.dwAbsTime >> 17) & 31; +// int dwHour = (strFaceSnapInfo.dwAbsTime >> 12) & 31; +// int dwMinute = (strFaceSnapInfo.dwAbsTime >> 6) & 63; +// int dwSecond = (strFaceSnapInfo.dwAbsTime >> 0) & 63; +// +// String strAbsTime = "" + String.format("%04d", dwYear) + +// String.format("%02d", dwMonth) + +// String.format("%02d", dwDay) + +// String.format("%02d", dwHour) + +// String.format("%02d", dwMinute) + +// String.format("%02d", dwSecond); +// +// //人脸属性信息 +// String sFaceAlarmInfo = "Abs时间:" + strAbsTime + ",是否戴口罩:" + +// strFaceSnapInfo.struFeature.byMask + ",是否微笑:" + strFaceSnapInfo.struFeature.bySmile; +// System.out.println("人脸信息:" + sFaceAlarmInfo); +// +// //人脸测温信息 +// if (strFaceSnapInfo.byAddInfo == 1) { +// HCNetSDK.NET_VCA_FACESNAP_ADDINFO strAddInfo = new HCNetSDK.NET_VCA_FACESNAP_ADDINFO(); +// strAddInfo.write(); +// Pointer pAddInfo = strAddInfo.getPointer(); +// pAddInfo.write(0, strFaceSnapInfo.pAddInfoBuffer.getByteArray(0, strAddInfo.size()), 0, strAddInfo.size()); +// strAddInfo.read(); +// +// String sTemperatureInfo = "测温是否开启:" + strAddInfo.byFaceSnapThermometryEnabled + "人脸温度:" + strAddInfo.fFaceTemperature + "温度是否异常" +// + strAddInfo.byIsAbnomalTemperature + "报警温度阈值:" + strAddInfo.fAlarmTemperature; +// System.out.println("人脸温度信息:" + sTemperatureInfo); +// +// } +// +// try { +// SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 +// String time = df.format(new Date());// new Date()为获取当前系统时间 +// +// //人脸图片写文件 +// FileOutputStream small = new FileOutputStream("../pic/" + time + "small.jpg"); +// FileOutputStream big = new FileOutputStream("../pic/" + time + "big.jpg"); +// try { +// small.write(strFaceSnapInfo.pBuffer1.getByteArray(0, strFaceSnapInfo.dwFacePicLen), 0, strFaceSnapInfo.dwFacePicLen); +// small.close(); +// } catch (IOException ex) { +// ex.printStackTrace(); +// } +// try { +// big.write(strFaceSnapInfo.pBuffer2.getByteArray(0, strFaceSnapInfo.dwBackgroundPicLen), 0, strFaceSnapInfo.dwBackgroundPicLen); +// big.close(); +// } catch (IOException ex) { +// ex.printStackTrace(); +// } +// +// } catch (FileNotFoundException ex) { +// ex.printStackTrace(); +// } +// break; +// +// case HCNetSDK.COMM_SNAP_MATCH_ALARM: //人脸比对报警 +// HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM strFaceSnapMatch = new HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM(); +// strFaceSnapMatch.write(); +// Pointer pFaceSnapMatch = strFaceSnapMatch.getPointer(); +// pFaceSnapMatch.write(0, pAlarmInfo.getByteArray(0, strFaceSnapMatch.size()), 0, strFaceSnapMatch.size()); +// strFaceSnapMatch.read(); +// //比对结果,0-保留,1-比对成功,2-比对失败 +// String sFaceSnapMatchInfo = "比对结果:" + strFaceSnapMatch.byContrastStatus + ",相似度:" + strFaceSnapMatch.fSimilarity; +// System.out.println(sFaceSnapMatchInfo); +// if (strFaceSnapMatch.struBlockListInfo.dwFDIDLen > 0) { +// long offset1 = 0; +// ByteBuffer buffers1 = strFaceSnapMatch.struBlockListInfo.pFDID.getByteBuffer(offset1, strFaceSnapMatch.struBlockListInfo.dwFDIDLen); +// byte[] bytes1 = new byte[strFaceSnapMatch.struBlockListInfo.dwFDIDLen]; +// buffers1.get(bytes1); +// System.out.println("人脸库ID:" + new String(bytes1)); +// } +// if (strFaceSnapMatch.struBlockListInfo.dwPIDLen > 0) { +// long offset2 = 0; +// ByteBuffer buffers2 = strFaceSnapMatch.struBlockListInfo.pPID.getByteBuffer(offset2, strFaceSnapMatch.struBlockListInfo.dwPIDLen); +// byte[] bytes2 = new byte[strFaceSnapMatch.struBlockListInfo.dwPIDLen]; +// buffers2.get(bytes2); +// System.out.println("图片ID:" + new String(bytes2)); +// } +// if (strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen > 0) { +// //抓拍库附加信息解析(解析人脸测温温度,人脸温度存放在附件信息的XML报文中,节点: ) +// SimpleDateFormat sf2 = new SimpleDateFormat("yyyyMMddHHmmss"); +// String curTime2 = sf2.format(new Date()); +// FileOutputStream AddtionData; +// String AddtionFile = "../pic" + new String(pAlarmer.sDeviceIP).trim() + curTime2 + "_FCAdditionInfo_" + ".xml"; +// try { +// Data = new FileOutputStream(AddtionFile); +// //将字节写入文件 +// ByteBuffer dataBuffer = strFaceSnapMatch.struBlockListInfo.struBlockListInfo.pFCAdditionInfoBuffer.getByteBuffer(0, strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen); +// byte[] dataByte = new byte[dwBufLen]; +// dataBuffer.rewind(); +// dataBuffer.get(dataByte); +// Data.write(dataByte); +// Data.close(); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// //人脸比对报警图片保存,图片格式二进制 +// if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) { // SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); -// String nowtime = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + SwipeTime1 + "_" + IDnum + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strIDCardInfo.pPicData.getByteBuffer(offset, strIDCardInfo.dwPicDataLen); - byte[] bytes = new byte[strIDCardInfo.dwPicDataLen]; - 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 (strIDCardInfo.dwCapturePicDataLen > 0 || strIDCardInfo.pCapturePicData != null) { +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_pSnapPicBuffer" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(offset, strFaceSnapMatch.dwSnapPicLen); +// byte[] bytes = new byte[strFaceSnapMatch.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 ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.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 = strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen); +// byte[] bytes = new byte[strFaceSnapMatch.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 ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// try { +// String filename = "../pic/" + newName + "_fSimilarity_" + strFaceSnapMatch.fSimilarity + "_struBlackListInfo_pBuffer1" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen); +// byte[] bytes = new byte[strFaceSnapMatch.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(); +// } +// } +// //人脸比对报警图片保存,图片格式URL格式 +// if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { +// +// long offset = 0; +// ByteBuffer buffers = strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(offset, strFaceSnapMatch.dwSnapPicLen); +// byte[] bytes = new byte[strFaceSnapMatch.dwSnapPicLen]; +// buffers.rewind(); +// buffers.get(bytes); +// String SnapPicUrl = new String(bytes); +// System.out.println("抓拍图URL:" + SnapPicUrl); +// } +// if ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { +// +// long offset = 0; +// ByteBuffer buffers = strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen); +// byte[] bytes = new byte[strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen]; +// buffers.rewind(); +// buffers.get(bytes); +// String SnapPicUrl = new String(bytes); +// System.out.println("抓拍人脸子图URL:" + SnapPicUrl); +// } +// if ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { +// +// long offset = 0; +// ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen); +// byte[] bytes = new byte[strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen]; +// buffers.rewind(); +// buffers.get(bytes); +// String SnapPicUrl = new String(bytes); +// System.out.println("人脸库人脸图的URL:" + SnapPicUrl); +// } +// +// +// break; +// // 客流量报警信息 +// case HCNetSDK.COMM_ALARM_PDC: +// HCNetSDK.NET_DVR_PDC_ALRAM_INFO strPDCResult = new HCNetSDK.NET_DVR_PDC_ALRAM_INFO(); +// strPDCResult.write(); +// Pointer pPDCInfo = strPDCResult.getPointer(); +// pPDCInfo.write(0, pAlarmInfo.getByteArray(0, strPDCResult.size()), 0, strPDCResult.size()); +// strPDCResult.read(); +// // byMode=0-实时统计结果(联合体中struStatFrame有效), +// if (strPDCResult.byMode == 0) { +// strPDCResult.uStatModeParam.setType(HCNetSDK.NET_DVR_STATFRAME.class); +// String sAlarmPDC0Info = "实时客流量统计,进入人数:" + strPDCResult.dwEnterNum + ",离开人数:" + strPDCResult.dwLeaveNum + +// ", byMode:" + strPDCResult.byMode + ", dwRelativeTime:" + strPDCResult.uStatModeParam.struStatFrame.dwRelativeTime + +// ", dwAbsTime:" + strPDCResult.uStatModeParam.struStatFrame.dwAbsTime; +// } +// // byMode=1-周期统计结果(联合体中struStatTime有效), +// if (strPDCResult.byMode == 1) { +// strPDCResult.uStatModeParam.setType(HCNetSDK.NET_DVR_STATTIME.class); +// String strtmStart = "" + String.format("%04d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwYear) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwMonth) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwDay) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwHour) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwMinute) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwSecond); +// String strtmEnd = "" + String.format("%04d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwYear) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwMonth) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwDay) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwHour) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwMinute) + +// String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwSecond); +// String sAlarmPDC1Info = "周期性客流量统计,进入人数:" + strPDCResult.dwEnterNum + ",离开人数:" + strPDCResult.dwLeaveNum + +// ", byMode:" + strPDCResult.byMode + ", tmStart:" + strtmStart + ",tmEnd :" + strtmEnd; +// } +// break; +// case HCNetSDK.COMM_ALARM_V30: //移动侦测、视频丢失、遮挡、IO信号量等报警信息(V3.0以上版本支持的设备) +// HCNetSDK.NET_DVR_ALARMINFO_V30 struAlarmInfo = new HCNetSDK.NET_DVR_ALARMINFO_V30(); +// struAlarmInfo.write(); +// Pointer pAlarmInfo_V30 = struAlarmInfo.getPointer(); +// pAlarmInfo_V30.write(0, pAlarmInfo.getByteArray(0, struAlarmInfo.size()), 0, struAlarmInfo.size()); +// struAlarmInfo.read(); +// System.out.println("报警类型:" + struAlarmInfo.dwAlarmType); // 3-移动侦测 +// break; +// case HCNetSDK.COMM_ALARM_V40: //移动侦测、视频丢失、遮挡、IO信号量等报警信息,报警数据为可变长 +// +// HCNetSDK.NET_DVR_ALARMINFO_V40 struAlarmInfoV40 = new HCNetSDK.NET_DVR_ALARMINFO_V40(); +// struAlarmInfoV40.write(); +// Pointer pAlarmInfoV40 = struAlarmInfoV40.getPointer(); +// pAlarmInfoV40.write(0, pAlarmInfo.getByteArray(0, struAlarmInfoV40.size()), 0, struAlarmInfoV40.size()); +// struAlarmInfoV40.read(); +// switch (struAlarmInfoV40.struAlarmFixedHeader.dwAlarmType) { +// case 0: +// struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.setType(HCNetSDK.struIOAlarm.class); +// struAlarmInfoV40.read(); +// System.out.println("信号量报警,报警输入口:"+struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.struioAlarm.dwAlarmInputNo); +// break; +// case 1: +// System.out.println("硬盘满"); +// break; +// case 2: +// System.out.println("信号丢失"); +// break; +// case 3: +// String sAlarmType=""; +// struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.setType(HCNetSDK.struAlarmChannel.class); +// struAlarmInfoV40.read(); +// int iChanNum = struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.strualarmChannel.dwAlarmChanNum; +// sAlarmType = sAlarmType + new String(":移动侦测") + "," + "报警通道个数:" + iChanNum + "," + "报警通道号:"; +// +// for (int i = 0; i < iChanNum; i++) { +// byte[] byChannel = struAlarmInfoV40.pAlarmData.getByteArray(i * 4, 4); +// +// int iChanneNo = 0; +// for (int j = 0; j < 4; j++) { +// int ioffset = j * 8; +// int iByte = byChannel[j] & 0xff; +// iChanneNo = iChanneNo + (iByte << ioffset); +// } +// +// sAlarmType = sAlarmType + "+ch[" + iChanneNo + "]"; +// } +// System.out.println(sAlarmType); +// break; +// case 4: +// System.out.println("硬盘未格式化"); +// break; +// case 5: +// System.out.println("读写硬盘出错"); +// break; +// case 6: +// System.out.println("遮挡报警"); +// break; +// case 7: +// System.out.println("制式不匹配"); +// break; +// case 8: +// System.out.println("非法访问"); +// break; +// } +// +// break; +// case HCNetSDK.COMM_THERMOMETRY_ALARM: //温度报警信息 +// HCNetSDK.NET_DVR_THERMOMETRY_ALARM struTemInfo = new HCNetSDK.NET_DVR_THERMOMETRY_ALARM(); +// struTemInfo.write(); +// Pointer pTemInfo = struTemInfo.getPointer(); +// pTemInfo.write(0, pAlarmInfo.getByteArray(0, struTemInfo.size()), 0, struTemInfo.size()); +// struTemInfo.read(); +// String sThermAlarmInfo = "规则ID:" + struTemInfo.byRuleID + "预置点号:" + struTemInfo.wPresetNo + "报警等级:" + struTemInfo.byAlarmLevel + "报警类型:" + +// struTemInfo.byAlarmType + "当前温度:" + struTemInfo.fCurrTemperature; +// System.out.println(sThermAlarmInfo); +// //可见光图片保存 +// if ((struTemInfo.dwPicLen > 0) && (struTemInfo.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_" + struTemInfo.fCurrTemperature + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struTemInfo.pPicBuff.getByteBuffer(offset, struTemInfo.dwPicLen); +// byte[] bytes = new byte[struTemInfo.dwPicLen]; +// 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 ((struTemInfo.dwThermalPicLen > 0) && (struTemInfo.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_" + "_ThermalPiC" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struTemInfo.pThermalPicBuff.getByteBuffer(offset, struTemInfo.dwThermalPicLen); +// byte[] bytes = new byte[struTemInfo.dwThermalPicLen]; +// 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(); +// } +// +// } +// break; +// case HCNetSDK.COMM_THERMOMETRY_DIFF_ALARM: //温差检测报警 +// HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM strThermDiffAlarm = new HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM(); +// strThermDiffAlarm.write(); +// Pointer pTemDiffInfo = strThermDiffAlarm.getPointer(); +// pTemDiffInfo.write(0, pAlarmInfo.getByteArray(0, strThermDiffAlarm.size()), 0, strThermDiffAlarm.size()); +// strThermDiffAlarm.read(); +// String sThremDiffInfo = "通道号:" + strThermDiffAlarm.dwChannel + ",报警规则:" + strThermDiffAlarm.byAlarmRule + ",当前温差:" + strThermDiffAlarm.fCurTemperatureDiff; +// System.out.println(sThremDiffInfo); +// //可见光图片保存 +// if ((strThermDiffAlarm.dwPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_" + strThermDiffAlarm.fCurTemperatureDiff + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strThermDiffAlarm.pPicBuff.getByteBuffer(offset, strThermDiffAlarm.dwPicLen); +// byte[] bytes = new byte[strThermDiffAlarm.dwPicLen]; +// 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 ((strThermDiffAlarm.dwThermalPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_" + "_ThermalDiffPiC" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strThermDiffAlarm.pThermalPicBuff.getByteBuffer(offset, strThermDiffAlarm.dwThermalPicLen); +// byte[] bytes = new byte[strThermDiffAlarm.dwThermalPicLen]; +// 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(); +// } +// +// } +// break; +// case HCNetSDK.COMM_ALARM_SHIPSDETECTION: //船只检测报警 +// HCNetSDK.NET_DVR_SHIPSDETECTION_ALARM struShipAlarm = new HCNetSDK.NET_DVR_SHIPSDETECTION_ALARM(); +// struShipAlarm.write(); +// Pointer pShipAlarm = struShipAlarm.getPointer(); +// pShipAlarm.write(0, pAlarmInfo.getByteArray(0, struShipAlarm.size()), 0, struShipAlarm.size()); +// struShipAlarm.read(); +// String sShipAlarm = "绝对时间:" + struShipAlarm.dwAbsTime + ",正跨越检测线的船只数:" + struShipAlarm.byShipsNum + ",船头检测的船只数 :" + struShipAlarm.byShipsNumHead +// + ", 船尾检测的船只数 :" + struShipAlarm.byShipsNumEnd; +// System.out.println(sShipAlarm); +// //可见光图片保存 +// if ((struShipAlarm.dwPicLen > 0) && (struShipAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_ShipAlarm" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struShipAlarm.pPicBuffer.getByteBuffer(offset, struShipAlarm.dwPicLen); +// byte[] bytes = new byte[struShipAlarm.dwPicLen]; +// 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 ((struShipAlarm.dwThermalPicLen > 0) && (struShipAlarm.byPicTransType == 0)) { // SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); -// String nowtime = sf.format(new Date()); - FileOutputStream fout; - try { - /** - * 人脸图片保存路径 - */ - String filename = "../pic/" + SwipeTime1 + "_CapturePic_" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strIDCardInfo.pCapturePicData.getByteBuffer(offset, strIDCardInfo.dwCapturePicDataLen); - byte[] bytes = new byte[strIDCardInfo.dwCapturePicDataLen]; - 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(); - } - } - break; - - case HCNetSDK.COMM_ALARM_VIDEO_INTERCOM: //可视对讲报警信息 - System.out.println("可视对讲报警触发"); - HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM strVideoIntercomAlarm = new HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM(); - strVideoIntercomAlarm.write(); - Pointer pVideoIntercomAlarm = strVideoIntercomAlarm.getPointer(); - pVideoIntercomAlarm.write(0, pAlarmInfo.getByteArray(0, strVideoIntercomAlarm.size()), 0, strVideoIntercomAlarm.size()); - strVideoIntercomAlarm.read(); - System.out.println("byAlarmType:" + strVideoIntercomAlarm.byAlarmType); - - if (strVideoIntercomAlarm.byAlarmType == 1) { - strVideoIntercomAlarm.uAlarmInfo.setType(HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM_INFO_UNION.class); - strVideoIntercomAlarm.uAlarmInfo.read(); - System.out.println("byZoneType :" + strVideoIntercomAlarm.uAlarmInfo.struZoneAlarm.byZoneType); - } - - break; - case HCNetSDK.COMM_UPLOAD_VIDEO_INTERCOM_EVENT: //可视对讲事件记录信息 - System.out.println("可视对讲事件记录报警触发"); - HCNetSDK.NET_DVR_VIDEO_INTERCOM_EVENT strVideoIntercomEvent = new HCNetSDK.NET_DVR_VIDEO_INTERCOM_EVENT(); - strVideoIntercomEvent.write(); - Pointer pVideoIntercomEvent = strVideoIntercomEvent.getPointer(); - pVideoIntercomEvent.write(0, pAlarmInfo.getByteArray(0, strVideoIntercomEvent.size()), 0, strVideoIntercomEvent.size()); - strVideoIntercomEvent.read(); - System.out.println("byEventType:" + strVideoIntercomEvent.byEventType); - - if (strVideoIntercomEvent.byEventType == 1) { - strVideoIntercomEvent.uEventInfo.setType(HCNetSDK.NET_DVR_UNLOCK_RECORD_INFO.class); - strVideoIntercomEvent.uEventInfo.read(); - System.out.println("byUnlockType:" + strVideoIntercomEvent.uEventInfo.struUnlockRecord.byUnlockType - + ",byControlSrc:" + new String(strVideoIntercomEvent.uEventInfo.struUnlockRecord.byControlSrc).trim()); - } - break; - case HCNetSDK.COMM_UPLOAD_FACESNAP_RESULT: //实时特征抓拍上传 - System.out.println("UPLOAD_FACESNAP_Alarm"); - HCNetSDK.NET_VCA_FACESNAP_RESULT strFaceSnapInfo = new HCNetSDK.NET_VCA_FACESNAP_RESULT(); - strFaceSnapInfo.write(); - Pointer pFaceSnapInfo = strFaceSnapInfo.getPointer(); - pFaceSnapInfo.write(0, pAlarmInfo.getByteArray(0, strFaceSnapInfo.size()), 0, strFaceSnapInfo.size()); - strFaceSnapInfo.read(); - - //事件时间 - int dwYear = (strFaceSnapInfo.dwAbsTime >> 26) + 2000; - int dwMonth = (strFaceSnapInfo.dwAbsTime >> 22) & 15; - int dwDay = (strFaceSnapInfo.dwAbsTime >> 17) & 31; - int dwHour = (strFaceSnapInfo.dwAbsTime >> 12) & 31; - int dwMinute = (strFaceSnapInfo.dwAbsTime >> 6) & 63; - int dwSecond = (strFaceSnapInfo.dwAbsTime >> 0) & 63; - - String strAbsTime = "" + String.format("%04d", dwYear) + - String.format("%02d", dwMonth) + - String.format("%02d", dwDay) + - String.format("%02d", dwHour) + - String.format("%02d", dwMinute) + - String.format("%02d", dwSecond); - - //人脸属性信息 - String sFaceAlarmInfo = "Abs时间:" + strAbsTime + ",是否戴口罩:" + - strFaceSnapInfo.struFeature.byMask + ",是否微笑:" + strFaceSnapInfo.struFeature.bySmile; - System.out.println("人脸信息:" + sFaceAlarmInfo); - - //人脸测温信息 - if (strFaceSnapInfo.byAddInfo == 1) { - HCNetSDK.NET_VCA_FACESNAP_ADDINFO strAddInfo = new HCNetSDK.NET_VCA_FACESNAP_ADDINFO(); - strAddInfo.write(); - Pointer pAddInfo = strAddInfo.getPointer(); - pAddInfo.write(0, strFaceSnapInfo.pAddInfoBuffer.getByteArray(0, strAddInfo.size()), 0, strAddInfo.size()); - strAddInfo.read(); - - String sTemperatureInfo = "测温是否开启:" + strAddInfo.byFaceSnapThermometryEnabled + "人脸温度:" + strAddInfo.fFaceTemperature + "温度是否异常" - + strAddInfo.byIsAbnomalTemperature + "报警温度阈值:" + strAddInfo.fAlarmTemperature; - System.out.println("人脸温度信息:" + sTemperatureInfo); - - } - - try { - SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 - String time = df.format(new Date());// new Date()为获取当前系统时间 - - //人脸图片写文件 - FileOutputStream small = new FileOutputStream("../pic/" + time + "small.jpg"); - FileOutputStream big = new FileOutputStream("../pic/" + time + "big.jpg"); - try { - small.write(strFaceSnapInfo.pBuffer1.getByteArray(0, strFaceSnapInfo.dwFacePicLen), 0, strFaceSnapInfo.dwFacePicLen); - small.close(); - } catch (IOException ex) { - ex.printStackTrace(); - } - try { - big.write(strFaceSnapInfo.pBuffer2.getByteArray(0, strFaceSnapInfo.dwBackgroundPicLen), 0, strFaceSnapInfo.dwBackgroundPicLen); - big.close(); - } catch (IOException ex) { - ex.printStackTrace(); - } - - } catch (FileNotFoundException ex) { - ex.printStackTrace(); - } - break; - - case HCNetSDK.COMM_SNAP_MATCH_ALARM: //人脸比对报警 - HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM strFaceSnapMatch = new HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM(); - strFaceSnapMatch.write(); - Pointer pFaceSnapMatch = strFaceSnapMatch.getPointer(); - pFaceSnapMatch.write(0, pAlarmInfo.getByteArray(0, strFaceSnapMatch.size()), 0, strFaceSnapMatch.size()); - strFaceSnapMatch.read(); - //比对结果,0-保留,1-比对成功,2-比对失败 - String sFaceSnapMatchInfo = "比对结果:" + strFaceSnapMatch.byContrastStatus + ",相似度:" + strFaceSnapMatch.fSimilarity; - System.out.println(sFaceSnapMatchInfo); - if (strFaceSnapMatch.struBlockListInfo.dwFDIDLen > 0) { - long offset1 = 0; - ByteBuffer buffers1 = strFaceSnapMatch.struBlockListInfo.pFDID.getByteBuffer(offset1, strFaceSnapMatch.struBlockListInfo.dwFDIDLen); - byte[] bytes1 = new byte[strFaceSnapMatch.struBlockListInfo.dwFDIDLen]; - buffers1.get(bytes1); - System.out.println("人脸库ID:" + new String(bytes1)); - } - if (strFaceSnapMatch.struBlockListInfo.dwPIDLen > 0) { - long offset2 = 0; - ByteBuffer buffers2 = strFaceSnapMatch.struBlockListInfo.pPID.getByteBuffer(offset2, strFaceSnapMatch.struBlockListInfo.dwPIDLen); - byte[] bytes2 = new byte[strFaceSnapMatch.struBlockListInfo.dwPIDLen]; - buffers2.get(bytes2); - System.out.println("图片ID:" + new String(bytes2)); - } - if (strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen > 0) { - //抓拍库附加信息解析(解析人脸测温温度,人脸温度存放在附件信息的XML报文中,节点: ) - SimpleDateFormat sf2 = new SimpleDateFormat("yyyyMMddHHmmss"); - String curTime2 = sf2.format(new Date()); - FileOutputStream AddtionData; - String AddtionFile = "../pic" + new String(pAlarmer.sDeviceIP).trim() + curTime2 + "_FCAdditionInfo_" + ".xml"; - try { - Data = new FileOutputStream(AddtionFile); - //将字节写入文件 - ByteBuffer dataBuffer = strFaceSnapMatch.struBlockListInfo.struBlockListInfo.pFCAdditionInfoBuffer.getByteBuffer(0, strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen); - byte[] dataByte = new byte[dwBufLen]; - dataBuffer.rewind(); - dataBuffer.get(dataByte); - Data.write(dataByte); - Data.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - //人脸比对报警图片保存,图片格式二进制 - if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.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 = strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(offset, strFaceSnapMatch.dwSnapPicLen); - byte[] bytes = new byte[strFaceSnapMatch.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 ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.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 = strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen); - byte[] bytes = new byte[strFaceSnapMatch.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 ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - try { - String filename = "../pic/" + newName + "_fSimilarity_" + strFaceSnapMatch.fSimilarity + "_struBlackListInfo_pBuffer1" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen); - byte[] bytes = new byte[strFaceSnapMatch.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(); - } - } - //人脸比对报警图片保存,图片格式URL格式 - if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { - - long offset = 0; - ByteBuffer buffers = strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(offset, strFaceSnapMatch.dwSnapPicLen); - byte[] bytes = new byte[strFaceSnapMatch.dwSnapPicLen]; - buffers.rewind(); - buffers.get(bytes); - String SnapPicUrl = new String(bytes); - System.out.println("抓拍图URL:" + SnapPicUrl); - } - if ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { - - long offset = 0; - ByteBuffer buffers = strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen); - byte[] bytes = new byte[strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen]; - buffers.rewind(); - buffers.get(bytes); - String SnapPicUrl = new String(bytes); - System.out.println("抓拍人脸子图URL:" + SnapPicUrl); - } - if ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { - - long offset = 0; - ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen); - byte[] bytes = new byte[strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen]; - buffers.rewind(); - buffers.get(bytes); - String SnapPicUrl = new String(bytes); - System.out.println("人脸库人脸图的URL:" + SnapPicUrl); - } - - - break; - // 客流量报警信息 - case HCNetSDK.COMM_ALARM_PDC: - HCNetSDK.NET_DVR_PDC_ALRAM_INFO strPDCResult = new HCNetSDK.NET_DVR_PDC_ALRAM_INFO(); - strPDCResult.write(); - Pointer pPDCInfo = strPDCResult.getPointer(); - pPDCInfo.write(0, pAlarmInfo.getByteArray(0, strPDCResult.size()), 0, strPDCResult.size()); - strPDCResult.read(); - // byMode=0-实时统计结果(联合体中struStatFrame有效), - if (strPDCResult.byMode == 0) { - strPDCResult.uStatModeParam.setType(HCNetSDK.NET_DVR_STATFRAME.class); - String sAlarmPDC0Info = "实时客流量统计,进入人数:" + strPDCResult.dwEnterNum + ",离开人数:" + strPDCResult.dwLeaveNum + - ", byMode:" + strPDCResult.byMode + ", dwRelativeTime:" + strPDCResult.uStatModeParam.struStatFrame.dwRelativeTime + - ", dwAbsTime:" + strPDCResult.uStatModeParam.struStatFrame.dwAbsTime; - } - // byMode=1-周期统计结果(联合体中struStatTime有效), - if (strPDCResult.byMode == 1) { - strPDCResult.uStatModeParam.setType(HCNetSDK.NET_DVR_STATTIME.class); - String strtmStart = "" + String.format("%04d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwYear) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwMonth) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwDay) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwHour) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwMinute) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwSecond); - String strtmEnd = "" + String.format("%04d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwYear) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwMonth) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwDay) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwHour) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwMinute) + - String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwSecond); - String sAlarmPDC1Info = "周期性客流量统计,进入人数:" + strPDCResult.dwEnterNum + ",离开人数:" + strPDCResult.dwLeaveNum + - ", byMode:" + strPDCResult.byMode + ", tmStart:" + strtmStart + ",tmEnd :" + strtmEnd; - } - break; - case HCNetSDK.COMM_ALARM_V30: //移动侦测、视频丢失、遮挡、IO信号量等报警信息(V3.0以上版本支持的设备) - HCNetSDK.NET_DVR_ALARMINFO_V30 struAlarmInfo = new HCNetSDK.NET_DVR_ALARMINFO_V30(); - struAlarmInfo.write(); - Pointer pAlarmInfo_V30 = struAlarmInfo.getPointer(); - pAlarmInfo_V30.write(0, pAlarmInfo.getByteArray(0, struAlarmInfo.size()), 0, struAlarmInfo.size()); - struAlarmInfo.read(); - System.out.println("报警类型:" + struAlarmInfo.dwAlarmType); // 3-移动侦测 - break; - case HCNetSDK.COMM_ALARM_V40: //移动侦测、视频丢失、遮挡、IO信号量等报警信息,报警数据为可变长 - - HCNetSDK.NET_DVR_ALARMINFO_V40 struAlarmInfoV40 = new HCNetSDK.NET_DVR_ALARMINFO_V40(); - struAlarmInfoV40.write(); - Pointer pAlarmInfoV40 = struAlarmInfoV40.getPointer(); - pAlarmInfoV40.write(0, pAlarmInfo.getByteArray(0, struAlarmInfoV40.size()), 0, struAlarmInfoV40.size()); - struAlarmInfoV40.read(); - switch (struAlarmInfoV40.struAlarmFixedHeader.dwAlarmType) { - case 0: - struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.setType(HCNetSDK.struIOAlarm.class); - struAlarmInfoV40.read(); - System.out.println("信号量报警,报警输入口:"+struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.struioAlarm.dwAlarmInputNo); - break; - case 1: - System.out.println("硬盘满"); - break; - case 2: - System.out.println("信号丢失"); - break; - case 3: - String sAlarmType=""; - struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.setType(HCNetSDK.struAlarmChannel.class); - struAlarmInfoV40.read(); - int iChanNum = struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.strualarmChannel.dwAlarmChanNum; - sAlarmType = sAlarmType + new String(":移动侦测") + "," + "报警通道个数:" + iChanNum + "," + "报警通道号:"; - - for (int i = 0; i < iChanNum; i++) { - byte[] byChannel = struAlarmInfoV40.pAlarmData.getByteArray(i * 4, 4); - - int iChanneNo = 0; - for (int j = 0; j < 4; j++) { - int ioffset = j * 8; - int iByte = byChannel[j] & 0xff; - iChanneNo = iChanneNo + (iByte << ioffset); - } - - sAlarmType = sAlarmType + "+ch[" + iChanneNo + "]"; - } - System.out.println(sAlarmType); - break; - case 4: - System.out.println("硬盘未格式化"); - break; - case 5: - System.out.println("读写硬盘出错"); - break; - case 6: - System.out.println("遮挡报警"); - break; - case 7: - System.out.println("制式不匹配"); - break; - case 8: - System.out.println("非法访问"); - break; - } - - break; - case HCNetSDK.COMM_THERMOMETRY_ALARM: //温度报警信息 - HCNetSDK.NET_DVR_THERMOMETRY_ALARM struTemInfo = new HCNetSDK.NET_DVR_THERMOMETRY_ALARM(); - struTemInfo.write(); - Pointer pTemInfo = struTemInfo.getPointer(); - pTemInfo.write(0, pAlarmInfo.getByteArray(0, struTemInfo.size()), 0, struTemInfo.size()); - struTemInfo.read(); - String sThermAlarmInfo = "规则ID:" + struTemInfo.byRuleID + "预置点号:" + struTemInfo.wPresetNo + "报警等级:" + struTemInfo.byAlarmLevel + "报警类型:" + - struTemInfo.byAlarmType + "当前温度:" + struTemInfo.fCurrTemperature; - System.out.println(sThermAlarmInfo); - //可见光图片保存 - if ((struTemInfo.dwPicLen > 0) && (struTemInfo.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_" + struTemInfo.fCurrTemperature + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struTemInfo.pPicBuff.getByteBuffer(offset, struTemInfo.dwPicLen); - byte[] bytes = new byte[struTemInfo.dwPicLen]; - 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 ((struTemInfo.dwThermalPicLen > 0) && (struTemInfo.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_" + "_ThermalPiC" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struTemInfo.pThermalPicBuff.getByteBuffer(offset, struTemInfo.dwThermalPicLen); - byte[] bytes = new byte[struTemInfo.dwThermalPicLen]; - 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(); - } - - } - break; - case HCNetSDK.COMM_THERMOMETRY_DIFF_ALARM: //温差检测报警 - HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM strThermDiffAlarm = new HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM(); - strThermDiffAlarm.write(); - Pointer pTemDiffInfo = strThermDiffAlarm.getPointer(); - pTemDiffInfo.write(0, pAlarmInfo.getByteArray(0, strThermDiffAlarm.size()), 0, strThermDiffAlarm.size()); - strThermDiffAlarm.read(); - String sThremDiffInfo = "通道号:" + strThermDiffAlarm.dwChannel + ",报警规则:" + strThermDiffAlarm.byAlarmRule + ",当前温差:" + strThermDiffAlarm.fCurTemperatureDiff; - System.out.println(sThremDiffInfo); - //可见光图片保存 - if ((strThermDiffAlarm.dwPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_" + strThermDiffAlarm.fCurTemperatureDiff + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strThermDiffAlarm.pPicBuff.getByteBuffer(offset, strThermDiffAlarm.dwPicLen); - byte[] bytes = new byte[strThermDiffAlarm.dwPicLen]; - 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 ((strThermDiffAlarm.dwThermalPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_" + "_ThermalDiffPiC" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strThermDiffAlarm.pThermalPicBuff.getByteBuffer(offset, strThermDiffAlarm.dwThermalPicLen); - byte[] bytes = new byte[strThermDiffAlarm.dwThermalPicLen]; - 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(); - } - - } - break; - case HCNetSDK.COMM_ALARM_SHIPSDETECTION: //船只检测报警 - HCNetSDK.NET_DVR_SHIPSDETECTION_ALARM struShipAlarm = new HCNetSDK.NET_DVR_SHIPSDETECTION_ALARM(); - struShipAlarm.write(); - Pointer pShipAlarm = struShipAlarm.getPointer(); - pShipAlarm.write(0, pAlarmInfo.getByteArray(0, struShipAlarm.size()), 0, struShipAlarm.size()); - struShipAlarm.read(); - String sShipAlarm = "绝对时间:" + struShipAlarm.dwAbsTime + ",正跨越检测线的船只数:" + struShipAlarm.byShipsNum + ",船头检测的船只数 :" + struShipAlarm.byShipsNumHead - + ", 船尾检测的船只数 :" + struShipAlarm.byShipsNumEnd; - System.out.println(sShipAlarm); - //可见光图片保存 - if ((struShipAlarm.dwPicLen > 0) && (struShipAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_ShipAlarm" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struShipAlarm.pPicBuffer.getByteBuffer(offset, struShipAlarm.dwPicLen); - byte[] bytes = new byte[struShipAlarm.dwPicLen]; - 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 ((struShipAlarm.dwThermalPicLen > 0) && (struShipAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_" + "_ThermalShipAlarm" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struShipAlarm.pThermalPicBuffer.getByteBuffer(offset, struShipAlarm.dwThermalPicLen); - byte[] bytes = new byte[struShipAlarm.dwThermalPicLen]; - 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(); - } - - } - break; - - case HCNetSDK.COMM_FIREDETECTION_ALARM://烟火检测 - 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.dwVisiblePicLen > 0) && (struFireDecAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_FireDecAlarm" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struFireDecAlarm.pVisiblePicBuf.getByteBuffer(offset, struFireDecAlarm.dwVisiblePicLen); - byte[] bytes = new byte[struFireDecAlarm.dwVisiblePicLen]; - 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 ((struFireDecAlarm.dwPicDataLen > 0) && (struFireDecAlarm.byPicTransType == 0)) { - SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); - String newName = sf.format(new Date()); - FileOutputStream fout; - - try { - String filename = "../pic/" + newName + "_" + "_ThermalFireAlarm" + ".jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struFireDecAlarm.pBuffer.getByteBuffer(offset, struFireDecAlarm.dwPicDataLen); - byte[] bytes = new byte[struFireDecAlarm.dwPicDataLen]; - 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(); - } - - } - break; - case HCNetSDK.COMM_UPLOAD_AIOP_VIDEO: //AI开放平台接入视频检测报警信息 - System.out.println("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(); - System.out.println("视频任务ID" + new String(struAIOPVideo.szTaskID)); - System.out.println("通道号:" + struAIOPVideo.dwChannel); - System.out.println("检测模型包ID" + new String(struAIOPVideo.szMPID)); - String strTime = 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); - //AIOPData数据 - if (struAIOPVideo.dwAIOPDataSize > 0) { - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + - "_" + strTime + "_VideoData.json"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struAIOPVideo.pBufferAIOPData.getByteBuffer(offset, struAIOPVideo.dwAIOPDataSize); - byte[] bytes = new byte[struAIOPVideo.dwAIOPDataSize]; - 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 (struAIOPVideo.dwPictureSize > 0) { - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + - "_" + strTime + "_VideoPic.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struAIOPVideo.pBufferPicture.getByteBuffer(offset, struAIOPVideo.dwPictureSize); - byte[] bytes = new byte[struAIOPVideo.dwPictureSize]; - 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(); - } - } - break; - case HCNetSDK.COMM_UPLOAD_AIOP_PICTURE: //AI开放平台接入图片检测报警信息 - System.out.println("AI开放平台接入图片检测报警上传"); - HCNetSDK.NET_AIOP_PICTURE_HEAD struAIOPPic = new HCNetSDK.NET_AIOP_PICTURE_HEAD(); - struAIOPPic.write(); - Pointer pAIOPPic = struAIOPPic.getPointer(); - pAIOPPic.write(0, pAlarmInfo.getByteArray(0, struAIOPPic.size()), 0, struAIOPPic.size()); - struAIOPPic.read(); - System.out.println("图片ID:" + new String(struAIOPPic.szPID)); - System.out.println("检测模型包ID:" + new String(struAIOPPic.szMPID)); - String strPicTime = "" + String.format("%04d", struAIOPPic.struTime.wYear) + - String.format("%02d", struAIOPPic.struTime.wMonth) + - String.format("%02d", struAIOPPic.struTime.wDay) + - String.format("%02d", struAIOPPic.struTime.wHour) + - String.format("%02d", struAIOPPic.struTime.wMinute) + - String.format("%02d", struAIOPPic.struTime.wSecond) + - String.format("%03d", struAIOPPic.struTime.wMilliSec); - //AIOPData数据 - if (struAIOPPic.dwAIOPDataSize > 0) { - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + - "_" + strPicTime + "_AIO_PicData.json"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struAIOPPic.pBufferAIOPData.getByteBuffer(offset, struAIOPPic.dwAIOPDataSize); - byte[] bytes = new byte[struAIOPPic.dwAIOPDataSize]; - 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(); - } - } - break; - - //AI开放平台接入轮询抓图检测报警信息 - case HCNetSDK.COMM_UPLOAD_AIOP_POLLING_SNAP: - System.out.println("AI开放平台接入轮询抓图检测报警事件上传"); - HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD strAiopPollingPic = new HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD(); - strAiopPollingPic.write(); - Pointer pAiopPollingPic = strAiopPollingPic.getPointer(); - pAiopPollingPic.write(0, pAlarmInfo.getByteArray(0, strAiopPollingPic.size()), 0, strAiopPollingPic.size()); - strAiopPollingPic.read(); - System.out.println("通道号:" + strAiopPollingPic.dwChannel); - System.out.println("轮询抓图任务ID:" + new String(strAiopPollingPic.szTaskID)); - String strPollingPicTime = "" + String.format("%04d", strAiopPollingPic.struTime.wYear) + - String.format("%02d", strAiopPollingPic.struTime.wMonth) + - String.format("%02d", strAiopPollingPic.struTime.wDay) + - String.format("%02d", strAiopPollingPic.struTime.wHour) + - String.format("%02d", strAiopPollingPic.struTime.wMinute) + - String.format("%02d", strAiopPollingPic.struTime.wSecond) + - String.format("%03d", strAiopPollingPic.struTime.wMilliSec); - //AIOPData数据保存 - if (strAiopPollingPic.dwAIOPDataSize > 0) { - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + - "_" + strPollingPicTime + "_PollingPicData.json"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strAiopPollingPic.pBufferAIOPData.getByteBuffer(offset, strAiopPollingPic.dwAIOPDataSize); - byte[] bytes = new byte[strAiopPollingPic.dwAIOPDataSize]; - 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 (strAiopPollingPic.dwPictureSize > 0) { - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + - "_" + strPollingPicTime + "_PollingPic.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strAiopPollingPic.pBufferPicture.getByteBuffer(offset, strAiopPollingPic.dwPictureSize); - byte[] bytes = new byte[strAiopPollingPic.dwPictureSize]; - 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(); - } - } - - break; - //AI开放平台接入轮询视频检测报警信息 - case HCNetSDK.COMM_UPLOAD_AIOP_POLLING_VIDEO: - System.out.println("AI开放平台接入轮询视频检测报警事件上传"); - HCNetSDK.NET_AIOP_POLLING_VIDEO_HEAD strAiopPollingVideo = new HCNetSDK.NET_AIOP_POLLING_VIDEO_HEAD(); - strAiopPollingVideo.write(); - Pointer pAiopPollingVideo = strAiopPollingVideo.getPointer(); - pAiopPollingVideo.write(0, pAlarmInfo.getByteArray(0, strAiopPollingVideo.size()), 0, strAiopPollingVideo.size()); - strAiopPollingVideo.read(); - System.out.println("通道号:" + strAiopPollingVideo.dwChannel); - System.out.println("轮询视频任务ID:" + new String(strAiopPollingVideo.szTaskID)); - String AiopPollingVideoTime = "" + String.format("%04d", strAiopPollingVideo.struTime.wYear) + - String.format("%02d", strAiopPollingVideo.struTime.wMonth) + - String.format("%02d", strAiopPollingVideo.struTime.wDay) + - String.format("%02d", strAiopPollingVideo.struTime.wHour) + - String.format("%02d", strAiopPollingVideo.struTime.wMinute) + - String.format("%02d", strAiopPollingVideo.struTime.wSecond) + - String.format("%03d", strAiopPollingVideo.struTime.wMilliSec); - //AIOPData数据保存 - if (strAiopPollingVideo.dwAIOPDataSize > 0) { - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + - "_" + AiopPollingVideoTime + "_PollingVideoData.json"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strAiopPollingVideo.pBufferAIOPData.getByteBuffer(offset, strAiopPollingVideo.dwAIOPDataSize); - byte[] bytes = new byte[strAiopPollingVideo.dwAIOPDataSize]; - 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 (strAiopPollingVideo.dwPictureSize > 0) { - FileOutputStream fout; - try { - String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + - "_" + AiopPollingVideoTime + "_PollingVideo.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = strAiopPollingVideo.pBufferPicture.getByteBuffer(offset, strAiopPollingVideo.dwPictureSize); - byte[] bytes = new byte[strAiopPollingVideo.dwPictureSize]; - 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(); - } - } - break; - default: - System.out.println("报警类型" + Integer.toHexString(lCommand)); - break; - } - } -} +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_" + "_ThermalShipAlarm" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struShipAlarm.pThermalPicBuffer.getByteBuffer(offset, struShipAlarm.dwThermalPicLen); +// byte[] bytes = new byte[struShipAlarm.dwThermalPicLen]; +// 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(); +// } +// +// } +// break; +// +// case HCNetSDK.COMM_FIREDETECTION_ALARM://烟火检测 +// 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.dwVisiblePicLen > 0) && (struFireDecAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_FireDecAlarm" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struFireDecAlarm.pVisiblePicBuf.getByteBuffer(offset, struFireDecAlarm.dwVisiblePicLen); +// byte[] bytes = new byte[struFireDecAlarm.dwVisiblePicLen]; +// 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 ((struFireDecAlarm.dwPicDataLen > 0) && (struFireDecAlarm.byPicTransType == 0)) { +// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String newName = sf.format(new Date()); +// FileOutputStream fout; +// +// try { +// String filename = "../pic/" + newName + "_" + "_ThermalFireAlarm" + ".jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struFireDecAlarm.pBuffer.getByteBuffer(offset, struFireDecAlarm.dwPicDataLen); +// byte[] bytes = new byte[struFireDecAlarm.dwPicDataLen]; +// 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(); +// } +// +// } +// break; +// case HCNetSDK.COMM_UPLOAD_AIOP_VIDEO: //AI开放平台接入视频检测报警信息 +// System.out.println("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(); +// System.out.println("视频任务ID" + new String(struAIOPVideo.szTaskID)); +// System.out.println("通道号:" + struAIOPVideo.dwChannel); +// System.out.println("检测模型包ID" + new String(struAIOPVideo.szMPID)); +// String strTime = 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); +// //AIOPData数据 +// if (struAIOPVideo.dwAIOPDataSize > 0) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + +// "_" + strTime + "_VideoData.json"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struAIOPVideo.pBufferAIOPData.getByteBuffer(offset, struAIOPVideo.dwAIOPDataSize); +// byte[] bytes = new byte[struAIOPVideo.dwAIOPDataSize]; +// 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 (struAIOPVideo.dwPictureSize > 0) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + +// "_" + strTime + "_VideoPic.jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struAIOPVideo.pBufferPicture.getByteBuffer(offset, struAIOPVideo.dwPictureSize); +// byte[] bytes = new byte[struAIOPVideo.dwPictureSize]; +// 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(); +// } +// } +// break; +// case HCNetSDK.COMM_UPLOAD_AIOP_PICTURE: //AI开放平台接入图片检测报警信息 +// System.out.println("AI开放平台接入图片检测报警上传"); +// HCNetSDK.NET_AIOP_PICTURE_HEAD struAIOPPic = new HCNetSDK.NET_AIOP_PICTURE_HEAD(); +// struAIOPPic.write(); +// Pointer pAIOPPic = struAIOPPic.getPointer(); +// pAIOPPic.write(0, pAlarmInfo.getByteArray(0, struAIOPPic.size()), 0, struAIOPPic.size()); +// struAIOPPic.read(); +// System.out.println("图片ID:" + new String(struAIOPPic.szPID)); +// System.out.println("检测模型包ID:" + new String(struAIOPPic.szMPID)); +// String strPicTime = "" + String.format("%04d", struAIOPPic.struTime.wYear) + +// String.format("%02d", struAIOPPic.struTime.wMonth) + +// String.format("%02d", struAIOPPic.struTime.wDay) + +// String.format("%02d", struAIOPPic.struTime.wHour) + +// String.format("%02d", struAIOPPic.struTime.wMinute) + +// String.format("%02d", struAIOPPic.struTime.wSecond) + +// String.format("%03d", struAIOPPic.struTime.wMilliSec); +// //AIOPData数据 +// if (struAIOPPic.dwAIOPDataSize > 0) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + +// "_" + strPicTime + "_AIO_PicData.json"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = struAIOPPic.pBufferAIOPData.getByteBuffer(offset, struAIOPPic.dwAIOPDataSize); +// byte[] bytes = new byte[struAIOPPic.dwAIOPDataSize]; +// 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(); +// } +// } +// break; +// +// //AI开放平台接入轮询抓图检测报警信息 +// case HCNetSDK.COMM_UPLOAD_AIOP_POLLING_SNAP: +// System.out.println("AI开放平台接入轮询抓图检测报警事件上传"); +// HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD strAiopPollingPic = new HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD(); +// strAiopPollingPic.write(); +// Pointer pAiopPollingPic = strAiopPollingPic.getPointer(); +// pAiopPollingPic.write(0, pAlarmInfo.getByteArray(0, strAiopPollingPic.size()), 0, strAiopPollingPic.size()); +// strAiopPollingPic.read(); +// System.out.println("通道号:" + strAiopPollingPic.dwChannel); +// System.out.println("轮询抓图任务ID:" + new String(strAiopPollingPic.szTaskID)); +// String strPollingPicTime = "" + String.format("%04d", strAiopPollingPic.struTime.wYear) + +// String.format("%02d", strAiopPollingPic.struTime.wMonth) + +// String.format("%02d", strAiopPollingPic.struTime.wDay) + +// String.format("%02d", strAiopPollingPic.struTime.wHour) + +// String.format("%02d", strAiopPollingPic.struTime.wMinute) + +// String.format("%02d", strAiopPollingPic.struTime.wSecond) + +// String.format("%03d", strAiopPollingPic.struTime.wMilliSec); +// //AIOPData数据保存 +// if (strAiopPollingPic.dwAIOPDataSize > 0) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + +// "_" + strPollingPicTime + "_PollingPicData.json"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strAiopPollingPic.pBufferAIOPData.getByteBuffer(offset, strAiopPollingPic.dwAIOPDataSize); +// byte[] bytes = new byte[strAiopPollingPic.dwAIOPDataSize]; +// 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 (strAiopPollingPic.dwPictureSize > 0) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + +// "_" + strPollingPicTime + "_PollingPic.jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strAiopPollingPic.pBufferPicture.getByteBuffer(offset, strAiopPollingPic.dwPictureSize); +// byte[] bytes = new byte[strAiopPollingPic.dwPictureSize]; +// 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(); +// } +// } +// +// break; +// //AI开放平台接入轮询视频检测报警信息 +// case HCNetSDK.COMM_UPLOAD_AIOP_POLLING_VIDEO: +// System.out.println("AI开放平台接入轮询视频检测报警事件上传"); +// HCNetSDK.NET_AIOP_POLLING_VIDEO_HEAD strAiopPollingVideo = new HCNetSDK.NET_AIOP_POLLING_VIDEO_HEAD(); +// strAiopPollingVideo.write(); +// Pointer pAiopPollingVideo = strAiopPollingVideo.getPointer(); +// pAiopPollingVideo.write(0, pAlarmInfo.getByteArray(0, strAiopPollingVideo.size()), 0, strAiopPollingVideo.size()); +// strAiopPollingVideo.read(); +// System.out.println("通道号:" + strAiopPollingVideo.dwChannel); +// System.out.println("轮询视频任务ID:" + new String(strAiopPollingVideo.szTaskID)); +// String AiopPollingVideoTime = "" + String.format("%04d", strAiopPollingVideo.struTime.wYear) + +// String.format("%02d", strAiopPollingVideo.struTime.wMonth) + +// String.format("%02d", strAiopPollingVideo.struTime.wDay) + +// String.format("%02d", strAiopPollingVideo.struTime.wHour) + +// String.format("%02d", strAiopPollingVideo.struTime.wMinute) + +// String.format("%02d", strAiopPollingVideo.struTime.wSecond) + +// String.format("%03d", strAiopPollingVideo.struTime.wMilliSec); +// //AIOPData数据保存 +// if (strAiopPollingVideo.dwAIOPDataSize > 0) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + +// "_" + AiopPollingVideoTime + "_PollingVideoData.json"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strAiopPollingVideo.pBufferAIOPData.getByteBuffer(offset, strAiopPollingVideo.dwAIOPDataSize); +// byte[] bytes = new byte[strAiopPollingVideo.dwAIOPDataSize]; +// 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 (strAiopPollingVideo.dwPictureSize > 0) { +// FileOutputStream fout; +// try { +// String filename = "../pic/" + new String(pAlarmer.sDeviceIP).trim() + +// "_" + AiopPollingVideoTime + "_PollingVideo.jpg"; +// fout = new FileOutputStream(filename); +// //将字节写入文件 +// long offset = 0; +// ByteBuffer buffers = strAiopPollingVideo.pBufferPicture.getByteBuffer(offset, strAiopPollingVideo.dwPictureSize); +// byte[] bytes = new byte[strAiopPollingVideo.dwPictureSize]; +// 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(); +// } +// } +// break; +// default: +// System.out.println("报警类型" + Integer.toHexString(lCommand)); +// break; +// } +// } +//} diff --git a/src/main/java/com/shxy/xyhkcamera/alarm/FMSGCallBack_V31.java b/src/main/java/com/shxy/xyhkcamera/alarm/FMSGCallBack_V31.java index 90af790..0a18041 100644 --- a/src/main/java/com/shxy/xyhkcamera/alarm/FMSGCallBack_V31.java +++ b/src/main/java/com/shxy/xyhkcamera/alarm/FMSGCallBack_V31.java @@ -1,22 +1,22 @@ - -package com.shxy.xyhkcamera.alarm; - -import com.shxy.xyhkcamera.hk.HCNetSDK; -import com.sun.jna.Pointer; - - - -public class FMSGCallBack_V31 implements HCNetSDK.FMSGCallBack_V31 { - //报警信息回调函数 - public boolean invoke(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) { - AlarmDataParse.alarmDataHandle(lCommand, pAlarmer, pAlarmInfo, dwBufLen, pUser); - return true; - } -} - - - - - - - +// +//package com.shxy.xyhkcamera.alarm; +// +//import com.shxy.xyhkcamera.hk.HCNetSDK; +//import com.sun.jna.Pointer; +// +// +// +//public class FMSGCallBack_V31 implements HCNetSDK.FMSGCallBack_V31 { +// //报警信息回调函数 +// public boolean invoke(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) { +// AlarmDataParse.alarmDataHandle(lCommand, pAlarmer, pAlarmInfo, dwBufLen, pUser); +// return true; +// } +//} +// +// +// +// +// +// +// diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/ACSManage.java b/src/main/java/com/shxy/xyhkcamera/ascest/ACSManage.java deleted file mode 100644 index 62e5289..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/ACSManage.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.shxy.xyhkcamera.ascest; - - -import com.shxy.xyhkcamera.hk.HCNetSDK; -import com.sun.jna.ptr.IntByReference; - -/** - * 门禁设备管理: - * 1、获取(设置)门禁主机参数 - * 2、获取门禁主机工作状态 - */ -public final class ACSManage { - - /** - * 获取(设置)门禁主机参数 - * - * @param lUserID 用户登录句柄 - */ - public static void acsCfg(int lUserID) { - - /**获取门禁主机参数*/ - HCNetSDK.NET_DVR_ACS_CFG struAcsCfg = new HCNetSDK.NET_DVR_ACS_CFG(); - struAcsCfg.dwSize = struAcsCfg.size(); - struAcsCfg.write(); - IntByReference intByReference = new IntByReference(0); - boolean b_GetAcsCfg = AcsMain.hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_ACS_CFG, 0xFFFFFFFF, struAcsCfg.getPointer(), - struAcsCfg.size(), intByReference); - if (b_GetAcsCfg = false) { - System.out.println("获取门禁主机参数,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - return; - } else { - System.out.println("获取门禁主机参数成功"); - struAcsCfg.read(); - System.out.println("1.是否显示抓拍图片:" + struAcsCfg.byShowCapPic + "\n"); //是否显示抓拍图片, 0-不显示,1-显示 - System.out.println("2.是否显示卡号:" + struAcsCfg.byShowCardNo + "\n"); //是否显示卡号,0-不显示,1-显示 - System.out.println("3.是否开启语音提示:" + struAcsCfg.byVoicePrompt + "\n"); //是否启用语音提示,0-不启用,1-启用 - System.out.println("4.联动抓图是否上传:" + struAcsCfg.byUploadCapPic + "\n"); //联动抓拍是否上传图片,0-不上传,1-上传 - } - - /**设置门禁主机参数*/ - struAcsCfg.byShowCardNo = 1; //开启显示卡号 - struAcsCfg.byVoicePrompt = 0; //关闭语音提示 - struAcsCfg.byUploadCapPic = 1; //开启联动抓图后,设备上抓拍的图片才会通过报警布防上传,否则没有不上传 - struAcsCfg.byShowCapPic = 1; - struAcsCfg.write(); - boolean b_SetAcsCfg = AcsMain.hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_ACS_CFG, 0xFFFFFFFF, struAcsCfg.getPointer(), struAcsCfg.size()); - if (b_SetAcsCfg = false) { - System.out.println("设置门禁主机参数,错误码为:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - return; - } else { - System.out.println("设置门禁主机参数成功!!!"); - } - } - - /** - * 获取门禁主机工作状态 - * - * @param lUserID 用户登录句柄 - */ - public static void getAcsStatus(int lUserID){ - HCNetSDK.NET_DVR_ACS_WORK_STATUS_V50 netDvrAcsWorkStatusV50 = new HCNetSDK.NET_DVR_ACS_WORK_STATUS_V50(); - netDvrAcsWorkStatusV50.dwSize = netDvrAcsWorkStatusV50.size(); - netDvrAcsWorkStatusV50.write(); - IntByReference intByReference = new IntByReference(0); - boolean b_GetAcsStatus = AcsMain.hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_ACS_WORK_STATUS_V50, 0xFFFFFFFF, netDvrAcsWorkStatusV50.getPointer(), - netDvrAcsWorkStatusV50.size(), intByReference); - if (b_GetAcsStatus = false) { - System.out.println("获取门禁主机工作状态,错误码为:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - return; - } else { - System.out.println("获取门禁主机工作状态成功!!!"); - netDvrAcsWorkStatusV50.read(); - System.out.println("1.门锁状态(或者梯控的继电器开合状态):" + netDvrAcsWorkStatusV50.byDoorLockStatus[0] + "\n"); //门锁状态:0- 正常关,1- 正常开,2- 短路报警,3- 断路报警,4- 异常报警 - System.out.println("2.门状态(或者梯控的楼层状态):" + netDvrAcsWorkStatusV50.byDoorStatus[0] + "\n"); //门状态(或者梯控的楼层状态):1- 休眠,2- 常开状态(对于梯控,表示自由状态),3- 常闭状态(对于梯控,表示禁用状态),4- 普通状态(对于梯控,表示受控状态) - System.out.println("3.门磁状态:" + netDvrAcsWorkStatusV50.byMagneticStatus[0] + "\n"); //门磁状态,0-正常关,1-正常开,2-短路报警,3-断路报警,4-异常报警 - System.out.println("4.事件报警输入状态:" + netDvrAcsWorkStatusV50.byCaseStatus[0] + "\n"); //事件报警输入状态:0- 无输入,1- 有输入 - } - } - - /** - * 远程控门 - * @param userID - */ - public static void remoteControlGate(int userID) - { - /**第二个参数lGatewayIndex - [in] 门禁序号(楼层编号、锁ID),从1开始,-1表示对所有门(或者梯控的所有楼层)进行操作 - 第三个参数dwStaic - [in] 命令值:0- 关闭(对于梯控,表示受控),1- 打开(对于梯控,表示开门),2- 常开(对于梯控,表示自由、通道状态),3- 常关(对于梯控,表示禁用),4- 恢复(梯控,普通状态),5- 访客呼梯(梯控),6- 住户呼梯(梯控)*/ - boolean b_gate= AcsMain.hCNetSDK.NET_DVR_ControlGateway(userID,1,1); - if (b_gate==false) - { - System.out.println("远程控门失败,err="+ AcsMain.hCNetSDK.NET_DVR_GetLastError()); - return; - } - System.out.println("远程控门成功"); - return; - } -} diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/AcsMain.java b/src/main/java/com/shxy/xyhkcamera/ascest/AcsMain.java deleted file mode 100644 index ed64b1f..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/AcsMain.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.shxy.xyhkcamera.ascest; - - -import com.shxy.xyhkcamera.hk.HCNetSDK; -import com.shxy.xyhkcamera.utils.osSelect; -import com.sun.jna.Native; - -import java.io.UnsupportedEncodingException; - - -public class AcsMain { - - static HCNetSDK hCNetSDK = null; - static int lUserID = -1;//用户句柄 - static int iCharEncodeType = 0;//设备字符集 - - - - /** - * 根据不同操作系统选择不同的库文件和库路径 - * @return - */ - private static boolean createSDKInstance() - { - if(hCNetSDK == null) - { - synchronized (HCNetSDK.class) - { - String strDllPath = ""; - try - { - //System.setProperty("jna.debug_load", "true"); - if(osSelect.isWindows()) - //win系统加载库路径 - strDllPath = System.getProperty("user.dir") + "\\lib\\HCNetSDK.dll"; - else if(osSelect.isLinux()) - //Linux系统加载库路径 - strDllPath = System.getProperty("user.dir") + "/lib/libhcnetsdk.so"; - hCNetSDK = (HCNetSDK) Native.loadLibrary(strDllPath, HCNetSDK.class); - }catch (Exception ex) { - System.out.println("loadLibrary: " + strDllPath + " Error: " + ex.getMessage()); - return false; - } - } - } - return true; - } - - /** - * @param args - * @throws UnsupportedEncodingException - * @throws InterruptedException - */ - public static void main(String[] args) throws UnsupportedEncodingException, InterruptedException { - - - if(hCNetSDK == null) - { - if(!createSDKInstance()) - { - System.out.println("Load SDK fail"); - return; - } - } - //linux系统建议调用以下接口加载组件库 - if (osSelect.isLinux()) - { - HCNetSDK.BYTE_ARRAY ptrByteArray1 = new HCNetSDK.BYTE_ARRAY(256); - HCNetSDK.BYTE_ARRAY ptrByteArray2 = new HCNetSDK.BYTE_ARRAY(256); - //这里是库的绝对路径,请根据实际情况修改,注意改路径必须有访问权限 - String strPath1 = System.getProperty("user.dir") + "/lib/libcrypto.so.1.1"; - String strPath2 = System.getProperty("user.dir") + "/lib/libssl.so.1.1"; - - System.arraycopy(strPath1.getBytes(), 0, ptrByteArray1.byValue, 0, strPath1.length()); - ptrByteArray1.write(); - hCNetSDK.NET_DVR_SetSDKInitCfg(3, ptrByteArray1.getPointer()); - - System.arraycopy(strPath2.getBytes(), 0, ptrByteArray2.byValue, 0, strPath2.length()); - ptrByteArray2.write(); - hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArray2.getPointer()); - - String strPathCom = System.getProperty("user.dir") + "/lib/"; - HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH(); - System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length()); - struComPath.write(); - hCNetSDK.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer()); - } - - hCNetSDK.NET_DVR_Init(); - //开启SDK日志打印 - boolean i= hCNetSDK.NET_DVR_SetLogToFile(3, "./sdklog", false); - - login_V40("10.16.36.13","admin","hik12345",(short) 8000); //登陆设备 - /** - * 人员管理模块 - */ -// UserManage.searchUserInfo(lUserID); //查询所有人员 -// UserManage.deleteUserInfo(lUserID); -// UserManage.addUserInfo(lUserID,"test20221122"); //添加人员 - - /** - * 人脸管理模块 - */ -// FaceManage.searchFaceInfo(lUserID,"tset123"); -// FaceManage.addFaceByBinary(lUserID,"test20221122"); -// FaceManage.addFaceByUrl(lUserID,"test111"); -// FaceManage.deleteFaceInfo(lUserID,"test111"); -// FaceManage.captureFaceInfo(lUserID); - - /** - * 卡号管理模块 - */ -// CardManage.searchCardInfo(lUserID,"ceshi1"); -// CardManage.addCardInfo(lUserID,"12345"); -// CardManage.searchCardInfo(lUserID,"test111"); -// CardManage.searchAllCardInfo(lUserID); -// CardManage.deleteCardInfo(lUserID,"111"); -// CardManage.deleteAllCardInfo(lUserID); -// CardManage.getAllCardNumber(lUserID); - /** - * 指纹管理模块 - */ -// FingerManage.fingerCapture(lUserID); -// FingerManage.fingerCpaureByisapi(lUserID); -// FingerManage.fingerCpaureByisapi(lUserID); -// FingerManage.SearchFingerInfo(lUserID,"2222"); - //指纹数据的BASE64编码 -// String fingerdata=""; -// FingerManage.setOneFinger(lUserID,"zhangsan",fingerdata); -// FingerManage.deleteFinger(lUserID,"zhangsan"); - - /** - * 事件查询 - */ -// EventSearch.searchAllEvent(lUserID); - - //多重认证 -// MutilCard.setGroupCfg(lUserID); -// MutilCard.setMultiCardCfg(lUserID); - //计划模板 -// UserManage.setCardTemplate(lUserID,2); - - - - /** - * 增加sleep时间,保证程序一直运行, - - */ - Thread.sleep(20000); - /** - * 撤防,端口监听,注销设备 - */ - AcsMain.logout(); - - //释放SDK,程序退出前调用 - hCNetSDK.NET_DVR_Cleanup(); - - } - - - /** - * 设备登录 - * @param ipadress IP地址 - * @param user 用户名 - * @param psw 密码 - * @param port 端口,默认8000 - */ - public static void login_V40(String ipadress, String user, String psw, short port) { - //注册 - HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息 - String m_sDeviceIP = ipadress;//设备ip地址 - m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN]; - System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length()); - String m_sUsername = user;//设备用户名 - m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN]; - System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length()); - String m_sPassword = psw;//设备密码 - m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN]; - System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length()); - m_strLoginInfo.wPort = port; //sdk端口 - m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是 - m_strLoginInfo.write(); - HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息 - lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo); - if (lUserID == -1) { - System.out.println("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError()); - return; - } else { - System.out.println("登录成功!"); - m_strDeviceInfo.read(); - iCharEncodeType = m_strDeviceInfo.byCharEncodeType; - return; - - } - } - - - /** - * 登出操作 - * - */ - public static void logout(){ - /**登出和清理,释放SDK资源*/ - if (lUserID>=0) - { - if (!hCNetSDK.NET_DVR_Logout(lUserID)) - { - System.out.println("设备注销失败,错误码:" + hCNetSDK.NET_DVR_GetLastError()); - return; - } - System.out.println("设备注销成功!!!"); - } - - } - - - - - -}//AcsMain Class结束 diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/CardManage.java b/src/main/java/com/shxy/xyhkcamera/ascest/CardManage.java deleted file mode 100644 index 0d59cdd..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/CardManage.java +++ /dev/null @@ -1,215 +0,0 @@ -//package com.shxy.xyhkcamera.ascest; -// -// -//import com.shxy.xyhkcamera.hk.HCNetSDK; -//import com.sun.jna.ptr.IntByReference; -// -///** -// * 卡管理,以人为中心,要先下发工号,卡号要关联在人员工号上 -// */ -//public final class CardManage { -// -// -//// /** -//// * 下发卡号, -//// * @param userID 用户注册ID -//// * @param cardNo 卡号 -//// */ -//// public static void addCardInfo(int userID,String cardNo) { -//// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -//// String strInBuffer = "POST /ISAPI/AccessControl/CardInfo/Record?format=json"; -//// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -//// ptrByteArray.write(); -//// -//// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -//// if (lHandler < 0) -//// { -//// System.out.println("AddCardInfo NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError()); -//// return; -//// } -//// else{ -//// System.out.println("AddCardInfo NET_DVR_StartRemoteConfig 成功!"); -//// HCNetSDK.BYTE_ARRAY lpInput = new HCNetSDK.BYTE_ARRAY(1024); //数组 -//// String strJsonData = "{\n" + -//// " \"CardInfo\" : {\n" + -//// " \"employeeNo\":\"ceshi1\", \n" + -//// " \"cardNo\":\""+cardNo+"\", \n" + -//// " \"cardType\":\"normalCard\"\n" + -//// " } \n" + -//// "}"; -//// System.arraycopy(strJsonData.getBytes(), 0, lpInput.byValue, 0, strJsonData.length());//字符串拷贝到数组中 -//// lpInput.write(); -//// HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1024); -//// IntByReference pInt = new IntByReference(0); -//// while(true){ -//// /* -//// 如果需要批量下发,循环调用NET_DVR_SendWithRecvRemoteConfig接口进行下发不同的卡号,下发结束完成后关闭下发卡号长连接 -//// */ -//// int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, lpInput.getPointer(), lpInput.byValue.length ,ptrOutuff.getPointer(), 1024, pInt); -//// //读取返回的json并解析 -//// ptrOutuff.read(); -//// String strResult = new String(ptrOutuff.byValue).trim(); -//// System.out.println("dwState:" + dwState + ",strResult:" + strResult); -//// -//// JSONObject jsonResult = new JSONObject(strResult); -//// int statusCode = jsonResult.getInt("statusCode"); -//// String statusString = jsonResult.getString("statusString"); -//// -//// if(dwState == -1){ -//// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -//// break; -//// } -//// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) -//// { -//// System.out.println("配置等待"); -//// try { -//// Thread.sleep(10); -//// } catch (InterruptedException e) { -//// e.printStackTrace(); -//// } -//// continue; -//// } -//// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) -//// { -//// System.out.println("下发卡号失败, json retun:" + jsonResult.toString()); -//// break; -//// } -//// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) -//// { -//// System.out.println("下发卡号异常, json retun:" + jsonResult.toString()); -//// break; -//// } -//// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) -//// { -//// if (statusCode != 1){ -//// System.out.println("下发卡号成功,但是有异常情况:" + jsonResult.toString()); -//// } -//// else{ -//// System.out.println("下发卡号成功, json retun:" + jsonResult.toString()); -//// } -//// break; -//// } -//// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -//// -//// System.out.println("下发卡号完成"); -//// break; -//// } -//// } -//// if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){ -//// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -//// } -//// else{ -//// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -//// } -//// } -//// } -// -// -// /** -// * 按照人员工号查询卡号 -// * @param userID -// * @param employeeNo -// */ -// public static void searchCardInfo(int userID, String employeeNo) -// { -// String searchCardInfoUrl="POST /ISAPI/AccessControl/CardInfo/Search?format=json"; -// String searchCardInfojson="{\n" + -// " \"CardInfoSearchCond\": {\n" + -// " \"searchID\": \"20201014001\",\n" + -// " \"searchResultPosition\": 0,\n" + -// " \"maxResults\": 30,\n" + -// " \"EmployeeNoList\" : [\n" + -// " {\n" + -// " \"employeeNo\": \""+employeeNo+"\"\n" + -// " }\n" + -// " ]\n" + -// " }\n" + -// "}"; -// String result= TransIsapi.put_isapi(userID,searchCardInfoUrl,searchCardInfojson); -// System.out.println(result); -// -// } -// -// /** -// * 查询所有卡号 -// * @param userID -// */ -// public static void searchAllCardInfo(int userID) -// { -// String searchCardInfoUrl="POST /ISAPI/AccessControl/CardInfo/Search?format=json"; -// /* -// "searchID": "", //必填,搜索记录唯一标识,用来确认上层客户端是否为同一个(倘若是同一个,设备记录内存, -// 下次搜索加快速度),string类型 -// "searchResultPosition": 0, //必填,查询结果在结果列表中的起始位置,integer32类型;当记录条数很多时, -// 一次查询不能获取所有的记录,下一次查询时指定位置可以查询后面的记录 -// "maxResults": 30, //必填,本次协议调用可获取的最大记录数,integer32类型(如maxResults值大于设备能力集返回的范围, -// 则设备按照能力集最大值返回,设备不进行报错 -// */ -// String searchCardInfojson="{\n" + -// " \"CardInfoSearchCond\": {\n" + -// " \"searchID\": \"20211129001\",\n" + -// " \"searchResultPosition\": 0,\n" + -// " \"maxResults\": 30\n" + -// " }\n" + -// "}"; -// String result= com.shxy.xyhkcamera.asc.TransIsapi.put_isapi(userID,searchCardInfoUrl,searchCardInfojson); -// System.out.println(result); -// } -// -// -// /** -// * 根据工号删除卡号, -// * @param userID -// * @param employeeNo -// */ -// public static void deleteCardInfo(int userID,String employeeNo ) -// { -// String deleteCardInfoURL="PUT /ISAPI/AccessControl/CardInfo/Delete?format=json "; -// String deleteCardInfojson="{\n" + -// " \"CardInfoDelCond\" : {\n" + -// " \"EmployeeNoList\" : [ \n" + -// " {\n" + -// " \"employeeNo\": \""+employeeNo+"\" \n" + -// " }\n" + -// " ]\n" + -// " }\n" + -// "}\n"; -// String result= com.shxy.xyhkcamera.asc.TransIsapi.put_isapi(userID,deleteCardInfoURL,deleteCardInfojson); -// System.out.println(result); -// } -// -// -// /** -// * 删除全部卡号信息, -// * @param userID -// */ -// public static void deleteAllCardInfo(int userID) -// { -// String deleteAllCardInfoURL="PUT /ISAPI/AccessControl/CardInfo/Delete?format=json"; -// String deleteAllCardInfoJson="{\"CardInfoDelCond\" : {}}"; -// /* -// 如果涉及大批量卡号删除,设备需要一定的时间去处理,需要将超时时间设置成60s,put_isapi中的NET_DVR_XML_CONFIG_INPUT中dwRecvTimeOut -// 参数设置成60000 -// */ -// String result= com.shxy.xyhkcamera.asc.TransIsapi.put_isapi(userID,deleteAllCardInfoURL,deleteAllCardInfoJson); -// System.out.println(result); -// } -//// -//// -//// /** -//// * 获取所有卡数量 -//// * @param userID -//// * @return -//// */ -//// public static int getAllCardNumber(int userID) { -//// String getAllCardNumberUrl="GET /ISAPI/AccessControl/CardInfo/Count?format=json"; -//// String result= com.shxy.xyhkcamera.asc.TransIsapi.get_isapi(userID,getAllCardNumberUrl); -//// System.out.println(result); -//// JSONObject jsonObject=new JSONObject(result); -//// int num=jsonObject.optJSONObject("CardInfoCount").getInt("cardNumber"); -//// return num; -//// } -// -// -// -//} diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/EventSearch.java b/src/main/java/com/shxy/xyhkcamera/ascest/EventSearch.java deleted file mode 100644 index 6321db8..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/EventSearch.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.shxy.xyhkcamera.ascest; - -import com.shxy.xyhkcamera.hk.HCNetSDK; -import com.sun.jna.Pointer; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; - -/** - * 事件查询模块 - */ -public final class EventSearch { - - public static void searchAllEvent(int lUserID) throws UnsupportedEncodingException, InterruptedException { - int i = 0; //事件条数 - HCNetSDK.NET_DVR_ACS_EVENT_COND struAcsEventCond = new HCNetSDK.NET_DVR_ACS_EVENT_COND(); - struAcsEventCond.read(); - struAcsEventCond.dwSize = struAcsEventCond.size(); - //查询全部主次类型的报警 - struAcsEventCond.dwMajor = 0; // 主次事件类型设为0,代表查询所有事件 - struAcsEventCond.dwMinor = 0; // - //开始时间 - struAcsEventCond.struStartTime.dwYear = 2022; - struAcsEventCond.struStartTime.dwMonth = 4; - struAcsEventCond.struStartTime.dwDay = 27; - struAcsEventCond.struStartTime.dwHour = 9; - struAcsEventCond.struStartTime.dwMinute = 0; - struAcsEventCond.struStartTime.dwSecond = 0; - //结束时间 - struAcsEventCond.struEndTime.dwYear = 2022; - struAcsEventCond.struEndTime.dwMonth = 4; - struAcsEventCond.struEndTime.dwDay = 30; - struAcsEventCond.struEndTime.dwHour = 16; - struAcsEventCond.struEndTime.dwMinute = 0; - struAcsEventCond.struEndTime.dwSecond = 0; - struAcsEventCond.wInductiveEventType = 1; - struAcsEventCond.byPicEnable = 1; //是否带图片,0-不带图片,1-带图片 - struAcsEventCond.write(); - Pointer ptrStruEventCond = struAcsEventCond.getPointer(); - int m_lSearchEventHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_ACS_EVENT, ptrStruEventCond, struAcsEventCond.size(), null, null); - if (m_lSearchEventHandle<=-1) - { - System.out.println("NET_DVR_StartRemoteConfig调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - } - HCNetSDK.NET_DVR_ACS_EVENT_CFG struAcsEventCfg = new HCNetSDK.NET_DVR_ACS_EVENT_CFG(); - struAcsEventCfg.read(); - struAcsEventCfg.dwSize = struAcsEventCfg.size(); - struAcsEventCfg.write(); - Pointer ptrStruEventCfg = struAcsEventCfg.getPointer(); - while (true) { - System.out.println("i=" + i); - int dwEventSearch = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(m_lSearchEventHandle, ptrStruEventCfg, struAcsEventCfg.size()); - if (dwEventSearch <= -1) { - System.out.println("NET_DVR_GetNextRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - } - if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_NEED_WAIT) { - System.out.println("配置等待...."); - Thread.sleep(10); - continue; - } else if (dwEventSearch == HCNetSDK.NET_SDK_NEXT_STATUS__FINISH) { - System.out.println("获取事件完成"); - break; - } else if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_FAILED) { - System.out.println("获取事件出现异常"); - break; - } else if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS) { - struAcsEventCfg.read(); - //获取的事件信息通过struAcsEventCfg结构体进行解析, - System.out.println(i + "获取事件成功, 报警主类型:" + Integer.toHexString(struAcsEventCfg.dwMajor) + "报警次类型:" + Integer.toHexString(struAcsEventCfg.dwMinor) + "卡号:" + new String(struAcsEventCfg.struAcsEventInfo.byCardNo).trim()); - /** - * 工号有两个字段,dwEmployeeNo表示工号,当值为0时,表示无效,解析byEmployeeNo参数 - */ - System.out.println("工号1:"+struAcsEventCfg.struAcsEventInfo.dwEmployeeNo); - System.out.println("工号2:"+new String(struAcsEventCfg.struAcsEventInfo.byEmployeeNo)); - //人脸温度数据,需要设备和支持测温功能 - System.out.println("人脸温度:" + struAcsEventCfg.struAcsEventInfo.fCurrTemperature + "是否异常:" + struAcsEventCfg.struAcsEventInfo.byIsAbnomalTemperature); - //口罩功能,需要设备支持此功能 0-保留,1-未知,2-不戴口罩,3-戴口罩 - System.out.println("是否带口罩:"+struAcsEventCfg.struAcsEventInfo.byMask); - //人脸图片保存 - if (struAcsEventCfg.dwPicDataLen>0 || struAcsEventCfg.pPicData != null ) - { - FileOutputStream fout; - try { - /** - * 人脸图片保存路径 - */ - String filename = "..\\pic\\"+i+"_event.jpg"; - fout = new FileOutputStream(filename); - //将字节写入文件 - long offset = 0; - ByteBuffer buffers = struAcsEventCfg.pPicData.getByteBuffer(offset, struAcsEventCfg.dwPicDataLen); - byte[] bytes = new byte[struAcsEventCfg.dwPicDataLen]; - 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(); - } - } - i++; - continue; - } - } - i = 0; - if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lSearchEventHandle)) { - System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - } else { - System.out.println("NET_DVR_StopRemoteConfig接口成功"); - } - return; - } - -} diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/FaceManage.java b/src/main/java/com/shxy/xyhkcamera/ascest/FaceManage.java deleted file mode 100644 index ae36ee1..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/FaceManage.java +++ /dev/null @@ -1,490 +0,0 @@ -//package com.shxy.xyhkcamera.ascest; -// -// -//import com.shxy.xyhkcamera.hk.HCNetSDK; -//import com.sun.jna.Pointer; -//import com.sun.jna.ptr.IntByReference; -// -//import java.io.*; -//import java.nio.ByteBuffer; -//import java.text.SimpleDateFormat; -//import java.util.Date; -// -///** -// * 功能模块:人员管理,下发、查询、删除人脸图片,注:下发人脸图片前,先下发人员工号。 -// */ -//public final class FaceManage { -// -// -// /** -// * 功能:按照二进制方式下发人脸图片 -// * @param userID 用户注册ID -// * @param employeeNo 人员工号 -// * @throws InterruptedException -// */ -// public static void addFaceByBinary(int userID,String employeeNo ) throws JSONException, InterruptedException{ -// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -// String strInBuffer = "PUT /ISAPI/Intelligent/FDLib/FDSetUp?format=json"; -// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// -// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_FACE_DATA_RECORD, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -// if (lHandler < 0) -// { -// System.out.println("Addface NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } -// else{ -// System.out.println("Addface NET_DVR_StartRemoteConfig 成功!"); -// -// HCNetSDK.NET_DVR_JSON_DATA_CFG struAddFaceDataCfg = new HCNetSDK.NET_DVR_JSON_DATA_CFG(); -// struAddFaceDataCfg.read(); -// -// JSONObject jsonObject = new JSONObject(); -// jsonObject.put("faceLibType", "blackFD"); -// jsonObject.put("FDID", "1"); -// jsonObject.put("FPID", employeeNo);//人脸下发关联的工号 -// -// String strJsonData = jsonObject.toString(); -// System.arraycopy(strJsonData.getBytes(), 0, ptrByteArray.byValue, 0, strJsonData.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// struAddFaceDataCfg.dwSize = struAddFaceDataCfg.size(); -// struAddFaceDataCfg.lpJsonData = ptrByteArray.getPointer(); -// struAddFaceDataCfg.dwJsonDataSize = strJsonData.length(); -// -// /***************************************** -// * 从本地文件里面读取JPEG图片二进制数据 -// *****************************************/ -// FileInputStream picfile = null; -// int picdataLength = 0; -// try{ -// -// picfile = new FileInputStream(new File(".//pic//FDLib.jpg")); -// } -// catch(FileNotFoundException e) -// { -// e.printStackTrace(); -// } -// -// try{ -// picdataLength = picfile.available(); -// } -// catch(IOException e1) -// { -// e1.printStackTrace(); -// } -// if(picdataLength < 0) -// { -// System.out.println("input file dataSize < 0"); -// return; -// } -// -// HCNetSDK.BYTE_ARRAY ptrpicByte = new HCNetSDK.BYTE_ARRAY(picdataLength); -// try { -// picfile.read(ptrpicByte.byValue); -// } catch (IOException e2) { -// e2.printStackTrace(); -// } -// ptrpicByte.write(); -// struAddFaceDataCfg.dwPicDataSize = picdataLength; -// struAddFaceDataCfg.lpPicData = ptrpicByte.getPointer(); -// struAddFaceDataCfg.write(); -// -// HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1024); -// -// IntByReference pInt = new IntByReference(0); -// -// while(true){ -// int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, struAddFaceDataCfg.getPointer(), struAddFaceDataCfg.dwSize ,ptrOutuff.getPointer(), 1024, pInt); -// if(dwState == -1){ -// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } -// //读取返回的json并解析 -// ptrOutuff.read(); -// String strResult = new String(ptrOutuff.byValue).trim(); -// System.out.println("dwState:" + dwState + ",strResult:" + strResult); -// -// JSONObject jsonResult = new JSONObject(strResult); -// int statusCode = jsonResult.getInt("statusCode"); -// String statusString = jsonResult.getString("statusString"); -// if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) -// { -// System.out.println("配置等待"); -// Thread.sleep(10); -// continue; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) -// { -// System.out.println("下发人脸失败, json retun:" + jsonResult.toString()); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) -// { -// System.out.println("下发人脸异常, json retun:" + jsonResult.toString()); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) -// {//返回NET_SDK_CONFIG_STATUS_SUCCESS代表流程走通了,但并不代表下发成功,比如人脸图片不符合设备规范等原因,所以需要解析Json报文 -// if (statusCode != 1){ -// System.out.println("下发人脸成功,但是有异常情况:" + jsonResult.toString()); -// } -// else{ -// System.out.println("下发人脸成功, json retun:" + jsonResult.toString()); -// } -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -// //下发人脸时:dwState其实不会走到这里,因为设备不知道我们会下发多少个人,所以长连接需要我们主动关闭 -// System.out.println("下发人脸完成"); -// break; -// } -// } -// if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){ -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } -// else{ -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// } -// } -// -// } -// -// -// /** -// * 按URL方式下发人脸图片 -// * @param userID 用户注销ID -// * @param employeeNo 人员工号 -// * @throws JSONException -// */ -// public static void addFaceByUrl(int userID,String employeeNo) throws JSONException { -// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -// String strInBuffer = "PUT /ISAPI/Intelligent/FDLib/FDSetUp?format=json"; -// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// -// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_FACE_DATA_RECORD, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -// if (lHandler < 0) -// { -// System.out.println("Addface NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } -// else{ -// System.out.println("Addface NET_DVR_StartRemoteConfig 成功!"); -// -// HCNetSDK.NET_DVR_JSON_DATA_CFG struAddFaceDataCfg = new HCNetSDK.NET_DVR_JSON_DATA_CFG(); -// struAddFaceDataCfg.read(); -// -// JSONObject jsonObject = new JSONObject(); -// jsonObject.put("faceURL","http://10.17.34.106:6011/pic?7DD9D70207A9D7F576F99AC197B2D6CAface.jpg"); //人脸图片URL -// jsonObject.put("faceLibType", "blackFD"); -// jsonObject.put("FDID", "1"); -// jsonObject.put("FPID", employeeNo);//人脸下发关联的工号 -// -// String strJsonData = jsonObject.toString(); -// System.arraycopy(strJsonData.getBytes(), 0, ptrByteArray.byValue, 0, strJsonData.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// struAddFaceDataCfg.dwSize = struAddFaceDataCfg.size(); -// struAddFaceDataCfg.lpJsonData = ptrByteArray.getPointer(); -// struAddFaceDataCfg.dwJsonDataSize = strJsonData.length(); -// struAddFaceDataCfg.lpPicData = null; -// struAddFaceDataCfg.dwPicDataSize=0; -// struAddFaceDataCfg.write(); -// HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1024); -// -// IntByReference pInt = new IntByReference(0); -// -// while(true){ -// int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, struAddFaceDataCfg.getPointer(), struAddFaceDataCfg.dwSize ,ptrOutuff.getPointer(), 1024, pInt); -// -// if(dwState == -1){ -// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } -// //读取返回的json并解析 -// ptrOutuff.read(); -// String strResult = new String(ptrOutuff.byValue).trim(); -// System.out.println("dwState:" + dwState + ",strResult:" + strResult); -// -// JSONObject jsonResult = new JSONObject(strResult); -// int statusCode = jsonResult.getInt("statusCode"); -// String statusString = jsonResult.getString("statusString"); -// if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) -// { -// System.out.println("配置等待"); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } -// continue; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) -// { -// System.out.println("下发人脸失败, json retun:" + jsonResult.toString()); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) -// { -// System.out.println("下发人脸异常, json retun:" + jsonResult.toString()); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) -// {//返回NET_SDK_CONFIG_STATUS_SUCCESS代表流程走通了,但并不代表下发成功,比如人脸图片不符合设备规范等原因,所以需要解析Json报文 -// if (statusCode != 1){ -// System.out.println("下发人脸成功,但是有异常情况:" + jsonResult.toString()); -// } -// else{ -// System.out.println("下发人脸成功, json retun:" + jsonResult.toString()); -// } -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -// //下发人脸时:dwState其实不会走到这里,因为设备不知道我们会下发多少个人,所以长连接需要我们主动关闭 -// System.out.println("下发人脸完成"); -// break; -// } -// } -// if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){ -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } -// else{ -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// } -// } -// } -// -// -// /** -// * 查询人脸 -// * @param userID -// * @param employeeNo -// * @throws JSONException -// */ -// public static void searchFaceInfo(int userID,String employeeNo) throws JSONException{ -// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -// String strInBuffer = "POST /ISAPI/Intelligent/FDLib/FDSearch?format=json"; -// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// -// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_FACE_DATA_SEARCH, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -// if (lHandler < 0) -// { -// System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } -// else{ -// System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig成功!"); -// -// JSONObject jsonObject = new JSONObject(); -// jsonObject.put("searchResultPosition", 0); -// jsonObject.put("maxResults", 1); -// jsonObject.put("faceLibType", "blackFD"); -// jsonObject.put("FDID","1"); -// jsonObject.put("FPID", employeeNo);//人脸关联的工号,同下发人员时的employeeNo字段 -// -// String strInbuff = jsonObject.toString(); -// System.out.println("查询的json报文:" + strInbuff); -// -// //把string传递到Byte数组中,后续用.getPointer()方法传入指针地址中。 -// HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length()); -// System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length()); -// ptrInbuff.write(); -// -// HCNetSDK.NET_DVR_JSON_DATA_CFG m_struJsonData = new HCNetSDK.NET_DVR_JSON_DATA_CFG(); -// m_struJsonData.write(); -// -// IntByReference pInt = new IntByReference(0); -// -// while(true){ -// int dwState =AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), m_struJsonData.getPointer(), m_struJsonData.size(), pInt); -// m_struJsonData.read(); -// System.out.println(dwState); -// if(dwState == -1){ -// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) -// { -// System.out.println("配置等待"); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// continue; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) -// { -// System.out.println("查询人脸失败"); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) -// { -// System.out.println("查询人脸异常"); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) -// { -// System.out.println("查询人脸成功"); -// -// //解析JSON字符串 -// HCNetSDK.BYTE_ARRAY pJsonData = new HCNetSDK.BYTE_ARRAY(m_struJsonData.dwJsonDataSize); -// pJsonData.write(); -// Pointer pPlateInfo = pJsonData.getPointer(); -// pPlateInfo.write(0, m_struJsonData.lpJsonData.getByteArray(0, pJsonData.size()), 0, pJsonData.size()); -// pJsonData.read(); -// String strResult = new String(pJsonData.byValue).trim(); -// System.out.println("strResult:" + strResult); -// JSONObject jsonResult = new JSONObject(strResult); -// -// int numOfMatches = jsonResult.getInt("numOfMatches"); -// if(numOfMatches != 0){//确认有人脸 -// JSONArray MatchList = jsonResult.getJSONArray("MatchList"); -// JSONObject MatchList_1 = MatchList.optJSONObject(0); -// String FPID = MatchList_1.getString("FPID"); //获取json中人脸关联的工号 -// -// FileOutputStream fout; -// try { -// fout = new FileOutputStream("..//AddFacePicture//["+ FPID +"]_FacePic.jpg"); -// //将字节写入文件 -// long offset = 0; -// ByteBuffer buffers = m_struJsonData.lpPicData.getByteBuffer(offset, m_struJsonData.dwPicDataSize); -// byte [] bytes = new byte[m_struJsonData.dwPicDataSize]; -// 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(); -// } -// } -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -// System.out.println("获取人脸完成"); -// break; -// } -// } -// if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){ -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } -// else{ -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// lHandler = -1; -// } -// -// } -// -// } -// -// /** -// * 人脸删除,支持批量删除,json中添加多个工号 -// * @param userID -// * @param employeeNo -// */ -// -// public static void deleteFaceInfo(int userID,String employeeNo) -// { -// String deleteFaceUrl="PUT /ISAPI/Intelligent/FDLib/FDSearch/Delete?format=json&FDID=1&faceLibType=blackFD"; -// String deleteFaceJson="{\n" + -// " \"FPID\": [{\n" + -// " \"value\": \""+employeeNo+"\"\n" + -// " }]\n" + -// "}"; -// String result= com.shxy.xyhkcamera.asc.TransIsapi.put_isapi(userID,deleteFaceUrl,deleteFaceJson); -// System.out.println("删除人员结果:"+result); -// } -// -// /** -// * 人脸采集,下发人脸采集命令,从设备中采集人脸图片保存到本地 -// * @param userID 用户注册ID -// */ -// public static void captureFaceInfo(int userID) -// { -// HCNetSDK.NET_DVR_CAPTURE_FACE_COND struCapCond = new HCNetSDK.NET_DVR_CAPTURE_FACE_COND(); -// struCapCond.read(); -// struCapCond.dwSize = struCapCond.size(); -// struCapCond.write(); -// int lCaptureFaceHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_CAPTURE_FACE_INFO, struCapCond.getPointer(), struCapCond.size(), null, null); -// if (lCaptureFaceHandle == -1) { -// System.out.println("建立采集人脸长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } else { -// System.out.println("建立采集人脸长连接成功!"); -// } -// //采集的人脸信息 -// HCNetSDK.NET_DVR_CAPTURE_FACE_CFG struFaceInfo = new HCNetSDK.NET_DVR_CAPTURE_FACE_CFG(); -// struFaceInfo.read(); -// while (true) { -// int dwState = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(lCaptureFaceHandle, struFaceInfo.getPointer(), struFaceInfo.size()); -// struFaceInfo.read(); -// if (dwState == -1) { -// System.out.println("NET_DVR_GetNextRemoteConfig采集人脸失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) { -// System.out.println("正在采集中,请等待..."); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// continue; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) { -// System.out.println("采集人脸失败"); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) { -// //超时时间5秒内设备本地人脸采集失败就会返回失败,连接会断开 -// System.out.println("采集人脸异常, 网络异常导致连接断开 "); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) { -// if ((struFaceInfo.dwFacePicSize > 0) && (struFaceInfo.pFacePicBuffer != null)) { -// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); -// String newName = sf.format(new Date()); -// FileOutputStream fout; -// try { -// String filename = "..\\pic\\" + newName + "_capFaceInfo.jpg"; -// fout = new FileOutputStream(filename); -// //将字节写入文件 -// long offset = 0; -// ByteBuffer buffers = struFaceInfo.pFacePicBuffer.getByteBuffer(offset, struFaceInfo.dwFacePicSize); -// byte[] bytes = new byte[struFaceInfo.dwFacePicSize]; -// buffers.rewind(); -// buffers.get(bytes); -// fout.write(bytes); -// fout.close(); -// System.out.println("采集人脸成功, 图片保存路径: " + filename); -// } catch (FileNotFoundException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// break; -// } else { -// System.out.println("其他异常, dwState: " + dwState); -// break; -// } -// } -// //采集成功之后断开连接、释放资源 -// if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lCaptureFaceHandle)) { -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } else { -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// } -// } -// -// -// -// -// -// -//} diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/FingerManage.java b/src/main/java/com/shxy/xyhkcamera/ascest/FingerManage.java deleted file mode 100644 index 80f3478..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/FingerManage.java +++ /dev/null @@ -1,378 +0,0 @@ -//package com.shxy.xyhkcamera.ascest; -// -// -//import com.shxy.xyhkcamera.hk.HCNetSDK; -//import com.sun.jna.Pointer; -//import com.sun.jna.ptr.IntByReference; -// -//import java.io.*; -//import java.nio.ByteBuffer; -//import java.text.SimpleDateFormat; -//import java.util.Date; -// -///** -// * 指纹管理:指纹采集,指纹下发,指纹信息查询,指纹删除 -// */ -//public final class FingerManage { -// /** -// * 采集指纹模块,采集指纹数据为二进制 -// * @param userID -// */ -// public static void fingerCapture(int userID) -// { -// -// HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_COND strFingerCond = new HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_COND(); -// strFingerCond.read(); -// strFingerCond.dwSize = strFingerCond.size(); -// strFingerCond.byFingerPrintPicType = 1; //指纹读卡器 -// strFingerCond.byFingerNo = 1; //指纹编号 -// strFingerCond.write(); -// int lGetFingerHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_INFO, strFingerCond.getPointer(), strFingerCond.dwSize, null, null); -// if (lGetFingerHandle == -1) { -// System.out.println("建立采集指纹长连接失败,错误码为:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } else { -// System.out.println("建立采集指纹长连接成功!"); -// } -// HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_CFG strFingerCfg = new HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_CFG(); -// strFingerCfg.dwSize=strFingerCfg.size(); -// strFingerCfg.write(); -// while (true) { -// int dwFingerState = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(lGetFingerHandle, strFingerCfg.getPointer(), strFingerCfg.size()); -// -// if (dwFingerState == -1) { -// System.out.println("NET_DVR_GetNextRemoteConfig采集指纹失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } else if (dwFingerState == HCNetSDK.NET_SDK_GET_NEXT_STATUS_FAILED) { -// System.out.println("采集指纹失败"); -// break; -// } else if (dwFingerState == HCNetSDK.NET_SDK_GET_NEXT_STATUS_NEED_WAIT) { -// System.out.println("正在采集指纹中,请等待..."); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// continue; -// } else if (dwFingerState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) { -// //超时时间5秒内设备本地人脸采集失败就会返回失败,连接会断开 -// System.out.println("采集指纹异常, 网络异常导致连接断开 "); -// break; -// } else if (dwFingerState == HCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS) { -// strFingerCfg.read(); -// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); -// String newName = sf.format(new Date()); -// String fileName = newName + "_capFinger.data"; -// String filePath = "..\\pic\\" + fileName; -// BufferedOutputStream bos = null; -// FileOutputStream fos = null; -// File file = null; -// try { -// File dir = new File(filePath); -// if (!dir.exists() && dir.isDirectory()) {//判断文件目录是否存在 -// dir.mkdirs(); -// } -// file = new File(filePath); -// fos = new FileOutputStream(file); -// bos = new BufferedOutputStream(fos); -// bos.write(strFingerCfg.byFingerData); -// System.out.println("采集指纹成功!"); -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// if (bos != null) { -// try { -// bos.close(); -// } catch (IOException e1) { -// e1.printStackTrace(); -// } -// } -// if (fos != null) { -// try { -// fos.close(); -// } catch (IOException e1) { -// e1.printStackTrace(); -// } -// } -// } -// if ((strFingerCfg.dwFingerPrintPicSize > 0) && (strFingerCfg.pFingerPrintPicBuffer != null)) { -// FileOutputStream fout; -// try { -// String filename = "..\\pic\\" + newName + "_FingerPrintPic.jpg"; -// fout = new FileOutputStream(filename); -// //将字节写入文件 -// long offset = 0; -// ByteBuffer buffers = strFingerCfg.pFingerPrintPicBuffer.getByteBuffer(offset, strFingerCfg.dwFingerPrintPicSize); -// byte[] bytes = new byte[strFingerCfg.dwFingerPrintPicSize]; -// buffers.rewind(); -// buffers.get(bytes); -// fout.write(bytes); -// fout.close(); -// System.out.println("采集指纹成功, 图片保存路径: " + filename); -// } catch (FileNotFoundException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// break; -// } else { -// System.out.println("其他异常, dwState: " + dwFingerState); -// break; -// } -// } -// //采集成功之后断开连接、释放资源 -// if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lGetFingerHandle)) { -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } else { -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// } -// } -// -// /** -// * 采用透传ISAPI协议方式采集指纹,获取的指纹信息为BASE64编码, -// */ -// public static void fingerCpaureByisapi(int userID) -// { -// //采集指纹URL -// String fingerCapUrl="POST /ISAPI/AccessControl/CaptureFingerPrint"; -// String XmlInput="\n" + -// "\n" + -// " 1\n" + -// ""; -// String result= com.shxy.xyhkcamera.asc.TransIsapi.put_isapi(userID,fingerCapUrl,XmlInput); -// System.out.println("采集指纹结果:"+result); -// } -// -// -// -// public static void setOneFinger(int userID, String employeeNo,String figerdata) throws JSONException { -// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -// String strInBuffer = "POST /ISAPI/AccessControl/FingerPrint/SetUp?format=json"; -// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// -// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -// if (lHandler < 0) -// { -// System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } -// else{ -// System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig成功!"); -// -// JSONObject jsonObject = new JSONObject(); -// JSONObject j_FingerPrintCond=new JSONObject(); -// j_FingerPrintCond.put("employeeNo", employeeNo); -// int[] CardReader = {1}; -// j_FingerPrintCond.put("enableCardReader",CardReader); //人员工号 -// j_FingerPrintCond.put("fingerPrintID", 1); -// j_FingerPrintCond.put("fingerType", "normalFP"); -// j_FingerPrintCond.put("fingerData",figerdata); -// jsonObject.put("FingerPrintCfg",j_FingerPrintCond); -// -// String strInbuff = jsonObject.toString(); -// System.out.println("查询的json报文:" + strInbuff); -// -// //把string传递到Byte数组中,后续用.getPointer()方法传入指针地址中。 -// HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length()); -// System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length()); -// ptrInbuff.write(); -// -// HCNetSDK.NET_DVR_STRING_POINTER ptrOutbuff = new HCNetSDK.NET_DVR_STRING_POINTER(3*1024); -// ptrOutbuff.write(); -// -// IntByReference pInt = new IntByReference(0); -// -// while(true){ -// int dwState =AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), ptrOutbuff.getPointer(), ptrOutbuff.size(), pInt); -// ptrOutbuff.read(); -// System.out.println(dwState); -// if(dwState == -1){ -// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) -// { -// System.out.println("配置等待"); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// continue; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) -// { -// System.out.println("下发指纹失败"); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) -// { -// System.out.println("下发指纹异常"); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) -// { -// System.out.println("下发指纹成功"); -// //解析JSON字符串 -// ptrOutbuff.read(); -// System.out.println("返回的报文:"+new String(ptrOutbuff.byString)); -// -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -// System.out.println("下发指纹完成"); -// break; -// } -// } -// if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){ -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } -// else{ -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// lHandler = -1; -// } -// } -// } -// -// public static void SearchFingerInfo(int userID,String employeeNo) throws JSONException { -// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -// String strInBuffer = "POST /ISAPI/AccessControl/FingerPrintUpload?format=json"; -// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// -// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -// if (lHandler < 0) -// { -// System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } -// else{ -// System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig成功!"); -// -// JSONObject jsonObject = new JSONObject(); -// JSONObject j_FingerPrintCond=new JSONObject(); -// j_FingerPrintCond.put("searchID", "20211223"); -// j_FingerPrintCond.put("employeeNo", employeeNo); //人员工号 -// j_FingerPrintCond.put("cardReaderNo", 1); -// j_FingerPrintCond.put("fingerPrintID", 1); -// jsonObject.put("FingerPrintCond",j_FingerPrintCond); -// -// String strInbuff = jsonObject.toString(); -// System.out.println("查询的json报文:" + strInbuff); -// -// //把string传递到Byte数组中,后续用.getPointer()方法传入指针地址中。 -// HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length()); -// System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length()); -// ptrInbuff.write(); -// -// HCNetSDK.NET_DVR_STRING_POINTER ptrOutbuff = new HCNetSDK.NET_DVR_STRING_POINTER(3*1024); -// ptrOutbuff.write(); -// -// IntByReference pInt = new IntByReference(0); -// -// while(true){ -// int dwState =AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), ptrOutbuff.getPointer(), ptrOutbuff.size(), pInt); -// ptrOutbuff.read(); -// System.out.println(dwState); -// if(dwState == -1){ -// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) -// { -// System.out.println("配置等待"); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// continue; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) -// { -// System.out.println("查询指纹失败"); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) -// { -// System.out.println("查询指纹异常"); -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) -// { -// System.out.println("查询指纹成功"); -// //解析JSON字符串 -// ptrOutbuff.read(); -// System.out.println("查询的报文:"+new String(ptrOutbuff.byString)); -// -// break; -// } -// else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -// System.out.println("获取指纹完成"); -// break; -// } -// } -// if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){ -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } -// else{ -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// lHandler = -1; -// } -// -// } -// } -// -// /** -// * 按工号和读卡器删除指纹,按工号是逐个删除,按读卡器是批量删除指定读卡器上所有的指纹数据 -// * @param userID -// * @param employeeNo -// */ -// public static void deleteFinger(int userID,String employeeNo ) -// { -// int iErr = 0; -// HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50 m_struFingerDelInfoParam = new HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50(); -// m_struFingerDelInfoParam.dwSize = m_struFingerDelInfoParam.size(); -// m_struFingerDelInfoParam.byMode = 0;// 删除方式,0-按卡号(人员ID)方式删除,1-按读卡器删除 -// m_struFingerDelInfoParam.struProcessMode.setType(HCNetSDK.NET_DVR_FINGER_PRINT_BYCARD_V50.class); -// for (int i = 0; i < employeeNo.length(); i++) { -// m_struFingerDelInfoParam.struProcessMode.struByCard.byEmployeeNo[i] = employeeNo.getBytes()[i]; -// } -// m_struFingerDelInfoParam.struProcessMode.struByCard.byEnableCardReader[0] = 1;//指纹的读卡器信息,按位表示 -// m_struFingerDelInfoParam.struProcessMode.struByCard.byFingerPrintID[0] = 1;//需要删除的指纹编号,按数组下标,值表示0-不删除,1-删除该指纹 ,指纹编号1删除 -// -// -// Pointer lpInBuffer1 = m_struFingerDelInfoParam.getPointer(); -// m_struFingerDelInfoParam.write(); -// -// -// int lHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_DEL_FINGERPRINT, lpInBuffer1, m_struFingerDelInfoParam.size(), null, null); -// if (lHandle < 0) { -// iErr = AcsMain.hCNetSDK.NET_DVR_GetLastError(); -// System.out.println("NET_DVR_DEL_FINGERPRINT_CFG_V50 建立长连接失败,错误号:" + iErr); -// return; -// } -// while (true) { -// HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50 v50 = new HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50(); -// v50.dwSize = v50.size(); -// v50.write(); -// int res = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(lHandle, v50.getPointer(), v50.size()); -// if (res == 1002) { -// AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandle); -// System.out.println("删除指纹成功!!!"); -// break; -// } else if (res == 1003) { -// System.out.println("接口失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandle); -// break; -// } -// } -// } -//} diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/MutilCard.java b/src/main/java/com/shxy/xyhkcamera/ascest/MutilCard.java deleted file mode 100644 index 51dad25..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/MutilCard.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.shxy.xyhkcamera.ascest; - - -import com.shxy.xyhkcamera.ascest.AcsMain; -import com.shxy.xyhkcamera.hk.HCNetSDK; - -/** - * 多重卡认证功能,下发人员的输入json中参数belongGroup绑定人员群组 - */ -public class MutilCard { - - - //设置群组参数 - public static void setGroupCfg(int lUserID) - { - HCNetSDK.NET_DVR_GROUP_CFG struGroupCfg = new HCNetSDK.NET_DVR_GROUP_CFG(); - struGroupCfg.read(); - - struGroupCfg.dwSize = struGroupCfg.size(); - struGroupCfg.byEnable = 1; - struGroupCfg.byGroupName = "test".getBytes(); // - struGroupCfg.struValidPeriodCfg.byEnable = 1; - struGroupCfg.struValidPeriodCfg.struBeginTime.wYear = 2021; - struGroupCfg.struValidPeriodCfg.struBeginTime.byMonth = 1; - struGroupCfg.struValidPeriodCfg.struBeginTime.byDay = 1; - struGroupCfg.struValidPeriodCfg.struBeginTime.byHour = 0; - struGroupCfg.struValidPeriodCfg.struBeginTime.byMinute = 0; - struGroupCfg.struValidPeriodCfg.struBeginTime.bySecond = 0; - struGroupCfg.struValidPeriodCfg.struEndTime.wYear = 2037; - struGroupCfg.struValidPeriodCfg.struEndTime.byMonth = 12; - struGroupCfg.struValidPeriodCfg.struEndTime.byDay = 31; - struGroupCfg.struValidPeriodCfg.struEndTime.byHour = 23; - struGroupCfg.struValidPeriodCfg.struEndTime.byMinute = 59; - struGroupCfg.struValidPeriodCfg.struEndTime.bySecond = 59; - struGroupCfg.write(); - if(!AcsMain.hCNetSDK.NET_DVR_SetDVRConfig(lUserID,2113,1,struGroupCfg.getPointer(),struGroupCfg.size())) - { - System.out.println("NET_DVR_SetDVRConfig NET_DVR_SET_GROUP_CFG失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - } else { - System.out.println("NET_DVR_SetDVRConfig NET_DVR_SET_GROUP_CFG成功"); - } - } - - - - //设置多重认证参数 - - /** - * 多重卡刷卡开门功能: - * 有权限的任意n张卡刷卡之后才能开门,不限制先后次序,则只需要设置一个群组组合(卡号都配置关联该群组),byMemberNum设为n,bySequenceNo设为1。 - * 有权限的n张A类卡和m张B类卡刷卡之后才能开门,而且先刷A类卡再刷B类卡,则需要设置2个群组组合,2个群组组合的byMemberNum分别为n和m, - * bySequenceNo分别为1、2;如果不需要限制刷卡先后次序,则bySequenceNo都设为0,0表示无序。 - * @param lUserID - */ - public static void setMultiCardCfg(int lUserID) - { - HCNetSDK.NET_DVR_MULTI_CARD_CFG_V50 struMultiCardCfg = new HCNetSDK.NET_DVR_MULTI_CARD_CFG_V50(); - struMultiCardCfg.read(); - struMultiCardCfg.dwSize = struMultiCardCfg.size(); - struMultiCardCfg.byEnable = 1; - struMultiCardCfg.bySwipeIntervalTimeout = 30; //刷卡认证超时时间 - struMultiCardCfg.struGroupCfg[0].byEnable = 1; - struMultiCardCfg.struGroupCfg[0].dwTemplateNo = 1; - struMultiCardCfg.struGroupCfg[0].struGroupCombination[0].byEnable = 1; - struMultiCardCfg.struGroupCfg[0].struGroupCombination[0].byMemberNum = 2; //刷卡成员数量,群组里面需要刷卡的卡个数 - struMultiCardCfg.struGroupCfg[0].struGroupCombination[0].bySequenceNo = 1; //群组刷卡次序号 - struMultiCardCfg.struGroupCfg[0].struGroupCombination[0].dwGroupNo = 1; //群组编号 //刷卡认证组 - struMultiCardCfg.write(); - - if(!AcsMain.hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_MULTI_CARD_CFG_V50,1,struMultiCardCfg.getPointer(),struMultiCardCfg.size())) - { - System.out.println("NET_DVR_SetDVRConfig NET_DVR_SET_MULTI_CARD_CFG_V50 失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); - } else { - System.out.println("NET_DVR_SetDVRConfig NET_DVR_SET_MULTI_CARD_CFG_V50 成功"); - } - } -} diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/TransIsapi.java b/src/main/java/com/shxy/xyhkcamera/ascest/TransIsapi.java deleted file mode 100644 index 27723d2..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/TransIsapi.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.shxy.xyhkcamera.ascest; - - -import com.shxy.xyhkcamera.ascest.AcsMain; -import com.shxy.xyhkcamera.hk.HCNetSDK; - -/** - * @create 2021-04-13-15:23 - * 功能:透传接口实现,透传ISAPI命令 - */ -public final class TransIsapi { - public static String get_isapi(int lUserID, String url) { - HCNetSDK.NET_DVR_XML_CONFIG_INPUT struXMLInput = new HCNetSDK.NET_DVR_XML_CONFIG_INPUT(); - struXMLInput.read(); - HCNetSDK.BYTE_ARRAY stringRequest = new HCNetSDK.BYTE_ARRAY(1024); - stringRequest.read(); - //输入ISAPI协议命令 - System.arraycopy(url.getBytes(), 0, stringRequest.byValue, 0, url.length()); - stringRequest.write(); - struXMLInput.dwSize = struXMLInput.size(); - struXMLInput.lpRequestUrl = stringRequest.getPointer(); - struXMLInput.dwRequestUrlLen = url.length(); - struXMLInput.lpInBuffer = null; - struXMLInput.dwInBufferSize = 0; - struXMLInput.write(); - - HCNetSDK.BYTE_ARRAY stringXMLOut = new HCNetSDK.BYTE_ARRAY(8 * 1024); - stringXMLOut.read(); - HCNetSDK.BYTE_ARRAY struXMLStatus = new HCNetSDK.BYTE_ARRAY(1024); - struXMLStatus.read(); - HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT struXMLOutput = new HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT(); - struXMLOutput.read(); - struXMLOutput.dwSize = struXMLOutput.size(); - struXMLOutput.lpOutBuffer = stringXMLOut.getPointer(); - struXMLOutput.dwOutBufferSize = stringXMLOut.size(); - struXMLOutput.lpStatusBuffer = struXMLStatus.getPointer(); - struXMLOutput.dwStatusSize = struXMLStatus.size(); - struXMLOutput.write(); - if (!AcsMain.hCNetSDK.NET_DVR_STDXMLConfig(lUserID, struXMLInput, struXMLOutput)) { - int iErr = AcsMain.hCNetSDK.NET_DVR_GetLastError(); - System.err.println("NET_DVR_STDXMLConfig失败,错误号" + iErr+"----URL:"+url); - return null; - } else { - stringXMLOut.read(); - System.out.println("输出文本大小:" + struXMLOutput.dwReturnedXMLSize); - //打印输出XML文本 - String strOutXML = new String(stringXMLOut.byValue).trim(); - System.out.println(strOutXML); - struXMLStatus.read(); - String strStatus = new String(struXMLStatus.byValue).trim(); - System.out.println(strStatus); - return strOutXML; - } - } - - - public static String put_isapi(int lUserID, String url, String inputXml) { - HCNetSDK.NET_DVR_XML_CONFIG_INPUT struXMLInput = new HCNetSDK.NET_DVR_XML_CONFIG_INPUT(); - struXMLInput.read(); - HCNetSDK.BYTE_ARRAY stringRequest = new HCNetSDK.BYTE_ARRAY(1024); - stringRequest.read(); - //输入ISAPI协议命令 - System.arraycopy(url.getBytes(), 0, stringRequest.byValue, 0, url.length()); - stringRequest.write(); - struXMLInput.dwSize = struXMLInput.size(); - struXMLInput.lpRequestUrl = stringRequest.getPointer(); - struXMLInput.dwRequestUrlLen = url.length(); - HCNetSDK.BYTE_ARRAY ptrInBuffer = new HCNetSDK.BYTE_ARRAY(inputXml.length()); - ptrInBuffer.read(); - System.arraycopy(inputXml.getBytes(), 0, ptrInBuffer.byValue, 0, inputXml.length()); - ptrInBuffer.write(); - struXMLInput.lpInBuffer = ptrInBuffer.getPointer(); - struXMLInput.dwInBufferSize = inputXml.length(); - struXMLInput.write(); - HCNetSDK.BYTE_ARRAY stringXMLOut = new HCNetSDK.BYTE_ARRAY(8 * 1024); - stringXMLOut.read(); - HCNetSDK.BYTE_ARRAY struXMLStatus = new HCNetSDK.BYTE_ARRAY(1024); - struXMLStatus.read(); - HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT struXMLOutput = new HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT(); - struXMLOutput.read(); - struXMLOutput.dwSize = struXMLOutput.size(); - struXMLOutput.lpOutBuffer = stringXMLOut.getPointer(); - struXMLOutput.dwOutBufferSize = stringXMLOut.size(); - struXMLOutput.lpStatusBuffer = struXMLStatus.getPointer(); - struXMLOutput.dwStatusSize = struXMLStatus.size(); - struXMLOutput.write(); - if (!AcsMain.hCNetSDK.NET_DVR_STDXMLConfig(lUserID, struXMLInput, struXMLOutput)){ - int iErr = AcsMain.hCNetSDK.NET_DVR_GetLastError(); - System.err.println("NET_DVR_STDXMLConfig失败,错误号" + iErr+"----URL:"+url); - return null; - } else { - stringXMLOut.read(); - System.out.println("输出文本大小:" + struXMLOutput.dwReturnedXMLSize); - //打印输出XML文本 - String strOutXML = new String(stringXMLOut.byValue).trim(); - struXMLStatus.read(); - String strStatus = new String(struXMLStatus.byValue).trim(); - return strOutXML; - } - } -} diff --git a/src/main/java/com/shxy/xyhkcamera/ascest/UserManage.java b/src/main/java/com/shxy/xyhkcamera/ascest/UserManage.java deleted file mode 100644 index 9ed7210..0000000 --- a/src/main/java/com/shxy/xyhkcamera/ascest/UserManage.java +++ /dev/null @@ -1,362 +0,0 @@ -//package com.shxy.xyhkcamera.ascest; -// -//import com.shxy.xyhkcamera.hk.HCNetSDK; -//import com.sun.jna.Pointer; -//import com.sun.jna.ptr.IntByReference; -// -//import java.io.UnsupportedEncodingException; -// -///** -// * 功能:人脸下发、查询、删除、人员计划模板配置 -// */ -//public class UserManage { -// /** -// * 添加人员 -// * -// * @param lUserID 登录句柄 -// * @param employeeNo 工号 -// * @throws UnsupportedEncodingException -// * @throws InterruptedException -// * @throws JSONException -// */ -// public static void addUserInfo(int lUserID, String employeeNo) throws UnsupportedEncodingException, InterruptedException, JSONException { -// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -// //"POST /ISAPI/AccessControl/UserInfo/Record?format=json" 此URL也是下发人员 -// String strInBuffer = "PUT /ISAPI/AccessControl/UserInfo/SetUp?format=json"; -// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// -// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -// if (lHandler < 0) { -// System.out.println("AddUserInfo NET_DVR_StartRemoteConfig 失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } else { -// System.out.println("AddUserInfo NET_DVR_StartRemoteConfig 成功!"); -// -// byte[] Name = "测试1".getBytes("utf-8"); //根据iCharEncodeType判断,如果iCharEncodeType返回6,则是UTF-8编码。 -// //如果是0或者1或者2,则是GBK编码 -// -// //将中文字符编码之后用数组拷贝的方式,避免因为编码导致的长度问题 -// String strInBuffer1 = "{\n" + -// " \"UserInfo\":{\n" + -// " \"employeeNo\":\""+employeeNo+"\",\n" + -// " \"name\":\""; -// String strInBuffer2 = "\",\n" + -// " \"userType\":\"normal\",\n" + -// " \"Valid\":{\n" + -// " \"enable\":true,\n" + -// " \"beginTime\":\"2019-08-01T17:30:08\",\n" + -// " \"endTime\":\"2030-08-01T17:30:08\",\n" + -// " \"timeType\":\"local\"\n" + -// " },\n" + -// " \"belongGroup\":\"1\",\n" + -// " \"doorRight\":\"1\",\n" + -// " \"RightPlan\":[\n" + -// " {\n" + -// " \"doorNo\":1,\n" + -// " \"planTemplateNo\":\"1\"\n" + -// " }\n" + -// " ]\n" + -// " }\n" + -// "}"; -// int iStringSize = Name.length + strInBuffer1.length() + strInBuffer2.length(); -// -// HCNetSDK.BYTE_ARRAY ptrByte = new HCNetSDK.BYTE_ARRAY(iStringSize); -// System.arraycopy(strInBuffer1.getBytes(), 0, ptrByte.byValue, 0, strInBuffer1.length()); -// System.arraycopy(Name, 0, ptrByte.byValue, strInBuffer1.length(), Name.length); -// System.arraycopy(strInBuffer2.getBytes(), 0, ptrByte.byValue, strInBuffer1.length() + Name.length, strInBuffer2.length()); -// ptrByte.write(); -// -// System.out.println(new String(ptrByte.byValue)); -// -// HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1024); -// -// IntByReference pInt = new IntByReference(0); -// while (true) { -// int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrByte.getPointer(), iStringSize, ptrOutuff.getPointer(), 1024, pInt); -// if (dwState == -1) { -// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } -// //读取返回的json并解析 -// ptrOutuff.read(); -// String strResult = new String(ptrOutuff.byValue).trim(); -// System.out.println("dwState:" + dwState + ",strResult:" + strResult); -// -// JSONObject jsonResult = new JSONObject(strResult); -// int statusCode = jsonResult.getInt("statusCode"); -// String statusString = jsonResult.getString("statusString"); -// if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) { -// System.out.println("配置等待"); -// Thread.sleep(10); -// continue; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) { -// System.out.println("下发人员失败, json retun:" + jsonResult.toString()); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) { -// System.out.println("下发人员异常, json retun:" + jsonResult.toString()); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {//返回NET_SDK_CONFIG_STATUS_SUCCESS代表流程走通了,但并不代表下发成功,比如有些设备可能因为人员已存在等原因下发失败,所以需要解析Json报文 -// if (statusCode != 1) { -// System.out.println("下发人员成功,但是有异常情况:" + jsonResult.toString()); -// } else { -// System.out.println("下发人员成功: json retun:" + jsonResult.toString()); -// } -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -// //下发人员时:dwState其实不会走到这里,因为设备不知道我们会下发多少个人,所以长连接需要我们主动关闭 -// System.out.println("下发人员完成"); -// break; -// } -// } -// if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)) { -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } else { -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// } -// } -// } -// -// /** -// * 查询人员信息 -// * @param userID -// * @throws JSONException -// */ -// public static void searchUserInfo(int userID) throws JSONException { -// HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组 -// String strInBuffer = "POST /ISAPI/AccessControl/UserInfo/Search?format=json"; -// System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中 -// ptrByteArray.write(); -// -// int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null); -// if (lHandler < 0) { -// System.out.println("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } else { -// //组装查询的JSON报文,这边查询的是所有的人员 -// JSONObject jsonObject = new JSONObject(); -// JSONObject jsonSearchCond = new JSONObject(); -// -// //如果需要查询指定的工号人员信息,把下面注释的内容去除掉即可 -// /* JSONArray EmployeeNoList = new JSONArray(); -// JSONObject employeeNo1 = new JSONObject(); -// employeeNo1.put("employeeNo", "12346"); -// JSONObject employeeNo2 = new JSONObject(); -// employeeNo2.put("employeeNo", "1000"); -// EmployeeNoList.put(employeeNo1); -// EmployeeNoList.put(employeeNo2); -// jsonSearchCond.put("EmployeeNoList", EmployeeNoList);*/ -// -// jsonSearchCond.put("searchID", "20211126"); -// jsonSearchCond.put("searchResultPosition", 0); -// jsonSearchCond.put("maxResults", 50); -// jsonObject.put("UserInfoSearchCond", jsonSearchCond); -// -// String strInbuff = jsonObject.toString(); -// System.out.println("查询的json报文:" + strInbuff); -// -// //把string传递到Byte数组中,后续用.getPointer()方法传入指针地址中。 -// HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length()); -// System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length()); -// ptrInbuff.write(); -// -// //定义接收结果的结构体 -// HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(10 * 1024); -// -// IntByReference pInt = new IntByReference(0); -// -// while (true) { -// /* -// dwOutBuffSize是输出缓冲区大小,需要自定义指定大小,如果接口报错错误码43.说明接收设备数据的缓冲区或存放图片缓冲区不足,应扩大缓冲区大小 -// */ -// int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), ptrOutuff.getPointer(), 20 * 1024, pInt); -// System.out.println(dwState); -// if (dwState == -1) { -// System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) { -// System.out.println("配置等待"); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// continue; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) { -// System.out.println("查询人员失败"); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) { -// System.out.println("查询人员异常"); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) { -// ptrOutuff.read(); -// System.out.println("查询人员成功, json:" + new String(ptrOutuff.byValue).trim()); -// break; -// } else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) { -// System.out.println("获取人员完成"); -// break; -// } -// } -// -// if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)) { -// System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } else { -// System.out.println("NET_DVR_StopRemoteConfig接口成功"); -// lHandler = -1; -// } -// } -// -// -// } -// -// public static void deleteUserInfo(int userID) throws JSONException { -// //删除单个人员 -//// String deleteUserjson="{\n" + -//// "\t\"UserInfoDetail\": {\t\n" + -//// "\t\t\"mode\": \"byEmployeeNo\",\t\n" + -//// "\t\t\"EmployeeNoList\": [\t\n" + -//// "\t\t\t{\n" + -//// "\t\t\t\t\"employeeNo\": \"test\"\t\n" + -//// "\t\t\t}\n" + -//// "\t\t]\n" + -//// "\n" + -//// "\t}\n" + -//// "}"; -// //删除所有人员 -// String deleteUserjson = "{\n" + -// "\t\"UserInfoDetail\": {\t\n" + -// "\t\t\"mode\": \"all\",\t\n" + -// "\t\t\"EmployeeNoList\": [\t\n" + -// "\t\t]\n" + -// "\n" + -// "\t}\n" + -// "}"; -// String deleteUserUrl = "PUT /ISAPI/AccessControl/UserInfoDetail/Delete?format=json"; -// String result = TransIsapi.put_isapi(userID, deleteUserUrl, deleteUserjson); -// System.out.println(result); -// //获取删除进度 -// while (true) { -// String getDeleteProcessUrl = "GET /ISAPI/AccessControl/UserInfoDetail/DeleteProcess?format=json"; -// String deleteResult = TransIsapi.get_isapi(userID, getDeleteProcessUrl); -// JSONObject jsonObject = new JSONObject(deleteResult); -// JSONObject jsonObject1 = jsonObject.getJSONObject("UserInfoDetailDeleteProcess"); -// String process = jsonObject1.getString("status"); -// System.out.println("process ="+process); -// if (process.equals("processing")) { -// System.out.println("正在删除"); -// continue; -// } else if (process.equals("success")) { -// System.out.println("删除成功"); -// break; -// }else if(process.equals("failed")){ -// System.out.println("删除失败"); -// break; -// } -// } -// } -// -// /** -// * 人员计划模板配置 -// * -// * @param userID 用户登录句柄 -// * @param iPlanTemplateNumber 计划模板编号,从1开始,最大值从门禁能力集获取 -// */ -// public static void setCardTemplate(int userID, int iPlanTemplateNumber) { -// //设置卡权限计划模板参数 -// HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND struPlanCond = new HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND(); -// struPlanCond.dwSize = struPlanCond.size(); -// struPlanCond.dwPlanTemplateNumber = iPlanTemplateNumber;//计划模板编号,从1开始,最大值从门禁能力集获取 -// struPlanCond.wLocalControllerID = 0;//就地控制器序号[1,64],0表示门禁主机 -// struPlanCond.write(); -// HCNetSDK.NET_DVR_PLAN_TEMPLATE struPlanTemCfg = new HCNetSDK.NET_DVR_PLAN_TEMPLATE(); -// struPlanTemCfg.dwSize = struPlanTemCfg.size(); -// struPlanTemCfg.byEnable = 1; //是否使能:0- 否,1- 是 -// struPlanTemCfg.dwWeekPlanNo = 2;//周计划编号,0表示无效 -// struPlanTemCfg.dwHolidayGroupNo[0] = 0;//假日组编号,按值表示,采用紧凑型排列,中间遇到0则后续无效 -// byte[] byTemplateName; -// try { -// byTemplateName = "CardTemplatePlan_2".getBytes("GBK"); -// //计划模板名称 -// for (int i = 0; i < HCNetSDK.NAME_LEN; i++) { -// struPlanTemCfg.byTemplateName[i] = 0; -// } -// System.arraycopy(byTemplateName, 0, struPlanTemCfg.byTemplateName, 0, byTemplateName.length); -// } catch (UnsupportedEncodingException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// struPlanTemCfg.write(); -// IntByReference pInt = new IntByReference(0); -// Pointer lpStatusList = pInt.getPointer(); -// if (false == AcsMain.hCNetSDK.NET_DVR_SetDeviceConfig(userID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50, 1, struPlanCond.getPointer(), struPlanCond.size(), lpStatusList, struPlanTemCfg.getPointer(), struPlanTemCfg.size())) { -// System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } -// System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50成功!"); -// //获取卡权限周计划参数 -// HCNetSDK.NET_DVR_WEEK_PLAN_COND struWeekPlanCond = new HCNetSDK.NET_DVR_WEEK_PLAN_COND(); -// struWeekPlanCond.dwSize = struWeekPlanCond.size(); -// struWeekPlanCond.dwWeekPlanNumber = 2; -// struWeekPlanCond.wLocalControllerID = 0; -// HCNetSDK.NET_DVR_WEEK_PLAN_CFG struWeekPlanCfg = new HCNetSDK.NET_DVR_WEEK_PLAN_CFG(); -// struWeekPlanCond.write(); -// struWeekPlanCfg.write(); -// Pointer lpCond = struWeekPlanCond.getPointer(); -// Pointer lpInbuferCfg = struWeekPlanCfg.getPointer(); -// if (false == AcsMain.hCNetSDK.NET_DVR_GetDeviceConfig(userID, HCNetSDK.NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) { -// System.out.println("NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// return; -// } -// struWeekPlanCfg.read(); -// struWeekPlanCfg.byEnable = 1; //是否使能:0- 否,1- 是 -// /**避免时间段交叉,先初始化, 七天八小时*/ -// for (int i = 0; i < 7; i++) { -// for (int j = 0; j < 8; j++) { -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].byEnable = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byHour = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byMinute = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.bySecond = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byHour = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byMinute = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.bySecond = 0; -// } -// } -// /**一周7天,全天24小时*/ -// for (int i = 0; i < 7; i++) { -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 21; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 23; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 0; -// } -// /**一周7天,每天设置2个时间段*/ -// /*for(int i=0;i<7;i++) -// { -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 11; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 59; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 59; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].byEnable = 1; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byHour = 13; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byMinute = 30; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.bySecond = 0; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byHour = 19; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byMinute = 59; -// struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.bySecond = 59; -// }*/ -// struWeekPlanCfg.write(); -// //设置卡权限周计划参数 -// if (false == AcsMain.hCNetSDK.NET_DVR_SetDeviceConfig(userID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) { -// System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError()); -// } else { -// System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50成功!"); -// } -// } -// -//} diff --git a/src/main/java/com/shxy/xyhkcamera/hk/HKConfigEnum.java b/src/main/java/com/shxy/xyhkcamera/hk/HKConfigEnum.java index d9db31e..7b737d5 100644 --- a/src/main/java/com/shxy/xyhkcamera/hk/HKConfigEnum.java +++ b/src/main/java/com/shxy/xyhkcamera/hk/HKConfigEnum.java @@ -1,69 +1,90 @@ package com.shxy.xyhkcamera.hk; public class HKConfigEnum { - - //回调状态值 - public enum NET_SDK_CALLBACK_TYPE { - NET_SDK_CALLBACK_TYPE_STATUS(0), - NET_SDK_CALLBACK_TYPE_PROGRESS(1), - NET_SDK_CALLBACK_TYPE_DATA(2); - - private int value; - - private NET_SDK_CALLBACK_TYPE(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - } + public static final int NET_SDK_CALLBACK_TYPE_STATUS = 0; + public static final int NET_SDK_CALLBACK_TYPE_PROGRESS = 1; + public static final int NET_SDK_CALLBACK_TYPE_DATA = 2; //规则标定类型:0- 点,1- 框,2- 线 // 数据库中1->点 2->线 3->框 - public enum BYRULECALIBTYPE { - POINT(0, 1), - FRAME(1, 3), - LINE(2, 2); - - private int value; - private int mysqlvalue; - - private BYRULECALIBTYPE(int value, int mysqlvalue) { - this.value = value; - this.mysqlvalue = mysqlvalue; - } - - public int getValue() { - return value; - } - - public int getMysqlvalue() { - return mysqlvalue; - } - } + public static final int POINT = 0; + public static final int MYSQLPOINT = 1; + public static final int FRAME = 1; + public static final int MYSQLFRAME = 3; + public static final int LINE = 2; + public static final int MYSQLLINE = 2; //测温单位: 0- 摄氏度(℃),1- 华氏度(℉),2- 开尔文(K) // 1=>摄氏度 2=>华氏度 - public enum BYTHERMOMETRYUNIT { - SSD(0, 1), - HSD(1, 2), - KEW(2, 3); - - private int value; - private int mysqlvalue; + public static final int SSD = 0; + public static final int MYSQLSSD = 1; + public static final int HSD = 1; + public static final int MYSQLHSD = 2; + public static final int KEW = 2; + public static final int MYSQLKEW = 3; - private BYTHERMOMETRYUNIT(int value, int mysqlvalue) { - this.value = value; - this.mysqlvalue = mysqlvalue; - } +// //回调状态值 +// public enum NET_SDK_CALLBACK_TYPE { +// NET_SDK_CALLBACK_TYPE_STATUS(0), +// NET_SDK_CALLBACK_TYPE_PROGRESS(1), +// NET_SDK_CALLBACK_TYPE_DATA(2); +// +// private int value; +// +// private NET_SDK_CALLBACK_TYPE(int value) { +// this.value = value; +// } +// +// public int getValue() { +// return value; +// } +// } - public int getValue() { - return value; - } +// //规则标定类型:0- 点,1- 框,2- 线 +//// 数据库中1->点 2->线 3->框 +// public enum BYRULECALIBTYPE { +// POINT(0, 1), +// FRAME(1, 3), +// LINE(2, 2); +// +// private int value; +// private int mysqlvalue; +// +// private BYRULECALIBTYPE(int value, int mysqlvalue) { +// this.value = value; +// this.mysqlvalue = mysqlvalue; +// } +// +// public int getValue() { +// return value; +// } +// +// public int getMysqlvalue() { +// return mysqlvalue; +// } +// } - public int getMysqlvalue() { - return mysqlvalue; - } - } +// //测温单位: 0- 摄氏度(℃),1- 华氏度(℉),2- 开尔文(K) +//// 1=>摄氏度 2=>华氏度 +// public enum BYTHERMOMETRYUNIT { +// SSD(0, 1), +// HSD(1, 2), +// KEW(2, 3); +// +// private int value; +// private int mysqlvalue; +// +// private BYTHERMOMETRYUNIT(int value, int mysqlvalue) { +// this.value = value; +// this.mysqlvalue = mysqlvalue; +// } +// +// public int getValue() { +// return value; +// } +// +// public int getMysqlvalue() { +// return mysqlvalue; +// } +// } } diff --git a/src/main/java/com/shxy/xyhkcamera/hk/HcNetSdkUtil.java b/src/main/java/com/shxy/xyhkcamera/hk/HcNetSdkUtil.java index 8830fb9..862299c 100644 --- a/src/main/java/com/shxy/xyhkcamera/hk/HcNetSdkUtil.java +++ b/src/main/java/com/shxy/xyhkcamera/hk/HcNetSdkUtil.java @@ -48,6 +48,10 @@ public class HcNetSdkUtil { return hCNetSDK; } + public HCNetSDK getInstance() { + return hCNetSDK; + } + /** * 使用 linux环境加载额外文件 */ diff --git a/src/main/java/com/shxy/xyhkcamera/hk/erew.java b/src/main/java/com/shxy/xyhkcamera/hk/erew.java deleted file mode 100644 index 355ca33..0000000 --- a/src/main/java/com/shxy/xyhkcamera/hk/erew.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.shxy.xyhkcamera.hk; - -public enum erew { -} diff --git a/src/main/java/com/shxy/xyhkcamera/interfacesss/Testint.java b/src/main/java/com/shxy/xyhkcamera/interfacesss/Testint.java deleted file mode 100644 index 3c080d8..0000000 --- a/src/main/java/com/shxy/xyhkcamera/interfacesss/Testint.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.shxy.xyhkcamera.interfacesss; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.shxy.xyhkcamera.entity.DataEaifHEntity; - -/** - *

- * 红外区域测温数据表 服务类 - *

- * - * @author jingjing - * @since 2024-05-20 - */ -public interface Testint{ - - void test(DataEaifHEntity entity); - -} diff --git a/src/main/java/com/shxy/xyhkcamera/interfacesss/Testintimpl.java b/src/main/java/com/shxy/xyhkcamera/interfacesss/Testintimpl.java deleted file mode 100644 index 25085a3..0000000 --- a/src/main/java/com/shxy/xyhkcamera/interfacesss/Testintimpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.shxy.xyhkcamera.interfacesss; - -import com.shxy.xyhkcamera.entity.DataEaifHEntity; -import com.shxy.xyhkcamera.service.DataEaifHService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Testintimpl implements Testint { - @Autowired - DataEaifHService dataEaifHService; - @Override - public void test(DataEaifHEntity entity) { - dataEaifHService.save(entity); - } -} diff --git a/src/main/java/com/shxy/xyhkcamera/service/AsyncService.java b/src/main/java/com/shxy/xyhkcamera/service/AsyncService.java index d728991..76649fc 100644 --- a/src/main/java/com/shxy/xyhkcamera/service/AsyncService.java +++ b/src/main/java/com/shxy/xyhkcamera/service/AsyncService.java @@ -1,19 +1,75 @@ package com.shxy.xyhkcamera.service; import com.shxy.xyhkcamera.entity.DataEaifHEntity; +import com.shxy.xyhkcamera.hk.HCNetSDK; +import com.shxy.xyhkcamera.hk.HKConfigEnum; +import com.shxy.xyhkcamera.hk.HcNetSdkUtil; +import com.sun.jna.Pointer; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.time.LocalDateTime; + @Service +@Slf4j public class AsyncService { @Autowired DataEaifHService dataEaifHService; @Async("syncExecutorPool") - public void executeAsyncTask(DataEaifHEntity eaifHEntity) { + public void executeAsyncTask(Pointer lpBuffer, Integer id) { + HCNetSDK.NET_DVR_THERMOMETRY_UPLOAD data = new HCNetSDK.NET_DVR_THERMOMETRY_UPLOAD(); +// data.write(); + Pointer pointer = data.getPointer(); + pointer.write(0, lpBuffer.getByteArray(0, data.size()), 0, data.size()); + data.read(); + log.info("返回的数据:" + data.toString()); + log.info("开始数据整理"); + byte byRuleCalibType = data.byRuleCalibType; + byte byThermometryUnit = data.byThermometryUnit; + DataEaifHEntity entity = new DataEaifHEntity(); + entity.setEqmid(id); + entity.setAreaid(1); + if (byThermometryUnit == HKConfigEnum.SSD) { + entity.setUnit((byte) HKConfigEnum.MYSQLSSD); + } else if (byThermometryUnit == HKConfigEnum.HSD) { + entity.setUnit((byte) HKConfigEnum.MYSQLHSD); + } else if (byThermometryUnit == HKConfigEnum.KEW) { + entity.setUnit((byte) HKConfigEnum.MYSQLKEW); + } + //数据库中1->点2->线3->框 + if (byRuleCalibType == HKConfigEnum.POINT) { + float fTemperature = data.struPointThermCfg.fTemperature; + double maxtemp = new BigDecimal(fTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue(); + entity.setMaxtemp(maxtemp); + entity.setMintemp(maxtemp); + entity.setAvgtemp(maxtemp); + entity.setType((byte) HKConfigEnum.MYSQLPOINT); + entity.setMid(Double.valueOf(0)); + } else if (byRuleCalibType == HKConfigEnum.FRAME || byRuleCalibType == HKConfigEnum.LINE) { + HCNetSDK.NET_DVR_LINEPOLYGON_THERM_CFG struLinePolygonThermCfg = data.struLinePolygonThermCfg; + float fAverageTemperature = struLinePolygonThermCfg.fAverageTemperature;//平均温度 + float fMinTemperature = struLinePolygonThermCfg.fMinTemperature; + float fMaxTemperature = struLinePolygonThermCfg.fMaxTemperature; + float fTemperatureDiff = struLinePolygonThermCfg.fTemperatureDiff; + entity.setMaxtemp(new BigDecimal(fMaxTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); + entity.setMintemp(new BigDecimal(fMinTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); + entity.setAvgtemp(new BigDecimal(fAverageTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); + entity.setMid(new BigDecimal(fTemperatureDiff).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); + if (byRuleCalibType == HKConfigEnum.FRAME) { + entity.setType((byte) HKConfigEnum.MYSQLFRAME); + } else if (byRuleCalibType == HKConfigEnum.LINE) { + entity.setType((byte) HKConfigEnum.MYSQLLINE); + } + } + entity.setStd(Double.valueOf(0)); + entity.setCapturetime(LocalDateTime.now()); + log.info("数据是:" + entity.toString()); // 异步执行的任务 - dataEaifHService.save(eaifHEntity); + dataEaifHService.save(entity); } } diff --git a/src/main/java/com/shxy/xyhkcamera/service/impl/TempMeasureServiceImpl.java b/src/main/java/com/shxy/xyhkcamera/service/impl/TempMeasureServiceImpl.java index 7dfabfc..2fb1e85 100644 --- a/src/main/java/com/shxy/xyhkcamera/service/impl/TempMeasureServiceImpl.java +++ b/src/main/java/com/shxy/xyhkcamera/service/impl/TempMeasureServiceImpl.java @@ -1,37 +1,30 @@ package com.shxy.xyhkcamera.service.impl; -import com.alibaba.druid.sql.visitor.functions.If; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shxy.xyhkcamera.entity.DataEaifHEntity; +import com.shxy.xyhkcamera.entity.ModevEaifEntity; import com.shxy.xyhkcamera.entity.ModevEntity; import com.shxy.xyhkcamera.hk.HCNetSDK; import com.shxy.xyhkcamera.hk.HKConfigEnum; import com.shxy.xyhkcamera.hk.HcNetSdkUtil; -import com.shxy.xyhkcamera.interfacesss.Testint; -import com.shxy.xyhkcamera.interfacesss.Testintimpl; import com.shxy.xyhkcamera.mapper.DataEaifHMapper; -import com.shxy.xyhkcamera.service.AsyncService; -import com.shxy.xyhkcamera.service.DataEaifHService; -import com.shxy.xyhkcamera.service.ModevService; -import com.shxy.xyhkcamera.service.TempMeasureService; +import com.shxy.xyhkcamera.service.*; import com.shxy.xyhkcamera.utils.CommonUtil; import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; import java.time.LocalDateTime; -import java.util.Date; +import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.ReentrantLock; @Service @@ -39,224 +32,166 @@ import java.util.List; public class TempMeasureServiceImpl implements TempMeasureService { @Autowired ModevService modevService; + @Autowired DataEaifHService dataEaifHService; @Autowired - DataEaifHMapper dataEaifHMapper; + ModevEaifService modevEaifService; + @Autowired HcNetSdkUtil hcNetSdkUtil; + @Autowired CommonUtil commonUtil; @Autowired AsyncService asyncService; -// @Autowired -// Testint testint; - - /** - * 海康用户名 - */ - @Value("${hkconfig.user}") - private String user; - /** - * 海康密码 - */ - @Value("${hkconfig.password}") - private String password; private int handle = -1; - private int test = 0; - private Connection conn; + // /** +// * 海康用户名 +// */ +// @Value("${hkconfig.user}") +// private String user; +// /** +// * 海康密码 +// */ +// @Value("${hkconfig.password}") +// private String password; +//初始化锁的状态变量为0 +// private AtomicInteger state = new AtomicInteger(0); +// private int num; +// // private int handle = -1; +// +// public void lock() { +// //判断如果state变量值如果是0,则获取锁,否则一直循环自旋,直到变量为0,获取锁 +// while (!state.compareAndSet(0, 1)) { +// // 自旋等待,直到成功获取锁 +// System.out.println(Thread.currentThread().getName() + " 自旋中。。。。"); +// } +// } +// +// public void unlock() { +// state.set(0); // 释放锁 +// } @Override public void measure() { - +// ReentrantLock lock = new ReentrantLock(true); hcNetSdkUtil.init(); - HCNetSDK instance = hcNetSdkUtil.createSDKInstance(); + HCNetSDK instance = hcNetSdkUtil.getInstance(); List list = modevService.list(Wrappers.lambdaQuery(ModevEntity.class).eq(ModevEntity::getModevtid, 9)); - - if (CollectionUtils.isNotEmpty(list)) { -// for (int i = 0; i < list.size(); i++) { - for (int i = 0; i < 1; i++) { -// List list1 = dataEaifHService.list(Wrappers.lambdaQuery(DataEaifHEntity.class).eq(DataEaifHEntity::getDataId, 12891)); - - -// DataEaifHEntity entitys = new DataEaifHEntity(); -// entitys.setEqmid(384); -// entitys.setMaxtemp((double) 0); -// entitys.setAreaid(1); -// entitys.setCapturetime(LocalDateTime.now()); -// entitys.setMintemp((double) 0); -// entitys.setAvgtemp((double) 0); -// entitys.setType((byte) HKConfigEnum.BYRULECALIBTYPE.POINT.getMysqlvalue()); -// entitys.setMid(Double.valueOf(0)); -// dataEaifHService.save(entitys); - -// ModevEntity entitys = new ModevEntity(); -// entitys.setModevtid(1919); -// entitys.setZsbid(1); -// entitys.setIedid(1); -// entitys.setAddress(12112); -// modevService.save(entitys); - + for (int i = 0; i < list.size(); i++) { +// for (int i = 0; i < 5; i++) { ModevEntity modevEntity = list.get(i); Integer id = modevEntity.getId(); String ip = modevEntity.getIp(); + String user = modevEntity.getUsername(); + String password = modevEntity.getPwd(); String port = modevEntity.getPort(); -// Short aShort = Short.valueOf(port); -// int admin = hcNetSdkUtil.login_V40(ip, aShort, user, password); - int admin = hcNetSdkUtil.login_V40("192.168.1.64", (short) 8000, user, password); + Short aShort = Short.valueOf(port); + if (StringUtils.isBlank(ip)) { + continue; + } + int admin = hcNetSdkUtil.login_V40(ip, aShort, user, password); +// int admin = hcNetSdkUtil.login_V40("192.168.1.64", (short) 8000, "admin", "SHxy@510"); if (admin != -1) { log.info("登录成功 " + "IP:" + ip + " " + port); - HCNetSDK.NET_DVR_REALTIME_THERMOMETRY_COND cond = new HCNetSDK.NET_DVR_REALTIME_THERMOMETRY_COND(); - cond.read(); - cond.dwSize = cond.size(); - cond.byRuleID = 1; - cond.dwChan = 2; - cond.wInterval = 0; - cond.write(); - HCNetSDK.FRemoteConfigCallBack cbStateCallBack = new HCNetSDK.FRemoteConfigCallBack() { - @Override - public void invoke(int dwType, Pointer lpBuffer, int dwBufLen, Pointer pUserData) { -// log.info("111111111" + Integer.toHexString(dwType)); -// new Thread(new Runnable() { -// @Override -// public void run() { -// log.info("3333333" + Integer.toHexString(dwType)); -// DataEaifHEntity entitys = new DataEaifHEntity(); -// entitys.setEqmid(384); -// entitys.setMaxtemp((double) 0); -// entitys.setAreaid(1); -// entitys.setCapturetime(LocalDateTime.now()); -// entitys.setMintemp((double) 0); -// entitys.setAvgtemp((double) 0); -// entitys.setType((byte) HKConfigEnum.BYRULECALIBTYPE.POINT.getMysqlvalue()); -// entitys.setMid(Double.valueOf(0)); -// dataEaifHService.save(entitys); -// log.info("222222222222222" + Integer.toHexString(dwType)); -// } -// }).start(); - - test++; - log.info("长连接返回: dwType:" + Integer.toHexString(dwType)); - if (dwType == HKConfigEnum.NET_SDK_CALLBACK_TYPE.NET_SDK_CALLBACK_TYPE_DATA.getValue()) { - HCNetSDK.NET_DVR_THERMOMETRY_UPLOAD data = new HCNetSDK.NET_DVR_THERMOMETRY_UPLOAD(); - data.write(); - Pointer pointer = data.getPointer(); - pointer.write(0, lpBuffer.getByteArray(0, data.size()), 0, data.size()); - data.read(); - log.info("返回的数据:" + data.toString()); - log.info("开始数据整理"); - byte byRuleCalibType = data.byRuleCalibType; - byte byThermometryUnit = data.byThermometryUnit; - DataEaifHEntity entity = new DataEaifHEntity(); - entity.setEqmid(id); - entity.setAreaid(1); - if (byThermometryUnit == HKConfigEnum.BYTHERMOMETRYUNIT.SSD.getValue()) { - entity.setUnit((byte) HKConfigEnum.BYTHERMOMETRYUNIT.SSD.getMysqlvalue()); - } else if (byThermometryUnit == HKConfigEnum.BYTHERMOMETRYUNIT.HSD.getValue()) { - entity.setUnit((byte) HKConfigEnum.BYTHERMOMETRYUNIT.HSD.getMysqlvalue()); - } else if (byThermometryUnit == HKConfigEnum.BYTHERMOMETRYUNIT.KEW.getValue()) { - entity.setUnit((byte) HKConfigEnum.BYTHERMOMETRYUNIT.KEW.getMysqlvalue()); - } - log.info("数据整理1"); - //数据库中1->点2->线3->框 - if (byRuleCalibType == HKConfigEnum.BYRULECALIBTYPE.POINT.getValue()) { - float fTemperature = data.struPointThermCfg.fTemperature; - double maxtemp = new BigDecimal(fTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue(); - entity.setMaxtemp(maxtemp); - entity.setMintemp(maxtemp); - entity.setAvgtemp(maxtemp); - entity.setType((byte) HKConfigEnum.BYRULECALIBTYPE.POINT.getMysqlvalue()); - entity.setMid(Double.valueOf(0)); - } else if (byRuleCalibType == HKConfigEnum.BYRULECALIBTYPE.FRAME.getValue() || byRuleCalibType == HKConfigEnum.BYRULECALIBTYPE.LINE.getValue()) { - HCNetSDK.NET_DVR_LINEPOLYGON_THERM_CFG struLinePolygonThermCfg = data.struLinePolygonThermCfg; - float fAverageTemperature = struLinePolygonThermCfg.fAverageTemperature;//平均温度 - float fMinTemperature = struLinePolygonThermCfg.fMinTemperature; - float fMaxTemperature = struLinePolygonThermCfg.fMaxTemperature; - float fTemperatureDiff = struLinePolygonThermCfg.fTemperatureDiff; - entity.setMaxtemp(new BigDecimal(fMaxTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); - entity.setMintemp(new BigDecimal(fMinTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); - entity.setAvgtemp(new BigDecimal(fAverageTemperature).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); - entity.setMid(new BigDecimal(fTemperatureDiff).setScale(4, BigDecimal.ROUND_DOWN).doubleValue()); - if (byRuleCalibType == HKConfigEnum.BYRULECALIBTYPE.FRAME.getValue()) { - entity.setType((byte) HKConfigEnum.BYRULECALIBTYPE.FRAME.getMysqlvalue()); - } else if (byRuleCalibType == HKConfigEnum.BYRULECALIBTYPE.LINE.getValue()) { - entity.setType((byte) HKConfigEnum.BYRULECALIBTYPE.LINE.getMysqlvalue()); - } - } - log.info("数据整理2"); - entity.setStd(Double.valueOf(0)); - entity.setCapturetime(LocalDateTime.now()); - log.info("开始插入"); - log.info("数据是:" + entity.toString()); - asyncService.executeAsyncTask(entity); -// Testintimpl testintimpl = new Testintimpl(); -// testintimpl.test(entity); - - -// String sql = "INSERT INTO data_eaif_h(eqmid,areaid,capturetime,maxtemp,mintemp,avgtemp,unit,type,mid,std) values('" + 666 + "','1','" + new Date() + "','" + 1 + "','" + 1 + "','" + 1 + "','" + 1 + "','" + 1 + "','" + 1 + "','" + 1 + "')"; -// System.out.println(sql); -// help.getConnection(); -// int ret = help.excuteUpdate(sql); -// log.info("啦啦啦" + ret); -// try { -// conn.close(); -// } catch (SQLException throwables) { -// throwables.printStackTrace(); -// } -// if (test == 1) { -// DataEaifHEntity entitys = new DataEaifHEntity(); -// entitys.setEqmid(384); -// entitys.setMaxtemp((double) 0); -// entitys.setAreaid(1); -// entitys.setCapturetime(LocalDateTime.now()); -// entitys.setMintemp((double) 0); -// entitys.setAvgtemp((double) 0); -// entitys.setType((byte) HKConfigEnum.BYRULECALIBTYPE.POINT.getMysqlvalue()); -// entitys.setMid(Double.valueOf(0)); -// dataEaifHService.save(entitys); + List modevEaifEntityList = modevEaifService.list(Wrappers.lambdaQuery(ModevEaifEntity.class).eq(ModevEaifEntity::getEqmid, id)); + if (CollectionUtils.isNotEmpty(modevEaifEntityList)) { + for (int z = 0; z < modevEaifEntityList.size(); z++) { +// this.lock(); +// handle = -1; + ModevEaifEntity modevEaifEntity = modevEaifEntityList.get(z); + Integer nPresetId = modevEaifEntity.getNPresetId();//预置点位 + Integer nRuleId = modevEaifEntity.getNRuleId();//规则编号 + Integer nMeterType = modevEaifEntity.getNMeterType();//测试点类型 + if (nPresetId != null) { + boolean b = instance.NET_DVR_PTZPreset_Other(admin, 2, HCNetSDK.GOTO_PRESET, nPresetId); +// boolean b = instance.NET_DVR_PTZCruise_Other(admin, 2, HCNetSDK.RUN_SEQ, (byte) 1, (byte) 1, (short) 1); + if (b) { + log.info("云台预置位成功:" + nPresetId); + HCNetSDK.NET_DVR_REALTIME_THERMOMETRY_COND cond = new HCNetSDK.NET_DVR_REALTIME_THERMOMETRY_COND(); + cond.read(); + cond.dwSize = cond.size(); + cond.byRuleID = nRuleId.byteValue(); + cond.dwChan = 2; + cond.wInterval = 3; + cond.byMode = 1; + cond.write(); +// ArrayList list1 = new ArrayList<>(); + HCNetSDK.FRemoteConfigCallBack cbStateCallBack = new HCNetSDK.FRemoteConfigCallBack() { + @Override + public void invoke(int dwType, Pointer lpBuffer, int dwBufLen, Pointer pUserData) { + log.info("长连接返回: dwType:" + Integer.toHexString(dwType)); +// lock.lock(); + log.info("已上锁"); + if (dwType == HKConfigEnum.NET_SDK_CALLBACK_TYPE_DATA) { +// DataEaifHEntity entity = getDataEaifHEntity(lpBuffer, id); +// list1.add(entity); +// dataEaifHService.save(entity); + asyncService.executeAsyncTask(lpBuffer, id); + log.info("准备解锁"); +// lock.unlock(); + log.info("已经解锁"); + if (handle != -1) { + log.info("开始退出1"); + instance.NET_DVR_StopRemoteConfig(handle); +// instance.NET_DVR_Logout(admin); + } + } +// else { +// log.info("开始退出2"); +// if (handle != -1) { +// instance.NET_DVR_StopRemoteConfig(handle); +//// instance.NET_DVR_Logout(admin); +// } +// } + } + }; + //NET_DVR_GET_REALTIME_THERMOMETRY 实时温度检测 NET_DVR_GET_MANUALTHERM_INFO 手动测温实时获取 + handle = instance.NET_DVR_StartRemoteConfig(admin, HCNetSDK.NET_DVR_GET_REALTIME_THERMOMETRY, cond.getPointer(), cond.size(), cbStateCallBack, null); + if (handle < 0) { + int j = instance.NET_DVR_GetLastError(); + IntByReference intByReference = new IntByReference(j); + log.error("长连接连接失败 " + "错误码:" + j + " 错误信息:" + instance.NET_DVR_GetErrorMsg(intByReference)); + } else { + log.info("长连接连接成功!!!"); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } +// asyncService.executeAsyncTask(entity); + +// if (handle != -1) { +// log.info("开始退出1:" + handle); +// instance.NET_DVR_StopRemoteConfig(handle); +//// instance.NET_DVR_Logout(admin); +// } +// log.info("开始插入测温数据"); //// -//// ModevEntity entitys = new ModevEntity(); -//// entitys.setModevtid(1919); -//// entitys.setZsbid(1); -//// entitys.setIedid(1); -//// entitys.setAddress(12112); -//// modevService.save(entitys); -// } - - if (handle != -1) { - log.info("开始退出"); - instance.NET_DVR_StopRemoteConfig(handle); - instance.NET_DVR_Logout(admin); - } - } else { - if (handle != -1) { - instance.NET_DVR_StopRemoteConfig(handle); - instance.NET_DVR_Logout(admin); +// if (CollectionUtils.isNotEmpty(list1)) { +// DataEaifHEntity entity = list1.get(0); +// if (entity != null) { +// dataEaifHService.save(entity); +// log.info("开始插入测温数据成功"); +// } +// } + } + } else { + int y = instance.NET_DVR_GetLastError(); + IntByReference intByReference1 = new IntByReference(y); + log.error("云台失败 " + "错误码:" + y + " 错误信息:" + instance.NET_DVR_GetErrorMsg(intByReference1)); } } } - }; - //NET_DVR_GET_REALTIME_THERMOMETRY 实时温度检测 NET_DVR_GET_MANUALTHERM_INFO 手动测温实时获取 - handle = instance.NET_DVR_StartRemoteConfig(admin, HCNetSDK.NET_DVR_GET_REALTIME_THERMOMETRY, cond.getPointer(), cond.size(), cbStateCallBack, null); - if (handle < 0) { - int j = instance.NET_DVR_GetLastError(); - IntByReference intByReference = new IntByReference(j); - log.error("长连接连接失败 " + "错误码:" + j + " 错误信息:" + instance.NET_DVR_GetErrorMsg(intByReference)); } else { - log.info("长连接连接成功!!!"); + log.error("登录失败 " + "IP:" + ip + " " + port); } - -// try { -// Thread.sleep(5000); -// } catch (InterruptedException e) { -// e.printStackTrace(); - -// } } else { - log.error("登录失败 " + "IP:" + ip + " " + port); + log.error("该设备" + id + "没有配置预置位"); } } } else { diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 4a23664..1d9daaf 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -32,7 +32,7 @@ spring: driverClassName: com.mysql.cj.jdbc.Driver druid: # 主库数据源 - url: jdbc:mysql://192.168.1.190:3306/cac?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://10.0.17.25:3306/cacdb?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: 123456 # 初始连接数 @@ -42,7 +42,7 @@ spring: # 最大连接池数量 maxActive: 50 # 配置获取连接等待超时的时间 - maxWait: 60000 + maxWait: 10000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 timeBetweenEvictionRunsMillis: 30000 # 配置一个连接在池中最小生存的时间,单位是毫秒