|
|
|
@@ -46,12 +46,21 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化 |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
HardwareEquipmentInfo info = new HardwareEquipmentInfo("192.168.69.142",(short) 37777,"admin","yzx123456",null); |
|
|
|
DaHua daHua = new DaHua(info); |
|
|
|
List<UserFaceInfo> allCard = daHua.findAllCard(); |
|
|
|
System.out.println("allCard.size() = " + allCard.size()); |
|
|
|
// int u6118 = daHua.findRecordNo("u6118"); |
|
|
|
// System.out.println("u6118 = " + u6118); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public DaHua(HardwareEquipmentInfo info){ |
|
|
|
this.info = info; |
|
|
|
this.login(); |
|
|
|
// this.login(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean downloadPersonPic(String szFileName, String pszFileDst) { |
|
|
|
/* |
|
|
|
* 入参 |
|
|
|
@@ -86,6 +95,7 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
boolean ret = LoginModule.netsdk.CLIENT_ControlDeviceEx(info.getLoginHandle(), |
|
|
|
NetSDKLib.CtrlType.CTRLTYPE_CTRL_ACCESS_OPEN, pointer, null, 10000); |
|
|
|
if (!ret) { |
|
|
|
System.err.println("开门失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -218,6 +228,8 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
if(recordNo != 0){ |
|
|
|
if(GateModule.deleteCardV2(info.getLoginHandle(),recordNo) && GateModule.deleteFaceInfoV2(info.getLoginHandle(),employeeNo)){ |
|
|
|
return true; |
|
|
|
}else{ |
|
|
|
System.err.println("删除人员失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -233,6 +245,9 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
private boolean addUserFace(String userId,byte[] imageBytes){ |
|
|
|
Memory memory = ToolKits.readPictureBytes(imageBytes); |
|
|
|
boolean b = GateModule.addFaceInfoV2(info.getLoginHandle(),userId, memory); |
|
|
|
if(!b){ |
|
|
|
System.err.println("添加人脸失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
} |
|
|
|
return b; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -245,6 +260,9 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
private boolean updateUserFace(String userId,byte[] imageBytes){ |
|
|
|
Memory memory = ToolKits.readPictureBytes(imageBytes); |
|
|
|
boolean b = GateModule.modifyFaceInfoV2(info.getLoginHandle(),userId, memory); |
|
|
|
if(!b){ |
|
|
|
System.err.println("更新人脸失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
} |
|
|
|
return b; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -260,7 +278,9 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
String endTime = userFaceInfo.getEndTime(); |
|
|
|
String cardNo = userFaceInfo.getCardNo(); |
|
|
|
boolean b = GateModule.insertCardV2(info.getLoginHandle(),cardNo, employeeNo, employeeName, "", 0, 0, 0, 0, 1, startTime, endTime); |
|
|
|
|
|
|
|
if(!b){ |
|
|
|
System.err.println("添加用户卡失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
} |
|
|
|
return b; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -279,6 +299,9 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
int recordNo = this.findRecordNo(employeeNo); |
|
|
|
|
|
|
|
boolean b = GateModule.modifyCardV2(info.getLoginHandle(),recordNo,cardNo, employeeNo, employeeName, "", 0, 0, 0, 0, 1, startTime, endTime); |
|
|
|
if(!b){ |
|
|
|
System.err.println("更新用户卡失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
} |
|
|
|
return b; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -289,6 +312,7 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
NetSDKLib.LLong findHandle = GateModule.findCardV2(this.info.getLoginHandle(), "", employeeNo); |
|
|
|
this.info.setFindHandle(findHandle); |
|
|
|
if(findHandle.longValue() == 0) { |
|
|
|
System.err.println("获取用户卡查询句柄失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -296,6 +320,7 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
while(true) { |
|
|
|
NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD[] pstRecord = GateModule.findNextCardV2(this.info.getFindHandle(),nFindCount); |
|
|
|
if(pstRecord == null) { |
|
|
|
System.err.println("查询用户卡失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -316,19 +341,22 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
|
|
|
|
public List<UserFaceInfo> findAllCard() { |
|
|
|
List<UserFaceInfo> userFaceInfoList = new ArrayList<>(); |
|
|
|
|
|
|
|
int nFindCount = 1; |
|
|
|
|
|
|
|
// 卡号: 为空,查询所有的卡信息 |
|
|
|
// 获取查询句柄 |
|
|
|
if(GateModule.findCardV2(info.getLoginHandle(),"","").longValue() == 0) { |
|
|
|
NetSDKLib.LLong findHandle = GateModule.findCardV2(this.info.getLoginHandle(), "", ""); |
|
|
|
this.info.setFindHandle(findHandle); |
|
|
|
if(findHandle.longValue() == 0) { |
|
|
|
System.err.println("获取用户卡查询句柄失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
return userFaceInfoList; |
|
|
|
} |
|
|
|
|
|
|
|
// 查询具体信息 |
|
|
|
while(true) { |
|
|
|
NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD[] pstRecord = GateModule.findNextCard(nFindCount); |
|
|
|
NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD[] pstRecord = GateModule.findNextCardV2(this.info.getFindHandle(),nFindCount); |
|
|
|
if(pstRecord == null) { |
|
|
|
System.err.println("查询所有用户卡失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -352,7 +380,7 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
} |
|
|
|
|
|
|
|
// 关闭查询接口 |
|
|
|
GateModule.findCardClose(); |
|
|
|
GateModule.findCardCloseV2(info.getFindHandle()); |
|
|
|
|
|
|
|
return userFaceInfoList; |
|
|
|
} |
|
|
|
@@ -360,6 +388,8 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
public boolean clearAllPerson(){ |
|
|
|
if(GateModule.clearCardV2(this.info.getLoginHandle()) && GateModule.clearFaceInfoV2(this.info.getLoginHandle())){ |
|
|
|
return true; |
|
|
|
}else{ |
|
|
|
System.err.println("清除所有用户数据失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
@@ -370,6 +400,9 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
public boolean login() { |
|
|
|
NetSDKLib.LLong lLong = LoginModule.login2(info.getIp(),info.getPort(),info.getUsername(),info.getPassword()); |
|
|
|
this.info.setLoginHandle(lLong); |
|
|
|
if(lLong.longValue() == 0){ |
|
|
|
System.err.println("登录失败!" + ToolKits.getErrorCodePrint()); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -438,7 +471,13 @@ public class DaHua implements IHardwareEquipment { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public HardwareEquipmentInfo getInfo(){ |
|
|
|
return this.info; |
|
|
|
} |
|
|
|
|
|
|
|
public void setInfo(HardwareEquipmentInfo info){ |
|
|
|
this.info = info; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void cleanup() { |
|
|
|
|