提交 | 用户 | 时间
|
ce910c
|
1 |
package com.netsdk.demo.module; |
H |
2 |
|
|
3 |
import java.io.UnsupportedEncodingException; |
|
4 |
|
|
5 |
import com.sun.jna.Memory; |
|
6 |
import com.sun.jna.ptr.IntByReference; |
|
7 |
|
|
8 |
import com.netsdk.lib.NetSDKLib; |
|
9 |
import com.netsdk.lib.NetSDKLib.*; |
|
10 |
import com.netsdk.lib.ToolKits; |
|
11 |
|
|
12 |
public class GateModule { |
|
13 |
// 查询句柄 |
|
14 |
private static LLong m_lFindHandle = new LLong(0); |
|
15 |
|
|
16 |
/** |
|
17 |
* 订阅实时上传智能分析数据 |
|
18 |
* @return |
|
19 |
*/ |
|
20 |
public static LLong realLoadPic(int ChannelId, NetSDKLib.fAnalyzerDataCallBack m_AnalyzerDataCB) { |
|
21 |
/** |
|
22 |
* 说明: |
|
23 |
* 通道数可以在有登录是返回的信息 m_stDeviceInfo.byChanNum 获取 |
|
24 |
* 下列仅订阅了0通道的智能事件. |
|
25 |
*/ |
|
26 |
int bNeedPicture = 1; // 是否需要图片 |
|
27 |
|
|
28 |
LLong m_hAttachHandle = LoginModule.netsdk.CLIENT_RealLoadPictureEx(LoginModule.m_hLoginHandle, ChannelId, NetSDKLib.EVENT_IVS_ALL, |
|
29 |
bNeedPicture , m_AnalyzerDataCB , null , null); |
|
30 |
if( m_hAttachHandle.longValue() != 0 ) { |
|
31 |
System.out.println("CLIENT_RealLoadPictureEx Success ChannelId : \n" + ChannelId); |
|
32 |
} else { |
|
33 |
System.err.println("CLIENT_RealLoadPictureEx Failed!" + ToolKits.getErrorCodePrint()); |
|
34 |
return null; |
|
35 |
} |
|
36 |
|
|
37 |
return m_hAttachHandle; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* 停止上传智能分析数据-图片 |
|
42 |
*/ |
|
43 |
public static void stopRealLoadPic(LLong m_hAttachHandle) { |
|
44 |
if (0 != m_hAttachHandle.longValue()) { |
|
45 |
LoginModule.netsdk.CLIENT_StopLoadPic(m_hAttachHandle); |
|
46 |
System.out.println("Stop detach IVS event"); |
|
47 |
m_hAttachHandle.setValue(0); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
////////////////////////////////////// 卡信息的增、删、改、清空 //////////////////////////////////////// |
|
52 |
|
|
53 |
/** |
|
54 |
* 添加卡 |
|
55 |
* @param cardNo 卡号 |
|
56 |
* @param userId 用户ID |
|
57 |
* @param cardName 卡名 |
|
58 |
* @param cardPwd 卡密码 |
|
59 |
* @param cardStatus 卡状态 |
|
60 |
* @param cardType 卡类型 |
|
61 |
* @param useTimes 使用次数 |
|
62 |
* @param isFirstEnter 是否首卡, 1-true, 0-false |
|
63 |
* @param isValid 是否有效, 1-true, 0-false |
|
64 |
* @param startValidTime 有效开始时间 |
|
65 |
* @param endValidTime 有效结束时间 |
|
66 |
* @return true:成功 false:失败 |
|
67 |
*/ |
|
68 |
public static boolean insertCard(String cardNo, String userId, String cardName, String cardPwd, |
|
69 |
int cardStatus, int cardType, int useTimes, int isFirstEnter, |
|
70 |
int isValid, String startValidTime, String endValidTime) { |
|
71 |
/** |
|
72 |
* 门禁卡记录集信息 |
|
73 |
*/ |
|
74 |
NET_RECORDSET_ACCESS_CTL_CARD accessCardInfo = new NET_RECORDSET_ACCESS_CTL_CARD(); |
|
75 |
|
|
76 |
// 卡号 |
|
77 |
System.arraycopy(cardNo.getBytes(), 0, accessCardInfo.szCardNo, 0, cardNo.getBytes().length); |
|
78 |
|
|
79 |
// 用户ID |
|
80 |
System.arraycopy(userId.getBytes(), 0, accessCardInfo.szUserID, 0, userId.getBytes().length); |
|
81 |
|
|
82 |
// 卡名(设备上显示的姓名) |
|
83 |
try { |
|
84 |
System.arraycopy(cardName.getBytes("GBK"), 0, accessCardInfo.szCardName, 0, cardName.getBytes("GBK").length); |
|
85 |
} catch (UnsupportedEncodingException e) { |
|
86 |
e.printStackTrace(); |
|
87 |
} |
|
88 |
|
|
89 |
// 卡密码 |
|
90 |
System.arraycopy(cardPwd.getBytes(), 0, accessCardInfo.szPsw, 0, cardPwd.getBytes().length); |
|
91 |
|
|
92 |
//-- 设置开门权限 |
|
93 |
accessCardInfo.nDoorNum = 2; |
|
94 |
accessCardInfo.sznDoors[0] = 0; |
|
95 |
accessCardInfo.sznDoors[1] = 1; |
|
96 |
accessCardInfo.nTimeSectionNum = 2; // 与门数对应 |
|
97 |
accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 |
|
98 |
accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 |
|
99 |
|
|
100 |
// 卡状态 |
|
101 |
accessCardInfo.emStatus = cardStatus; |
|
102 |
|
|
103 |
// 卡类型 |
|
104 |
accessCardInfo.emType = cardType; |
|
105 |
|
|
106 |
// 使用次数 |
|
107 |
accessCardInfo.nUserTime = useTimes; |
|
108 |
|
|
109 |
// 是否首卡 |
|
110 |
accessCardInfo.bFirstEnter = isFirstEnter; |
|
111 |
|
|
112 |
// 是否有效 |
|
113 |
accessCardInfo.bIsValid = isValid; |
|
114 |
|
|
115 |
// 有效开始时间 |
|
116 |
String[] startTimes = startValidTime.split(" "); |
|
117 |
accessCardInfo.stuValidStartTime.dwYear = Integer.parseInt(startTimes[0].split("-")[0]); |
|
118 |
accessCardInfo.stuValidStartTime.dwMonth = Integer.parseInt(startTimes[0].split("-")[1]); |
|
119 |
accessCardInfo.stuValidStartTime.dwDay = Integer.parseInt(startTimes[0].split("-")[2]); |
|
120 |
accessCardInfo.stuValidStartTime.dwHour = Integer.parseInt(startTimes[1].split(":")[0]); |
|
121 |
accessCardInfo.stuValidStartTime.dwMinute = Integer.parseInt(startTimes[1].split(":")[1]); |
|
122 |
accessCardInfo.stuValidStartTime.dwSecond = Integer.parseInt(startTimes[01].split(":")[2]); |
|
123 |
|
|
124 |
// 有效结束时间 |
|
125 |
String[] endTimes = endValidTime.split(" "); |
|
126 |
accessCardInfo.stuValidEndTime.dwYear = Integer.parseInt(endTimes[0].split("-")[0]); |
|
127 |
accessCardInfo.stuValidEndTime.dwMonth = Integer.parseInt(endTimes[0].split("-")[1]); |
|
128 |
accessCardInfo.stuValidEndTime.dwDay = Integer.parseInt(endTimes[0].split("-")[2]); |
|
129 |
accessCardInfo.stuValidEndTime.dwHour = Integer.parseInt(endTimes[1].split(":")[0]); |
|
130 |
accessCardInfo.stuValidEndTime.dwMinute = Integer.parseInt(endTimes[1].split(":")[1]); |
|
131 |
accessCardInfo.stuValidEndTime.dwSecond = Integer.parseInt(endTimes[1].split(":")[2]); |
|
132 |
|
|
133 |
/** |
|
134 |
* 记录集操作 |
|
135 |
*/ |
|
136 |
NET_CTRL_RECORDSET_INSERT_PARAM insert = new NET_CTRL_RECORDSET_INSERT_PARAM(); |
|
137 |
insert.stuCtrlRecordSetInfo.emType = EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD; // 记录集类型 |
|
138 |
insert.stuCtrlRecordSetInfo.pBuf = accessCardInfo.getPointer(); |
|
139 |
|
|
140 |
accessCardInfo.write(); |
|
141 |
insert.write(); |
|
142 |
boolean bRet = LoginModule.netsdk.CLIENT_ControlDevice(LoginModule.m_hLoginHandle, |
|
143 |
CtrlType.CTRLTYPE_CTRL_RECORDSET_INSERT, insert.getPointer(), 5000); |
|
144 |
insert.read(); |
|
145 |
accessCardInfo.read(); |
|
146 |
|
|
147 |
if(!bRet) { |
|
148 |
System.err.println("添加卡信息失败." + ToolKits.getErrorCodePrint()); |
|
149 |
return false; |
|
150 |
} else { |
|
151 |
System.out.println("添加卡信息成功,卡信息记录集编号 : " + insert.stuCtrlRecordSetResult.nRecNo); |
|
152 |
} |
|
153 |
|
|
154 |
return true; |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* 修改卡信息 |
|
159 |
* @param recordNo 记录集编号 |
|
160 |
* @param cardNo 卡号 |
|
161 |
* @param userId 用户ID |
|
162 |
* @param cardName 卡名 |
|
163 |
* @param cardPwd 卡密码 |
|
164 |
* @param cardStatus 卡状态 |
|
165 |
* @param cardType 卡类型 |
|
166 |
* @param useTimes 使用次数 |
|
167 |
* @param isFirstEnter 是否首卡, 1-true, 0-false |
|
168 |
* @param isValid 是否有效, 1-true, 0-false |
|
169 |
* @param startValidTime 有效开始时间 |
|
170 |
* @param endValidTime 有效结束时间 |
|
171 |
* @return true:成功 false:失败 |
|
172 |
*/ |
|
173 |
public static boolean modifyCard(int recordNo, String cardNo, String userId, String cardName, String cardPwd, |
|
174 |
int cardStatus, int cardType, int useTimes, int isFirstEnter, |
|
175 |
int isValid, String startValidTime, String endValidTime) { |
|
176 |
/** |
|
177 |
* 门禁卡记录集信息 |
|
178 |
*/ |
|
179 |
NET_RECORDSET_ACCESS_CTL_CARD accessCardInfo = new NET_RECORDSET_ACCESS_CTL_CARD(); |
|
180 |
// 记录集编号, 修改、删除卡信息必须填写 |
|
181 |
accessCardInfo.nRecNo = recordNo; |
|
182 |
|
|
183 |
// 卡号 |
|
184 |
System.arraycopy(cardNo.getBytes(), 0, accessCardInfo.szCardNo, 0, cardNo.getBytes().length); |
|
185 |
|
|
186 |
// 用户ID |
|
187 |
System.arraycopy(userId.getBytes(), 0, accessCardInfo.szUserID, 0, userId.getBytes().length); |
|
188 |
|
|
189 |
// 卡名(设备上显示的姓名) |
|
190 |
try { |
|
191 |
System.arraycopy(cardName.getBytes("GBK"), 0, accessCardInfo.szCardName, 0, cardName.getBytes("GBK").length); |
|
192 |
} catch (UnsupportedEncodingException e) { |
|
193 |
e.printStackTrace(); |
|
194 |
} |
|
195 |
|
|
196 |
// 卡密码 |
|
197 |
System.arraycopy(cardPwd.getBytes(), 0, accessCardInfo.szPsw, 0, cardPwd.getBytes().length); |
|
198 |
|
|
199 |
//-- 设置开门权限 |
|
200 |
accessCardInfo.nDoorNum = 2; |
|
201 |
accessCardInfo.sznDoors[0] = 0; |
|
202 |
accessCardInfo.sznDoors[1] = 1; |
|
203 |
accessCardInfo.nTimeSectionNum = 2; // 与门数对应 |
|
204 |
accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 |
|
205 |
accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 |
|
206 |
|
|
207 |
// 卡状态 |
|
208 |
accessCardInfo.emStatus = cardStatus; |
|
209 |
|
|
210 |
// 卡类型 |
|
211 |
accessCardInfo.emType = cardType; |
|
212 |
|
|
213 |
// 使用次数 |
|
214 |
accessCardInfo.nUserTime = useTimes; |
|
215 |
|
|
216 |
// 是否首卡 |
|
217 |
accessCardInfo.bFirstEnter = isFirstEnter; |
|
218 |
|
|
219 |
// 是否有效 |
|
220 |
accessCardInfo.bIsValid = isValid; |
|
221 |
|
|
222 |
// 有效开始时间 |
|
223 |
String[] startTimes = startValidTime.split(" "); |
|
224 |
accessCardInfo.stuValidStartTime.dwYear = Integer.parseInt(startTimes[0].split("-")[0]); |
|
225 |
accessCardInfo.stuValidStartTime.dwMonth = Integer.parseInt(startTimes[0].split("-")[1]); |
|
226 |
accessCardInfo.stuValidStartTime.dwDay = Integer.parseInt(startTimes[0].split("-")[2]); |
|
227 |
accessCardInfo.stuValidStartTime.dwHour = Integer.parseInt(startTimes[1].split(":")[0]); |
|
228 |
accessCardInfo.stuValidStartTime.dwMinute = Integer.parseInt(startTimes[1].split(":")[1]); |
|
229 |
accessCardInfo.stuValidStartTime.dwSecond = Integer.parseInt(startTimes[01].split(":")[2]); |
|
230 |
|
|
231 |
// 有效结束时间 |
|
232 |
String[] endTimes = endValidTime.split(" "); |
|
233 |
accessCardInfo.stuValidEndTime.dwYear = Integer.parseInt(endTimes[0].split("-")[0]); |
|
234 |
accessCardInfo.stuValidEndTime.dwMonth = Integer.parseInt(endTimes[0].split("-")[1]); |
|
235 |
accessCardInfo.stuValidEndTime.dwDay = Integer.parseInt(endTimes[0].split("-")[2]); |
|
236 |
accessCardInfo.stuValidEndTime.dwHour = Integer.parseInt(endTimes[1].split(":")[0]); |
|
237 |
accessCardInfo.stuValidEndTime.dwMinute = Integer.parseInt(endTimes[1].split(":")[1]); |
|
238 |
accessCardInfo.stuValidEndTime.dwSecond = Integer.parseInt(endTimes[1].split(":")[2]); |
|
239 |
|
|
240 |
/** |
|
241 |
* 记录集操作 |
|
242 |
*/ |
|
243 |
NET_CTRL_RECORDSET_PARAM update = new NET_CTRL_RECORDSET_PARAM(); |
|
244 |
update.emType = EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD; // 记录集信息类型 |
|
245 |
update.pBuf = accessCardInfo.getPointer(); |
|
246 |
|
|
247 |
accessCardInfo.write(); |
|
248 |
update.write(); |
|
249 |
boolean bRet = LoginModule.netsdk.CLIENT_ControlDevice(LoginModule.m_hLoginHandle, |
|
250 |
CtrlType.CTRLTYPE_CTRL_RECORDSET_UPDATE, update.getPointer(), 5000); |
|
251 |
update.read(); |
|
252 |
accessCardInfo.read(); |
|
253 |
|
|
254 |
if(!bRet) { |
|
255 |
System.err.println("修改卡信息失败." + ToolKits.getErrorCodePrint()); |
|
256 |
return false; |
|
257 |
} else { |
|
258 |
System.out.println("修改卡信息成功 "); |
|
259 |
} |
|
260 |
|
|
261 |
return true; |
|
262 |
} |
|
263 |
|
|
264 |
/** |
|
265 |
* 删除卡信息(单个删除) |
|
266 |
* @param recordNo 记录集编号 |
|
267 |
*/ |
|
268 |
public static boolean deleteCard(int recordNo) { |
|
269 |
/** |
|
270 |
* 记录集操作 |
|
271 |
*/ |
|
272 |
NET_CTRL_RECORDSET_PARAM msg = new NET_CTRL_RECORDSET_PARAM(); |
|
273 |
msg.emType = EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD; |
|
274 |
msg.pBuf = new IntByReference(recordNo).getPointer(); |
|
275 |
|
|
276 |
msg.write(); |
|
277 |
boolean bRet = LoginModule.netsdk.CLIENT_ControlDevice(LoginModule.m_hLoginHandle, |
|
278 |
CtrlType.CTRLTYPE_CTRL_RECORDSET_REMOVE, msg.getPointer(), 5000); |
|
279 |
msg.read(); |
|
280 |
|
|
281 |
if(!bRet){ |
|
282 |
System.err.println("删除卡信息失败." + ToolKits.getErrorCodePrint()); |
|
283 |
} else { |
|
284 |
System.out.println("删除卡信息成功."); |
|
285 |
} |
|
286 |
|
|
287 |
return bRet; |
|
288 |
} |
|
289 |
|
|
290 |
/** |
|
291 |
* 清除所有卡信息 |
|
292 |
*/ |
|
293 |
public static boolean clearCard() { |
|
294 |
/** |
|
295 |
* 记录集操作 |
|
296 |
*/ |
|
297 |
NetSDKLib.NET_CTRL_RECORDSET_PARAM msg = new NetSDKLib.NET_CTRL_RECORDSET_PARAM(); |
|
298 |
msg.emType = EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD; // 门禁卡记录集信息类型 |
|
299 |
|
|
300 |
msg.write(); |
|
301 |
boolean bRet = LoginModule.netsdk.CLIENT_ControlDevice(LoginModule.m_hLoginHandle, |
|
302 |
CtrlType.CTRLTYPE_CTRL_RECORDSET_CLEAR, msg.getPointer(), 5000); |
|
303 |
msg.read(); |
|
304 |
if(!bRet){ |
|
305 |
System.err.println("清空卡信息失败." + ToolKits.getErrorCodePrint()); |
|
306 |
} else { |
|
307 |
System.out.println("清空卡信息成功."); |
|
308 |
} |
|
309 |
|
|
310 |
return bRet; |
|
311 |
} |
|
312 |
|
|
313 |
|
|
314 |
///////////////////////////////// 人脸的增、删、改、清空 /////////////////////////////////////// |
|
315 |
|
|
316 |
/** |
|
317 |
* 添加人脸 |
|
318 |
* @param userId 用户ID |
|
319 |
* @param memory 图片缓存 |
|
320 |
* @return |
|
321 |
*/ |
|
322 |
public static boolean addFaceInfo(String userId, Memory memory) { |
|
323 |
int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_ADD; // 添加 |
|
324 |
|
|
325 |
/** |
|
326 |
* 入参 |
|
327 |
*/ |
|
328 |
NET_IN_ADD_FACE_INFO stIn = new NET_IN_ADD_FACE_INFO(); |
|
329 |
|
|
330 |
// 用户ID |
|
331 |
System.arraycopy(userId.getBytes(), 0, stIn.szUserID, 0, userId.getBytes().length); |
|
332 |
|
|
333 |
// 人脸照片个数 |
|
334 |
stIn.stuFaceInfo.nFacePhoto = 1; |
|
335 |
|
|
336 |
// 每张图片的大小 |
|
337 |
stIn.stuFaceInfo.nFacePhotoLen[0] = (int) memory.size(); |
|
338 |
|
|
339 |
// 人脸照片数据,大小不超过100K, 图片格式为jpg |
|
340 |
stIn.stuFaceInfo.pszFacePhotoArr[0].pszFacePhoto = memory; |
|
341 |
|
|
342 |
/** |
|
343 |
* 出参 |
|
344 |
*/ |
|
345 |
NET_OUT_ADD_FACE_INFO stOut = new NET_OUT_ADD_FACE_INFO(); |
|
346 |
|
|
347 |
stIn.write(); |
|
348 |
stOut.write(); |
|
349 |
boolean bRet = LoginModule.netsdk.CLIENT_FaceInfoOpreate(LoginModule.m_hLoginHandle, emType, stIn.getPointer(), stOut.getPointer(), 5000); |
|
350 |
stIn.read(); |
|
351 |
stOut.read(); |
|
352 |
if(bRet) { |
|
353 |
System.out.println("添加人脸成功!"); |
|
354 |
} else { |
|
355 |
System.err.println("添加人脸失败!" + ToolKits.getErrorCodePrint()); |
|
356 |
return false; |
|
357 |
} |
|
358 |
|
|
359 |
return true; |
|
360 |
} |
|
361 |
|
|
362 |
/** |
|
363 |
* 修改人脸 |
|
364 |
* @param userId 用户ID |
|
365 |
* @param memory 图片缓存 |
|
366 |
* @return |
|
367 |
*/ |
|
368 |
public static boolean modifyFaceInfo(String userId, Memory memory) { |
|
369 |
int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_UPDATE; // 修改 |
|
370 |
|
|
371 |
/** |
|
372 |
* 入参 |
|
373 |
*/ |
|
374 |
NET_IN_UPDATE_FACE_INFO stIn = new NET_IN_UPDATE_FACE_INFO(); |
|
375 |
|
|
376 |
// 用户ID |
|
377 |
System.arraycopy(userId.getBytes(), 0, stIn.szUserID, 0, userId.getBytes().length); |
|
378 |
|
|
379 |
// 人脸照片个数 |
|
380 |
stIn.stuFaceInfo.nFacePhoto = 1; |
|
381 |
|
|
382 |
// 每张图片的大小 |
|
383 |
stIn.stuFaceInfo.nFacePhotoLen[0] = (int) memory.size(); |
|
384 |
|
|
385 |
// 人脸照片数据,大小不超过100K, 图片格式为jpg |
|
386 |
stIn.stuFaceInfo.pszFacePhotoArr[0].pszFacePhoto = memory; |
|
387 |
|
|
388 |
/** |
|
389 |
* 出参 |
|
390 |
*/ |
|
391 |
NET_OUT_UPDATE_FACE_INFO stOut = new NET_OUT_UPDATE_FACE_INFO(); |
|
392 |
|
|
393 |
stIn.write(); |
|
394 |
stOut.write(); |
|
395 |
boolean bRet = LoginModule.netsdk.CLIENT_FaceInfoOpreate(LoginModule.m_hLoginHandle, emType, stIn.getPointer(), stOut.getPointer(), 5000); |
|
396 |
stIn.read(); |
|
397 |
stOut.read(); |
|
398 |
if(bRet) { |
|
399 |
System.out.println("修改人脸成功!"); |
|
400 |
} else { |
|
401 |
System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); |
|
402 |
return false; |
|
403 |
} |
|
404 |
|
|
405 |
return true; |
|
406 |
} |
|
407 |
|
|
408 |
/** |
|
409 |
* 删除人脸(单个删除) |
|
410 |
* @param userId 用户ID |
|
411 |
*/ |
|
412 |
public static boolean deleteFaceInfo(String userId) { |
|
413 |
int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_REMOVE; |
|
414 |
|
|
415 |
/** |
|
416 |
* 入参 |
|
417 |
*/ |
|
418 |
NET_IN_REMOVE_FACE_INFO inRemove = new NET_IN_REMOVE_FACE_INFO(); |
|
419 |
|
|
420 |
// 用户ID |
|
421 |
System.arraycopy(userId.getBytes(), 0, inRemove.szUserID, 0, userId.getBytes().length); |
|
422 |
|
|
423 |
/** |
|
424 |
* 出参 |
|
425 |
*/ |
|
426 |
NET_OUT_REMOVE_FACE_INFO outRemove = new NET_OUT_REMOVE_FACE_INFO(); |
|
427 |
|
|
428 |
inRemove.write(); |
|
429 |
outRemove.write(); |
|
430 |
boolean bRet = LoginModule.netsdk.CLIENT_FaceInfoOpreate(LoginModule.m_hLoginHandle, emType, inRemove.getPointer(), outRemove.getPointer(), 5000); |
|
431 |
inRemove.read(); |
|
432 |
outRemove.read(); |
|
433 |
if(bRet) { |
|
434 |
System.out.println("删除人脸成功!"); |
|
435 |
} else { |
|
436 |
System.err.println("删除人脸失败!" + ToolKits.getErrorCodePrint()); |
|
437 |
} |
|
438 |
|
|
439 |
return bRet; |
|
440 |
} |
|
441 |
|
|
442 |
/** |
|
443 |
* 清除所有人脸 |
|
444 |
*/ |
|
445 |
public static boolean clearFaceInfo() { |
|
446 |
int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_CLEAR; // 清除 |
|
447 |
|
|
448 |
/** |
|
449 |
* 入参 |
|
450 |
*/ |
|
451 |
NET_IN_CLEAR_FACE_INFO stIn = new NET_IN_CLEAR_FACE_INFO(); |
|
452 |
|
|
453 |
/** |
|
454 |
* 出参 |
|
455 |
*/ |
|
456 |
NET_OUT_REMOVE_FACE_INFO stOut = new NET_OUT_REMOVE_FACE_INFO(); |
|
457 |
|
|
458 |
stIn.write(); |
|
459 |
stOut.write(); |
|
460 |
boolean bRet = LoginModule.netsdk.CLIENT_FaceInfoOpreate(LoginModule.m_hLoginHandle, emType, |
|
461 |
stIn.getPointer(), stOut.getPointer(), 5000); |
|
462 |
stIn.read(); |
|
463 |
stOut.read(); |
|
464 |
if(bRet) { |
|
465 |
System.out.println("清空人脸成功!"); |
|
466 |
} else { |
|
467 |
System.err.println("清空人脸失败!" + ToolKits.getErrorCodePrint()); |
|
468 |
} |
|
469 |
|
|
470 |
return bRet; |
|
471 |
} |
|
472 |
|
|
473 |
/** |
|
474 |
* 查询卡信息,获取查询句柄 |
|
475 |
* @param cardNo 卡号,为空,查询所有的 |
|
476 |
* @return |
|
477 |
*/ |
|
478 |
public static boolean findCard(String cardNo) { |
|
479 |
/** |
|
480 |
* 查询条件 |
|
481 |
*/ |
|
482 |
NetSDKLib.FIND_RECORD_ACCESSCTLCARD_CONDITION findCondition = new NetSDKLib.FIND_RECORD_ACCESSCTLCARD_CONDITION(); |
|
483 |
|
|
484 |
if(!cardNo.isEmpty()) { |
|
485 |
// 卡号查询条件是否有效 |
|
486 |
findCondition.abCardNo = 1; |
|
487 |
|
|
488 |
// 卡号 |
|
489 |
System.arraycopy(cardNo.getBytes(), 0, findCondition.szCardNo, 0, cardNo.getBytes().length); |
|
490 |
} |
|
491 |
|
|
492 |
/** |
|
493 |
* CLIENT_FindRecord 接口入参 |
|
494 |
*/ |
|
495 |
NetSDKLib.NET_IN_FIND_RECORD_PARAM stIn = new NetSDKLib.NET_IN_FIND_RECORD_PARAM(); |
|
496 |
stIn.emType = NetSDKLib.EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD; |
|
497 |
if(!cardNo.isEmpty()) { |
|
498 |
stIn.pQueryCondition = findCondition.getPointer(); |
|
499 |
} |
|
500 |
|
|
501 |
/** |
|
502 |
* CLIENT_FindRecord 接口出参 |
|
503 |
*/ |
|
504 |
NetSDKLib.NET_OUT_FIND_RECORD_PARAM stOut = new NetSDKLib.NET_OUT_FIND_RECORD_PARAM(); |
|
505 |
|
|
506 |
findCondition.write(); |
|
507 |
if(!LoginModule.netsdk.CLIENT_FindRecord(LoginModule.m_hLoginHandle, stIn, stOut, 5000)) { |
|
508 |
System.err.println("没查到卡信息!" + ToolKits.getErrorCodePrint()); |
|
509 |
return false; |
|
510 |
} |
|
511 |
findCondition.read(); |
|
512 |
|
|
513 |
m_lFindHandle = stOut.lFindeHandle; |
|
514 |
return true; |
|
515 |
} |
|
516 |
|
|
517 |
/** |
|
518 |
* 查询具体的卡信息 |
|
519 |
* @param nFindCount 每次查询的个数 |
|
520 |
* @return 返回具体的查询信息 |
|
521 |
*/ |
|
522 |
public static NET_RECORDSET_ACCESS_CTL_CARD[] findNextCard(int nFindCount) { |
|
523 |
// 用于申请内存 |
|
524 |
NET_RECORDSET_ACCESS_CTL_CARD[] pstRecord = new NET_RECORDSET_ACCESS_CTL_CARD[nFindCount]; |
|
525 |
for(int i = 0; i < nFindCount; i++) { |
|
526 |
pstRecord[i] = new NET_RECORDSET_ACCESS_CTL_CARD(); |
|
527 |
} |
|
528 |
|
|
529 |
/** |
|
530 |
* CLIENT_FindNextRecord 接口入参 |
|
531 |
*/ |
|
532 |
NET_IN_FIND_NEXT_RECORD_PARAM stNextIn = new NET_IN_FIND_NEXT_RECORD_PARAM(); |
|
533 |
stNextIn.lFindeHandle = m_lFindHandle; |
|
534 |
stNextIn.nFileCount = nFindCount; //想查询的记录条数 |
|
535 |
|
|
536 |
/** |
|
537 |
* CLIENT_FindNextRecord 接口出参 |
|
538 |
*/ |
|
539 |
NET_OUT_FIND_NEXT_RECORD_PARAM stNextOut = new NET_OUT_FIND_NEXT_RECORD_PARAM(); |
|
540 |
stNextOut.nMaxRecordNum = nFindCount; |
|
541 |
stNextOut.pRecordList = new Memory(pstRecord[0].dwSize * nFindCount); // 申请内存 |
|
542 |
stNextOut.pRecordList.clear(pstRecord[0].dwSize * nFindCount); |
|
543 |
|
|
544 |
ToolKits.SetStructArrToPointerData(pstRecord, stNextOut.pRecordList); // 将数组内存拷贝给指针 |
|
545 |
|
|
546 |
if(LoginModule.netsdk.CLIENT_FindNextRecord(stNextIn, stNextOut, 5000)) { |
|
547 |
if(stNextOut.nRetRecordNum == 0) { |
|
548 |
return null; |
|
549 |
} |
|
550 |
|
|
551 |
ToolKits.GetPointerDataToStructArr(stNextOut.pRecordList, pstRecord); // 获取卡信息 |
|
552 |
|
|
553 |
// 获取有用的信息 |
|
554 |
NET_RECORDSET_ACCESS_CTL_CARD[] pstRecordEx = new NET_RECORDSET_ACCESS_CTL_CARD[stNextOut.nRetRecordNum]; |
|
555 |
for(int i = 0; i < stNextOut.nRetRecordNum; i++) { |
|
556 |
pstRecordEx[i] = new NET_RECORDSET_ACCESS_CTL_CARD(); |
|
557 |
pstRecordEx[i] = pstRecord[i]; |
|
558 |
} |
|
559 |
|
|
560 |
return pstRecordEx; |
|
561 |
} |
|
562 |
|
|
563 |
return null; |
|
564 |
} |
|
565 |
|
|
566 |
/** |
|
567 |
* 关闭查询 |
|
568 |
*/ |
|
569 |
public static void findCardClose() { |
|
570 |
if(m_lFindHandle.longValue() != 0) { |
|
571 |
LoginModule.netsdk.CLIENT_FindRecordClose(m_lFindHandle); |
|
572 |
m_lFindHandle.setValue(0); |
|
573 |
} |
|
574 |
} |
|
575 |
} |