人脸上传修改
This commit is contained in:
parent
48afdd77c1
commit
b3bb6e1dc9
|
|
@ -9,5 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Data
|
||||
public class FaceServiceProperties {
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
private String faceUrl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.bonus.bmw.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.bonus.bmw.domain.dto.PmWorkerDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.face.FaceResult;
|
||||
|
|
@ -159,10 +158,6 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
file = new File(newPath);
|
||||
//转成file
|
||||
MultipartFile multipartFile = CustomMultipartFile.convert(file);
|
||||
if (file.exists()) {
|
||||
boolean delete = file.delete();
|
||||
System.out.println("删除临时文件--->"+delete);
|
||||
}
|
||||
workerFiles[0] = multipartFile;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ import com.bonus.bmw.domain.face.UserInfo;
|
|||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
@ -185,7 +182,7 @@ public class FaceFeatureExtractorUtil {
|
|||
// 构建请求体 JSON
|
||||
JSONObject requestBody = JSONUtil.createObj().set("name", name).set("description", description); // Hutool 会自动忽略 null 值(不会序列化)
|
||||
try {
|
||||
HttpResponse response = HttpRequest.post(properties.getFaceUrl() + GROUP_ADD_PATH).body(requestBody.toString()) // 发送 JSON 字符串
|
||||
HttpResponse response = HttpRequest.post(properties.getBaseUrl() + GROUP_ADD_PATH).body(requestBody.toString()) // 发送 JSON 字符串
|
||||
.contentType("application/json") // 设置 Content-Type
|
||||
.timeout(5000) // 超时 5 秒
|
||||
.execute();
|
||||
|
|
@ -270,7 +267,7 @@ public class FaceFeatureExtractorUtil {
|
|||
return new FaceResult(500, "照片文件无效", null);
|
||||
}
|
||||
try {
|
||||
HttpRequest request = HttpRequest.post(properties.getFaceUrl() + USER_ADD_PATH)
|
||||
HttpRequest request = HttpRequest.post(properties.getBaseUrl() + USER_ADD_PATH)
|
||||
.form("name", idNumber)
|
||||
// Hutool 自动处理 multipart
|
||||
.form("photo", photoFile);
|
||||
|
|
@ -320,7 +317,7 @@ public class FaceFeatureExtractorUtil {
|
|||
return new FaceResult(500, "人员主键不能为空", null);
|
||||
}
|
||||
try {
|
||||
HttpRequest request = HttpRequest.post(properties.getFaceUrl() + USER_UPDATE_PATH +"/"+ id)
|
||||
HttpRequest request = HttpRequest.post(properties.getBaseUrl() + USER_UPDATE_PATH +"/"+ id)
|
||||
.form("name", idNumber); // 必填
|
||||
if (groupId != null) {
|
||||
request.form("groupId", groupId.toString());
|
||||
|
|
@ -363,7 +360,7 @@ public class FaceFeatureExtractorUtil {
|
|||
return new FaceResult(500, "分组Id不能为空", null);
|
||||
}
|
||||
try {
|
||||
HttpRequest request = HttpRequest.post(properties.getFaceUrl() + USER_SEARCH_PATH)
|
||||
HttpRequest request = HttpRequest.post(properties.getBaseUrl() + USER_SEARCH_PATH)
|
||||
.form("photo", photoFile)
|
||||
.form("groupId", groupId);
|
||||
HttpResponse response = request.timeout(10000).execute();
|
||||
|
|
@ -430,7 +427,7 @@ public class FaceFeatureExtractorUtil {
|
|||
*/
|
||||
public FaceResult getFaceUserList(String idNumber, Long groupId) {
|
||||
try {
|
||||
HttpRequest request = HttpRequest.get(properties.getFaceUrl() + USER_LIST_PATH);
|
||||
HttpRequest request = HttpRequest.get(properties.getBaseUrl() + USER_LIST_PATH);
|
||||
// 动态添加查询参数(仅当值有效时)
|
||||
if (idNumber != null && !idNumber.trim().isEmpty()) {
|
||||
request.form("name", idNumber.trim()); // Hutool GET 也支持 .form() 自动转 query
|
||||
|
|
|
|||
|
|
@ -27,5 +27,9 @@ jasypt:
|
|||
encryptor:
|
||||
password: Encrypt
|
||||
|
||||
#人脸
|
||||
face:
|
||||
path: http://112.29.103.165:1616/faceIdentification
|
||||
service:
|
||||
face-url: http://192.168.0.58:18000
|
||||
base-url: http://192.168.0.58:18080
|
||||
groupId: 1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 38084
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: Bonus@admin123!
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 192.168.0.58:18849
|
||||
namespace: huadong_realname_prod
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 192.168.0.58:18849
|
||||
namespace: huadong_realname_prod
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
Loading…
Reference in New Issue