|
|
@@ -15,6 +15,7 @@ import org.dromara.server.consume.service.FaceEngineService;
|
|
|
import org.dromara.server.consume.service.IPtArcFaceFeatureService;
|
|
|
import org.dromara.server.consume.service.IPtArcFaceKeyService;
|
|
|
import org.dromara.server.consume.service.IPtTermFaceVersionService;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
@@ -36,6 +37,11 @@ import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
public class ArcFaceBusiness {
|
|
|
+ @Value("${upload.upload-path}/") // 文件上传路径
|
|
|
+ private String uploadPath;
|
|
|
+ @Value("${upload.image.user}/") // 用户头像路径
|
|
|
+ private String userPath;
|
|
|
+
|
|
|
private final IPtTermFaceVersionService termFaceVersionService;
|
|
|
private final IPtArcFaceFeatureService arcFaceFeatureService;
|
|
|
private final IPtArcFaceKeyService arcFaceKeyService;
|
|
|
@@ -82,31 +88,32 @@ public class ArcFaceBusiness {
|
|
|
PtArcFaceFeatureVo vo = arcFaceFeatureService.getOneFeatureDataUser(userId);
|
|
|
// 人脸照片
|
|
|
ImageInfo imageInfo = null;
|
|
|
+ String featureData = "";
|
|
|
// 获取人员照片地址
|
|
|
RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoById(userId);
|
|
|
String photoUrl = ObjectUtil.isEmpty(accountVo.getPhoto()) ? "" : accountVo.getPhoto();
|
|
|
|
|
|
// 如果不存在或者已更新,则重新生成特征码
|
|
|
if (ObjectUtil.isEmpty(vo) || ObjectUtil.notEqual(photoUrl, vo.getPhotoUrl())) {
|
|
|
- String fileUrl = photoUrl;
|
|
|
+ String fileUrl = uploadPath + userPath +photoUrl;
|
|
|
File imageFile = new File(fileUrl);
|
|
|
if (!imageFile.exists()) {
|
|
|
return null;
|
|
|
}
|
|
|
imageInfo = getRGBData(imageFile);
|
|
|
- }
|
|
|
- if (imageInfo == null) {
|
|
|
- return null;
|
|
|
+ if (imageInfo == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ featureData = faceEngineService.createFeatureData(imageInfo);
|
|
|
+ if (ObjectUtil.isEmpty(featureData)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
// 生成特征码数据
|
|
|
- String featureData = faceEngineService.createFeatureData(imageInfo);
|
|
|
- if (ObjectUtil.isEmpty(featureData)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
if (ObjectUtil.isEmpty(vo)) {
|
|
|
PtArcFaceFeatureBo bo = new PtArcFaceFeatureBo();
|
|
|
bo.setUserId(userId);
|
|
|
- bo.setPhoto(photoUrl);
|
|
|
+ bo.setPhotoUrl(photoUrl);
|
|
|
bo.setFeatureData(featureData);
|
|
|
arcFaceFeatureService.insertByBo(bo);
|
|
|
} else if (ObjectUtil.notEqual(photoUrl, vo.getPhotoUrl())) {
|
|
|
@@ -114,6 +121,7 @@ public class ArcFaceBusiness {
|
|
|
}
|
|
|
// 重新从数据中获取数据
|
|
|
vo = arcFaceFeatureService.getOneFeatureDataUser(userId);
|
|
|
+ vo.setUserNo(accountVo.getUserNo().toString());
|
|
|
return MapstructUtils.convert(vo, YcFaceFeatureVo.class);
|
|
|
}
|
|
|
|