|
|
@@ -8,6 +8,7 @@ import com.arcsoft.face.toolkit.ImageInfo;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import me.zhengjie.base.ResultCode;
|
|
|
+import me.zhengjie.base.file.FaceMinioFileHandle;
|
|
|
import me.zhengjie.base.file.FileHandleVo;
|
|
|
import me.zhengjie.base.file.MinioFileHandle;
|
|
|
import me.zhengjie.base.util.JuheServiceUtil;
|
|
|
@@ -18,22 +19,16 @@ import me.zhengjie.dao.mybatis.entity.UserAXQInfoEntity;
|
|
|
import me.zhengjie.dao.mybatis.mapper.FileInfoMapper;
|
|
|
import me.zhengjie.dao.mybatis.mapper.SysUserMapper;
|
|
|
import me.zhengjie.dao.mybatis.mapper.UserAXQInfoMapper;
|
|
|
-import me.zhengjie.domain.Jvhe.JuheDomain;
|
|
|
-import me.zhengjie.domain.Jvhe.ResultDomain;
|
|
|
import me.zhengjie.domain.img.CompareImageDomain;
|
|
|
import me.zhengjie.domain.notary.NotaryDomain;
|
|
|
-import me.zhengjie.sign.converter.JsonObjectMapper;
|
|
|
import me.zhengjie.utils.RedisUtils;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
|
|
@@ -44,7 +39,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
|
|
|
private final SysUserMapper userMapper;
|
|
|
private final UserAXQInfoMapper userAXQInfoMapper;
|
|
|
- private final MinioFileHandle minioFileHandle;
|
|
|
+ private final FaceMinioFileHandle minioFileHandle;
|
|
|
private final FileInfoMapper fileInfoMapper;
|
|
|
private final RedisUtils redis;
|
|
|
private static final String APPID = "6F5JVsCCeSEbBSLSXWVwPki71yK5Y4Jf7oUjA4Y3mLtu";
|
|
|
@@ -157,25 +152,10 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
if (!ObjectUtils.isEmpty(userAXQInfoEntity)) {
|
|
|
id = userAXQInfoEntity.getCompareImgId();
|
|
|
}
|
|
|
- Integer fileId = compareImage(base, id,redisCount,count);
|
|
|
- if (fileId == null) {
|
|
|
+ if (! compareImage(base, id,redisCount,count)) {
|
|
|
System.err.println("人脸比对失败");
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(sysUserEntity)) {
|
|
|
- SysUserEntity user = new SysUserEntity();
|
|
|
- user.setUserId(sysUserEntity.getUserId());
|
|
|
- user.setCompareImgId(fileId);
|
|
|
- userMapper.updateById(user);
|
|
|
- System.err.println("客户经理认证成功");
|
|
|
- }
|
|
|
- if (!ObjectUtils.isEmpty(userAXQInfoEntity)) {
|
|
|
- UserAXQInfoEntity user = new UserAXQInfoEntity();
|
|
|
- user.setId(userAXQInfoEntity.getId());
|
|
|
- user.setCompareImgId(fileId);
|
|
|
- userAXQInfoMapper.updateById(user);
|
|
|
- System.err.println("当事人认证成功");
|
|
|
- }
|
|
|
if (count != null) {
|
|
|
redis.del(redisCount);
|
|
|
}
|
|
|
@@ -190,7 +170,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
* @param count redis当中的次数
|
|
|
* @return
|
|
|
*/
|
|
|
- public Integer compareImage(File base, Integer id,String redisCount,Integer count) {
|
|
|
+ public boolean compareImage(File base, Integer id,String redisCount,Integer count) {
|
|
|
//从官网获取
|
|
|
FaceEngine faceEngine = new FaceEngine(LIBPATH);
|
|
|
//激活引擎
|
|
|
@@ -243,7 +223,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
if (pitch > 10 || yaw > 10) {
|
|
|
//照片不符合标准
|
|
|
System.err.println("图片不符合标准");
|
|
|
- return null;
|
|
|
+ return false;
|
|
|
}
|
|
|
//特征提取
|
|
|
FaceFeature faceFeature = new FaceFeature();
|
|
|
@@ -277,9 +257,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
if (faceSimilar.getScore() > 0.8) {
|
|
|
FileInfoEntity fileInfo = saveCompareImage(base);
|
|
|
fileInfoMapper.insert(fileInfo);
|
|
|
- return fileInfo.getId();
|
|
|
- }else {
|
|
|
- System.out.println("特征值不符合");
|
|
|
+ return true;
|
|
|
}
|
|
|
if (count == null) {
|
|
|
redis.set(redisCount, 1, 30, TimeUnit.MINUTES);
|
|
|
@@ -287,13 +265,13 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
redis.set(redisCount, count + 1, 30, TimeUnit.MINUTES);
|
|
|
}
|
|
|
System.err.println("人脸照片比对未通过");
|
|
|
- return null;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
private FileInfoEntity saveCompareImage(File base) {
|
|
|
FileHandleVo fileHandleVo = new FileHandleVo();
|
|
|
fileHandleVo.setFilePath(base.getPath());
|
|
|
- fileHandleVo.setSourceFilePath("/compareImage/" + base.getName());
|
|
|
+ fileHandleVo.setSourceFilePath("/face/" + base.getName());
|
|
|
fileHandleVo.setContentType("JPEG");
|
|
|
try {
|
|
|
minioFileHandle.uploadfilePath(fileHandleVo);
|
|
|
@@ -301,7 +279,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
throw new RuntimeException("照片保存到minio异常");
|
|
|
}
|
|
|
FileInfoEntity fileInfo = new FileInfoEntity();
|
|
|
- fileInfo.setLoanNo("compareImage");
|
|
|
+ fileInfo.setLoanNo("face");
|
|
|
fileInfo.setFileName(base.getName());
|
|
|
fileInfo.setPath(fileInfo.getLoanNo() + "/" + base.getName());
|
|
|
return fileInfo;
|