Commit ab1437f82f83280643d6caf8b5609c4932326646
1 parent
718fcb62
Exists in
master
下发失败人脸接口代码提交
Showing
4 changed files
with
112 additions
and
0 deletions
Show diff stats
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java
@@ -83,6 +83,12 @@ public class UserOperateController { | @@ -83,6 +83,12 @@ public class UserOperateController { | ||
83 | return userOperateService.sendFailFace(schoolId); | 83 | return userOperateService.sendFailFace(schoolId); |
84 | } | 84 | } |
85 | 85 | ||
86 | + @RequestMapping(value = "sendFailFace2", method = RequestMethod.POST) | ||
87 | + @ApiOperation(value = "重新下发失败人脸2.1") | ||
88 | + public Result sendFailFace(@RequestParam("schoolId") Integer schoolId,@RequestParam(value = "deviceIds",required = false) String deviceIds) { | ||
89 | + return userOperateService.sendFailFace2(schoolId,deviceIds); | ||
90 | + } | ||
91 | + | ||
86 | @ApiOperation(value = "删除指定人脸2.0") | 92 | @ApiOperation(value = "删除指定人脸2.0") |
87 | @RequestMapping(value = "deleteFace", method = RequestMethod.POST) | 93 | @RequestMapping(value = "deleteFace", method = RequestMethod.POST) |
88 | public Result deleteFace(@RequestParam("schoolId") Integer schoolId, @RequestParam("cards") String cards, | 94 | public Result deleteFace(@RequestParam("schoolId") Integer schoolId, @RequestParam("cards") String cards, |
cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java
@@ -72,6 +72,8 @@ public interface UserOperateService { | @@ -72,6 +72,8 @@ public interface UserOperateService { | ||
72 | */ | 72 | */ |
73 | Result sendFailFace(Integer schoolId); | 73 | Result sendFailFace(Integer schoolId); |
74 | 74 | ||
75 | + Result sendFailFace2(Integer schoolId,String deviceIds); | ||
76 | + | ||
75 | /** | 77 | /** |
76 | * 删除指定人脸 | 78 | * 删除指定人脸 |
77 | * @param schoolId | 79 | * @param schoolId |
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java
@@ -458,6 +458,107 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -458,6 +458,107 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
458 | return ResultGenerator.genSuccessResult(); | 458 | return ResultGenerator.genSuccessResult(); |
459 | } | 459 | } |
460 | 460 | ||
461 | + | ||
462 | + @Override | ||
463 | + public Result sendFailFace2(Integer schoolId,String deviceIds) { | ||
464 | + if(schoolId ==null){ | ||
465 | + return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空"); | ||
466 | + } | ||
467 | + List<SendRecordBean> resultList = new ArrayList<>(); | ||
468 | + if(StringUtils.isNotBlank(deviceIds)){ | ||
469 | + //设备集合 | ||
470 | + String[] deviceArr = deviceIds.split(","); | ||
471 | + List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr)); | ||
472 | + for(String deviceId : deviceList){ | ||
473 | + List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord2(schoolId,deviceId); | ||
474 | + resultList.addAll(recordBeanList); | ||
475 | + } | ||
476 | + }else{ | ||
477 | + List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId); | ||
478 | + resultList.addAll(recordBeanList); | ||
479 | + } | ||
480 | + if(resultList.size()>0){ | ||
481 | + for(SendRecordBean recordBean : resultList){ | ||
482 | + try{ | ||
483 | + //用户类型1老师2学生 | ||
484 | + int userType = recordBean.getUserType(); | ||
485 | + //人脸卡号 | ||
486 | + String cardNum = recordBean.getNum(); | ||
487 | + //设备ID、设备类型 | ||
488 | + String deviceId = recordBean.getDeviceID(); | ||
489 | + Integer clintType = userDao.getClintTypeByDeviceId(deviceId); | ||
490 | + //2.重新下发 | ||
491 | + StudentBean studentBean= null; | ||
492 | + String typeName =""; | ||
493 | + String photo = ""; | ||
494 | + if(userType ==1){ | ||
495 | + typeName= "Teacher"; | ||
496 | + studentBean = userDao.getTeacherWithCard(cardNum,schoolId); | ||
497 | + photo=studentBean.getFace(); | ||
498 | + }else{ | ||
499 | + typeName= "Student"; | ||
500 | + studentBean= userDao.getStudentWithCard(cardNum,schoolId); | ||
501 | + photo=studentBean.getPhoto(); | ||
502 | + } | ||
503 | + if(studentBean==null|| StringUtils.isBlank(photo)){ | ||
504 | + continue; | ||
505 | + } | ||
506 | + String userName= studentBean.getName(); | ||
507 | + String studentCode = studentBean.getStudentCode(); | ||
508 | + String filePath=""; | ||
509 | + //下发海康人脸 | ||
510 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
511 | + //1.先删除人脸 | ||
512 | + if (cmsServer.getIsDeviceOnline(deviceId)) { | ||
513 | + String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + ""; | ||
514 | + cmsServer.deleteFace(deviceId, cardNo,schoolId); | ||
515 | + }else{ | ||
516 | + //不在线,去253服务器上删除 | ||
517 | + HttpUtil.deleteCard(deviceId, cardNum); | ||
518 | + } | ||
519 | + //以学籍号为名的文件名 | ||
520 | + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); | ||
521 | + //100服务器人脸照绝对路径 | ||
522 | + String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
523 | + String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; | ||
524 | + String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; | ||
525 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
526 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
527 | + filePath= path_3 + afterStr; | ||
528 | + } | ||
529 | + if(photo.indexOf("face17e5")!=-1){ | ||
530 | + filePath = path_2 + "\\" + fileName; | ||
531 | + } | ||
532 | + if(photo.indexOf("face17e50")!=-1){ | ||
533 | + filePath = path_1 + "\\" + fileName; | ||
534 | + } | ||
535 | + File file = new File(filePath);//图片 | ||
536 | + if(file.exists()){ | ||
537 | + String targetPath = FileUtils.picPathComp + file.getName(); | ||
538 | + try { | ||
539 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); | ||
540 | + } catch (Exception e) { | ||
541 | + log.error("压缩图片失败:",e); | ||
542 | + continue; | ||
543 | + } | ||
544 | + if(!StringUtils.isBlank(cardNum)) { | ||
545 | + baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); | ||
546 | + } | ||
547 | + } | ||
548 | + } | ||
549 | + //下发大华人脸 | ||
550 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
551 | + HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId); | ||
552 | + } | ||
553 | + }catch (Exception e){ | ||
554 | + log.error("下发失败表人脸失败,异常信息:{}",e); | ||
555 | + continue; | ||
556 | + } | ||
557 | + } | ||
558 | + } | ||
559 | + return ResultGenerator.genSuccessResult(); | ||
560 | + } | ||
561 | + | ||
461 | @Override | 562 | @Override |
462 | public Result deleteFace(Integer schoolId,String cards,String deviceIds) { | 563 | public Result deleteFace(Integer schoolId,String cards,String deviceIds) { |
463 | if(StringUtils.isBlank(cards)){ | 564 | if(StringUtils.isBlank(cards)){ |
cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java
@@ -77,6 +77,9 @@ public interface SendRecordDao { | @@ -77,6 +77,9 @@ public interface SendRecordDao { | ||
77 | @Select("select * from Face_SendRecord where schoolId = #{schoolId} and status =2") | 77 | @Select("select * from Face_SendRecord where schoolId = #{schoolId} and status =2") |
78 | List<SendRecordBean> getFailRecord(@Param("schoolId") Integer schoolId); | 78 | List<SendRecordBean> getFailRecord(@Param("schoolId") Integer schoolId); |
79 | 79 | ||
80 | + @Select("select * from Face_SendRecord where schoolId = #{schoolId} and deviceID = #{deviceId} and status =2") | ||
81 | + List<SendRecordBean> getFailRecord2(@Param("schoolId") Integer schoolId,@Param("deviceId") String deviceId); | ||
82 | + | ||
80 | @Select("select * from Face_SendRecord where schoolId = #{schoolId}") | 83 | @Select("select * from Face_SendRecord where schoolId = #{schoolId}") |
81 | List<SendRecordBean> getFaceRecord(@Param("schoolId") Integer schoolId); | 84 | List<SendRecordBean> getFaceRecord(@Param("schoolId") Integer schoolId); |
82 | 85 |