Commit fc5b7f69c60e50d0202575d34f5c0076a53c74a9
Exists in
master
本地合并远程的优化
Showing
4 changed files
with
294 additions
and
176 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
| 1 | 1 | package com.example.dahua; |
| 2 | 2 | |
| 3 | -import com.example.dahua.bean.CardBean; | |
| 4 | -import com.example.dahua.bean.DeviceInfoBean; | |
| 5 | -import com.example.dahua.bean.TeacherBean; | |
| 6 | -import com.example.dahua.bean.UserInfoBean; | |
| 3 | +import com.example.dahua.bean.*; | |
| 4 | +import com.example.dahua.dao.SearchDao; | |
| 7 | 5 | import com.example.dahua.dao.UserDao; |
| 8 | 6 | import com.example.dahua.lib.NetSDKLib; |
| 9 | 7 | import com.example.dahua.lib.ToolKits; |
| 10 | 8 | import com.example.dahua.lib.Utils; |
| 11 | 9 | import com.example.dahua.module.AutoRegisterModule; |
| 10 | +import com.example.dahua.module.FaceRecognitionModule; | |
| 12 | 11 | import com.example.dahua.module.GateModule; |
| 13 | 12 | import com.example.dahua.module.LoginModule; |
| 14 | 13 | import com.example.dahua.service.AttendanceService; |
| 14 | +import com.example.dahua.utils.DateUtils; | |
| 15 | +import com.example.dahua.utils.FileUtils; | |
| 15 | 16 | import com.example.dahua.xiananDao.SendRecordDao; |
| 16 | 17 | import com.sun.jna.Pointer; |
| 18 | +import lombok.extern.slf4j.Slf4j; | |
| 17 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | 20 | import org.springframework.boot.ApplicationArguments; |
| 19 | 21 | import org.springframework.boot.ApplicationRunner; |
| ... | ... | @@ -31,6 +33,7 @@ import java.util.*; |
| 31 | 33 | import java.util.List; |
| 32 | 34 | |
| 33 | 35 | @Component |
| 36 | +@Slf4j | |
| 34 | 37 | public class MyTask implements ApplicationRunner { |
| 35 | 38 | |
| 36 | 39 | // 主动注册监听回调 |
| ... | ... | @@ -58,6 +61,9 @@ public class MyTask implements ApplicationRunner { |
| 58 | 61 | SendRecordDao sendRecordDao; |
| 59 | 62 | |
| 60 | 63 | @Autowired |
| 64 | + SearchDao searchDao; | |
| 65 | + | |
| 66 | + @Autowired | |
| 61 | 67 | UserDao userDao; |
| 62 | 68 | |
| 63 | 69 | public boolean isHasNewDevice = false;//判断是否有新设备上线 |
| ... | ... | @@ -65,10 +71,10 @@ public class MyTask implements ApplicationRunner { |
| 65 | 71 | @Override |
| 66 | 72 | public void run(ApplicationArguments args) throws Exception { |
| 67 | 73 | // 121.40.109.21 |
| 68 | - | |
| 69 | - LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化 | |
| 70 | - | |
| 71 | - autoRegister();//自注册 | |
| 74 | + // 打开工程,初始化 | |
| 75 | + LoginModule.init(disConnect, haveReConnect); | |
| 76 | + //自注册 | |
| 77 | + autoRegister(); | |
| 72 | 78 | |
| 73 | 79 | // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess()); |
| 74 | 80 | } |
| ... | ... | @@ -228,7 +234,7 @@ public class MyTask implements ApplicationRunner { |
| 228 | 234 | break; |
| 229 | 235 | } |
| 230 | 236 | |
| 231 | - return 0; | |
| 237 | + return 1; | |
| 232 | 238 | } |
| 233 | 239 | } |
| 234 | 240 | |
| ... | ... | @@ -238,7 +244,7 @@ public class MyTask implements ApplicationRunner { |
| 238 | 244 | for (DeviceInfoBean dev : |
| 239 | 245 | deviceInfoBeans) { |
| 240 | 246 | if (lLongMap.get(dev.getDevcieId()).intValue() > 0) { |
| 241 | - NetSDKLib.LLong lLong = GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId())); | |
| 247 | + NetSDKLib.LLong lLong = GateModule.realLoadPic2(0, analyzerCallback, lLongMap.get(dev.getDevcieId()),dev.getDevcieId()); | |
| 242 | 248 | // System.out.println("监听成功:"+dev.getDevcieId()); |
| 243 | 249 | // if (lLong.intValue() != -1) { |
| 244 | 250 | // //deviceInfoBeans.remove(dev); |
| ... | ... | @@ -273,32 +279,25 @@ public class MyTask implements ApplicationRunner { |
| 273 | 279 | path.mkdir(); |
| 274 | 280 | } |
| 275 | 281 | |
| 282 | + //设备ID获取 | |
| 283 | + NetSDKLib.NET_DEVICEINFO_Ex deviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); | |
| 284 | + ToolKits.GetPointerData(dwUser, deviceInfo); | |
| 285 | + | |
| 286 | + String szSn = new String(deviceInfo.sSerialNumber).trim(); | |
| 287 | + | |
| 276 | 288 | ///< 门禁事件 |
| 277 | 289 | if (dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { |
| 278 | 290 | NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO msg = new NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO(); |
| 279 | 291 | ToolKits.GetPointerData(pAlarmInfo, msg); |
| 292 | + //卡号 | |
| 293 | + String card = new String(msg.szCardNo).trim(); | |
| 280 | 294 | |
| 281 | -// String b =new String(msg.szSN); | |
| 282 | -// System.out.println("readid: "+new String(msg.szReaderID)); | |
| 283 | -// System.out.println("imageurl: "+new String(msg.szSnapURL)); | |
| 284 | -// NetSDKLib.ALARM_ACCESS_CTL_STATUS_INFO msg1 = new NetSDKLib.ALARM_ACCESS_CTL_STATUS_INFO(); | |
| 285 | -// ToolKits.GetPointerData(pBuffer, msg1); | |
| 286 | -// try{ | |
| 287 | -// String a =new String(msg1.szSerialNumber,"utf-8").trim(); | |
| 288 | -// System.out.println("无线设备序列号: "+ a); | |
| 289 | -// } catch (UnsupportedEncodingException e) { | |
| 290 | -// e.printStackTrace(); | |
| 291 | -// } | |
| 292 | -// System.out.println("sda:" + new String(msg.szCardNo) + " 抓拍照片存储地址:"); | |
| 293 | -// NetSDKLib.ALARM_ACCESS_CTL_EVENT_INFO msg2 = new NetSDKLib.ALARM_ACCESS_CTL_EVENT_INFO(); | |
| 294 | -// ToolKits.GetPointerData(pBuffer, msg2); | |
| 295 | -// String c =new String(msg2.szSN); | |
| 296 | -// System.out.println("智能锁序列号 " +c); | |
| 295 | + System.out.println("sda:" + card + " 抓拍照片存储地址:"); | |
| 297 | 296 | |
| 298 | 297 | try { |
| 299 | - String card = new String(msg.szCardNo).trim(); | |
| 300 | 298 | if (!StringUtils.isEmpty(card)) { |
| 301 | 299 | // 保存图片,获取图片缓存 |
| 300 | + // 图片服务器路径 | |
| 302 | 301 | String snapPicPath = path + "\\" + System.currentTimeMillis() + ".png"; // 保存图片地址 |
| 303 | 302 | byte[] buffer = pBuffer.getByteArray(0, dwBufSize); |
| 304 | 303 | ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer); |
| ... | ... | @@ -306,19 +305,32 @@ public class MyTask implements ApplicationRunner { |
| 306 | 305 | if (gateBufferedImage != null) { |
| 307 | 306 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); |
| 308 | 307 | } |
| 308 | + //卡号取反(大写) | |
| 309 | 309 | card = cardNo(card); |
| 310 | - | |
| 311 | - CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 | |
| 310 | + //根据卡号获取卡身份信息 | |
| 311 | + CardBean cardBean = userDao.getCards(card); | |
| 312 | 312 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
| 313 | 313 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); |
| 314 | 314 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); |
| 315 | - if (null != cardBean && cardBean.getType() == 0) {//老师 | |
| 315 | + if (null != cardBean && cardBean.getType() == 0) { | |
| 316 | + //老师人脸信息,保存人脸记录表 | |
| 316 | 317 | TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); |
| 317 | - sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card,""); | |
| 318 | - } else if (null != cardBean && cardBean.getType() == 2) {//学生 | |
| 318 | + sendRecordDao.addFaceRecoder(szSn, teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card,""); | |
| 319 | + } else if (null != cardBean && cardBean.getType() == 2) { | |
| 320 | + //学生人脸信息,保存人脸记录表 | |
| 319 | 321 | UserInfoBean userInfoBean = userDao.getStudentWithid(cardBean.getUser_id()); |
| 320 | - sendRecordDao.addFaceRecoder("", userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card,""); | |
| 322 | + sendRecordDao.addFaceRecoder(szSn, userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card,""); | |
| 321 | 323 | } |
| 324 | + | |
| 325 | + // TODO 考勤记录 | |
| 326 | + //刷卡结果,1表示成功, 0表示失败 | |
| 327 | + int status = msg.bStatus; | |
| 328 | + //门禁事件类型:1进2出 | |
| 329 | + int eventType = msg.emEventType; | |
| 330 | + //刷卡时间 | |
| 331 | + String eventTime = msg.UTC.toStringTime(); | |
| 332 | + //保存考勤记录 | |
| 333 | + kaoQinRecord(status,eventType,card,szSn,eventTime,snapPicPath); | |
| 322 | 334 | } |
| 323 | 335 | |
| 324 | 336 | } catch (IOException e2) { |
| ... | ... | @@ -338,6 +350,7 @@ public class MyTask implements ApplicationRunner { |
| 338 | 350 | } |
| 339 | 351 | } |
| 340 | 352 | |
| 353 | + | |
| 341 | 354 | /** |
| 342 | 355 | * 卡号两两取反 |
| 343 | 356 | * |
| ... | ... | @@ -361,4 +374,85 @@ public class MyTask implements ApplicationRunner { |
| 361 | 374 | |
| 362 | 375 | } |
| 363 | 376 | |
| 377 | + /** | |
| 378 | + * 大华设备考勤记录 | |
| 379 | + * @param status | |
| 380 | + * @param eventType | |
| 381 | + * @param cardNo | |
| 382 | + * @param deviceId | |
| 383 | + * @param eventTime | |
| 384 | + * @param imageUrl | |
| 385 | + */ | |
| 386 | + public void kaoQinRecord(int status,int eventType,String cardNo,String deviceId,String eventTime,String imageUrl) { | |
| 387 | + if (status == 1) { | |
| 388 | + //有效刷卡调考勤存储过程 | |
| 389 | + CheckIn checkIn = new CheckIn(); | |
| 390 | + checkIn.setDeviceId(deviceId); | |
| 391 | + checkIn.setCardNo(cardNo); | |
| 392 | + checkIn.setFunNo(8); | |
| 393 | + checkIn.setFlag(eventType == 2 ? 1 : 0); | |
| 394 | + checkIn.setCheckTime(eventTime); | |
| 395 | + searchDao.checkIn(checkIn); | |
| 396 | + if (checkIn.getIsSuccess() == 1) { | |
| 397 | + //考勤成功 | |
| 398 | + String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:" + (eventType == 1 ? "进门" : "出门") + "______" + eventTime; | |
| 399 | + //记录学生考勤签到记录 | |
| 400 | + FileUtils.getInstance().writeLogs(content, FileUtils.qiandaoSuccess); | |
| 401 | + } else { | |
| 402 | + //考勤失败 | |
| 403 | + String content = "考勤失败!,设备:" + deviceId + "卡号:" + cardNo + "---" + checkIn.getOut(); | |
| 404 | + //记录学生考勤签到记录 | |
| 405 | + FileUtils.getInstance().writeLogs(content, FileUtils.qiandaoErr); | |
| 406 | + } | |
| 407 | + } else { | |
| 408 | + //判断是否请假 | |
| 409 | + String studentNum = searchDao.checkLeave(cardNo); | |
| 410 | + if (org.apache.commons.lang.StringUtils.isNotBlank(studentNum)) { | |
| 411 | + //短信信息 | |
| 412 | + Message mobileMessage = searchDao.selectByParentMobile(cardNo); | |
| 413 | + if (mobileMessage.getSchoolId() == 4) { | |
| 414 | + //才发送短信 | |
| 415 | + ShortMsg shortMsg = new ShortMsg(); | |
| 416 | + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
| 417 | + shortMsg.setTableName("smsNew" + tableSuffix); | |
| 418 | + shortMsg.setSchoolId(mobileMessage.getSchoolId()); | |
| 419 | + shortMsg.setMobile(mobileMessage.getParentMobile()); | |
| 420 | + if (eventType == 2) { | |
| 421 | + //出门 | |
| 422 | + shortMsg.setMsg(mobileMessage.getName() + "家长您好,你的孩子于" + DateUtils.date2String(new Date(), DateUtils.format2) + "请假后出校,请知晓;"); | |
| 423 | + } else { | |
| 424 | + shortMsg.setMsg(mobileMessage.getName() + "家长您好,你的孩子于" + DateUtils.date2String(new Date(), DateUtils.format2) + "请假后进校,请知晓;"); | |
| 425 | + } | |
| 426 | + searchDao.insertMessage(shortMsg.getTableName(),shortMsg.getSchoolId()+"",shortMsg.getMobile(),shortMsg.getMsg()); | |
| 427 | + } | |
| 428 | + } else { | |
| 429 | + //若即不成功,也不是请假,则按刷卡异常处理 | |
| 430 | + User user = searchDao.selectUserByCardNum(cardNo).get(0); | |
| 431 | + if(user ==null ){ | |
| 432 | + System.out.println("卡号"+cardNo+"没找到对应学生或老师"); | |
| 433 | + } | |
| 434 | + int deviceType; | |
| 435 | + if (deviceId.startsWith("ytj")){ | |
| 436 | + deviceType = 29; | |
| 437 | + }else { | |
| 438 | + deviceType = 22; | |
| 439 | + } | |
| 440 | + //失败记录 | |
| 441 | + SendRecordBean sendRecordBean = new SendRecordBean(); | |
| 442 | + sendRecordBean.setSchoolId(user.getSchoolId()); | |
| 443 | + sendRecordBean.setSchoolName(userDao.getSchoolName(String.valueOf(user.getSchoolId()))); | |
| 444 | + sendRecordBean.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | |
| 445 | + sendRecordBean.setUserType(2); | |
| 446 | + sendRecordBean.setNum(cardNo); | |
| 447 | + sendRecordBean.setName(user.getName()); | |
| 448 | + sendRecordBean.setImgPath(imageUrl); | |
| 449 | + sendRecordBean.setCustomerid(String.valueOf(user.getStudentId())); | |
| 450 | + sendRecordBean.setFailType(8); | |
| 451 | + sendRecordBean.setFailContent("人脸认证失败"); | |
| 452 | + sendRecordBean.setDeviceID(deviceId); | |
| 453 | + sendRecordDao.addFaceFail(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), | |
| 454 | + sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), deviceType); | |
| 455 | + } | |
| 456 | + } | |
| 457 | + } | |
| 364 | 458 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java
| 1 | 1 | package com.example.dahua.async; |
| 2 | 2 | |
| 3 | 3 | //import com.example.dahua.Gate.Gate; |
| 4 | + | |
| 5 | +import com.alibaba.fastjson.JSON; | |
| 4 | 6 | import com.example.dahua.MyTask; |
| 5 | -import com.example.dahua.bean.*; | |
| 7 | +import com.example.dahua.bean.AttendanceBean; | |
| 8 | +import com.example.dahua.bean.SendRecordBean; | |
| 9 | +import com.example.dahua.bean.TeacherBean; | |
| 10 | +import com.example.dahua.bean.UserInfoBean; | |
| 6 | 11 | import com.example.dahua.common.Res; |
| 7 | 12 | import com.example.dahua.dao.UserDao; |
| 8 | 13 | import com.example.dahua.lib.CompressPic; |
| ... | ... | @@ -14,15 +19,11 @@ import com.example.dahua.utils.FileUtils; |
| 14 | 19 | import com.example.dahua.utils.HttpUtils; |
| 15 | 20 | import com.example.dahua.xiananDao.SendRecordDao; |
| 16 | 21 | import com.sun.jna.Memory; |
| 22 | +import lombok.extern.slf4j.Slf4j; | |
| 17 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | -import org.springframework.http.HttpEntity; | |
| 19 | -import org.springframework.http.HttpHeaders; | |
| 20 | -import org.springframework.http.MediaType; | |
| 21 | 24 | import org.springframework.http.ResponseEntity; |
| 22 | 25 | import org.springframework.scheduling.annotation.Async; |
| 23 | 26 | import org.springframework.stereotype.Component; |
| 24 | -import org.springframework.util.LinkedMultiValueMap; | |
| 25 | -import org.springframework.util.MultiValueMap; | |
| 26 | 27 | import org.springframework.util.StringUtils; |
| 27 | 28 | import org.springframework.web.client.RestTemplate; |
| 28 | 29 | |
| ... | ... | @@ -34,6 +35,7 @@ import java.util.*; |
| 34 | 35 | * 下发卡号的异步操作 |
| 35 | 36 | */ |
| 36 | 37 | @Component |
| 38 | +@Slf4j | |
| 37 | 39 | public class SendUserInfoTask { |
| 38 | 40 | |
| 39 | 41 | @Autowired |
| ... | ... | @@ -281,6 +283,16 @@ public class SendUserInfoTask { |
| 281 | 283 | } |
| 282 | 284 | } |
| 283 | 285 | |
| 286 | + /** | |
| 287 | + * 下发人脸/卡信息 | |
| 288 | + * @param attendanceBean | |
| 289 | + * @param user_id | |
| 290 | + * @param student_num | |
| 291 | + * @param name | |
| 292 | + * @param memory | |
| 293 | + * @param sendRecordBean | |
| 294 | + * @param userType | |
| 295 | + */ | |
| 284 | 296 | private synchronized void pushCardAndFace(AttendanceBean attendanceBean, String user_id, String student_num, String name, Memory memory, SendRecordBean sendRecordBean,String userType) { |
| 285 | 297 | try{ |
| 286 | 298 | sendRecordBean.setDeviceID(attendanceBean.getClint_id()); |
| ... | ... | @@ -291,14 +303,17 @@ public class SendUserInfoTask { |
| 291 | 303 | Calendar calendar = Calendar.getInstance(); |
| 292 | 304 | calendar.add(Calendar.YEAR, 4); |
| 293 | 305 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); |
| 294 | - int bCardFlags = -1;//记录集编号,存在于设备的 | |
| 306 | + //记录集编号,存在于设备的,默认为 -1, 其他值为存在下发记录 | |
| 307 | + int bCardFlags = -1; | |
| 308 | + //从下发记录表:SZ_Student_RecoderNo 获取记录集编号 | |
| 295 | 309 | bCardFlags = userDao.getRecordNo(user_id, attendanceBean.getClint_id()) == null ? -1 : Integer.parseInt(userDao.getRecordNo(user_id, attendanceBean.getClint_id())); |
| 296 | 310 | |
| 297 | 311 | NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(attendanceBean.getClint_id()); |
| 298 | -// System.out.println("loginHandleLong:" + loginHandleLong + MyTask.lLongMap.toString() + " 设备ID:" + attendanceBean.getClint_id()); | |
| 299 | -// System.out.println("loginHandleLong:" +loginHandleLong); | |
| 312 | + log.info("设备ID: {},设备登录句柄: {}",loginHandleLong,attendanceBean.getClint_id() ); | |
| 313 | + | |
| 314 | + //若设备不在线时,且人脸下发失败表中存在记录,则执行修改下发失败状态为:设备不在线 | |
| 300 | 315 | if (loginHandleLong == null) { |
| 301 | - System.out.println("设备不在线:" + attendanceBean.getClint_id()); | |
| 316 | + log.info("设备不在线, 设备ID: {} ",attendanceBean.getClint_id() ); | |
| 302 | 317 | FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); |
| 303 | 318 | String deviceId = sendRecordDao.getFailIsExit(attendanceBean.getClint_id(), attendanceBean.getSchool_id()); |
| 304 | 319 | sendRecordBean.setFailType(2); |
| ... | ... | @@ -307,76 +322,50 @@ public class SendUserInfoTask { |
| 307 | 322 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 2);//更新下发失败状态 |
| 308 | 323 | addFailDace(sendRecordBean); |
| 309 | 324 | } |
| 310 | - | |
| 311 | 325 | } else { |
| 326 | + //人脸下发成功标识:false:失败 true:成功 | |
| 312 | 327 | boolean bFaceFalgs = false; |
| 313 | - | |
| 314 | - String cardNum = ""; | |
| 315 | - //大华一体机,刷卡开门需要平台十六进制反读直接下发才可正常开门,因这两所学校已下发完成且不用刷卡,所以不做处理, | |
| 316 | - // 以后使用大华一体机,下发卡号统一处理直接下发,不做取反处理 | |
| 317 | - if(attendanceBean.getClint_id().startsWith("ytj") | |
| 318 | - &&Integer.parseInt(attendanceBean.getSchool_id())!=126 | |
| 319 | - &&Integer.parseInt(attendanceBean.getSchool_id())!=393) | |
| 320 | - {cardNum = student_num;} | |
| 321 | - else{cardNum =cardNo(student_num);} | |
| 322 | -// GateModule.getFace(user_id, loginHandleLong); | |
| 323 | -// GateModule.getUser(user_id, loginHandleLong); | |
| 324 | -// GateModule.getCard(cardNum, loginHandleLong); | |
| 325 | - if (bCardFlags != -1) {//修改卡信息 | |
| 326 | - int newRecordNo=0; | |
| 327 | - int bFaceFalgsInt=0; | |
| 328 | - | |
| 329 | - newRecordNo=GateModule.modifyCard(bCardFlags, cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), | |
| 328 | + //卡号取反 | |
| 329 | + String cardNum = cardNo(student_num); | |
| 330 | + log.info("=====开始执行下发人脸及卡号任务=====: clintId:{}, userId:{}, cardNum:{}, name:{} ",attendanceBean.getClint_id(),user_id,cardNum,name); | |
| 331 | + if (bCardFlags != -1) { | |
| 332 | + //修改设备卡信息 | |
| 333 | + boolean isEditCard = GateModule.modifyCard(bCardFlags, cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), | |
| 330 | 334 | 0, 0, 1, startTime, endTime, loginHandleLong, userType); |
| 331 | 335 | |
| 332 | - if(newRecordNo==1) { | |
| 333 | - | |
| 336 | + if (isEditCard) { | |
| 337 | + //设备修改卡成功, 更新下发记录表 | |
| 334 | 338 | userDao.updateRecordNo(user_id, bCardFlags, attendanceBean.getClint_id()); |
| 335 | - | |
| 336 | - bFaceFalgsInt = GateModule.modifyFaceInfo(user_id, memory, loginHandleLong); | |
| 337 | - if (bFaceFalgsInt == 1) {//1照片修改成功 | |
| 338 | - bFaceFalgs = true; | |
| 339 | - } | |
| 340 | -// else if (bFaceFalgsInt == 1029)//问题,编辑人脸提示用户id不存在,故此增加此 | |
| 341 | -// { | |
| 342 | -// bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" | |
| 343 | -// , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 | |
| 344 | -// , 1, startTime, endTime, loginHandleLong, userType); | |
| 345 | -// if (bCardFlags != -1) { | |
| 346 | -// userDao.updateRecordNo(user_id, bCardFlags, attendanceBean.getClint_id()); | |
| 347 | -// } | |
| 348 | -// //添加人脸 | |
| 349 | -// bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); | |
| 350 | -// } | |
| 351 | - else { | |
| 352 | - bFaceFalgs = false; | |
| 353 | - } | |
| 354 | - //卡号添加成功,但是人脸不成功的话,就需要新增人脸 | |
| 355 | - if (!bFaceFalgs) | |
| 339 | + //设备卡修改成功后,更新设备人脸信息 | |
| 340 | + boolean isEditFace = GateModule.modifyFaceInfo(user_id, memory, loginHandleLong); | |
| 341 | + //修改卡信息成功,但是人脸不成功的话,就需要新增人脸 | |
| 342 | + if (!isEditFace) { | |
| 356 | 343 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); |
| 357 | - } | |
| 358 | - else{ | |
| 344 | + } | |
| 345 | + }else{ | |
| 346 | + //设备修改卡信息失败,则删除下发记录集编号表记录:SZ_Student_RecoderNo,重新下发. | |
| 359 | 347 | userDao.deleteRecordNo(user_id, bCardFlags); |
| 348 | + //重新下发卡号至设备 | |
| 360 | 349 | bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" |
| 361 | 350 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 |
| 362 | 351 | , 1, startTime, endTime, loginHandleLong,userType); |
| 352 | + //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 | |
| 363 | 353 | if (bCardFlags != -1) { |
| 364 | - int index = userDao.saveRecordNo(user_id, bCardFlags, name, attendanceBean.getClint_id());//存储记录集编号 | |
| 354 | + userDao.saveRecordNo(user_id, bCardFlags, name, attendanceBean.getClint_id());//存储记录集编号 | |
| 365 | 355 | } |
| 366 | 356 | //添加人脸 |
| 367 | 357 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); |
| 368 | 358 | } |
| 369 | 359 | |
| 370 | - } else {//新增卡信息 | |
| 371 | - | |
| 360 | + } else { | |
| 361 | + //新增卡信息, 新增人脸信息至设备 | |
| 372 | 362 | bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" |
| 373 | 363 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 |
| 374 | 364 | , 1, startTime, endTime, loginHandleLong,userType); |
| 375 | - | |
| 365 | + //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 | |
| 376 | 366 | if (bCardFlags != -1) { |
| 377 | - int index = userDao.saveRecordNo(user_id, bCardFlags, name, attendanceBean.getClint_id());//存储记录集编号 | |
| 367 | + userDao.saveRecordNo(user_id, bCardFlags, name, attendanceBean.getClint_id()); | |
| 378 | 368 | } |
| 379 | - | |
| 380 | 369 | //添加人脸 |
| 381 | 370 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); |
| 382 | 371 | |
| ... | ... | @@ -384,25 +373,21 @@ public class SendUserInfoTask { |
| 384 | 373 | |
| 385 | 374 | if (bCardFlags != -1 && bFaceFalgs) { |
| 386 | 375 | FileUtils.getInstance().writeLogs("下发人脸和卡号成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); |
| 387 | - System.out.println("人脸下发成功" + "sendRecordBean:" + sendRecordBean); | |
| 376 | + log.info("下发人脸和卡号成功, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | |
| 388 | 377 | |
| 389 | - //先判断是否已经存在了 | |
| 378 | + //人脸下发成功记录, 先判断是否已经存在了 | |
| 390 | 379 | List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceSucceIsexit(sendRecordBean.getDeviceID(), String.valueOf(sendRecordBean.getSchoolId()), sendRecordBean.getCustomerid()); |
| 391 | 380 | if (sendRecordBeanList.size() > 0) { |
| 392 | - | |
| 393 | 381 | //删除重复数据 |
| 394 | 382 | for (int i = 0; i < sendRecordBeanList.size(); i++) { |
| 395 | 383 | sendRecordDao.deleteFaceSuccess(sendRecordBeanList.get(i).getDeviceID(), sendRecordBeanList.get(i).getNum()); |
| 396 | 384 | } |
| 397 | 385 | |
| 398 | -// //更新数据 | |
| 399 | -// sendRecordDao.updateFaceSuccess(sendRecordBean.getTime(), sendRecordBean.getDeviceID(), sendRecordBean.getNum()); | |
| 400 | - } else { | |
| 401 | 386 | } |
| 402 | - int index = sendRecordDao.addFaceSuccess(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), | |
| 387 | + //重新添加人脸下发记录 | |
| 388 | + sendRecordDao.addFaceSuccess(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), | |
| 403 | 389 | sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getUserType(), 22); |
| 404 | -// File imgFile = new File(sendRecordBean.getImgPath()); | |
| 405 | -// imgFile.deleteOnExit(); | |
| 390 | + | |
| 406 | 391 | //删除成功 |
| 407 | 392 | if (sendRecordBean.getFailType() != 0) |
| 408 | 393 | sendRecordDao.deleteFaceFail(sendRecordBean.getNum(), sendRecordBean.getDeviceID()); |
| ... | ... | @@ -412,8 +397,7 @@ public class SendUserInfoTask { |
| 412 | 397 | // 添加卡信息和人脸失败 |
| 413 | 398 | if (bCardFlags == -1 && !bFaceFalgs) { |
| 414 | 399 | FileUtils.getInstance().writeLogs("下发人脸和卡号失败:" + cardNum + " user_id: " + user_id + " loginHandleLong: " + loginHandleLong, FileUtils.sendUserErrTxt); |
| 415 | -// System.out.println("添加卡信息和人脸失败"); | |
| 416 | - System.out.println("下发人脸和卡号失败" + "sendRecordBean:" + sendRecordBean.getDeviceID() + " ," + sendRecordBean.getNum() + "," + loginHandleLong + ",bCardFlags:" + bCardFlags + "\r\n"); | |
| 400 | + log.error("下发人脸和卡号失败, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | |
| 417 | 401 | sendRecordBean.setFailContent("下发人脸和卡号失败"); |
| 418 | 402 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 7);//更新下发失败状态 |
| 419 | 403 | sendRecordBean.setFailType(8); |
| ... | ... | @@ -422,16 +406,15 @@ public class SendUserInfoTask { |
| 422 | 406 | |
| 423 | 407 | // 添加卡信息成功,添加人脸失败 |
| 424 | 408 | if (bCardFlags != -1 && !bFaceFalgs) { |
| 425 | - FileUtils.getInstance().writeLogs("下发卡号成功,人脸失败:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserErrTxt); | |
| 426 | -// System.out.println("添加卡信息成功,添加人脸失败"); | |
| 427 | - System.out.println("customerId:" + sendRecordBean.getCustomerid() + " deviceId:" + sendRecordBean.getDeviceID() + " failType:" + sendRecordBean.getFailType() + "\r\n"); | |
| 409 | + FileUtils.getInstance().writeLogs("下发卡号成功,下发人脸失败:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserErrTxt); | |
| 410 | + log.error("下发人脸和卡号失败, sendRecordBean: " + JSON.toJSONString(sendRecordBean)); | |
| 428 | 411 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 5);//更新下发失败状态 |
| 429 | 412 | sendRecordBean.setFailContent("下发卡号成功,人脸失败:照片特征值提取失败"); |
| 430 | 413 | sendRecordBean.setFailType(5); |
| 431 | 414 | addFailDace(sendRecordBean); |
| 432 | 415 | } |
| 433 | 416 | |
| 434 | - // 卡信息已存在,添加人脸成功 | |
| 417 | + // 卡信息已存在,添加人脸成功,此情况不存在. | |
| 435 | 418 | if (bCardFlags == -1 && bFaceFalgs) { |
| 436 | 419 | FileUtils.getInstance().writeLogs("下发人脸成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); |
| 437 | 420 | System.out.println("卡信息已存在,添加人脸成功-----------\n"); |
| ... | ... | @@ -440,32 +423,35 @@ public class SendUserInfoTask { |
| 440 | 423 | } catch (Exception e) { |
| 441 | 424 | e.printStackTrace(); |
| 442 | 425 | } |
| 443 | - System.out.println("\n"); | |
| 444 | 426 | } |
| 445 | 427 | |
| 446 | - //人脸发送失败信息添加 | |
| 428 | + | |
| 429 | + /** | |
| 430 | + * 添加人脸下发失败记录 | |
| 431 | + * @param sendRecordBean | |
| 432 | + */ | |
| 447 | 433 | private void addFailDace(SendRecordBean sendRecordBean) { |
| 448 | -// System.out.println("sendRecordBean:" + sendRecordBean != null ? sendRecordBean.toString() : "不存在"); | |
| 434 | + //获取指定设备指定用户的人脸失败记录 | |
| 449 | 435 | List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceFailIsExit(sendRecordBean.getDeviceID(), sendRecordBean.getCustomerid()); |
| 450 | - | |
| 436 | + if(sendRecordBeanList.size() ==0){ | |
| 437 | + return; | |
| 438 | + } | |
| 439 | + //删除失败记录 | |
| 451 | 440 | for (int i = 0; i < sendRecordBeanList.size(); i++) { |
| 452 | 441 | sendRecordDao.deleteFaceFail(sendRecordBeanList.get(i).getNum(), sendRecordBeanList.get(i).getDeviceID()); |
| 453 | 442 | } |
| 454 | 443 | |
| 455 | -// String name = sendRecordDao.getFailNameIsExit(sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getFailType()); | |
| 456 | - | |
| 457 | -// if (StringUtils.isEmpty(name)) { | |
| 458 | - | |
| 459 | 444 | if (sendRecordBean.getFailType() == 5) sendRecordBean.setFailType(8); |
| 460 | 445 | |
| 461 | 446 | String imagePath = sendRecordBean.getImgPath().replace("C:/imgCom", |
| 462 | 447 | String.format("E:\\wwwhtdocs\\smartcampus\\face17e5\\School%s\\%s", sendRecordBean.getSchoolId(), sendRecordBean.getUserType() == 1 ? "Teacher" : "Student")); |
| 463 | 448 | |
| 449 | + //添加失败记录 | |
| 464 | 450 | sendRecordDao.addFaceFail(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), |
| 465 | 451 | sendRecordBean.getSchoolName(), imagePath, sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), 22); |
| 466 | -// } | |
| 467 | 452 | } |
| 468 | 453 | |
| 454 | + | |
| 469 | 455 | public String cardNo(String cardDex) { |
| 470 | 456 | |
| 471 | 457 | String cardR = ""; | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java
| ... | ... | @@ -18,10 +18,12 @@ import com.example.dahua.lib.NetSDKLib.*; |
| 18 | 18 | import com.example.dahua.lib.ToolKits; |
| 19 | 19 | import com.sun.jna.Memory; |
| 20 | 20 | import com.sun.jna.ptr.IntByReference; |
| 21 | +import lombok.extern.slf4j.Slf4j; | |
| 21 | 22 | |
| 22 | 23 | import javax.imageio.ImageIO; |
| 23 | 24 | |
| 24 | 25 | |
| 26 | +@Slf4j | |
| 25 | 27 | public class GateModule { |
| 26 | 28 | // 查询句柄 |
| 27 | 29 | private static LLong m_lFindHandle = new LLong(0); |
| ... | ... | @@ -50,6 +52,33 @@ public class GateModule { |
| 50 | 52 | return m_hAttachHandle; |
| 51 | 53 | } |
| 52 | 54 | |
| 55 | + public static LLong realLoadPic2(int ChannelId, NetSDKLib.fAnalyzerDataCallBack m_AnalyzerDataCB, LLong lLong,String devcieId) { | |
| 56 | + | |
| 57 | + final NetSDKLib.NET_DEVICEINFO_Ex deviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); | |
| 58 | + | |
| 59 | + // 设备ID | |
| 60 | + System.arraycopy(devcieId.getBytes(), 0, deviceInfo.sSerialNumber, 0, devcieId.getBytes().length); | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 说明: | |
| 64 | + * 通道数可以在有登录是返回的信息 m_stDeviceInfo.byChanNum 获取 | |
| 65 | + * 下列仅订阅了0通道的智能事件. | |
| 66 | + */ | |
| 67 | + int bNeedPicture = 1; // 是否需要图片 | |
| 68 | + deviceInfo.write(); | |
| 69 | + LLong m_hAttachHandle = LoginModule.netsdk.CLIENT_RealLoadPictureEx(lLong, ChannelId, NetSDKLib.EVENT_IVS_ALL, | |
| 70 | + bNeedPicture, m_AnalyzerDataCB, deviceInfo.getPointer(), null); | |
| 71 | + deviceInfo.read(); | |
| 72 | + if (m_hAttachHandle.longValue() != 0) { | |
| 73 | + System.out.println("CLIENT_RealLoadPictureEx Success ChannelId : \n" + ChannelId); | |
| 74 | + } else { | |
| 75 | + System.err.println("CLIENT_RealLoadPictureEx Failed!" + ToolKits.getErrorCodePrint()); | |
| 76 | + return null; | |
| 77 | + } | |
| 78 | + | |
| 79 | + return m_hAttachHandle; | |
| 80 | + } | |
| 81 | + | |
| 53 | 82 | /** |
| 54 | 83 | * 停止上传智能分析数据-图片 |
| 55 | 84 | */ |
| ... | ... | @@ -169,6 +198,7 @@ public class GateModule { |
| 169 | 198 | // return true; |
| 170 | 199 | } |
| 171 | 200 | |
| 201 | + | |
| 172 | 202 | public static synchronized int insertCard(String cardNo, String userId, String cardName, String cardPwd, |
| 173 | 203 | int cardStatus, int cardType, int useTimes, int isFirstEnter, |
| 174 | 204 | int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { |
| ... | ... | @@ -254,24 +284,25 @@ public class GateModule { |
| 254 | 284 | accessCardInfo.read(); |
| 255 | 285 | |
| 256 | 286 | if(!bRet) { |
| 257 | - //System.err.println("添加卡信息失败." + ToolKits.getErrorCodePrint()); | |
| 258 | 287 | String ret=ToolKits.getErrorCodePrint(); |
| 259 | - System.err.println("添加卡信息失败." + ret); | |
| 260 | 288 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); |
| 261 | - if(number.equals("21")||number.equals("146"))//146用户已存在,21对返回数据的校验出错,1162未知错误 number.equals("1162")|| | |
| 262 | - { | |
| 289 | + log.info("添加卡信息失败,错误信息:{} ,错误码:{} ",ret,number); | |
| 290 | + //146用户已存在,21对返回数据的校验出错,1162未知错误 number.equals("1162")|| | |
| 291 | + if(number.equals("21")||number.equals("146")) { | |
| 292 | + //用户已存在/返回数据校验出错时,执行删除用户 | |
| 263 | 293 | deleteUser( userId, lLong); |
| 294 | + //重新下发卡至设备 | |
| 264 | 295 | return insertCard( cardNo, userId, cardName, cardPwd, |
| 265 | 296 | cardStatus, cardType, useTimes, isFirstEnter, |
| 266 | 297 | isValid, startValidTime, endValidTime, lLong, userType); |
| 267 | 298 | } |
| 299 | + //其他错误码,返回-1 | |
| 268 | 300 | return -1; |
| 269 | 301 | } else { |
| 270 | - System.out.println("添加卡信息成功,卡信息记录集编号 : " + insert.stuCtrlRecordSetResult.nRecNo); | |
| 302 | + log.info("添加卡信息成功,卡信息记录集编号 : "+ insert.stuCtrlRecordSetResult.nRecNo); | |
| 271 | 303 | return insert.stuCtrlRecordSetResult.nRecNo; |
| 272 | 304 | } |
| 273 | 305 | |
| 274 | - | |
| 275 | 306 | // return true; |
| 276 | 307 | } |
| 277 | 308 | |
| ... | ... | @@ -378,22 +409,21 @@ public class GateModule { |
| 378 | 409 | |
| 379 | 410 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); |
| 380 | 411 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; |
| 381 | - int nChannel = 120; // 通道号 | |
| 412 | + // 通道号 | |
| 413 | + int nChannel = 120; | |
| 382 | 414 | // msg.stuTimeWeekDay[0].stuTimeSection[0].dwRecordMask |
| 383 | - String name = "4"; | |
| 415 | + String name = "3"; | |
| 384 | 416 | System.arraycopy(name.getBytes(), 0, msg.szName, 0, name.getBytes().length); |
| 385 | 417 | msg.bEnable = 1; |
| 386 | 418 | |
| 387 | 419 | List<WeekDay> weekDays = permissionBean.getWeekDays(); |
| 388 | 420 | Map<Integer, List<WeekTime>> map = new HashMap<>(); |
| 389 | 421 | |
| 390 | - for (WeekDay weekDay : | |
| 391 | - weekDays) { | |
| 422 | + for (WeekDay weekDay : weekDays) { | |
| 392 | 423 | //整理时间 |
| 393 | 424 | initWeedayAndTimes(weekDay, map); |
| 394 | 425 | //设置周计划信息 |
| 395 | - for (Map.Entry<Integer, List<WeekTime>> entry : | |
| 396 | - map.entrySet()) { | |
| 426 | + for (Map.Entry<Integer, List<WeekTime>> entry : map.entrySet()) { | |
| 397 | 427 | |
| 398 | 428 | int weekDayIndex = entry.getKey(); |
| 399 | 429 | |
| ... | ... | @@ -632,7 +662,25 @@ public class GateModule { |
| 632 | 662 | return true; |
| 633 | 663 | } |
| 634 | 664 | |
| 635 | - public static int modifyCard(int recordNo, String cardNo, String userId, String cardName, String cardPwd, | |
| 665 | + /** | |
| 666 | + * 修改设备卡信息 | |
| 667 | + * @param recordNo | |
| 668 | + * @param cardNo | |
| 669 | + * @param userId | |
| 670 | + * @param cardName | |
| 671 | + * @param cardPwd | |
| 672 | + * @param cardStatus | |
| 673 | + * @param cardType | |
| 674 | + * @param useTimes | |
| 675 | + * @param isFirstEnter | |
| 676 | + * @param isValid | |
| 677 | + * @param startValidTime | |
| 678 | + * @param endValidTime | |
| 679 | + * @param lLong | |
| 680 | + * @param userType | |
| 681 | + * @return | |
| 682 | + */ | |
| 683 | + public static boolean modifyCard(int recordNo, String cardNo, String userId, String cardName, String cardPwd, | |
| 636 | 684 | int cardStatus, int cardType, int useTimes, int isFirstEnter, |
| 637 | 685 | int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { |
| 638 | 686 | /** |
| ... | ... | @@ -717,29 +765,24 @@ public class GateModule { |
| 717 | 765 | CtrlType.CTRLTYPE_CTRL_RECORDSET_UPDATE, update.getPointer(), 5000); |
| 718 | 766 | update.read(); |
| 719 | 767 | accessCardInfo.read(); |
| 720 | - | |
| 768 | + // 返回值:1成功,否则返回 | |
| 721 | 769 | if (!bRet) { |
| 722 | - //System.err.println("修改卡信息失败." + ToolKits.getErrorCodePrint()); | |
| 723 | 770 | String ret=ToolKits.getErrorCodePrint(); |
| 771 | + //结果码 | |
| 724 | 772 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); |
| 725 | - System.err.println("修改卡信息失败." + ret+" "+number); | |
| 726 | - if(number.equals("21")||number.equals("147"))//147用户不存在,21对返回数据的校验出错 | |
| 727 | - { | |
| 728 | -// newRecordNo= insertCard( cardNo, userId, cardName, cardPwd, | |
| 729 | -// cardStatus, cardType, useTimes, isFirstEnter, | |
| 730 | -// isValid, startValidTime, endValidTime, lLong, userType); | |
| 731 | - } | |
| 732 | - if(number.equals("1091")||number.equals("1147"))//未知错误 | |
| 733 | - { | |
| 734 | - return Integer.parseInt(number); | |
| 735 | - } | |
| 736 | - return 0; | |
| 737 | - } | |
| 738 | - else { | |
| 739 | - System.out.println("修改卡信息成功 "); | |
| 773 | + //147用户不存在,21对返回数据的校验出错 | |
| 774 | +// if(number.equals("21")||number.equals("147")) { | |
| 775 | +// | |
| 776 | +// } | |
| 777 | +// if(number.equals("1091")||number.equals("1147"))//未知错误 | |
| 778 | +// { | |
| 779 | +// return Integer.parseInt(number); | |
| 780 | +// } | |
| 781 | + log.error("修改卡信息失败,错误信息:{} ,错误码:{} ",ret,number); | |
| 782 | + return false; | |
| 740 | 783 | } |
| 741 | - | |
| 742 | - return 1; | |
| 784 | + log.info("修改卡信息成功!"); | |
| 785 | + return true; | |
| 743 | 786 | } |
| 744 | 787 | |
| 745 | 788 | /** |
| ... | ... | @@ -779,8 +822,7 @@ public class GateModule { |
| 779 | 822 | msg.pBuf = new IntByReference(recordNo).getPointer(); |
| 780 | 823 | |
| 781 | 824 | msg.write(); |
| 782 | - boolean bRet = LoginModule.netsdk.CLIENT_ControlDevice(lLong, | |
| 783 | - CtrlType.CTRLTYPE_CTRL_RECORDSET_REMOVE, msg.getPointer(), 5000); | |
| 825 | + boolean bRet = LoginModule.netsdk.CLIENT_ControlDevice(lLong, CtrlType.CTRLTYPE_CTRL_RECORDSET_REMOVE, msg.getPointer(), 5000); | |
| 784 | 826 | msg.read(); |
| 785 | 827 | |
| 786 | 828 | if (!bRet) { |
| ... | ... | @@ -1036,12 +1078,10 @@ public class GateModule { |
| 1036 | 1078 | * 打印具体的信息 |
| 1037 | 1079 | */ |
| 1038 | 1080 | for (int i = 0; i < nMaxNum; i++) { |
| 1039 | - System.out.println("[" + i + "]删除用户结果:" | |
| 1040 | - + failCodes[i].nFailCode); | |
| 1081 | + log.info("[" + i + "]删除用户结果:" + failCodes[i].nFailCode); | |
| 1041 | 1082 | } |
| 1042 | 1083 | } else { |
| 1043 | - //System.err.println("删除用户失败, " + getErrorCode()); | |
| 1044 | - System.err.println("删除用户失败, " + ToolKits.getErrorCodePrint()); | |
| 1084 | + log.error("添加卡信息失败"+ ToolKits.getErrorCodePrint()); | |
| 1045 | 1085 | } |
| 1046 | 1086 | |
| 1047 | 1087 | stIn.read(); |
| ... | ... | @@ -1129,23 +1169,21 @@ public class GateModule { |
| 1129 | 1169 | stIn.read(); |
| 1130 | 1170 | stOut.read(); |
| 1131 | 1171 | if (bRet) { |
| 1132 | - System.out.println("添加人脸成功!"); | |
| 1172 | + log.info("添加人脸成功!"); | |
| 1133 | 1173 | } else { |
| 1134 | -// System.err.println("添加人脸失败!" + ToolKits.getErrorCodePrint()); | |
| 1135 | 1174 | String ret=ToolKits.getErrorCodePrint(); |
| 1136 | - System.err.println("添加人脸失败!" + ret); | |
| 1137 | 1175 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); |
| 1138 | - if(number.equals("1031"))//照片已存在 | |
| 1139 | - { | |
| 1140 | - return modifyFaceInfo( userId, memory, lLong)==1?true:false; | |
| 1176 | + log.error("修改卡信息失败,错误信息:{} ,错误码:{} ",ret,number); | |
| 1177 | + //number = 1031:照片已存在;number = 1029 :用户ID不存在 | |
| 1178 | + if(number.equals("1031")){ | |
| 1179 | + return modifyFaceInfo( userId, memory, lLong); | |
| 1141 | 1180 | } |
| 1142 | - if(number.equals("1029"))//用户ID不存在 | |
| 1181 | + if(number.equals("1029")) | |
| 1143 | 1182 | { |
| 1144 | - //return addFaceInfo( userId, memory, lLong); | |
| 1183 | + return addFaceInfo( userId, memory, lLong); | |
| 1145 | 1184 | } |
| 1146 | 1185 | return false; |
| 1147 | 1186 | } |
| 1148 | - | |
| 1149 | 1187 | return true; |
| 1150 | 1188 | } |
| 1151 | 1189 | |
| ... | ... | @@ -1187,7 +1225,7 @@ public class GateModule { |
| 1187 | 1225 | stIn.read(); |
| 1188 | 1226 | stOut.read(); |
| 1189 | 1227 | if (bRet) { |
| 1190 | - System.out.println("修改人脸成功!"); | |
| 1228 | + log.info("修改人脸成功!"); | |
| 1191 | 1229 | } else { |
| 1192 | 1230 | // System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); |
| 1193 | 1231 | String ret=ToolKits.getErrorCodePrint(); |
| ... | ... | @@ -1200,7 +1238,7 @@ public class GateModule { |
| 1200 | 1238 | } |
| 1201 | 1239 | |
| 1202 | 1240 | |
| 1203 | - public static int modifyFaceInfo(String userId, Memory memory, LLong lLong) { | |
| 1241 | + public static boolean modifyFaceInfo(String userId, Memory memory, LLong lLong) { | |
| 1204 | 1242 | int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_UPDATE; // 修改 |
| 1205 | 1243 | |
| 1206 | 1244 | /** |
| ... | ... | @@ -1230,22 +1268,16 @@ public class GateModule { |
| 1230 | 1268 | boolean bRet = LoginModule.netsdk.CLIENT_FaceInfoOpreate(lLong, emType, stIn.getPointer(), stOut.getPointer(), 5000); |
| 1231 | 1269 | stIn.read(); |
| 1232 | 1270 | stOut.read(); |
| 1271 | + | |
| 1233 | 1272 | if (bRet) { |
| 1234 | - System.out.println("修改人脸成功!"); | |
| 1273 | + log.info("修改人脸成功!"); | |
| 1235 | 1274 | } else { |
| 1236 | -// System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); | |
| 1237 | 1275 | String ret=ToolKits.getErrorCodePrint(); |
| 1238 | - System.err.println("修改人脸失败!" + ret); | |
| 1239 | 1276 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); |
| 1240 | - if(number.equals("1029"))//1029用户ID不存在 | |
| 1241 | - { | |
| 1242 | - //return addFaceInfo(userId, memory, lLong); | |
| 1243 | - return Integer.parseInt(number); | |
| 1244 | - } | |
| 1245 | - return 0; | |
| 1277 | + log.error("修改人脸失败,错误信息:{} ,错误码:{} ",ret,number); | |
| 1278 | + return false; | |
| 1246 | 1279 | } |
| 1247 | - | |
| 1248 | - return 1; | |
| 1280 | + return true; | |
| 1249 | 1281 | } |
| 1250 | 1282 | |
| 1251 | 1283 | /** | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/service/UserService.java
| ... | ... | @@ -54,6 +54,12 @@ public interface UserService { |
| 54 | 54 | */ |
| 55 | 55 | boolean sendPermission(PermissionBean permissionBean); |
| 56 | 56 | |
| 57 | + /** | |
| 58 | + * 根据学籍号、学校id获取用户id | |
| 59 | + * @param code | |
| 60 | + * @param schoolId | |
| 61 | + * @return | |
| 62 | + */ | |
| 57 | 63 | String getUserId(String code,String schoolId); |
| 58 | 64 | |
| 59 | 65 | ... | ... |