From 20c3076e78a9286121032602dfca01f446699a1a Mon Sep 17 00:00:00 2001 From: xuquan <1099815072@qq.com> Date: Mon, 15 Nov 2021 17:18:36 +0800 Subject: [PATCH] 下发失败人脸接口代码提交 --- cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java | 4 ++-- cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java | 40 +++++++++++++++++++++++++++------------- cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java | 7 ++----- cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java | 23 ++++++++++++++++++++--- cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java | 1 - cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java | 12 ++++++++++++ 6 files changed, 63 insertions(+), 24 deletions(-) diff --git a/cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java b/cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java index cdaf5bb..f1a5b27 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java +++ b/cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java @@ -87,8 +87,8 @@ public class UserOperateController { @ApiOperation(value = "按班级指定下发") @RequestMapping(value = "sendFaceByClassId", method = RequestMethod.POST) public void exportFace(@RequestParam("schoolId") Integer schoolId, - @RequestParam(value = "classIds",required = false) String classIds, - @RequestParam(value = "deviceIds",required = false) String deviceIds){ + @RequestParam(value = "classIds",required = false) String classIds, + @RequestParam(value = "deviceIds",required = false) String deviceIds){ userOperateService.sendFaceByClassId(schoolId,classIds,deviceIds); } diff --git a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java index 46afabc..685df08 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java +++ b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java @@ -108,22 +108,27 @@ public class UserOperateServiceImpl implements UserOperateService { if(photo.indexOf("face17e50")!=-1){ filePath = path_1 + "\\" + fileName; } + if(filePath.indexOf("?v=")!=-1){ + filePath = filePath.split("\\?")[0]; + } log.info("学籍号:{},人脸路径:{}, ",studentCode,filePath); //100服务人脸照图片路径 File file = new File(filePath); - if(file.exists()){ - String targetPath = FilePath.picPathComp+ file.getName(); - try { - CompressPic.CompressPic(file.getAbsolutePath(), targetPath,""); - } catch (Exception e) { - log.error("压缩图片失败"); - e.printStackTrace(); - continue; - } - for(String sno : deviceList){ - String clint_type = userDao.getClintType(sno); - HttpUtils.uploadImgs(new File(targetPath), String.valueOf(schoolId), studentCode, clint_type, userType, sno); - } + if (!file.exists()) { + log.error("文件不存在:" + filePath); + continue; + } + String targetPath = FilePath.picPathComp+ file.getName(); + try { + CompressPic.CompressPic(file.getAbsolutePath(), targetPath,""); + } catch (Exception e) { + log.error("压缩图片失败"); + e.printStackTrace(); + continue; + } + for(String sno : deviceList){ + String clint_type = userDao.getClintType(sno); + HttpUtils.uploadImgs(new File(targetPath), String.valueOf(schoolId), studentCode, clint_type, userType, sno); } }catch (Exception e){ log.error("人脸下发失败"); @@ -133,6 +138,15 @@ public class UserOperateServiceImpl implements UserOperateService { } } + public static void main(String[] args) { + File file = new File("http://campus.myjxt.com//face17e5/School1485/Student/202170214.png?v=1635478750130"); + if (!file.isFile()) { + System.out.println(false); + }else{ + System.out.println(true); + } + } + @Override public void test6(Integer schoolId, Integer roomId, Integer type, Integer outof, String intime, String clintId, String startTime, String endTime) { List studentIds = userDao.queryStudentIdList(schoolId,roomId); diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java index 3eec45c..8aa8e5a 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java @@ -67,7 +67,7 @@ public class CMSServer implements ApplicationRunner { //114.55.30.100 //120.26.116.253 // private String ip_cloud = "114.55.30.100"; - private String ip_cloud = "120.26.116.253"; + private String ip_cloud = "114.55.30.100"; private String ip; { @@ -290,7 +290,6 @@ public class CMSServer implements ApplicationRunner { // int type = pInBuffer.dwAlarmServerType; // int picServerType = pInBuffer.dwPicServerType; // System.out.println("type=" + type + " picType=" + picServerType); - } else if (3 == enumType) { } return true; @@ -300,7 +299,7 @@ public class CMSServer implements ApplicationRunner { //文件保存回调函数(下载) public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack { public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { - String strPath = "D://EhomePicServer/"; + String strPath = "E://EhomePicServer/"; //若此目录不存在,则创建之 File myPath = new File(strPath); if (!myPath.exists()) { @@ -422,7 +421,6 @@ public class CMSServer implements ApplicationRunner { } }); } else { - log.info("处理报警进来了"); //处理报警事件 alarmUtils.deleAlarm(strXML); } @@ -490,7 +488,6 @@ public class CMSServer implements ApplicationRunner { String imgUrl = "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + picDataUrlId; face_recoder.setImgurl(imgUrl); log.info("设备: {},人脸抓怕:学校id: {} ,班级:{} ,用户名:{} ,卡号:{} ,",deviceID,schoolId,className,name,cardNo); - log.info("抓拍人脸:" + imgUrl); if (!TextUtils.isEmpty(currTemperature)) {//只有有温度的才存记录 userDao.addWGTem(studentBean.getUser_id(), studentBean.getStudent_id(), studentBean.getName(), studentBean.getClass_id() + "", studentBean.getClass_name(), currTemperature, studentBean.getStudent_type() + "", studentBean.getSchool_id() + "", time); diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java index c15b98d..27a9966 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java @@ -235,6 +235,9 @@ public class UserOperateServiceImpl implements UserOperateService { if(photo.indexOf("face17e50")!=-1){ filePath = path_1 + "\\" + fileName; } + if(filePath.indexOf("?v=")!=-1){ + filePath = filePath.split("\\?")[0]; + } //校验100服务文件存储地址上是否存在此人脸 File file = new File(filePath.trim());//图片 if (!file.exists()) { @@ -431,6 +434,9 @@ public class UserOperateServiceImpl implements UserOperateService { if(photo.indexOf("face17e50")!=-1){ filePath = path_1 + "\\" + fileName; } + if(filePath.indexOf("?v=")!=-1){ + filePath = filePath.split("\\?")[0]; + } File file = new File(filePath);//图片 if(file.exists()){ String targetPath = FileUtils.picPathComp + file.getName(); @@ -532,6 +538,9 @@ public class UserOperateServiceImpl implements UserOperateService { if(photo.indexOf("face17e50")!=-1){ filePath = path_1 + "\\" + fileName; } + if(filePath.indexOf("?v=")!=-1){ + filePath = filePath.split("\\?")[0]; + } File file = new File(filePath);//图片 if(file.exists()){ String targetPath = FileUtils.picPathComp + file.getName(); @@ -967,9 +976,17 @@ public class UserOperateServiceImpl implements UserOperateService { //去重重复数据 deviceList = resultDevices.stream().distinct().collect(Collectors.toList()); } - //发送海康设备:异步执行 - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList); - + log.info("统计共有下发用户数量:{}",studentBeanList.size()); + //设备类型 + Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0)); + if(clintType.intValue()== 22 || clintType.intValue()== 29){ + //发送大华设备 + HttpUtil.uploadDHImgByClassId(String.valueOf(schoolId),deviceIds,classIds); + } + if(clintType.intValue()== 18 || clintType.intValue()== 28){ + //发送海康设备:异步执行 + baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList); + } int fileSize = studentBeanList.size(); int clintNum = deviceList.size(); //下发所用时长 diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java index 9a6056a..5a28bfe 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java @@ -331,7 +331,6 @@ public class AlarmUtils { faceWaterRecoder.setTime(time); faceWaterRecoder.setCardNo(cardNo); faceWaterRecoder.setSystime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); - log.info("保存流水记录,流水信息: {}",objectMapper.toJson(faceWaterRecoder)); deviceDao.saveFaceWaterRecoder(faceWaterRecoder.getDeviceId(), faceWaterRecoder.getDeviceType() + "", faceWaterRecoder.getMinorType(), faceWaterRecoder.getContent(), faceWaterRecoder.getMajorType(), faceWaterRecoder.getTime(), faceWaterRecoder.getCardNo(), faceWaterRecoder.getSystime()); } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java index 2306883..bd08264 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java @@ -300,6 +300,18 @@ public class HttpUtil { } } + public static void uploadDHImgByClassId(String schoolId,String deviceIds,String classIds) { + String api = "http://114.55.30.100:8991/operate/sendFaceByClassId"; + try { + String url = String.format(api +"?schoolId=%s&deviceIds=%s&classIds%s",schoolId,deviceIds,classIds); + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity responseEntity = restTemplate.getForEntity(url, String.class); + log.info("发送请求,照片下发至大华设备,请求地址:{},返回信息: {}",url,responseEntity.getBody()); + } catch (Exception e) { + log.error("发送请求,照片下发至大华设备,异常信息:{}",e); + } + } + /** * 删除大华设备人脸 * @param schoolId -- libgit2 0.21.0