|
|
@@ -14,15 +14,16 @@ import me.zhengjie.base.file.FileHandleVo;
|
|
|
import me.zhengjie.base.file.MinioFileHandle;
|
|
|
import me.zhengjie.base.util.JuheServiceUtil;
|
|
|
import me.zhengjie.base.util.tencent.utils.Img2Base64Util;
|
|
|
-import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.SysUserEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.UserAXQInfoEntity;
|
|
|
+import me.zhengjie.dao.mybatis.ThirdPartyInterfaceRepository;
|
|
|
+import me.zhengjie.dao.mybatis.entity.*;
|
|
|
+import me.zhengjie.dao.mybatis.mapper.ContractOrderMapper;
|
|
|
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.img.CompareImageDomain;
|
|
|
import me.zhengjie.domain.notary.NotaryDomain;
|
|
|
import me.zhengjie.utils.RedisUtils;
|
|
|
+import me.zhengjie.utils.StringUtils;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
@@ -41,18 +42,92 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
|
|
|
private final SysUserMapper userMapper;
|
|
|
private final UserAXQInfoMapper userAXQInfoMapper;
|
|
|
+ private final ContractOrderMapper contractOrderMapper;
|
|
|
private final FaceMinioFileHandle minioFileHandle;
|
|
|
private final FileInfoMapper fileInfoMapper;
|
|
|
private final RedisUtils redis;
|
|
|
+
|
|
|
+ private final ThirdPartyInterfaceRepository thirdPartyInterfaceRepository;
|
|
|
+
|
|
|
//以下为测试部署环境
|
|
|
private static final String APPID = "6F5JVsCCeSEbBSLSXWVwPki71yK5Y4Jf7oUjA4Y3mLtu";
|
|
|
private static final String SDKKEY = "5qKM4a9oNSXNhXdwd7Ycrvnxdw2JXjcyeccYmb4zND7S";
|
|
|
private static final String LIBPATH = "/home/tom/nt-test/lib/so";
|
|
|
|
|
|
//以下为本地测试
|
|
|
-// private static final String APPID = "H6Er8ksqAcKc7Dk4Yum9Rkz4g9Gm77ZXAEMgvenjkTQQ";
|
|
|
-// private static final String SDKKEY = "Abd9D8xZQUqG8vDtU2a1tEkdfThkK1tZppjXzydGwEd6";
|
|
|
-// private static final String LIBPATH = "D:\\arcsoft_lib";
|
|
|
+/* private static final String APPID = "H6Er8ksqAcKc7Dk4Yum9Rkz4g9Gm77ZXAEMgvenjkTQQ";
|
|
|
+ private static final String SDKKEY = "Abd9D8xZQUqG8vDtU2a1tEkdfThkK1tZppjXzydGwEd6";
|
|
|
+ private static final String LIBPATH = "D:\\arcsoft_lib";*/
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取base64取消文件头
|
|
|
+ * @param base64
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getBase64(String base64){
|
|
|
+ String[] base64s = base64.split("base64");
|
|
|
+ if (base64s!=null && base64s.length>1){
|
|
|
+ base64 = base64s[1];
|
|
|
+ }
|
|
|
+ return base64;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * app端的人脸核身
|
|
|
+ * @param compareImageDomain
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultCode appCompareFace(CompareImageDomain compareImageDomain){
|
|
|
+ String base64 = compareImageDomain.getBase64();
|
|
|
+ if (base64==null){
|
|
|
+ return ResultCode.PARAM_IS_BLANK;
|
|
|
+ }
|
|
|
+ base64 = getBase64(base64);
|
|
|
+ String idCard = compareImageDomain.getIdCard();
|
|
|
+ String nickName = compareImageDomain.getName();
|
|
|
+ //当事人的人脸核身
|
|
|
+ QueryWrapper<UserAXQInfoEntity> userAXQInfoEntityQueryWrapper = new QueryWrapper<>();
|
|
|
+ userAXQInfoEntityQueryWrapper.eq("id_card",idCard).eq("nick_name",nickName);
|
|
|
+ UserAXQInfoEntity userAXQInfoEntity = userAXQInfoMapper.selectOne(userAXQInfoEntityQueryWrapper);
|
|
|
+ if (ObjectUtils.isEmpty(userAXQInfoEntity)){
|
|
|
+ return ResultCode.PARAM_IS_INVALID;
|
|
|
+ }
|
|
|
+ //做过安心签的用户 直接人脸核身 保存图片
|
|
|
+
|
|
|
+ ThirdPartyInterfaceEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
|
|
|
+ File base = null;
|
|
|
+ try {
|
|
|
+ base = File.createTempFile("compare", ".jpeg");
|
|
|
+ base.deleteOnExit();
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ if (!Img2Base64Util.generateImage(base64, base.getPath())) {
|
|
|
+ log.info("base64转图片异常");
|
|
|
+ return ResultCode.FACEAUTH_FAIL;
|
|
|
+ }
|
|
|
+
|
|
|
+ FileInfoEntity fileInfo = saveCompareImage(base);
|
|
|
+ fileInfoMapper.insert(fileInfo);
|
|
|
+ thirdPartyInterfaceEntity.setFileId(fileInfo.getId()+"");
|
|
|
+ thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
+ if (StringUtils.isNotBlank(thirdPartyInterfaceEntity.getMessage())){
|
|
|
+ //没有message说明人脸核身成功
|
|
|
+ UserAXQInfoEntity userAxq = new UserAXQInfoEntity();
|
|
|
+ userAxq.setId(userAXQInfoEntity.getId());
|
|
|
+ userAxq.setCompareImgId(fileInfo.getId());
|
|
|
+ userAXQInfoMapper.updateById(userAxq);
|
|
|
+ log.info("当事人人脸核身通过");
|
|
|
+ thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
+ return ResultCode.SUCCESS;
|
|
|
+ }
|
|
|
+ thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
+ return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 照片比对
|
|
|
@@ -65,10 +140,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
if (base64==null){
|
|
|
return ResultCode.PARAM_IS_BLANK;
|
|
|
}
|
|
|
- String[] base64s = base64.split("base64");
|
|
|
- if (base64s!=null && base64s.length>1){
|
|
|
- base64 = base64s[1];
|
|
|
- }
|
|
|
+ base64 = getBase64(base64);
|
|
|
//先判断是银行客户经理还是当事人
|
|
|
String roleId = compareImageDomain.getRoleId();
|
|
|
SysUserEntity sysUserEntity = null;
|
|
|
@@ -78,6 +150,12 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
boolean flag = "-1".equals(roleId);
|
|
|
if (flag) {
|
|
|
//说明是银行客户经理
|
|
|
+ QueryWrapper<ContractOrderEntity> contractOrderEntityQueryWrapper = new QueryWrapper<>();
|
|
|
+ contractOrderEntityQueryWrapper.eq("business_no",compareImageDomain.getBusinessNo()).eq("customer_name",compareImageDomain.getName());
|
|
|
+ ContractOrderEntity contractOrderEntity = contractOrderMapper.selectOne(contractOrderEntityQueryWrapper);
|
|
|
+ if (ObjectUtils.isEmpty(contractOrderEntity)){
|
|
|
+ return ResultCode.ACCOUNT_MANAGER_NO_ASSIGNED;
|
|
|
+ }
|
|
|
QueryWrapper<SysUserEntity> sysUserEntityQueryWrapper = new QueryWrapper<>();
|
|
|
sysUserEntityQueryWrapper.eq("id_card", idCard).eq("nick_name", nickName);
|
|
|
sysUserEntity = userMapper.selectOne(sysUserEntityQueryWrapper);
|
|
|
@@ -100,7 +178,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
//将base64转成图片
|
|
|
File base = null;
|
|
|
try {
|
|
|
- base = File.createTempFile("compare", ".JPEG");
|
|
|
+ base = File.createTempFile("compare", ".jpeg");
|
|
|
base.deleteOnExit();
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
@@ -109,44 +187,52 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
log.info("base64转图片异常");
|
|
|
return ResultCode.FACEAUTH_FAIL;
|
|
|
}
|
|
|
+ FileInfoEntity fileInfo = saveCompareImage(base);
|
|
|
+ fileInfoMapper.insert(fileInfo);
|
|
|
+
|
|
|
boolean redisFlag = (count != null && count >= 2);
|
|
|
if (flag) {
|
|
|
//说明是客户经理
|
|
|
if (sysUserEntity.getCompareImgId() == null || redisFlag) {
|
|
|
//说明客户经理需要做人脸核身
|
|
|
- System.err.println(idCard+nickName);
|
|
|
- if (JuheServiceUtil.URLPost(idCard, nickName, base64)) {
|
|
|
+ ThirdPartyInterfaceEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
|
|
|
+ thirdPartyInterfaceEntity.setFileId(fileInfo.getId()+"");
|
|
|
+ thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
+ if (StringUtils.isNotBlank(thirdPartyInterfaceEntity.getMessage())){
|
|
|
//上传图片到minio FileInfo
|
|
|
- FileInfoEntity fileInfo = saveCompareImage(base);
|
|
|
- fileInfoMapper.insert(fileInfo);
|
|
|
SysUserEntity bank = new SysUserEntity();
|
|
|
bank.setUserId(sysUserEntity.getUserId());
|
|
|
bank.setCompareImgId(fileInfo.getId());
|
|
|
userMapper.updateById(bank);
|
|
|
log.info("银行客户经理人脸核身通过");
|
|
|
redis.del(redisCount);
|
|
|
+ thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
return ResultCode.SUCCESS;
|
|
|
}
|
|
|
log.info("客户经理人脸核身失败");
|
|
|
+ thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}
|
|
|
} else {
|
|
|
//说明是当事人
|
|
|
if (userAXQInfoEntity.getCompareImgId() == null || redisFlag) {
|
|
|
//说明当事人需要做人脸核身
|
|
|
- if (JuheServiceUtil.URLPost(idCard, nickName, base64)) {
|
|
|
+ ThirdPartyInterfaceEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
|
|
|
+ thirdPartyInterfaceEntity.setFileId(fileInfo.getId()+"");
|
|
|
+ thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
|
|
|
+ if (thirdPartyInterfaceEntity.getResult()==1){
|
|
|
//上传图片到minio FileInfo
|
|
|
- FileInfoEntity fileInfo = saveCompareImage(base);
|
|
|
- fileInfoMapper.insert(fileInfo);
|
|
|
UserAXQInfoEntity userAxq = new UserAXQInfoEntity();
|
|
|
userAxq.setId(userAXQInfoEntity.getId());
|
|
|
userAxq.setCompareImgId(fileInfo.getId());
|
|
|
userAXQInfoMapper.updateById(userAxq);
|
|
|
log.info("当事人人脸核身通过");
|
|
|
redis.del(redisCount);
|
|
|
+ thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
return ResultCode.SUCCESS;
|
|
|
}
|
|
|
log.info("当事人人脸核身失败");
|
|
|
+ thirdPartyInterfaceRepository.insert(thirdPartyInterfaceEntity);
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}
|
|
|
}
|
|
|
@@ -277,7 +363,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
FileHandleVo fileHandleVo = new FileHandleVo();
|
|
|
fileHandleVo.setFilePath(base.getPath());
|
|
|
fileHandleVo.setSourceFilePath("/face/" + base.getName());
|
|
|
- fileHandleVo.setContentType("JPEG");
|
|
|
+ fileHandleVo.setContentType("image/jpeg");
|
|
|
try {
|
|
|
minioFileHandle.uploadfilePath(fileHandleVo);
|
|
|
} catch (Exception e) {
|