|
|
@@ -28,10 +28,9 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Base64;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
@@ -80,6 +79,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultCode appCompareFace(CompareImageDomain compareImageDomain) {
|
|
|
+ FaceCompareEntity thirdPartyInterfaceEntity = new FaceCompareEntity();
|
|
|
String base64 = compareImageDomain.getBase64();
|
|
|
if (base64 == null) {
|
|
|
return ResultCode.PARAM_IS_BLANK;
|
|
|
@@ -124,6 +124,8 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
+ thirdPartyInterfaceEntity.setConsultNo(contractOrderEntity.getConsultNo());
|
|
|
FileInfoEntity fileInfo = uploadFaceFile(base64);
|
|
|
boolean redisFlag = (count != null && count >= 2);
|
|
|
if (ObjectUtils.isEmpty(id) || redisFlag) {
|
|
|
@@ -131,10 +133,9 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
return ResultCode.IMAGE_NOT_STANDARD;
|
|
|
}
|
|
|
//要做人脸核身
|
|
|
- FaceCompareEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
|
|
|
+ thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64,thirdPartyInterfaceEntity);
|
|
|
thirdPartyInterfaceEntity.setFileId(fileInfo.getId() + "");
|
|
|
- thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
- thirdPartyInterfaceEntity.setConsultNo(contractOrderEntity.getConsultNo());
|
|
|
+
|
|
|
thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
if (thirdPartyInterfaceEntity.getResult() == 1) {
|
|
|
ContractOrderEntity orderEntity = new ContractOrderEntity();
|
|
|
@@ -158,7 +159,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}*/
|
|
|
|
|
|
- ResultCode resultCode = compareImage(base, id, redisCount, count);
|
|
|
+ ResultCode resultCode = compareImage(base, id, redisCount, thirdPartyInterfaceEntity);
|
|
|
|
|
|
if (resultCode.code()==100){
|
|
|
if (count != null) {
|
|
|
@@ -178,6 +179,8 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultCode compareFace(CompareImageDomain compareImageDomain) {
|
|
|
+ FaceCompareEntity faceCompareEntity = new FaceCompareEntity();
|
|
|
+
|
|
|
String base64 = compareImageDomain.getBase64();
|
|
|
if (base64 == null) {
|
|
|
return ResultCode.PARAM_IS_BLANK;
|
|
|
@@ -218,6 +221,12 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ faceCompareEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
+ faceCompareEntity.setConsultNo(contractOrder.getConsultNo());
|
|
|
+ faceCompareEntity.setIdCard(idCard);
|
|
|
+ faceCompareEntity.setName(nickName);
|
|
|
+
|
|
|
//后面需要的三个参数 base64 身份证号 姓名
|
|
|
String redisCount = "idCard:" + idCard + ":COUNT:";
|
|
|
Integer count = null;
|
|
|
@@ -251,11 +260,9 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
}
|
|
|
//说明客户经理需要做人脸核身
|
|
|
FileInfoEntity fileInfo = uploadFaceFile(base64);
|
|
|
- FaceCompareEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
|
|
|
- thirdPartyInterfaceEntity.setFileId(fileInfo.getId() + "");
|
|
|
- thirdPartyInterfaceEntity.setConsultNo(contractOrder.getConsultNo());
|
|
|
- thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
- if (thirdPartyInterfaceEntity.getResult() == 1) {
|
|
|
+ faceCompareEntity = JuheServiceUtil.URLPost(idCard, nickName, base64,faceCompareEntity);
|
|
|
+ faceCompareEntity.setFileId(fileInfo.getId() + "");
|
|
|
+ if (faceCompareEntity.getResult() == 1) {
|
|
|
//上传图片到minio FileInfo
|
|
|
SysUserEntity bank = new SysUserEntity();
|
|
|
bank.setUserId(sysUserEntity.getUserId());
|
|
|
@@ -263,11 +270,11 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
userMapper.updateById(bank);
|
|
|
log.info("银行客户经理人脸核身通过");
|
|
|
redis.del(redisCount);
|
|
|
- thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
+ thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
|
return ResultCode.SUCCESS;
|
|
|
}
|
|
|
log.info("客户经理人脸核身失败");
|
|
|
- thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
+ thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}
|
|
|
} else if (ObjectUtils.isEmpty(compareImageId) || redisFlag) {
|
|
|
@@ -277,12 +284,11 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
|
|
|
//说明当事人需要做人脸核身
|
|
|
FileInfoEntity fileInfo = uploadFaceFile(base64);
|
|
|
- FaceCompareEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
|
|
|
- thirdPartyInterfaceEntity.setFileId(fileInfo.getId() + "");
|
|
|
- thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
- thirdPartyInterfaceEntity.setConsultNo(contractOrder.getConsultNo());
|
|
|
- thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
- if (thirdPartyInterfaceEntity.getResult() == 1) {
|
|
|
+ faceCompareEntity = JuheServiceUtil.URLPost(idCard, nickName, base64,faceCompareEntity);
|
|
|
+ faceCompareEntity.setFileId(fileInfo.getId() + "");
|
|
|
+
|
|
|
+ thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
|
+ if (faceCompareEntity.getResult() == 1) {
|
|
|
//上传图片到minio FileInfo;
|
|
|
ContractOrderEntity orderEntity = new ContractOrderEntity();
|
|
|
orderEntity.setId(contractOrder.getId());
|
|
|
@@ -315,7 +321,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}*/
|
|
|
|
|
|
- ResultCode resultCode = compareImage(base, id, redisCount, count);
|
|
|
+ ResultCode resultCode = compareImage(base, id, redisCount, faceCompareEntity);
|
|
|
|
|
|
if (resultCode.code()==100){
|
|
|
if (count != null) {
|
|
|
@@ -463,7 +469,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
* @param count redis当中的次数
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultCode compareImage(File base, Integer id, String redisCount, Integer count) {
|
|
|
+ public ResultCode compareImage(File base, Integer id, String redisCount, FaceCompareEntity faceCompareEntity) {
|
|
|
//从官网获取
|
|
|
FaceEngine faceEngine = new FaceEngine(libpath);
|
|
|
//激活引擎
|
|
|
@@ -584,8 +590,30 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
//如果通过 上传文件 修改用户绑定id 如果没通过 返回null证明失败了
|
|
|
//引擎卸载
|
|
|
errorCode = faceEngine.unInit();
|
|
|
- if (faceSimilar.getScore() > 0.8) {
|
|
|
+ float score = faceSimilar.getScore();
|
|
|
+ faceCompareEntity.setScore(score+"");
|
|
|
+ FileInputStream fileInputStream = null;
|
|
|
+ try {
|
|
|
+ fileInputStream = new FileInputStream(file);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ byte[] bytes = new byte[(int) file.length()];
|
|
|
+ try {
|
|
|
+ fileInputStream.read(bytes);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ String s = Base64.getEncoder().encodeToString(bytes);
|
|
|
+
|
|
|
+ FileInfoEntity fileInfo = uploadFaceFile(s);
|
|
|
+ faceCompareEntity.setFileId(fileInfo.getId()+"");
|
|
|
+ if (score > 0.8) {
|
|
|
log.info("人脸照片比对通过");
|
|
|
+ faceCompareEntity.setMessage("人脸照片对比通过");
|
|
|
+ faceCompareEntity.setResult(1);
|
|
|
+ thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
|
base.delete();
|
|
|
file.delete();
|
|
|
redis.del(redisCount);
|
|
|
@@ -593,6 +621,9 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
}
|
|
|
redis.increment(redisCount);
|
|
|
log.info("人脸照片比对未通过");
|
|
|
+ faceCompareEntity.setMessage("人脸照片对比未通过");
|
|
|
+ faceCompareEntity.setResult(0);
|
|
|
+ thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
|
base.delete();
|
|
|
file.delete();
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|