From 1ed9ec8f0a174fa64ffe7b77ba708773ea0c40ed Mon Sep 17 00:00:00 2001 From: guoshengxiong <1923636941@qq.com> Date: Wed, 29 May 2024 19:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E8=84=B8=E8=AF=84=E5=88=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UfaceRecognitionController.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/controller/UfaceRecognitionController.java b/src/main/java/com/zhgd/xmgl/modules/worker/controller/UfaceRecognitionController.java index 117f25951..25bebcd09 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/controller/UfaceRecognitionController.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/controller/UfaceRecognitionController.java @@ -15,6 +15,7 @@ import com.zhgd.xmgl.modules.project.entity.Project; import com.zhgd.xmgl.modules.project.mapper.ProjectMapper; import com.zhgd.xmgl.modules.worker.entity.WorkerInfo; import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService; +import com.zhgd.xmgl.util.Base64Util; import com.zhgd.xmgl.util.MessageUtil; import com.zhgd.xmgl.util.PathUtil; import io.swagger.annotations.Api; @@ -118,12 +119,15 @@ public class UfaceRecognitionController { } JSONObject param = new JSONObject(); String fileUrl = MapUtils.getString(map, "fileUrl"); - if (StrUtil.isBlank(fileUrl)) { - throw new OpenAlertException("fileUrl不能为空"); + String facePicBinaryData = MapUtils.getString(map, "facePicBinaryData"); + if (StrUtil.isBlank(fileUrl) && StrUtil.isBlank(facePicBinaryData)) { + throw new OpenAlertException("fileUrl和facePicBinaryData不能同时为空"); + } + if (StrUtil.isNotBlank(fileUrl)) { + param.put("facePicUrl", PathUtil.reviseSlash(imageUrlPrefix + "/" + fileUrl)); + } else { + param.put("facePicBinaryData", Base64Util.convertFileToBase64(PathUtil.reviseSlash(basePath + "/" + fileUrl))); } - //base64可能卡 - //param.put("facePicBinaryData", Base64Util.convertFileToBase64(PathUtil.reviseSlash(basePath + "/" + fileUrl))); - param.put("facePicUrl", PathUtil.reviseSlash(imageUrlPrefix + "/" + fileUrl)); boolean b = hikvisionCall.faceScore(project, param); //boolean b = true; if (b) {