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 | package com.example.dahua; | 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 | import com.example.dahua.dao.UserDao; | 5 | import com.example.dahua.dao.UserDao; |
| 8 | import com.example.dahua.lib.NetSDKLib; | 6 | import com.example.dahua.lib.NetSDKLib; |
| 9 | import com.example.dahua.lib.ToolKits; | 7 | import com.example.dahua.lib.ToolKits; |
| 10 | import com.example.dahua.lib.Utils; | 8 | import com.example.dahua.lib.Utils; |
| 11 | import com.example.dahua.module.AutoRegisterModule; | 9 | import com.example.dahua.module.AutoRegisterModule; |
| 10 | +import com.example.dahua.module.FaceRecognitionModule; | ||
| 12 | import com.example.dahua.module.GateModule; | 11 | import com.example.dahua.module.GateModule; |
| 13 | import com.example.dahua.module.LoginModule; | 12 | import com.example.dahua.module.LoginModule; |
| 14 | import com.example.dahua.service.AttendanceService; | 13 | import com.example.dahua.service.AttendanceService; |
| 14 | +import com.example.dahua.utils.DateUtils; | ||
| 15 | +import com.example.dahua.utils.FileUtils; | ||
| 15 | import com.example.dahua.xiananDao.SendRecordDao; | 16 | import com.example.dahua.xiananDao.SendRecordDao; |
| 16 | import com.sun.jna.Pointer; | 17 | import com.sun.jna.Pointer; |
| 18 | +import lombok.extern.slf4j.Slf4j; | ||
| 17 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | import org.springframework.boot.ApplicationArguments; | 20 | import org.springframework.boot.ApplicationArguments; |
| 19 | import org.springframework.boot.ApplicationRunner; | 21 | import org.springframework.boot.ApplicationRunner; |
| @@ -31,6 +33,7 @@ import java.util.*; | @@ -31,6 +33,7 @@ import java.util.*; | ||
| 31 | import java.util.List; | 33 | import java.util.List; |
| 32 | 34 | ||
| 33 | @Component | 35 | @Component |
| 36 | +@Slf4j | ||
| 34 | public class MyTask implements ApplicationRunner { | 37 | public class MyTask implements ApplicationRunner { |
| 35 | 38 | ||
| 36 | // 主动注册监听回调 | 39 | // 主动注册监听回调 |
| @@ -58,6 +61,9 @@ public class MyTask implements ApplicationRunner { | @@ -58,6 +61,9 @@ public class MyTask implements ApplicationRunner { | ||
| 58 | SendRecordDao sendRecordDao; | 61 | SendRecordDao sendRecordDao; |
| 59 | 62 | ||
| 60 | @Autowired | 63 | @Autowired |
| 64 | + SearchDao searchDao; | ||
| 65 | + | ||
| 66 | + @Autowired | ||
| 61 | UserDao userDao; | 67 | UserDao userDao; |
| 62 | 68 | ||
| 63 | public boolean isHasNewDevice = false;//判断是否有新设备上线 | 69 | public boolean isHasNewDevice = false;//判断是否有新设备上线 |
| @@ -65,10 +71,10 @@ public class MyTask implements ApplicationRunner { | @@ -65,10 +71,10 @@ public class MyTask implements ApplicationRunner { | ||
| 65 | @Override | 71 | @Override |
| 66 | public void run(ApplicationArguments args) throws Exception { | 72 | public void run(ApplicationArguments args) throws Exception { |
| 67 | // 121.40.109.21 | 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 | // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess()); | 79 | // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess()); |
| 74 | } | 80 | } |
| @@ -228,7 +234,7 @@ public class MyTask implements ApplicationRunner { | @@ -228,7 +234,7 @@ public class MyTask implements ApplicationRunner { | ||
| 228 | break; | 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,7 +244,7 @@ public class MyTask implements ApplicationRunner { | ||
| 238 | for (DeviceInfoBean dev : | 244 | for (DeviceInfoBean dev : |
| 239 | deviceInfoBeans) { | 245 | deviceInfoBeans) { |
| 240 | if (lLongMap.get(dev.getDevcieId()).intValue() > 0) { | 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 | // System.out.println("监听成功:"+dev.getDevcieId()); | 248 | // System.out.println("监听成功:"+dev.getDevcieId()); |
| 243 | // if (lLong.intValue() != -1) { | 249 | // if (lLong.intValue() != -1) { |
| 244 | // //deviceInfoBeans.remove(dev); | 250 | // //deviceInfoBeans.remove(dev); |
| @@ -273,32 +279,25 @@ public class MyTask implements ApplicationRunner { | @@ -273,32 +279,25 @@ public class MyTask implements ApplicationRunner { | ||
| 273 | path.mkdir(); | 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 | if (dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { | 289 | if (dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { |
| 278 | NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO msg = new NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO(); | 290 | NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO msg = new NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO(); |
| 279 | ToolKits.GetPointerData(pAlarmInfo, msg); | 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 | try { | 297 | try { |
| 299 | - String card = new String(msg.szCardNo).trim(); | ||
| 300 | if (!StringUtils.isEmpty(card)) { | 298 | if (!StringUtils.isEmpty(card)) { |
| 301 | // 保存图片,获取图片缓存 | 299 | // 保存图片,获取图片缓存 |
| 300 | + // 图片服务器路径 | ||
| 302 | String snapPicPath = path + "\\" + System.currentTimeMillis() + ".png"; // 保存图片地址 | 301 | String snapPicPath = path + "\\" + System.currentTimeMillis() + ".png"; // 保存图片地址 |
| 303 | byte[] buffer = pBuffer.getByteArray(0, dwBufSize); | 302 | byte[] buffer = pBuffer.getByteArray(0, dwBufSize); |
| 304 | ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer); | 303 | ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer); |
| @@ -306,19 +305,32 @@ public class MyTask implements ApplicationRunner { | @@ -306,19 +305,32 @@ public class MyTask implements ApplicationRunner { | ||
| 306 | if (gateBufferedImage != null) { | 305 | if (gateBufferedImage != null) { |
| 307 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); | 306 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); |
| 308 | } | 307 | } |
| 308 | + //卡号取反(大写) | ||
| 309 | card = cardNo(card); | 309 | card = cardNo(card); |
| 310 | - | ||
| 311 | - CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 | 310 | + //根据卡号获取卡身份信息 |
| 311 | + CardBean cardBean = userDao.getCards(card); | ||
| 312 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | 312 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
| 313 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); | 313 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); |
| 314 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); | 314 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); |
| 315 | - if (null != cardBean && cardBean.getType() == 0) {//老师 | 315 | + if (null != cardBean && cardBean.getType() == 0) { |
| 316 | + //老师人脸信息,保存人脸记录表 | ||
| 316 | TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); | 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 | UserInfoBean userInfoBean = userDao.getStudentWithid(cardBean.getUser_id()); | 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 | } catch (IOException e2) { | 336 | } catch (IOException e2) { |
| @@ -338,6 +350,7 @@ public class MyTask implements ApplicationRunner { | @@ -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,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 | package com.example.dahua.async; | 1 | package com.example.dahua.async; |
| 2 | 2 | ||
| 3 | //import com.example.dahua.Gate.Gate; | 3 | //import com.example.dahua.Gate.Gate; |
| 4 | + | ||
| 5 | +import com.alibaba.fastjson.JSON; | ||
| 4 | import com.example.dahua.MyTask; | 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 | import com.example.dahua.common.Res; | 11 | import com.example.dahua.common.Res; |
| 7 | import com.example.dahua.dao.UserDao; | 12 | import com.example.dahua.dao.UserDao; |
| 8 | import com.example.dahua.lib.CompressPic; | 13 | import com.example.dahua.lib.CompressPic; |
| @@ -14,15 +19,11 @@ import com.example.dahua.utils.FileUtils; | @@ -14,15 +19,11 @@ import com.example.dahua.utils.FileUtils; | ||
| 14 | import com.example.dahua.utils.HttpUtils; | 19 | import com.example.dahua.utils.HttpUtils; |
| 15 | import com.example.dahua.xiananDao.SendRecordDao; | 20 | import com.example.dahua.xiananDao.SendRecordDao; |
| 16 | import com.sun.jna.Memory; | 21 | import com.sun.jna.Memory; |
| 22 | +import lombok.extern.slf4j.Slf4j; | ||
| 17 | import org.springframework.beans.factory.annotation.Autowired; | 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 | import org.springframework.http.ResponseEntity; | 24 | import org.springframework.http.ResponseEntity; |
| 22 | import org.springframework.scheduling.annotation.Async; | 25 | import org.springframework.scheduling.annotation.Async; |
| 23 | import org.springframework.stereotype.Component; | 26 | import org.springframework.stereotype.Component; |
| 24 | -import org.springframework.util.LinkedMultiValueMap; | ||
| 25 | -import org.springframework.util.MultiValueMap; | ||
| 26 | import org.springframework.util.StringUtils; | 27 | import org.springframework.util.StringUtils; |
| 27 | import org.springframework.web.client.RestTemplate; | 28 | import org.springframework.web.client.RestTemplate; |
| 28 | 29 | ||
| @@ -34,6 +35,7 @@ import java.util.*; | @@ -34,6 +35,7 @@ import java.util.*; | ||
| 34 | * 下发卡号的异步操作 | 35 | * 下发卡号的异步操作 |
| 35 | */ | 36 | */ |
| 36 | @Component | 37 | @Component |
| 38 | +@Slf4j | ||
| 37 | public class SendUserInfoTask { | 39 | public class SendUserInfoTask { |
| 38 | 40 | ||
| 39 | @Autowired | 41 | @Autowired |
| @@ -281,6 +283,16 @@ public class SendUserInfoTask { | @@ -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 | private synchronized void pushCardAndFace(AttendanceBean attendanceBean, String user_id, String student_num, String name, Memory memory, SendRecordBean sendRecordBean,String userType) { | 296 | private synchronized void pushCardAndFace(AttendanceBean attendanceBean, String user_id, String student_num, String name, Memory memory, SendRecordBean sendRecordBean,String userType) { |
| 285 | try{ | 297 | try{ |
| 286 | sendRecordBean.setDeviceID(attendanceBean.getClint_id()); | 298 | sendRecordBean.setDeviceID(attendanceBean.getClint_id()); |
| @@ -291,14 +303,17 @@ public class SendUserInfoTask { | @@ -291,14 +303,17 @@ public class SendUserInfoTask { | ||
| 291 | Calendar calendar = Calendar.getInstance(); | 303 | Calendar calendar = Calendar.getInstance(); |
| 292 | calendar.add(Calendar.YEAR, 4); | 304 | calendar.add(Calendar.YEAR, 4); |
| 293 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | 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 | bCardFlags = userDao.getRecordNo(user_id, attendanceBean.getClint_id()) == null ? -1 : Integer.parseInt(userDao.getRecordNo(user_id, attendanceBean.getClint_id())); | 309 | bCardFlags = userDao.getRecordNo(user_id, attendanceBean.getClint_id()) == null ? -1 : Integer.parseInt(userDao.getRecordNo(user_id, attendanceBean.getClint_id())); |
| 296 | 310 | ||
| 297 | NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(attendanceBean.getClint_id()); | 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 | if (loginHandleLong == null) { | 315 | if (loginHandleLong == null) { |
| 301 | - System.out.println("设备不在线:" + attendanceBean.getClint_id()); | 316 | + log.info("设备不在线, 设备ID: {} ",attendanceBean.getClint_id() ); |
| 302 | FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); | 317 | FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); |
| 303 | String deviceId = sendRecordDao.getFailIsExit(attendanceBean.getClint_id(), attendanceBean.getSchool_id()); | 318 | String deviceId = sendRecordDao.getFailIsExit(attendanceBean.getClint_id(), attendanceBean.getSchool_id()); |
| 304 | sendRecordBean.setFailType(2); | 319 | sendRecordBean.setFailType(2); |
| @@ -307,76 +322,50 @@ public class SendUserInfoTask { | @@ -307,76 +322,50 @@ public class SendUserInfoTask { | ||
| 307 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 2);//更新下发失败状态 | 322 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 2);//更新下发失败状态 |
| 308 | addFailDace(sendRecordBean); | 323 | addFailDace(sendRecordBean); |
| 309 | } | 324 | } |
| 310 | - | ||
| 311 | } else { | 325 | } else { |
| 326 | + //人脸下发成功标识:false:失败 true:成功 | ||
| 312 | boolean bFaceFalgs = false; | 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 | 0, 0, 1, startTime, endTime, loginHandleLong, userType); | 334 | 0, 0, 1, startTime, endTime, loginHandleLong, userType); |
| 331 | 335 | ||
| 332 | - if(newRecordNo==1) { | ||
| 333 | - | 336 | + if (isEditCard) { |
| 337 | + //设备修改卡成功, 更新下发记录表 | ||
| 334 | userDao.updateRecordNo(user_id, bCardFlags, attendanceBean.getClint_id()); | 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 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); | 343 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); |
| 357 | - } | ||
| 358 | - else{ | 344 | + } |
| 345 | + }else{ | ||
| 346 | + //设备修改卡信息失败,则删除下发记录集编号表记录:SZ_Student_RecoderNo,重新下发. | ||
| 359 | userDao.deleteRecordNo(user_id, bCardFlags); | 347 | userDao.deleteRecordNo(user_id, bCardFlags); |
| 348 | + //重新下发卡号至设备 | ||
| 360 | bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" | 349 | bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" |
| 361 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 | 350 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 |
| 362 | , 1, startTime, endTime, loginHandleLong,userType); | 351 | , 1, startTime, endTime, loginHandleLong,userType); |
| 352 | + //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 | ||
| 363 | if (bCardFlags != -1) { | 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 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); | 357 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); |
| 368 | } | 358 | } |
| 369 | 359 | ||
| 370 | - } else {//新增卡信息 | ||
| 371 | - | 360 | + } else { |
| 361 | + //新增卡信息, 新增人脸信息至设备 | ||
| 372 | bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" | 362 | bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" |
| 373 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 | 363 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 |
| 374 | , 1, startTime, endTime, loginHandleLong,userType); | 364 | , 1, startTime, endTime, loginHandleLong,userType); |
| 375 | - | 365 | + //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 |
| 376 | if (bCardFlags != -1) { | 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 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); | 370 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); |
| 382 | 371 | ||
| @@ -384,25 +373,21 @@ public class SendUserInfoTask { | @@ -384,25 +373,21 @@ public class SendUserInfoTask { | ||
| 384 | 373 | ||
| 385 | if (bCardFlags != -1 && bFaceFalgs) { | 374 | if (bCardFlags != -1 && bFaceFalgs) { |
| 386 | FileUtils.getInstance().writeLogs("下发人脸和卡号成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | 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 | List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceSucceIsexit(sendRecordBean.getDeviceID(), String.valueOf(sendRecordBean.getSchoolId()), sendRecordBean.getCustomerid()); | 379 | List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceSucceIsexit(sendRecordBean.getDeviceID(), String.valueOf(sendRecordBean.getSchoolId()), sendRecordBean.getCustomerid()); |
| 391 | if (sendRecordBeanList.size() > 0) { | 380 | if (sendRecordBeanList.size() > 0) { |
| 392 | - | ||
| 393 | //删除重复数据 | 381 | //删除重复数据 |
| 394 | for (int i = 0; i < sendRecordBeanList.size(); i++) { | 382 | for (int i = 0; i < sendRecordBeanList.size(); i++) { |
| 395 | sendRecordDao.deleteFaceSuccess(sendRecordBeanList.get(i).getDeviceID(), sendRecordBeanList.get(i).getNum()); | 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 | sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getUserType(), 22); | 389 | sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getUserType(), 22); |
| 404 | -// File imgFile = new File(sendRecordBean.getImgPath()); | ||
| 405 | -// imgFile.deleteOnExit(); | 390 | + |
| 406 | //删除成功 | 391 | //删除成功 |
| 407 | if (sendRecordBean.getFailType() != 0) | 392 | if (sendRecordBean.getFailType() != 0) |
| 408 | sendRecordDao.deleteFaceFail(sendRecordBean.getNum(), sendRecordBean.getDeviceID()); | 393 | sendRecordDao.deleteFaceFail(sendRecordBean.getNum(), sendRecordBean.getDeviceID()); |
| @@ -412,8 +397,7 @@ public class SendUserInfoTask { | @@ -412,8 +397,7 @@ public class SendUserInfoTask { | ||
| 412 | // 添加卡信息和人脸失败 | 397 | // 添加卡信息和人脸失败 |
| 413 | if (bCardFlags == -1 && !bFaceFalgs) { | 398 | if (bCardFlags == -1 && !bFaceFalgs) { |
| 414 | FileUtils.getInstance().writeLogs("下发人脸和卡号失败:" + cardNum + " user_id: " + user_id + " loginHandleLong: " + loginHandleLong, FileUtils.sendUserErrTxt); | 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 | sendRecordBean.setFailContent("下发人脸和卡号失败"); | 401 | sendRecordBean.setFailContent("下发人脸和卡号失败"); |
| 418 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 7);//更新下发失败状态 | 402 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 7);//更新下发失败状态 |
| 419 | sendRecordBean.setFailType(8); | 403 | sendRecordBean.setFailType(8); |
| @@ -422,16 +406,15 @@ public class SendUserInfoTask { | @@ -422,16 +406,15 @@ public class SendUserInfoTask { | ||
| 422 | 406 | ||
| 423 | // 添加卡信息成功,添加人脸失败 | 407 | // 添加卡信息成功,添加人脸失败 |
| 424 | if (bCardFlags != -1 && !bFaceFalgs) { | 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 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 5);//更新下发失败状态 | 411 | sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 5);//更新下发失败状态 |
| 429 | sendRecordBean.setFailContent("下发卡号成功,人脸失败:照片特征值提取失败"); | 412 | sendRecordBean.setFailContent("下发卡号成功,人脸失败:照片特征值提取失败"); |
| 430 | sendRecordBean.setFailType(5); | 413 | sendRecordBean.setFailType(5); |
| 431 | addFailDace(sendRecordBean); | 414 | addFailDace(sendRecordBean); |
| 432 | } | 415 | } |
| 433 | 416 | ||
| 434 | - // 卡信息已存在,添加人脸成功 | 417 | + // 卡信息已存在,添加人脸成功,此情况不存在. |
| 435 | if (bCardFlags == -1 && bFaceFalgs) { | 418 | if (bCardFlags == -1 && bFaceFalgs) { |
| 436 | FileUtils.getInstance().writeLogs("下发人脸成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | 419 | FileUtils.getInstance().writeLogs("下发人脸成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); |
| 437 | System.out.println("卡信息已存在,添加人脸成功-----------\n"); | 420 | System.out.println("卡信息已存在,添加人脸成功-----------\n"); |
| @@ -440,32 +423,35 @@ public class SendUserInfoTask { | @@ -440,32 +423,35 @@ public class SendUserInfoTask { | ||
| 440 | } catch (Exception e) { | 423 | } catch (Exception e) { |
| 441 | e.printStackTrace(); | 424 | e.printStackTrace(); |
| 442 | } | 425 | } |
| 443 | - System.out.println("\n"); | ||
| 444 | } | 426 | } |
| 445 | 427 | ||
| 446 | - //人脸发送失败信息添加 | 428 | + |
| 429 | + /** | ||
| 430 | + * 添加人脸下发失败记录 | ||
| 431 | + * @param sendRecordBean | ||
| 432 | + */ | ||
| 447 | private void addFailDace(SendRecordBean sendRecordBean) { | 433 | private void addFailDace(SendRecordBean sendRecordBean) { |
| 448 | -// System.out.println("sendRecordBean:" + sendRecordBean != null ? sendRecordBean.toString() : "不存在"); | 434 | + //获取指定设备指定用户的人脸失败记录 |
| 449 | List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceFailIsExit(sendRecordBean.getDeviceID(), sendRecordBean.getCustomerid()); | 435 | List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceFailIsExit(sendRecordBean.getDeviceID(), sendRecordBean.getCustomerid()); |
| 450 | - | 436 | + if(sendRecordBeanList.size() ==0){ |
| 437 | + return; | ||
| 438 | + } | ||
| 439 | + //删除失败记录 | ||
| 451 | for (int i = 0; i < sendRecordBeanList.size(); i++) { | 440 | for (int i = 0; i < sendRecordBeanList.size(); i++) { |
| 452 | sendRecordDao.deleteFaceFail(sendRecordBeanList.get(i).getNum(), sendRecordBeanList.get(i).getDeviceID()); | 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 | if (sendRecordBean.getFailType() == 5) sendRecordBean.setFailType(8); | 444 | if (sendRecordBean.getFailType() == 5) sendRecordBean.setFailType(8); |
| 460 | 445 | ||
| 461 | String imagePath = sendRecordBean.getImgPath().replace("C:/imgCom", | 446 | String imagePath = sendRecordBean.getImgPath().replace("C:/imgCom", |
| 462 | String.format("E:\\wwwhtdocs\\smartcampus\\face17e5\\School%s\\%s", sendRecordBean.getSchoolId(), sendRecordBean.getUserType() == 1 ? "Teacher" : "Student")); | 447 | String.format("E:\\wwwhtdocs\\smartcampus\\face17e5\\School%s\\%s", sendRecordBean.getSchoolId(), sendRecordBean.getUserType() == 1 ? "Teacher" : "Student")); |
| 463 | 448 | ||
| 449 | + //添加失败记录 | ||
| 464 | sendRecordDao.addFaceFail(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), | 450 | sendRecordDao.addFaceFail(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), |
| 465 | sendRecordBean.getSchoolName(), imagePath, sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), 22); | 451 | sendRecordBean.getSchoolName(), imagePath, sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), 22); |
| 466 | -// } | ||
| 467 | } | 452 | } |
| 468 | 453 | ||
| 454 | + | ||
| 469 | public String cardNo(String cardDex) { | 455 | public String cardNo(String cardDex) { |
| 470 | 456 | ||
| 471 | String cardR = ""; | 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,10 +18,12 @@ import com.example.dahua.lib.NetSDKLib.*; | ||
| 18 | import com.example.dahua.lib.ToolKits; | 18 | import com.example.dahua.lib.ToolKits; |
| 19 | import com.sun.jna.Memory; | 19 | import com.sun.jna.Memory; |
| 20 | import com.sun.jna.ptr.IntByReference; | 20 | import com.sun.jna.ptr.IntByReference; |
| 21 | +import lombok.extern.slf4j.Slf4j; | ||
| 21 | 22 | ||
| 22 | import javax.imageio.ImageIO; | 23 | import javax.imageio.ImageIO; |
| 23 | 24 | ||
| 24 | 25 | ||
| 26 | +@Slf4j | ||
| 25 | public class GateModule { | 27 | public class GateModule { |
| 26 | // 查询句柄 | 28 | // 查询句柄 |
| 27 | private static LLong m_lFindHandle = new LLong(0); | 29 | private static LLong m_lFindHandle = new LLong(0); |
| @@ -50,6 +52,33 @@ public class GateModule { | @@ -50,6 +52,33 @@ public class GateModule { | ||
| 50 | return m_hAttachHandle; | 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,6 +198,7 @@ public class GateModule { | ||
| 169 | // return true; | 198 | // return true; |
| 170 | } | 199 | } |
| 171 | 200 | ||
| 201 | + | ||
| 172 | public static synchronized int insertCard(String cardNo, String userId, String cardName, String cardPwd, | 202 | public static synchronized int insertCard(String cardNo, String userId, String cardName, String cardPwd, |
| 173 | int cardStatus, int cardType, int useTimes, int isFirstEnter, | 203 | int cardStatus, int cardType, int useTimes, int isFirstEnter, |
| 174 | int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { | 204 | int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { |
| @@ -254,24 +284,25 @@ public class GateModule { | @@ -254,24 +284,25 @@ public class GateModule { | ||
| 254 | accessCardInfo.read(); | 284 | accessCardInfo.read(); |
| 255 | 285 | ||
| 256 | if(!bRet) { | 286 | if(!bRet) { |
| 257 | - //System.err.println("添加卡信息失败." + ToolKits.getErrorCodePrint()); | ||
| 258 | String ret=ToolKits.getErrorCodePrint(); | 287 | String ret=ToolKits.getErrorCodePrint(); |
| 259 | - System.err.println("添加卡信息失败." + ret); | ||
| 260 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | 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 | deleteUser( userId, lLong); | 293 | deleteUser( userId, lLong); |
| 294 | + //重新下发卡至设备 | ||
| 264 | return insertCard( cardNo, userId, cardName, cardPwd, | 295 | return insertCard( cardNo, userId, cardName, cardPwd, |
| 265 | cardStatus, cardType, useTimes, isFirstEnter, | 296 | cardStatus, cardType, useTimes, isFirstEnter, |
| 266 | isValid, startValidTime, endValidTime, lLong, userType); | 297 | isValid, startValidTime, endValidTime, lLong, userType); |
| 267 | } | 298 | } |
| 299 | + //其他错误码,返回-1 | ||
| 268 | return -1; | 300 | return -1; |
| 269 | } else { | 301 | } else { |
| 270 | - System.out.println("添加卡信息成功,卡信息记录集编号 : " + insert.stuCtrlRecordSetResult.nRecNo); | 302 | + log.info("添加卡信息成功,卡信息记录集编号 : "+ insert.stuCtrlRecordSetResult.nRecNo); |
| 271 | return insert.stuCtrlRecordSetResult.nRecNo; | 303 | return insert.stuCtrlRecordSetResult.nRecNo; |
| 272 | } | 304 | } |
| 273 | 305 | ||
| 274 | - | ||
| 275 | // return true; | 306 | // return true; |
| 276 | } | 307 | } |
| 277 | 308 | ||
| @@ -378,22 +409,21 @@ public class GateModule { | @@ -378,22 +409,21 @@ public class GateModule { | ||
| 378 | 409 | ||
| 379 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | 410 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); |
| 380 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | 411 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; |
| 381 | - int nChannel = 120; // 通道号 | 412 | + // 通道号 |
| 413 | + int nChannel = 120; | ||
| 382 | // msg.stuTimeWeekDay[0].stuTimeSection[0].dwRecordMask | 414 | // msg.stuTimeWeekDay[0].stuTimeSection[0].dwRecordMask |
| 383 | - String name = "4"; | 415 | + String name = "3"; |
| 384 | System.arraycopy(name.getBytes(), 0, msg.szName, 0, name.getBytes().length); | 416 | System.arraycopy(name.getBytes(), 0, msg.szName, 0, name.getBytes().length); |
| 385 | msg.bEnable = 1; | 417 | msg.bEnable = 1; |
| 386 | 418 | ||
| 387 | List<WeekDay> weekDays = permissionBean.getWeekDays(); | 419 | List<WeekDay> weekDays = permissionBean.getWeekDays(); |
| 388 | Map<Integer, List<WeekTime>> map = new HashMap<>(); | 420 | Map<Integer, List<WeekTime>> map = new HashMap<>(); |
| 389 | 421 | ||
| 390 | - for (WeekDay weekDay : | ||
| 391 | - weekDays) { | 422 | + for (WeekDay weekDay : weekDays) { |
| 392 | //整理时间 | 423 | //整理时间 |
| 393 | initWeedayAndTimes(weekDay, map); | 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 | int weekDayIndex = entry.getKey(); | 428 | int weekDayIndex = entry.getKey(); |
| 399 | 429 | ||
| @@ -632,7 +662,25 @@ public class GateModule { | @@ -632,7 +662,25 @@ public class GateModule { | ||
| 632 | return true; | 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 | int cardStatus, int cardType, int useTimes, int isFirstEnter, | 684 | int cardStatus, int cardType, int useTimes, int isFirstEnter, |
| 637 | int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { | 685 | int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { |
| 638 | /** | 686 | /** |
| @@ -717,29 +765,24 @@ public class GateModule { | @@ -717,29 +765,24 @@ public class GateModule { | ||
| 717 | CtrlType.CTRLTYPE_CTRL_RECORDSET_UPDATE, update.getPointer(), 5000); | 765 | CtrlType.CTRLTYPE_CTRL_RECORDSET_UPDATE, update.getPointer(), 5000); |
| 718 | update.read(); | 766 | update.read(); |
| 719 | accessCardInfo.read(); | 767 | accessCardInfo.read(); |
| 720 | - | 768 | + // 返回值:1成功,否则返回 |
| 721 | if (!bRet) { | 769 | if (!bRet) { |
| 722 | - //System.err.println("修改卡信息失败." + ToolKits.getErrorCodePrint()); | ||
| 723 | String ret=ToolKits.getErrorCodePrint(); | 770 | String ret=ToolKits.getErrorCodePrint(); |
| 771 | + //结果码 | ||
| 724 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | 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,8 +822,7 @@ public class GateModule { | ||
| 779 | msg.pBuf = new IntByReference(recordNo).getPointer(); | 822 | msg.pBuf = new IntByReference(recordNo).getPointer(); |
| 780 | 823 | ||
| 781 | msg.write(); | 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 | msg.read(); | 826 | msg.read(); |
| 785 | 827 | ||
| 786 | if (!bRet) { | 828 | if (!bRet) { |
| @@ -1036,12 +1078,10 @@ public class GateModule { | @@ -1036,12 +1078,10 @@ public class GateModule { | ||
| 1036 | * 打印具体的信息 | 1078 | * 打印具体的信息 |
| 1037 | */ | 1079 | */ |
| 1038 | for (int i = 0; i < nMaxNum; i++) { | 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 | } else { | 1083 | } else { |
| 1043 | - //System.err.println("删除用户失败, " + getErrorCode()); | ||
| 1044 | - System.err.println("删除用户失败, " + ToolKits.getErrorCodePrint()); | 1084 | + log.error("添加卡信息失败"+ ToolKits.getErrorCodePrint()); |
| 1045 | } | 1085 | } |
| 1046 | 1086 | ||
| 1047 | stIn.read(); | 1087 | stIn.read(); |
| @@ -1129,23 +1169,21 @@ public class GateModule { | @@ -1129,23 +1169,21 @@ public class GateModule { | ||
| 1129 | stIn.read(); | 1169 | stIn.read(); |
| 1130 | stOut.read(); | 1170 | stOut.read(); |
| 1131 | if (bRet) { | 1171 | if (bRet) { |
| 1132 | - System.out.println("添加人脸成功!"); | 1172 | + log.info("添加人脸成功!"); |
| 1133 | } else { | 1173 | } else { |
| 1134 | -// System.err.println("添加人脸失败!" + ToolKits.getErrorCodePrint()); | ||
| 1135 | String ret=ToolKits.getErrorCodePrint(); | 1174 | String ret=ToolKits.getErrorCodePrint(); |
| 1136 | - System.err.println("添加人脸失败!" + ret); | ||
| 1137 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | 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 | return false; | 1185 | return false; |
| 1147 | } | 1186 | } |
| 1148 | - | ||
| 1149 | return true; | 1187 | return true; |
| 1150 | } | 1188 | } |
| 1151 | 1189 | ||
| @@ -1187,7 +1225,7 @@ public class GateModule { | @@ -1187,7 +1225,7 @@ public class GateModule { | ||
| 1187 | stIn.read(); | 1225 | stIn.read(); |
| 1188 | stOut.read(); | 1226 | stOut.read(); |
| 1189 | if (bRet) { | 1227 | if (bRet) { |
| 1190 | - System.out.println("修改人脸成功!"); | 1228 | + log.info("修改人脸成功!"); |
| 1191 | } else { | 1229 | } else { |
| 1192 | // System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); | 1230 | // System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); |
| 1193 | String ret=ToolKits.getErrorCodePrint(); | 1231 | String ret=ToolKits.getErrorCodePrint(); |
| @@ -1200,7 +1238,7 @@ public class GateModule { | @@ -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 | int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_UPDATE; // 修改 | 1242 | int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_UPDATE; // 修改 |
| 1205 | 1243 | ||
| 1206 | /** | 1244 | /** |
| @@ -1230,22 +1268,16 @@ public class GateModule { | @@ -1230,22 +1268,16 @@ public class GateModule { | ||
| 1230 | boolean bRet = LoginModule.netsdk.CLIENT_FaceInfoOpreate(lLong, emType, stIn.getPointer(), stOut.getPointer(), 5000); | 1268 | boolean bRet = LoginModule.netsdk.CLIENT_FaceInfoOpreate(lLong, emType, stIn.getPointer(), stOut.getPointer(), 5000); |
| 1231 | stIn.read(); | 1269 | stIn.read(); |
| 1232 | stOut.read(); | 1270 | stOut.read(); |
| 1271 | + | ||
| 1233 | if (bRet) { | 1272 | if (bRet) { |
| 1234 | - System.out.println("修改人脸成功!"); | 1273 | + log.info("修改人脸成功!"); |
| 1235 | } else { | 1274 | } else { |
| 1236 | -// System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); | ||
| 1237 | String ret=ToolKits.getErrorCodePrint(); | 1275 | String ret=ToolKits.getErrorCodePrint(); |
| 1238 | - System.err.println("修改人脸失败!" + ret); | ||
| 1239 | String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | 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,6 +54,12 @@ public interface UserService { | ||
| 54 | */ | 54 | */ |
| 55 | boolean sendPermission(PermissionBean permissionBean); | 55 | boolean sendPermission(PermissionBean permissionBean); |
| 56 | 56 | ||
| 57 | + /** | ||
| 58 | + * 根据学籍号、学校id获取用户id | ||
| 59 | + * @param code | ||
| 60 | + * @param schoolId | ||
| 61 | + * @return | ||
| 62 | + */ | ||
| 57 | String getUserId(String code,String schoolId); | 63 | String getUserId(String code,String schoolId); |
| 58 | 64 | ||
| 59 | 65 |