提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.demo.module; |
H |
2 |
|
|
3 |
import java.io.UnsupportedEncodingException; |
|
4 |
|
|
5 |
import com.sun.jna.Memory; |
|
6 |
|
|
7 |
import com.iailab.netsdk.lib.NetSDKLib; |
|
8 |
import com.iailab.netsdk.lib.ToolKits; |
|
9 |
import com.iailab.netsdk.lib.NetSDKLib.*; |
|
10 |
|
|
11 |
/** |
|
12 |
* \if ENGLISH_LANG |
|
13 |
* Attendance Interface |
|
14 |
* contains:smart subscribe、CRUD of user&&fingerprint and collection fingerprint |
|
15 |
* \else |
|
16 |
* 考勤机接口实现 |
|
17 |
* 包含: 智能订阅、考勤用户及信息的增删改查、信息采集 |
|
18 |
* \endif |
|
19 |
*/ |
|
20 |
public class AttendanceModule { |
|
21 |
|
|
22 |
public static final int TIME_OUT = 3000; |
|
23 |
public static final int nMaxFingerPrintSize = 2048; |
|
24 |
public static LLong m_hAttachHandle = new LLong(0); |
|
25 |
|
|
26 |
/** |
|
27 |
* 智能订阅 |
|
28 |
* @param callback 智能订阅回调函数 |
|
29 |
*/ |
|
30 |
public static boolean realLoadPicture(fAnalyzerDataCallBack callback) { |
|
31 |
|
|
32 |
int bNeedPicture = 0; // 不需要图片 |
|
33 |
|
|
34 |
m_hAttachHandle = LoginModule.netsdk.CLIENT_RealLoadPictureEx(LoginModule.m_hLoginHandle, -1, |
|
35 |
NetSDKLib.EVENT_IVS_ALL, bNeedPicture, callback, null, null); |
|
36 |
|
|
37 |
if(m_hAttachHandle.longValue() == 0) { |
|
38 |
System.err.printf("CLIENT_RealLoadPictureEx Failed!" + ToolKits.getErrorCodePrint()); |
|
39 |
} |
|
40 |
|
|
41 |
return m_hAttachHandle.longValue() != 0; |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* 停止智能订阅 |
|
46 |
*/ |
|
47 |
public static void stopRealLoadPicture(){ |
|
48 |
if (m_hAttachHandle.longValue() == 0) { |
|
49 |
return; |
|
50 |
} |
|
51 |
|
|
52 |
LoginModule.netsdk.CLIENT_StopLoadPic(m_hAttachHandle); |
|
53 |
m_hAttachHandle.setValue(0); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* 考勤新增加用户 |
|
58 |
* @param userId 用户ID |
|
59 |
* @param userName 用户名 |
|
60 |
* @param cardNo 卡号 |
|
61 |
*/ |
|
62 |
public static boolean addUser(String userId, String userName, String cardNo) { |
|
63 |
|
|
64 |
/* |
|
65 |
* 入参 |
|
66 |
*/ |
|
67 |
NET_IN_ATTENDANCE_ADDUSER stuIn = new NET_IN_ATTENDANCE_ADDUSER(); |
|
68 |
stringToByteArray(userId, stuIn.stuUserInfo.szUserID); |
|
69 |
stringToByteArray(userName, stuIn.stuUserInfo.szUserName); |
|
70 |
stringToByteArray(cardNo, stuIn.stuUserInfo.szCardNo); |
|
71 |
|
|
72 |
/* |
|
73 |
* 出参 |
|
74 |
*/ |
|
75 |
NET_OUT_ATTENDANCE_ADDUSER stuOut = new NET_OUT_ATTENDANCE_ADDUSER(); |
|
76 |
|
|
77 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_AddUser(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
78 |
if (!bRet) { |
|
79 |
System.err.printf("CLIENT_Attendance_AddUser Failed!" + ToolKits.getErrorCodePrint()); |
|
80 |
} |
|
81 |
|
|
82 |
return bRet; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* 考勤删除用户 |
|
87 |
* @param userId 用户ID |
|
88 |
*/ |
|
89 |
public static boolean deleteUser(String userId) { |
|
90 |
|
|
91 |
removeFingerByUserId(userId); // 先去删除信息 |
|
92 |
|
|
93 |
/* |
|
94 |
* 入参 |
|
95 |
*/ |
|
96 |
NET_IN_ATTENDANCE_DELUSER stuIn = new NET_IN_ATTENDANCE_DELUSER(); |
|
97 |
stringToByteArray(userId, stuIn.szUserID); |
|
98 |
|
|
99 |
/* |
|
100 |
* 出参 |
|
101 |
*/ |
|
102 |
NET_OUT_ATTENDANCE_DELUSER stuOut = new NET_OUT_ATTENDANCE_DELUSER(); |
|
103 |
|
|
104 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_DelUser(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
105 |
if (!bRet) { |
|
106 |
System.err.printf("CLIENT_Attendance_DelUser Failed!" + ToolKits.getErrorCodePrint()); |
|
107 |
} |
|
108 |
|
|
109 |
return bRet; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* 考勤修改用户 |
|
114 |
* @param userId 用户ID |
|
115 |
* @param userName 用户名 |
|
116 |
* @param cardNo 卡号 |
|
117 |
*/ |
|
118 |
public static boolean modifyUser(String userId, String userName, String cardNo) { |
|
119 |
|
|
120 |
/* |
|
121 |
* 入参 |
|
122 |
*/ |
|
123 |
NET_IN_ATTENDANCE_ModifyUSER stuIn = new NET_IN_ATTENDANCE_ModifyUSER(); |
|
124 |
stringToByteArray(userId, stuIn.stuUserInfo.szUserID); |
|
125 |
stringToByteArray(userName, stuIn.stuUserInfo.szUserName); |
|
126 |
stringToByteArray(cardNo, stuIn.stuUserInfo.szCardNo); |
|
127 |
|
|
128 |
/* |
|
129 |
* 出参 |
|
130 |
*/ |
|
131 |
NET_OUT_ATTENDANCE_ModifyUSER stuOut = new NET_OUT_ATTENDANCE_ModifyUSER(); |
|
132 |
|
|
133 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_ModifyUser(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
134 |
if (!bRet) { |
|
135 |
System.err.printf("CLIENT_Attendance_ModifyUser Failed!" + ToolKits.getErrorCodePrint()); |
|
136 |
} |
|
137 |
|
|
138 |
return bRet; |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* 考勤机 查找用户 |
|
143 |
* @param nOffset 查询偏移 |
|
144 |
* @param nPagedQueryCount 查询个数 |
|
145 |
* @return UserData[] 用户信息组 |
|
146 |
*/ |
|
147 |
public static UserData[] findUser(int nOffset, int nPagedQueryCount) { |
|
148 |
|
|
149 |
/* |
|
150 |
* 入参 |
|
151 |
*/ |
|
152 |
NET_IN_ATTENDANCE_FINDUSER stuIn = new NET_IN_ATTENDANCE_FINDUSER(); |
|
153 |
stuIn.nOffset = nOffset; |
|
154 |
stuIn.nPagedQueryCount = nPagedQueryCount; |
|
155 |
|
|
156 |
/* |
|
157 |
* 出参 |
|
158 |
*/ |
|
159 |
NET_OUT_ATTENDANCE_FINDUSER stuOut = new NET_OUT_ATTENDANCE_FINDUSER(); |
|
160 |
NET_ATTENDANCE_USERINFO[] userInfo = new NET_ATTENDANCE_USERINFO[nPagedQueryCount]; |
|
161 |
for(int i = 0; i < nPagedQueryCount; i++) { |
|
162 |
userInfo[i] = new NET_ATTENDANCE_USERINFO(); |
|
163 |
} |
|
164 |
stuOut.nMaxUserCount = nPagedQueryCount; |
|
165 |
stuOut.stuUserInfo = new Memory(userInfo[0].size() * stuOut.nMaxUserCount); |
|
166 |
stuOut.stuUserInfo.clear(userInfo[0].size() * stuOut.nMaxUserCount); |
|
167 |
ToolKits.SetStructArrToPointerData(userInfo, stuOut.stuUserInfo); // 将数组内存拷贝到Pointer |
|
168 |
stuOut.nMaxPhotoDataLength = 128; |
|
169 |
stuOut.pbyPhotoData = new Memory(stuOut.nMaxPhotoDataLength); // 申请内存 |
|
170 |
|
|
171 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_FindUser(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
172 |
if (!bRet) { |
|
173 |
System.err.printf("CLIENT_Attendance_FindUser Failed!" + ToolKits.getErrorCodePrint()); |
|
174 |
return null; |
|
175 |
} |
|
176 |
|
|
177 |
ToolKits.GetPointerDataToStructArr(stuOut.stuUserInfo, userInfo); // 将 Pointer 的内容 输出到 数组 |
|
178 |
|
|
179 |
UserData[] userData = new UserData[stuOut.nRetUserCount]; |
|
180 |
for(int i = 0; i < stuOut.nRetUserCount; i++) { |
|
181 |
userData[i] = new UserData(); |
|
182 |
try { |
|
183 |
userData[i].userId = new String(userInfo[i].szUserID, "GBK").trim(); |
|
184 |
userData[i].userName = new String(userInfo[i].szUserName, "GBK").trim(); |
|
185 |
userData[i].cardNo = new String(userInfo[i].szCardNo, "GBK").trim(); |
|
186 |
}catch(Exception e) { // 如果转化失败就采用原始数据 |
|
187 |
userData[i].userId = new String(userInfo[i].szUserID).trim(); |
|
188 |
userData[i].userName = new String(userInfo[i].szUserName).trim(); |
|
189 |
userData[i].cardNo = new String(userInfo[i].szCardNo).trim(); |
|
190 |
} |
|
191 |
|
|
192 |
// getFingerByUserId(userData[i].userId, userData[i]); // 获取信息信息 |
|
193 |
} |
|
194 |
|
|
195 |
UserData.nTotalUser = stuOut.nTotalUser; |
|
196 |
|
|
197 |
return userData; |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* 考勤获取用户信息 |
|
202 |
* @param userId 用户ID |
|
203 |
* @return UserData 用户信息 |
|
204 |
*/ |
|
205 |
public static UserData getUser(String userId) { |
|
206 |
|
|
207 |
/* |
|
208 |
* 入参 |
|
209 |
*/ |
|
210 |
NET_IN_ATTENDANCE_GetUSER stuIn = new NET_IN_ATTENDANCE_GetUSER(); |
|
211 |
stringToByteArray(userId, stuIn.szUserID); |
|
212 |
|
|
213 |
/* |
|
214 |
* 出参 |
|
215 |
*/ |
|
216 |
NET_OUT_ATTENDANCE_GetUSER stuOut = new NET_OUT_ATTENDANCE_GetUSER(); |
|
217 |
stuOut.nMaxLength = 128; |
|
218 |
stuOut.pbyPhotoData = new Memory(stuOut.nMaxLength); // 申请内存 |
|
219 |
stuOut.pbyPhotoData.clear(stuOut.nMaxLength); |
|
220 |
|
|
221 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_GetUser(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
222 |
if (!bRet) { |
|
223 |
System.err.printf("CLIENT_Attendance_GetUser Failed!" + ToolKits.getErrorCodePrint()); |
|
224 |
return null; |
|
225 |
} |
|
226 |
|
|
227 |
UserData userData = new UserData(); |
|
228 |
try { |
|
229 |
userData.userId = new String(stuOut.stuUserInfo.szUserID, "GBK").trim(); |
|
230 |
userData.userName = new String(stuOut.stuUserInfo.szUserName, "GBK").trim(); |
|
231 |
userData.cardNo = new String(stuOut.stuUserInfo.szCardNo, "GBK").trim(); |
|
232 |
}catch(Exception e) { // 如果转化失败就采用原始数据 |
|
233 |
userData.userId = new String(stuOut.stuUserInfo.szUserID).trim(); |
|
234 |
userData.userName = new String(stuOut.stuUserInfo.szUserName).trim(); |
|
235 |
userData.cardNo = new String(stuOut.stuUserInfo.szCardNo).trim(); |
|
236 |
} |
|
237 |
|
|
238 |
// getFingerByUserId(userId, userData); // 获取信息信息 |
|
239 |
|
|
240 |
return userData; |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 |
* 考勤机 通过用户ID插入信息数据 |
|
245 |
* @param userId 用户ID |
|
246 |
* @param szFingerPrintInfo 信息信息 |
|
247 |
*/ |
|
248 |
public static boolean insertFingerByUserId(String userId, byte[] szFingerPrintInfo) { |
|
249 |
|
|
250 |
/* |
|
251 |
* 入参 |
|
252 |
*/ |
|
253 |
NET_IN_FINGERPRINT_INSERT_BY_USERID stuIn = new NET_IN_FINGERPRINT_INSERT_BY_USERID(); |
|
254 |
stringToByteArray(userId, stuIn.szUserID); |
|
255 |
stuIn.nPacketCount = 1; |
|
256 |
stuIn.nSinglePacketLen = szFingerPrintInfo.length; |
|
257 |
stuIn.szFingerPrintInfo = new Memory(stuIn.nPacketCount * stuIn.nSinglePacketLen); // 申请内存 |
|
258 |
stuIn.szFingerPrintInfo.clear(stuIn.nPacketCount * stuIn.nSinglePacketLen); |
|
259 |
stuIn.szFingerPrintInfo.write(0, szFingerPrintInfo, 0, szFingerPrintInfo.length); |
|
260 |
|
|
261 |
/* |
|
262 |
* 出参 |
|
263 |
*/ |
|
264 |
NET_OUT_FINGERPRINT_INSERT_BY_USERID stuOut = new NET_OUT_FINGERPRINT_INSERT_BY_USERID(); |
|
265 |
|
|
266 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_InsertFingerByUserID(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
267 |
if (!bRet) { |
|
268 |
System.err.printf("CLIENT_Attendance_InsertFingerByUserID Failed!" + ToolKits.getErrorCodePrint()); |
|
269 |
} |
|
270 |
|
|
271 |
return bRet; |
|
272 |
} |
|
273 |
|
|
274 |
/** |
|
275 |
* 考勤机 删除单个用户下所有信息数据 |
|
276 |
* @param userId 用户ID |
|
277 |
*/ |
|
278 |
public static boolean removeFingerByUserId(String userId) { |
|
279 |
|
|
280 |
/* |
|
281 |
* 入参 |
|
282 |
*/ |
|
283 |
NET_CTRL_IN_FINGERPRINT_REMOVE_BY_USERID stuIn = new NET_CTRL_IN_FINGERPRINT_REMOVE_BY_USERID(); |
|
284 |
stringToByteArray(userId, stuIn.szUserID); |
|
285 |
|
|
286 |
/* |
|
287 |
* 出参 |
|
288 |
*/ |
|
289 |
NET_CTRL_OUT_FINGERPRINT_REMOVE_BY_USERID stuOut = new NET_CTRL_OUT_FINGERPRINT_REMOVE_BY_USERID(); |
|
290 |
|
|
291 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_RemoveFingerByUserID(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
292 |
if (!bRet) { |
|
293 |
System.err.printf("CLIENT_Attendance_RemoveFingerByUserID Failed!" + ToolKits.getErrorCodePrint()); |
|
294 |
} |
|
295 |
|
|
296 |
return bRet; |
|
297 |
} |
|
298 |
|
|
299 |
/** |
|
300 |
* 考勤机 通过信息ID删除信息数据 |
|
301 |
* @param nFingerPrintID 信息ID |
|
302 |
*/ |
|
303 |
public static boolean removeFingerRecord(int nFingerPrintID) { |
|
304 |
|
|
305 |
/* |
|
306 |
* 入参 |
|
307 |
*/ |
|
308 |
NET_CTRL_IN_FINGERPRINT_REMOVE stuIn = new NET_CTRL_IN_FINGERPRINT_REMOVE(); |
|
309 |
stuIn.nFingerPrintID = nFingerPrintID; |
|
310 |
|
|
311 |
/* |
|
312 |
* 出参 |
|
313 |
*/ |
|
314 |
NET_CTRL_OUT_FINGERPRINT_REMOVE stuOut = new NET_CTRL_OUT_FINGERPRINT_REMOVE(); |
|
315 |
|
|
316 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_RemoveFingerRecord(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
317 |
if (!bRet) { |
|
318 |
System.err.printf("CLIENT_Attendance_RemoveFingerRecord Failed!" + ToolKits.getErrorCodePrint()); |
|
319 |
} |
|
320 |
|
|
321 |
return bRet; |
|
322 |
} |
|
323 |
|
|
324 |
/** |
|
325 |
* 考勤机 通过信息ID获取信息数据 |
|
326 |
* @param nFingerPrintID 信息ID |
|
327 |
* @return userData 用户数据 |
|
328 |
*/ |
|
329 |
public static UserData getFingerRecord(int nFingerPrintID) { |
|
330 |
|
|
331 |
/* |
|
332 |
* 入参 |
|
333 |
*/ |
|
334 |
NET_CTRL_IN_FINGERPRINT_GET stuIn = new NET_CTRL_IN_FINGERPRINT_GET(); |
|
335 |
stuIn.nFingerPrintID = nFingerPrintID; |
|
336 |
|
|
337 |
/* |
|
338 |
* 出参 |
|
339 |
*/ |
|
340 |
NET_CTRL_OUT_FINGERPRINT_GET stuOut = new NET_CTRL_OUT_FINGERPRINT_GET(); |
|
341 |
stuOut.nMaxFingerDataLength = nMaxFingerPrintSize; |
|
342 |
stuOut.szFingerPrintInfo = new Memory(stuOut.nMaxFingerDataLength); // 申请内存 |
|
343 |
stuOut.szFingerPrintInfo.clear(stuOut.nMaxFingerDataLength); |
|
344 |
|
|
345 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_GetFingerRecord(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
346 |
if (!bRet) { |
|
347 |
System.err.printf("CLIENT_Attendance_GetFingerRecord Failed!" + ToolKits.getErrorCodePrint()); |
|
348 |
return null; |
|
349 |
} |
|
350 |
|
|
351 |
if (stuOut.nRetLength == 0) { |
|
352 |
System.err.println("GetFingerRecord Failed nRetLength == 0!"); |
|
353 |
} |
|
354 |
|
|
355 |
UserData userData = new UserData(); |
|
356 |
userData.userId = new String(stuOut.szUserID).trim(); |
|
357 |
userData.nFingerPrintIDs = new int[1]; |
|
358 |
userData.nFingerPrintIDs[0] = nFingerPrintID; |
|
359 |
userData.szFingerPrintInfo = new byte[1][stuOut.nRetLength]; |
|
360 |
stuOut.szFingerPrintInfo.read(0, userData.szFingerPrintInfo[0], 0, stuOut.nRetLength); |
|
361 |
|
|
362 |
return userData; |
|
363 |
} |
|
364 |
|
|
365 |
/** |
|
366 |
* 考勤机 通过用户ID查找该用户下的所有信息数据 |
|
367 |
* @param userId 用户ID |
|
368 |
* @param userData 用户数据 |
|
369 |
*/ |
|
370 |
public static boolean getFingerByUserId(String userId, UserData userData) { |
|
371 |
|
|
372 |
/* |
|
373 |
* 入参 |
|
374 |
*/ |
|
375 |
NET_IN_FINGERPRINT_GETBYUSER stuIn = new NET_IN_FINGERPRINT_GETBYUSER(); |
|
376 |
stringToByteArray(userId, stuIn.szUserID); |
|
377 |
|
|
378 |
/* |
|
379 |
* 出参 |
|
380 |
*/ |
|
381 |
NET_OUT_FINGERPRINT_GETBYUSER stuOut = new NET_OUT_FINGERPRINT_GETBYUSER(); |
|
382 |
stuOut.nMaxFingerDataLength = NetSDKLib.NET_MAX_FINGER_PRINT * nMaxFingerPrintSize; |
|
383 |
stuOut.pbyFingerData = new Memory(stuOut.nMaxFingerDataLength); // 申请内存 |
|
384 |
stuOut.pbyFingerData.clear(stuOut.nMaxFingerDataLength); |
|
385 |
|
|
386 |
boolean bRet = LoginModule.netsdk.CLIENT_Attendance_GetFingerByUserID(LoginModule.m_hLoginHandle, stuIn, stuOut, TIME_OUT); |
|
387 |
if (!bRet) { |
|
388 |
System.err.printf("CLIENT_Attendance_GetFingerByUserID Failed!" + ToolKits.getErrorCodePrint()); |
|
389 |
}else { |
|
390 |
userData.nFingerPrintIDs = new int[stuOut.nRetFingerPrintCount]; |
|
391 |
userData.szFingerPrintInfo = new byte[stuOut.nRetFingerPrintCount][stuOut.nSinglePacketLength]; |
|
392 |
int offset = 0; |
|
393 |
for (int i = 0; i < stuOut.nRetFingerPrintCount; ++i) { |
|
394 |
userData.nFingerPrintIDs[i] = stuOut.nFingerPrintIDs[i]; |
|
395 |
stuOut.pbyFingerData.read(offset, userData.szFingerPrintInfo[i], 0, stuOut.nSinglePacketLength); |
|
396 |
offset += stuOut.nSinglePacketLength; |
|
397 |
} |
|
398 |
} |
|
399 |
|
|
400 |
return bRet; |
|
401 |
} |
|
402 |
|
|
403 |
/** |
|
404 |
* 信息采集 |
|
405 |
* @param nChannelID 门禁序号 |
|
406 |
* @param szReaderID 读卡器ID |
|
407 |
*/ |
|
408 |
public static boolean collectionFinger(int nChannelID, String szReaderID) { |
|
409 |
/* |
|
410 |
* 入参 |
|
411 |
*/ |
|
412 |
NET_CTRL_CAPTURE_FINGER_PRINT stuCollection = new NET_CTRL_CAPTURE_FINGER_PRINT(); |
|
413 |
stuCollection.nChannelID = nChannelID; |
|
414 |
stringToByteArray(szReaderID, stuCollection.szReaderID); |
|
415 |
|
|
416 |
stuCollection.write(); |
|
417 |
boolean bRet = LoginModule.netsdk.CLIENT_ControlDeviceEx(LoginModule.m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_CTRL_CAPTURE_FINGER_PRINT, stuCollection.getPointer(), null, 5000); |
|
418 |
if (!bRet) { |
|
419 |
System.err.printf("CLIENT_ControlDeviceEx CAPTURE_FINGER_PRINT Failed!" + ToolKits.getErrorCodePrint()); |
|
420 |
} |
|
421 |
return bRet; |
|
422 |
} |
|
423 |
|
|
424 |
/** |
|
425 |
* 字符串转字符数组 |
|
426 |
* @param src 源字符串 |
|
427 |
* @param dst 目标字符数组 |
|
428 |
*/ |
|
429 |
public static void stringToByteArray(String src, byte[] dst) { |
|
430 |
|
|
431 |
if (src == null || src.isEmpty()) { |
|
432 |
return; |
|
433 |
} |
|
434 |
|
|
435 |
for(int i = 0; i < dst.length; i++) { |
|
436 |
dst[i] = 0; |
|
437 |
} |
|
438 |
|
|
439 |
byte []szSrc; |
|
440 |
|
|
441 |
try { |
|
442 |
szSrc = src.getBytes("GBK"); |
|
443 |
} catch (UnsupportedEncodingException e) { |
|
444 |
szSrc = src.getBytes(); |
|
445 |
} |
|
446 |
|
|
447 |
if (szSrc != null) { |
|
448 |
int len = szSrc.length >= dst.length ? dst.length-1:szSrc.length; |
|
449 |
System.arraycopy(szSrc, 0, dst, 0, len); |
|
450 |
} |
|
451 |
} |
|
452 |
|
|
453 |
/** |
|
454 |
* 用户信息 |
|
455 |
* */ |
|
456 |
public static class UserData { |
|
457 |
public static int nTotalUser; // 用户总数 |
|
458 |
|
|
459 |
public String userId; // 用户ID |
|
460 |
public String userName; // 用户名 |
|
461 |
public String cardNo; // 卡号 |
|
462 |
public int[] nFingerPrintIDs; // 信息ID数组 |
|
463 |
public byte[][] szFingerPrintInfo; // 信息数据数组 |
|
464 |
} |
|
465 |
|
|
466 |
/** |
|
467 |
* 门禁事件信息 |
|
468 |
* */ |
|
469 |
public static class AccessEventInfo { |
|
470 |
public String userId; // 用户ID |
|
471 |
public String cardNo; // 卡号 |
|
472 |
public String eventTime; // 事件发生时间 |
|
473 |
public int openDoorMethod; // 开门方式 |
|
474 |
} |
|
475 |
|
|
476 |
/** |
|
477 |
* 操作类型 |
|
478 |
* */ |
|
479 |
public enum OPERATE_TYPE { |
|
480 |
UNKNOWN, // 未知 |
|
481 |
SEARCH_USER, // 搜索用户(第一页) |
|
482 |
PRE_SEARCH_USER, // 搜索用户(上一页) |
|
483 |
NEXT_SEARCH_USER, // 搜索用户(下一页) |
|
484 |
SEARCH_USER_BY_USERID, // 通过用户ID搜索用户 |
|
485 |
ADD_USER, // 添加用户 |
|
486 |
DELETE_USER, // 删除用户 |
|
487 |
MODIFIY_USER, // 修改用户 |
|
488 |
FINGERPRINT_OPEARTE_BY_USERID, // 通过用户ID操作信息 |
|
489 |
FINGERPRINT_OPEARTE_BY_ID, // 通过信息ID操作信息 |
|
490 |
SEARCH_FINGERPRINT_BY_USERID, // 通过用户ID搜索信息 |
|
491 |
SEARCH_FINGERPRINT_BY_ID, // 通过信息ID搜索信息 |
|
492 |
ADD_FINGERPRINT, // 添加信息 |
|
493 |
DELETE_FINGERPRINT_BY_USERID, // 通过用户ID删除信息 |
|
494 |
DELETE_FINGERPRINT_BY_ID // 通过信息ID删除信息 |
|
495 |
}; |
|
496 |
} |
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|