Commit 20c3076e78a9286121032602dfca01f446699a1a
1 parent
ab1437f8
Exists in
master
下发失败人脸接口代码提交
Showing
6 changed files
with
63 additions
and
24 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java
@@ -87,8 +87,8 @@ public class UserOperateController { | @@ -87,8 +87,8 @@ public class UserOperateController { | ||
87 | @ApiOperation(value = "按班级指定下发") | 87 | @ApiOperation(value = "按班级指定下发") |
88 | @RequestMapping(value = "sendFaceByClassId", method = RequestMethod.POST) | 88 | @RequestMapping(value = "sendFaceByClassId", method = RequestMethod.POST) |
89 | public void exportFace(@RequestParam("schoolId") Integer schoolId, | 89 | public void exportFace(@RequestParam("schoolId") Integer schoolId, |
90 | - @RequestParam(value = "classIds",required = false) String classIds, | ||
91 | - @RequestParam(value = "deviceIds",required = false) String deviceIds){ | 90 | + @RequestParam(value = "classIds",required = false) String classIds, |
91 | + @RequestParam(value = "deviceIds",required = false) String deviceIds){ | ||
92 | userOperateService.sendFaceByClassId(schoolId,classIds,deviceIds); | 92 | userOperateService.sendFaceByClassId(schoolId,classIds,deviceIds); |
93 | } | 93 | } |
94 | 94 |
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java
@@ -108,22 +108,27 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -108,22 +108,27 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
108 | if(photo.indexOf("face17e50")!=-1){ | 108 | if(photo.indexOf("face17e50")!=-1){ |
109 | filePath = path_1 + "\\" + fileName; | 109 | filePath = path_1 + "\\" + fileName; |
110 | } | 110 | } |
111 | + if(filePath.indexOf("?v=")!=-1){ | ||
112 | + filePath = filePath.split("\\?")[0]; | ||
113 | + } | ||
111 | log.info("学籍号:{},人脸路径:{}, ",studentCode,filePath); | 114 | log.info("学籍号:{},人脸路径:{}, ",studentCode,filePath); |
112 | //100服务人脸照图片路径 | 115 | //100服务人脸照图片路径 |
113 | File file = new File(filePath); | 116 | File file = new File(filePath); |
114 | - if(file.exists()){ | ||
115 | - String targetPath = FilePath.picPathComp+ file.getName(); | ||
116 | - try { | ||
117 | - CompressPic.CompressPic(file.getAbsolutePath(), targetPath,""); | ||
118 | - } catch (Exception e) { | ||
119 | - log.error("压缩图片失败"); | ||
120 | - e.printStackTrace(); | ||
121 | - continue; | ||
122 | - } | ||
123 | - for(String sno : deviceList){ | ||
124 | - String clint_type = userDao.getClintType(sno); | ||
125 | - HttpUtils.uploadImgs(new File(targetPath), String.valueOf(schoolId), studentCode, clint_type, userType, sno); | ||
126 | - } | 117 | + if (!file.exists()) { |
118 | + log.error("文件不存在:" + filePath); | ||
119 | + continue; | ||
120 | + } | ||
121 | + String targetPath = FilePath.picPathComp+ file.getName(); | ||
122 | + try { | ||
123 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath,""); | ||
124 | + } catch (Exception e) { | ||
125 | + log.error("压缩图片失败"); | ||
126 | + e.printStackTrace(); | ||
127 | + continue; | ||
128 | + } | ||
129 | + for(String sno : deviceList){ | ||
130 | + String clint_type = userDao.getClintType(sno); | ||
131 | + HttpUtils.uploadImgs(new File(targetPath), String.valueOf(schoolId), studentCode, clint_type, userType, sno); | ||
127 | } | 132 | } |
128 | }catch (Exception e){ | 133 | }catch (Exception e){ |
129 | log.error("人脸下发失败"); | 134 | log.error("人脸下发失败"); |
@@ -133,6 +138,15 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -133,6 +138,15 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
133 | } | 138 | } |
134 | } | 139 | } |
135 | 140 | ||
141 | + public static void main(String[] args) { | ||
142 | + File file = new File("http://campus.myjxt.com//face17e5/School1485/Student/202170214.png?v=1635478750130"); | ||
143 | + if (!file.isFile()) { | ||
144 | + System.out.println(false); | ||
145 | + }else{ | ||
146 | + System.out.println(true); | ||
147 | + } | ||
148 | + } | ||
149 | + | ||
136 | @Override | 150 | @Override |
137 | public void test6(Integer schoolId, Integer roomId, Integer type, Integer outof, String intime, String clintId, String startTime, String endTime) { | 151 | public void test6(Integer schoolId, Integer roomId, Integer type, Integer outof, String intime, String clintId, String startTime, String endTime) { |
138 | List<String> studentIds = userDao.queryStudentIdList(schoolId,roomId); | 152 | List<String> studentIds = userDao.queryStudentIdList(schoolId,roomId); |
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
@@ -67,7 +67,7 @@ public class CMSServer implements ApplicationRunner { | @@ -67,7 +67,7 @@ public class CMSServer implements ApplicationRunner { | ||
67 | //114.55.30.100 | 67 | //114.55.30.100 |
68 | //120.26.116.253 | 68 | //120.26.116.253 |
69 | // private String ip_cloud = "114.55.30.100"; | 69 | // private String ip_cloud = "114.55.30.100"; |
70 | - private String ip_cloud = "120.26.116.253"; | 70 | + private String ip_cloud = "114.55.30.100"; |
71 | 71 | ||
72 | private String ip; | 72 | private String ip; |
73 | { | 73 | { |
@@ -290,7 +290,6 @@ public class CMSServer implements ApplicationRunner { | @@ -290,7 +290,6 @@ public class CMSServer implements ApplicationRunner { | ||
290 | // int type = pInBuffer.dwAlarmServerType; | 290 | // int type = pInBuffer.dwAlarmServerType; |
291 | // int picServerType = pInBuffer.dwPicServerType; | 291 | // int picServerType = pInBuffer.dwPicServerType; |
292 | // System.out.println("type=" + type + " picType=" + picServerType); | 292 | // System.out.println("type=" + type + " picType=" + picServerType); |
293 | - | ||
294 | } else if (3 == enumType) { | 293 | } else if (3 == enumType) { |
295 | } | 294 | } |
296 | return true; | 295 | return true; |
@@ -300,7 +299,7 @@ public class CMSServer implements ApplicationRunner { | @@ -300,7 +299,7 @@ public class CMSServer implements ApplicationRunner { | ||
300 | //文件保存回调函数(下载) | 299 | //文件保存回调函数(下载) |
301 | public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack { | 300 | public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack { |
302 | public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { | 301 | public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { |
303 | - String strPath = "D://EhomePicServer/"; | 302 | + String strPath = "E://EhomePicServer/"; |
304 | //若此目录不存在,则创建之 | 303 | //若此目录不存在,则创建之 |
305 | File myPath = new File(strPath); | 304 | File myPath = new File(strPath); |
306 | if (!myPath.exists()) { | 305 | if (!myPath.exists()) { |
@@ -422,7 +421,6 @@ public class CMSServer implements ApplicationRunner { | @@ -422,7 +421,6 @@ public class CMSServer implements ApplicationRunner { | ||
422 | } | 421 | } |
423 | }); | 422 | }); |
424 | } else { | 423 | } else { |
425 | - log.info("处理报警进来了"); | ||
426 | //处理报警事件 | 424 | //处理报警事件 |
427 | alarmUtils.deleAlarm(strXML); | 425 | alarmUtils.deleAlarm(strXML); |
428 | } | 426 | } |
@@ -490,7 +488,6 @@ public class CMSServer implements ApplicationRunner { | @@ -490,7 +488,6 @@ public class CMSServer implements ApplicationRunner { | ||
490 | String imgUrl = "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + picDataUrlId; | 488 | String imgUrl = "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + picDataUrlId; |
491 | face_recoder.setImgurl(imgUrl); | 489 | face_recoder.setImgurl(imgUrl); |
492 | log.info("设备: {},人脸抓怕:学校id: {} ,班级:{} ,用户名:{} ,卡号:{} ,",deviceID,schoolId,className,name,cardNo); | 490 | log.info("设备: {},人脸抓怕:学校id: {} ,班级:{} ,用户名:{} ,卡号:{} ,",deviceID,schoolId,className,name,cardNo); |
493 | - log.info("抓拍人脸:" + imgUrl); | ||
494 | if (!TextUtils.isEmpty(currTemperature)) {//只有有温度的才存记录 | 491 | if (!TextUtils.isEmpty(currTemperature)) {//只有有温度的才存记录 |
495 | userDao.addWGTem(studentBean.getUser_id(), studentBean.getStudent_id(), studentBean.getName(), studentBean.getClass_id() + "", | 492 | userDao.addWGTem(studentBean.getUser_id(), studentBean.getStudent_id(), studentBean.getName(), studentBean.getClass_id() + "", |
496 | studentBean.getClass_name(), currTemperature, studentBean.getStudent_type() + "", studentBean.getSchool_id() + "", time); | 493 | studentBean.getClass_name(), currTemperature, studentBean.getStudent_type() + "", studentBean.getSchool_id() + "", time); |
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java
@@ -235,6 +235,9 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -235,6 +235,9 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
235 | if(photo.indexOf("face17e50")!=-1){ | 235 | if(photo.indexOf("face17e50")!=-1){ |
236 | filePath = path_1 + "\\" + fileName; | 236 | filePath = path_1 + "\\" + fileName; |
237 | } | 237 | } |
238 | + if(filePath.indexOf("?v=")!=-1){ | ||
239 | + filePath = filePath.split("\\?")[0]; | ||
240 | + } | ||
238 | //校验100服务文件存储地址上是否存在此人脸 | 241 | //校验100服务文件存储地址上是否存在此人脸 |
239 | File file = new File(filePath.trim());//图片 | 242 | File file = new File(filePath.trim());//图片 |
240 | if (!file.exists()) { | 243 | if (!file.exists()) { |
@@ -431,6 +434,9 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -431,6 +434,9 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
431 | if(photo.indexOf("face17e50")!=-1){ | 434 | if(photo.indexOf("face17e50")!=-1){ |
432 | filePath = path_1 + "\\" + fileName; | 435 | filePath = path_1 + "\\" + fileName; |
433 | } | 436 | } |
437 | + if(filePath.indexOf("?v=")!=-1){ | ||
438 | + filePath = filePath.split("\\?")[0]; | ||
439 | + } | ||
434 | File file = new File(filePath);//图片 | 440 | File file = new File(filePath);//图片 |
435 | if(file.exists()){ | 441 | if(file.exists()){ |
436 | String targetPath = FileUtils.picPathComp + file.getName(); | 442 | String targetPath = FileUtils.picPathComp + file.getName(); |
@@ -532,6 +538,9 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -532,6 +538,9 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
532 | if(photo.indexOf("face17e50")!=-1){ | 538 | if(photo.indexOf("face17e50")!=-1){ |
533 | filePath = path_1 + "\\" + fileName; | 539 | filePath = path_1 + "\\" + fileName; |
534 | } | 540 | } |
541 | + if(filePath.indexOf("?v=")!=-1){ | ||
542 | + filePath = filePath.split("\\?")[0]; | ||
543 | + } | ||
535 | File file = new File(filePath);//图片 | 544 | File file = new File(filePath);//图片 |
536 | if(file.exists()){ | 545 | if(file.exists()){ |
537 | String targetPath = FileUtils.picPathComp + file.getName(); | 546 | String targetPath = FileUtils.picPathComp + file.getName(); |
@@ -967,9 +976,17 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -967,9 +976,17 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
967 | //去重重复数据 | 976 | //去重重复数据 |
968 | deviceList = resultDevices.stream().distinct().collect(Collectors.toList()); | 977 | deviceList = resultDevices.stream().distinct().collect(Collectors.toList()); |
969 | } | 978 | } |
970 | - //发送海康设备:异步执行 | ||
971 | - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList); | ||
972 | - | 979 | + log.info("统计共有下发用户数量:{}",studentBeanList.size()); |
980 | + //设备类型 | ||
981 | + Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0)); | ||
982 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
983 | + //发送大华设备 | ||
984 | + HttpUtil.uploadDHImgByClassId(String.valueOf(schoolId),deviceIds,classIds); | ||
985 | + } | ||
986 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
987 | + //发送海康设备:异步执行 | ||
988 | + baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList); | ||
989 | + } | ||
973 | int fileSize = studentBeanList.size(); | 990 | int fileSize = studentBeanList.size(); |
974 | int clintNum = deviceList.size(); | 991 | int clintNum = deviceList.size(); |
975 | //下发所用时长 | 992 | //下发所用时长 |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java
@@ -331,7 +331,6 @@ public class AlarmUtils { | @@ -331,7 +331,6 @@ public class AlarmUtils { | ||
331 | faceWaterRecoder.setTime(time); | 331 | faceWaterRecoder.setTime(time); |
332 | faceWaterRecoder.setCardNo(cardNo); | 332 | faceWaterRecoder.setCardNo(cardNo); |
333 | faceWaterRecoder.setSystime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | 333 | faceWaterRecoder.setSystime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
334 | - log.info("保存流水记录,流水信息: {}",objectMapper.toJson(faceWaterRecoder)); | ||
335 | deviceDao.saveFaceWaterRecoder(faceWaterRecoder.getDeviceId(), faceWaterRecoder.getDeviceType() + "", faceWaterRecoder.getMinorType(), | 334 | deviceDao.saveFaceWaterRecoder(faceWaterRecoder.getDeviceId(), faceWaterRecoder.getDeviceType() + "", faceWaterRecoder.getMinorType(), |
336 | faceWaterRecoder.getContent(), faceWaterRecoder.getMajorType(), faceWaterRecoder.getTime(), faceWaterRecoder.getCardNo(), faceWaterRecoder.getSystime()); | 335 | faceWaterRecoder.getContent(), faceWaterRecoder.getMajorType(), faceWaterRecoder.getTime(), faceWaterRecoder.getCardNo(), faceWaterRecoder.getSystime()); |
337 | } | 336 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java
@@ -300,6 +300,18 @@ public class HttpUtil { | @@ -300,6 +300,18 @@ public class HttpUtil { | ||
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | + public static void uploadDHImgByClassId(String schoolId,String deviceIds,String classIds) { | ||
304 | + String api = "http://114.55.30.100:8991/operate/sendFaceByClassId"; | ||
305 | + try { | ||
306 | + String url = String.format(api +"?schoolId=%s&deviceIds=%s&classIds%s",schoolId,deviceIds,classIds); | ||
307 | + RestTemplate restTemplate = new RestTemplate(); | ||
308 | + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
309 | + log.info("发送请求,照片下发至大华设备,请求地址:{},返回信息: {}",url,responseEntity.getBody()); | ||
310 | + } catch (Exception e) { | ||
311 | + log.error("发送请求,照片下发至大华设备,异常信息:{}",e); | ||
312 | + } | ||
313 | + } | ||
314 | + | ||
303 | /** | 315 | /** |
304 | * 删除大华设备人脸 | 316 | * 删除大华设备人脸 |
305 | * @param schoolId | 317 | * @param schoolId |