Просмотр исходного кода

进行数据解析处理中

doorRight设置
chd 3 лет назад
Родитель
Сommit
3cb3d3b321
4 измененных файлов: 37 добавлений и 14 удалений
  1. +14
    -11
      src/main/java/com/hkversion/AlarmDataParse.java
  2. +3
    -2
      src/main/java/com/yzx/Main.java
  3. +2
    -1
      src/main/java/com/yzx/callback/AlarmCallback.java
  4. +18
    -0
      src/main/java/com/yzx/pojo/AlarmDataInfo.java

+ 14
- 11
src/main/java/com/hkversion/AlarmDataParse.java Просмотреть файл

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.common.CommonUtil;
import com.sun.jna.Pointer;
import com.yzx.callback.AlarmCallback;
import com.yzx.pojo.AlarmDataInfo;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -379,7 +380,7 @@ public class AlarmDataParse {
break;
case HCNetSDK.COMM_ALARM_ACS: //门禁主机报警信息
//组装数据
JSONObject json = new JSONObject();
AlarmDataInfo info = new AlarmDataInfo();
HCNetSDK.NET_DVR_ACS_ALARM_INFO strACSInfo = new HCNetSDK.NET_DVR_ACS_ALARM_INFO();
strACSInfo.write();
Pointer pACSInfo = strACSInfo.getPointer();
@@ -389,11 +390,13 @@ public class AlarmDataParse {
主类型: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);
json.put("dwEmployeeNo",strACSInfo.struAcsEventInfo.dwEmployeeNo);
json.put("byCardNo",new String(strACSInfo.struAcsEventInfo.byCardNo).trim());
json.put("byCardType",strACSInfo.struAcsEventInfo.byCardType);
json.put("dwMajor",Integer.toHexString(strACSInfo.dwMajor));
json.put("dwMinor",Integer.toHexString(strACSInfo.dwMinor));
info.setDwEmployeeNo(strACSInfo.struAcsEventInfo.dwEmployeeNo);
info.setByCardNo(new String(strACSInfo.struAcsEventInfo.byCardNo).trim());
info.setByCardType(strACSInfo.struAcsEventInfo.byCardType);
info.setDwMajor(Integer.toHexString(strACSInfo.dwMajor));
info.setDwMinor(Integer.toHexString(strACSInfo.dwMinor));
info.setSerialNumber(new String(pAlarmer.sSerialNumber).trim());
info.setSerialNo(strACSInfo.struAcsEventInfo.dwSerialNo);
//温度信息(如果设备支持测温功能,人脸温度信息从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();
@@ -402,7 +405,7 @@ public class AlarmDataParse {
pAcsInfoExV20.write(0, strACSInfo.pAcsEventInfoExtendV20.getByteArray(0, strAcsInfoExV20.size()), 0, strAcsInfoExV20.size());
strAcsInfoExV20.read();
//System.out.println("实时温度值:" + strAcsInfoExV20.fCurrTemperature);
json.put("currTemperature",strAcsInfoExV20.fCurrTemperature);
info.setCurrTemperature(strAcsInfoExV20.fCurrTemperature);
}
//考勤状态
if (strACSInfo.byAcsEventInfoExtend == 1) {
@@ -413,8 +416,8 @@ public class AlarmDataParse {
strAcsInfoEx.read();
//System.out.println("考勤状态:" + strAcsInfoEx.byAttendanceStatus);
//System.out.println("工号2:" + new String(strAcsInfoEx.byEmployeeNo).trim());
json.put("byEmployeeNo",new String(strAcsInfoEx.byEmployeeNo).trim());
json.put("attendanceStatus",strAcsInfoEx.byAttendanceStatus);
info.setByEmployeeNo(new String(strAcsInfoEx.byEmployeeNo).trim());
info.setAttendanceStatus(strAcsInfoEx.byAttendanceStatus);
}

/**
@@ -430,9 +433,9 @@ public class AlarmDataParse {
byte[] bytes = new byte[strACSInfo.dwPicDataLen];
buffers.rewind();
buffers.get(bytes);
json.put("pic",bytes);
info.setPic(bytes);
}
callback.process(json);
callback.process(info);
break;

case HCNetSDK.COMM_ID_INFO_ALARM: //身份证信息


+ 3
- 2
src/main/java/com/yzx/Main.java Просмотреть файл

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yzx.callback.AlarmCallback;
import com.yzx.impl.HKVersion;
import com.yzx.impl.HardwareEquipmentInfo;
import com.yzx.pojo.AlarmDataInfo;

import java.util.ArrayList;
import java.util.List;
@@ -43,9 +44,9 @@ public class Main {

private static class AlarmCallbackImpl implements AlarmCallback{
@Override
public void process(JSONObject json) {
public void process(AlarmDataInfo info) {
System.out.println(" 告警回调触发......");
System.out.println("json = " + json);
System.out.println("info = " + info);
}
};
}

+ 2
- 1
src/main/java/com/yzx/callback/AlarmCallback.java Просмотреть файл

@@ -1,10 +1,11 @@
package com.yzx.callback;

import com.alibaba.fastjson.JSONObject;
import com.yzx.pojo.AlarmDataInfo;

public interface AlarmCallback {
/**
* 告警回调函数,调用方必须实现该函数方可收到硬件设备的告警数据
*/
void process(JSONObject json);
void process(AlarmDataInfo info);
}

+ 18
- 0
src/main/java/com/yzx/pojo/AlarmDataInfo.java Просмотреть файл

@@ -0,0 +1,18 @@
package com.yzx.pojo;

import lombok.Data;

@Data
public class AlarmDataInfo {
private int dwEmployeeNo;
private String byCardNo;
private byte byCardType;
private String dwMajor;
private String dwMinor;
private float currTemperature;
private String byEmployeeNo;
private byte attendanceStatus;
private byte[] pic;
private String serialNumber;
private int serialNo;
}

Загрузка…
Отмена
Сохранить