瀏覽代碼

银行客户经理和公证处的人脸比对接口

tongfeng 2 年之前
父節點
當前提交
74a9083aec

+ 11 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/AdminOrderController.java

@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.application.admin.controller.vo.*;
 import me.zhengjie.application.admin.service.AdminOrderService;
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
 import me.zhengjie.base.AppBaseResponse;
 import me.zhengjie.base.AppResultData;
 import me.zhengjie.base.ResponseDTO;
@@ -239,4 +240,14 @@ public class AdminOrderController {
 		return adminOrderService.uploadIssuedTime(file);
 	}
 
+	/**
+	 * 公证处的照片比对
+	 * @param imageUploadVO
+	 * @return
+	 */
+	@GetMapping("/face-compare")
+	public AppBaseResponse faceCompare(@RequestBody ImageUploadVO imageUploadVO){
+		return adminOrderService.faceCompare( imageUploadVO);
+	}
+
 }

+ 8 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/AdminOrderService.java

@@ -1,6 +1,7 @@
 package me.zhengjie.application.admin.service;
 
 import me.zhengjie.application.admin.controller.vo.*;
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
 import me.zhengjie.base.AppBaseResponse;
 import me.zhengjie.dao.mybatis.entity.BorrowerEntity;
 import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
@@ -70,6 +71,13 @@ public interface AdminOrderService {
     AppBaseResponse download(NotaryOrderQueryReq queryReq, HttpServletResponse response) throws IOException;
 
     AppBaseResponse uploadIssuedTime(UploadIssuedTimeReq queryReq);
+
+    /**
+     * 公证处的照片比对
+     * @param imageUploadVO
+     * @return
+     */
+    AppBaseResponse faceCompare(ImageUploadVO imageUploadVO);
 //
 //    /**
 //     * 查询全部

+ 14 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/AdminOrderServiceImpl.java

@@ -9,6 +9,7 @@ import me.zhengjie.application.admin.service.AdminOrderService;
 import me.zhengjie.application.admin.service.DictDetailService;
 import me.zhengjie.application.admin.service.OrderCochainService;
 import me.zhengjie.application.admin.service.SmsTemplateService;
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
 import me.zhengjie.application.bank.service.BankOrderService;
 import me.zhengjie.application.bank.service.FileInfoService;
 import me.zhengjie.base.AppBaseResponse;
@@ -24,6 +25,7 @@ import me.zhengjie.dao.mybatis.entity.*;
 import me.zhengjie.dao.mybatis.mapper.*;
 import me.zhengjie.domain.model.ModelConstant;
 import me.zhengjie.domain.model.ModelSynthesizerDomain;
+import me.zhengjie.domain.notary.NotaryDomain;
 import me.zhengjie.domain.order.OrderBizCodeMessage;
 import me.zhengjie.domain.order.OrderConstant;
 import me.zhengjie.domain.user.UserDomain;
@@ -104,6 +106,8 @@ public class AdminOrderServiceImpl implements AdminOrderService {
     @Autowired
     HtmlConvertToPdf htmlConvertToPdf;
     @Autowired
+    private NotaryDomain notaryDomain;
+    @Autowired
     private DictDetailService dictDetailService;
 
     @Override
@@ -358,6 +362,16 @@ public class AdminOrderServiceImpl implements AdminOrderService {
         return baseResponse;
     }
 
+    /**
+     * 公证处的照片比对
+     * @param imageUploadVO
+     * @return
+     */
+    @Override
+    public AppBaseResponse faceCompare(ImageUploadVO imageUploadVO) {
+        return  new AppBaseResponse(notaryDomain.compareParty(imageUploadVO));
+    }
+
     @Override
     public AppBaseResponse orderReject(NotaryOrderQueryReq req) {
         AppBaseResponse response = new AppBaseResponse();

+ 8 - 71
eladmin-system/src/main/java/me/zhengjie/application/bank/controller/BankNotarizeController.java

@@ -15,6 +15,7 @@ import me.zhengjie.annotation.rest.AnonymousGetMapping;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.application.admin.service.SmsTemplateService;
 import me.zhengjie.application.bank.BaseController;
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
 import me.zhengjie.application.bank.service.BankNotarizeService;
 import me.zhengjie.application.bank.service.UserAXQInfoService;
 import me.zhengjie.base.ResponseDTO;
@@ -227,77 +228,13 @@ public class BankNotarizeController extends BaseController {
 		return ResponseDTO.success();
 	}
 
+	/**
+	 * 银行客户经理的人脸照片比对
+	 * @param imageUploadVO
+	 * @return
+	 */
 	@RequestMapping("/face-compare")
-	public ResponseDTO<?> faceCompare() {
-		// 从官网获取
-		String appId = "6F5JVsCCeSEbBSLSXWVwPki71yK5Y4Jf7oUjA4Y3mLtu";
-		String sdkKey = "5qKM4a9oNSXNhXdwd7Ycrvnxdw2JXjcyeccYmb4zND7S";
-		FaceEngine faceEngine = new FaceEngine("/home/tom/nt/lib/so");
-		// 人脸比对
-		ActiveFileInfo activeFileInfo = new ActiveFileInfo();
-		int errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
-		if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
-			System.out.println("获取激活文件信息失败");
-		}
-		// 引擎配置
-		EngineConfiguration engineConfiguration = new EngineConfiguration();
-		engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
-		engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
-		engineConfiguration.setDetectFaceMaxNum(10);
-		engineConfiguration.setDetectFaceScaleVal(16);
-		// 功能配置
-		FunctionConfiguration functionConfiguration = new FunctionConfiguration();
-		functionConfiguration.setSupportAge(true);
-		functionConfiguration.setSupportFace3dAngle(true);
-		functionConfiguration.setSupportFaceDetect(true);
-		functionConfiguration.setSupportFaceRecognition(true);
-		functionConfiguration.setSupportGender(true);
-		functionConfiguration.setSupportLiveness(true);
-		functionConfiguration.setSupportIRLiveness(true);
-		engineConfiguration.setFunctionConfiguration(functionConfiguration);
-		// 初始化引擎
-		errorCode = faceEngine.init(engineConfiguration);
-		if (errorCode != ErrorInfo.MOK.getValue()) {
-			System.out.println("初始化引擎失败");
-		}
-		// 人脸检测
-		ImageInfo imageInfo = getRGBData(new File("/home/tom/nt/test/aaa.jpeg"));
-		List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
-		errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(),
-				imageInfo.getImageFormat(), faceInfoList);
-		System.out.println(faceInfoList);
-
-		// 特征提取
-		FaceFeature faceFeature = new FaceFeature();
-		errorCode = faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(),
-				imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
-		System.out.println("特征值大小:" + faceFeature.getFeatureData().length);
-
-		// 人脸检测2
-		ImageInfo imageInfo2 = getRGBData(new File("/home/tom/nt/test/bbb.jpeg"));
-		List<FaceInfo> faceInfoList2 = new ArrayList<FaceInfo>();
-		errorCode = faceEngine.detectFaces(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(),
-				imageInfo2.getImageFormat(), faceInfoList2);
-		System.out.println(faceInfoList2);
-
-		// 特征提取2
-		FaceFeature faceFeature2 = new FaceFeature();
-		errorCode = faceEngine.extractFaceFeature(imageInfo2.getImageData(), imageInfo2.getWidth(),
-				imageInfo2.getHeight(), imageInfo2.getImageFormat(), faceInfoList2.get(0), faceFeature2);
-		System.out.println("特征值大小:" + faceFeature2.getFeatureData().length);
-
-		// 特征比对
-		FaceFeature targetFaceFeature = new FaceFeature();
-		targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
-		FaceFeature sourceFaceFeature = new FaceFeature();
-		sourceFaceFeature.setFeatureData(faceFeature2.getFeatureData());
-		FaceSimilar faceSimilar = new FaceSimilar();
-
-		errorCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature, faceSimilar);
-
-		System.out.println("相似度:" + faceSimilar.getScore());
-		// 引擎卸载
-		errorCode = faceEngine.unInit();
-		return ResponseDTO.success();
+	public ResponseDTO<?> faceCompare(@RequestBody ImageUploadVO imageUploadVO){
+		return  bankNotarizeService.appFaceCompare(imageUploadVO, getCurrentUser());
 	}
 }

+ 11 - 0
eladmin-system/src/main/java/me/zhengjie/application/bank/service/BankNotarizeService.java

@@ -1,6 +1,8 @@
 package me.zhengjie.application.bank.service;
 
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
 import me.zhengjie.base.ResponseDTO;
+import me.zhengjie.dao.mybatis.entity.SysUserEntity;
 
 public interface BankNotarizeService {
     /**
@@ -23,4 +25,13 @@ public interface BankNotarizeService {
      * @return
      */
     public ResponseDTO<?> onlineNotary(String businessNo);
+
+
+    /**
+     * 来自银行客户经理的人脸比对
+     * @param imageUploadVO
+     * @param sysUser
+     * @return
+     */
+    ResponseDTO<?> appFaceCompare(ImageUploadVO imageUploadVO, SysUserEntity sysUser);
 }

+ 26 - 1
eladmin-system/src/main/java/me/zhengjie/application/bank/service/impl/BankNotarizeServiceImpl.java

@@ -9,6 +9,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
+import me.zhengjie.domain.notary.NotaryDomain;
+import me.zhengjie.utils.StringUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,7 +27,6 @@ import me.zhengjie.application.bank.controller.vo.FileInfoVO;
 import me.zhengjie.application.bank.service.BankNotarizeService;
 import me.zhengjie.base.ResponseDTO;
 import me.zhengjie.base.ResultCode;
-import me.zhengjie.base.mq.RedisCacheConfig;
 import me.zhengjie.base.util.FileUploadUtil;
 import me.zhengjie.base.websocket.AppPcBindSocketIo;
 import me.zhengjie.base.websocket.PcSocketClientCache;
@@ -51,6 +53,7 @@ public class BankNotarizeServiceImpl implements BankNotarizeService {
 	private final SysUserMapper sysUserMapper;
 	private final OnlineUserService onlineUserService;
 	private final AppPcBindSocketIo appPcBindSocketIo;
+	private final NotaryDomain notaryDomain;
 	@Autowired
 	OrderFileMapper orderFileMapper;
 	
@@ -162,4 +165,26 @@ public class BankNotarizeServiceImpl implements BankNotarizeService {
 		log.info("方法getOrderPDF的url地址返回参数: " + infos);
 		return ResponseDTO.success(infos);
 	}
+
+	/**
+	 * 客户经理的照片比对
+	 * @param imageUploadVO
+	 * @param user
+	 * @return
+	 */
+	@Override
+	public ResponseDTO<?> appFaceCompare(ImageUploadVO imageUploadVO, SysUserEntity user) {
+		if (imageUploadVO.getIdCard()==null){
+			ResultCode resultCode = notaryDomain.compareBank(imageUploadVO, user);
+			if(resultCode.code()==100){
+				return ResponseDTO.success();
+			}
+			return ResponseDTO.error(resultCode);
+		}
+		ResultCode resultCode = notaryDomain.compareParty(imageUploadVO);
+		if(resultCode.code()==100){
+			return ResponseDTO.success();
+		}
+		return ResponseDTO.error(resultCode);
+	}
 }

+ 21 - 4
eladmin-system/src/main/java/me/zhengjie/base/file/MinioFileHandle.java

@@ -1,8 +1,6 @@
 package me.zhengjie.base.file;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
+import java.io.*;
 
 import javax.annotation.PostConstruct;
 
@@ -20,7 +18,6 @@ import io.minio.ObjectStat;
 import io.minio.PutObjectOptions;
 import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
-import me.zhengjie.application.bank.service.FileInfoService;
 import me.zhengjie.base.config.AppConfigInfo;
 
 @Slf4j
@@ -143,6 +140,26 @@ public class MinioFileHandle extends AbstractFileHandle {
 		}
 	}
 
+	/**
+	 * 根据文件路径从minio获取文件
+	 * @param filePath
+	 * @return
+	 * @throws Exception
+	 */
+	public File getFileWithPath(String filePath) throws Exception {
+		InputStream inputStream = minioClient.getObject(bucketName, filePath);
+		File file = new File("/home/tom/nt/test/bbb.jpeg");
+		OutputStream outputStream = new FileOutputStream(file);
+		int bytesRead = 0;
+		byte[] buffer = new byte[8192];
+		while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
+			outputStream.write(buffer, 0, bytesRead);
+		}
+		inputStream.close();
+		outputStream.close();
+		return file;
+	}
+
 	public byte[] getByte(String fileId) throws Exception {
 		FileInfoEntity fileInfo = fileInfoMapper.selectById(fileId);
 		String path = fileInfo.getPath();

+ 2 - 1
eladmin-system/src/main/java/me/zhengjie/dao/mybatis/entity/SysUserEntity.java

@@ -144,5 +144,6 @@ public class SysUserEntity implements Serializable {
 	private String axqIsAuth;
 	@TableField("sign_img_id")
 	private String signImgId;
-
+	@TableField("compare_img_id")
+	private Integer compareImgId;
 }

+ 3 - 0
eladmin-system/src/main/java/me/zhengjie/dao/mybatis/entity/UserAXQInfoEntity.java

@@ -45,4 +45,7 @@ public class UserAXQInfoEntity implements Serializable {
 
     @TableField("img_seal_id")
     private Integer imgSealId;
+
+    @TableField("compare_img_id")
+    private Integer compareImgId;
 }

+ 12 - 0
eladmin-system/src/main/java/me/zhengjie/domain/Jvhe/JuheDomain.java

@@ -0,0 +1,12 @@
+package me.zhengjie.domain.Jvhe;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class JuheDomain implements Serializable {
+    private String reason;
+    private ResultDomain result;
+    private int error_code;
+}

+ 16 - 0
eladmin-system/src/main/java/me/zhengjie/domain/Jvhe/ResultDomain.java

@@ -0,0 +1,16 @@
+package me.zhengjie.domain.Jvhe;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class ResultDomain implements Serializable {
+    private int res;
+    private BigDecimal score;
+    private String code;
+    private String message;
+    private String desc;
+    private String orderid;
+}

+ 16 - 0
eladmin-system/src/main/java/me/zhengjie/domain/notary/NotaryDomain.java

@@ -0,0 +1,16 @@
+package me.zhengjie.domain.notary;
+
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
+
+import me.zhengjie.base.ResultCode;
+import me.zhengjie.dao.mybatis.entity.SysUserEntity;
+
+import javax.xml.transform.Result;
+
+public interface NotaryDomain {
+
+
+    ResultCode compareParty(ImageUploadVO imageUploadVO);
+
+    ResultCode compareBank(ImageUploadVO imageUploadVO, SysUserEntity user);
+}

+ 406 - 0
eladmin-system/src/main/java/me/zhengjie/domain/notary/impl/NotaryDomainImpl.java

@@ -0,0 +1,406 @@
+package me.zhengjie.domain.notary.impl;
+
+import com.arcsoft.face.*;
+import com.arcsoft.face.enums.DetectMode;
+import com.arcsoft.face.enums.DetectOrient;
+import com.arcsoft.face.enums.ErrorInfo;
+import com.arcsoft.face.toolkit.ImageInfo;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
+import me.zhengjie.base.ResultCode;
+import me.zhengjie.base.file.FileHandleVo;
+import me.zhengjie.base.file.MinioFileHandle;
+import me.zhengjie.base.util.JuheServiceUtil;
+import me.zhengjie.base.util.UUIDGenerator;
+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.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.notary.NotaryDomain;
+import me.zhengjie.sign.converter.JsonObjectMapper;
+import me.zhengjie.utils.RedisUtils;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+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;
+
+@Component
+@RequiredArgsConstructor
+public class NotaryDomainImpl implements NotaryDomain {
+
+    private final SysUserMapper userMapper;
+    private final UserAXQInfoMapper userAXQInfoMapper;
+    private final MinioFileHandle minioFileHandle;
+    private final FileInfoMapper fileInfoMapper;
+
+    private final RedisUtils redis;
+
+    private static final String APPID = "H6Er8ksqAcKc7Dk4Yum9Rkz4g9Gm77ZXAEMgvenjkTQQ";
+    private static final String SDKKEY = "Abd9D8xZQUqG8vDtU2a1tEkdfThkK1tZppjXzydGwEd6";
+
+    private static final String LIBPATH = "/home/tom/nt/lib/so";
+    //本地测试路径
+    //private static final String LIBPATH = "D:\\arcsoft_lib";
+    private static final String JuHeURl = "http://apis.juhe.cn/verifyface/verify";
+
+
+
+
+    /**
+     * 银行客户经理的人脸比对
+     *
+     * @param imageUploadVO
+     * @param sysUserEntity
+     * @return
+     */
+    @Override
+    public ResultCode compareBank(ImageUploadVO imageUploadVO, SysUserEntity sysUserEntity) {
+        //判断是做人脸核身还是照片比对
+        String bankRedis= "BANK:" + sysUserEntity.getUserId() + "COUNT:";
+        Integer count=null;
+        if (redis.hasKey(bankRedis)){
+            count= (Integer) redis.get(bankRedis);
+        }
+        //接收照片 判断
+        File base = new File("/home/tom/nt/test/aaa.jpeg");
+        if (!Img2Base64Util.generateImage(imageUploadVO.getBase64(), base.getPath())) {
+            return ResultCode.FACEAUTH_FAIL;
+        }
+        boolean flag = (count!=null && count==2);
+        if (sysUserEntity.getCompareImgId() == null || flag ) {
+            //要做人脸核身
+            Map<String, Object> params = new HashMap<>();
+            params.put("idcard", sysUserEntity.getIdCard());
+            params.put("realname", sysUserEntity.getNickName());
+            params.put("image", imageUploadVO.getBase64());
+            params.put("key", "6db21a71bee88af1eac38480c1574e2a");
+            String json = JuheServiceUtil.URLPost(JuHeURl, params);
+            ResultCode result = getResult(json);
+            if (result.code()==100) {
+                FileInfoEntity fileInfo = saveCompareImage(base);
+                fileInfo.setStep(imageUploadVO.getStep());
+                fileInfoMapper.insert(fileInfo);
+                sysUserEntity.setCompareImgId(fileInfo.getId());
+                userMapper.updateById(sysUserEntity);
+                return ResultCode.SUCCESS;
+            }
+            return ResultCode.FACEAUTH_FAIL;
+        }
+        //从官网获取
+        FaceEngine faceEngine = new FaceEngine(LIBPATH);
+        //激活引擎
+        int errorCode = faceEngine.activeOnline(APPID, SDKKEY);
+        if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
+            throw new RuntimeException("引擎激活失败");
+        }
+        ActiveFileInfo activeFileInfo = new ActiveFileInfo();
+        errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
+        if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
+            throw new RuntimeException("获取激活文件信息失败");
+        }
+        //引擎配置
+        EngineConfiguration engineConfiguration = new EngineConfiguration();
+        engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
+        engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
+        engineConfiguration.setDetectFaceMaxNum(10);
+        engineConfiguration.setDetectFaceScaleVal(16);
+        //功能配置
+        FunctionConfiguration functionConfiguration = new FunctionConfiguration();
+        functionConfiguration.setSupportAge(true);
+        functionConfiguration.setSupportFace3dAngle(true);
+        functionConfiguration.setSupportFaceDetect(true);
+        functionConfiguration.setSupportFaceRecognition(true);
+        functionConfiguration.setSupportGender(true);
+        functionConfiguration.setSupportLiveness(true);
+        functionConfiguration.setSupportIRLiveness(true);
+        engineConfiguration.setFunctionConfiguration(functionConfiguration);
+        //初始化引擎
+        errorCode = faceEngine.init(engineConfiguration);
+        if (errorCode != ErrorInfo.MOK.getValue()) {
+            throw new RuntimeException("初始化引擎失败");
+        }
+        //人脸检测
+        ImageInfo imageInfo = getRGBData(base);
+        List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
+        errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
+        System.out.println(faceInfoList);
+        //人脸属性检测
+        FunctionConfiguration configuration = new FunctionConfiguration();
+        configuration.setSupportFace3dAngle(true);
+        errorCode = faceEngine.process(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList, configuration);
+        //3D信息检测
+        List<Face3DAngle> face3DAngleList = new ArrayList<Face3DAngle>();
+        errorCode = faceEngine.getFace3DAngle(face3DAngleList);
+        //俯仰角
+        float pitch = Math.abs(face3DAngleList.get(0).getPitch());
+        //偏向角
+        float yaw = Math.abs(face3DAngleList.get(0).getYaw());
+        if (pitch > 10 || yaw > 10) {
+            //照片不符合标准
+            return ResultCode.DATA_UPDATE_ERROR;
+        }
+        //特征提取
+        FaceFeature faceFeature = new FaceFeature();
+        errorCode = faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
+        //根据id 查找文件
+        QueryWrapper<FileInfoEntity> fileInfoQw = new QueryWrapper<>();
+        fileInfoQw.eq("id", sysUserEntity.getCompareImgId());
+        FileInfoEntity fileInfoEntity = fileInfoMapper.selectOne(fileInfoQw);
+        String filePath = fileInfoEntity.getPath();
+        File file = null;
+        try {
+            file = minioFileHandle.getFileWithPath(filePath);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        //人脸检测2
+        ImageInfo imageInfo2 = getRGBData(file);
+        List<FaceInfo> faceInfoList2 = new ArrayList<FaceInfo>();
+        errorCode = faceEngine.detectFaces(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo2.getImageFormat(), faceInfoList2);
+        //特征提取2
+        FaceFeature faceFeature2 = new FaceFeature();
+        errorCode = faceEngine.extractFaceFeature(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo2.getImageFormat(), faceInfoList2.get(0), faceFeature2);
+        //特征比对
+        FaceFeature targetFaceFeature = new FaceFeature();
+        targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
+        FaceFeature sourceFaceFeature = new FaceFeature();
+        sourceFaceFeature.setFeatureData(faceFeature2.getFeatureData());
+        FaceSimilar faceSimilar = new FaceSimilar();
+        errorCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature, faceSimilar);
+        //如果通过 上传文件 修改用户绑定id 如果没通过 返回失败 次数加1
+        if (faceSimilar.getScore() > 0.8) {
+            FileInfoEntity fileInfo = saveCompareImage(base);
+            fileInfo.setStep(imageUploadVO.getStep());
+            fileInfoMapper.insert(fileInfo);
+            sysUserEntity.setCompareImgId(fileInfo.getId());
+            userMapper.updateById(sysUserEntity);
+            return ResultCode.SUCCESS;
+        }
+        if (count == null) {
+            redis.set(bankRedis, 1, 30, TimeUnit.MINUTES);
+        } else {
+            redis.set(bankRedis, count + 1, 30, TimeUnit.MINUTES);
+        }
+        return ResultCode.FACEAUTH_FAIL;
+    }
+
+    /**
+     * 当事人的人脸比对
+     *
+     * @param imageUploadVO
+     * @return
+     */
+    @Override
+    public ResultCode compareParty(ImageUploadVO imageUploadVO) {
+        String idCard = imageUploadVO.getIdCard();
+        String partyRedis = "PARTY:" + idCard + "COUNT:";
+        Integer count=null;
+        if (redis.hasKey(partyRedis)){
+            count= (Integer) redis.get(partyRedis);
+        }
+        //通过身份证号得到当事人
+        QueryWrapper<UserAXQInfoEntity> userQueryWrapper = new QueryWrapper<>();
+        userQueryWrapper.eq("id_card", idCard);
+        UserAXQInfoEntity userAXQInfoEntity = userAXQInfoMapper.selectOne(userQueryWrapper);
+        //接收照片 判断
+        File base = new File("/home/tom/nt/test/aaa.jpeg");
+        if (!Img2Base64Util.generateImage(imageUploadVO.getBase64(), base.getPath())) {
+            System.err.println("接受文件转换失败");
+            return ResultCode.FACEAUTH_FAIL;
+        }
+        boolean flag = (count!=null && count ==2);
+        if (userAXQInfoEntity.getCompareImgId() == null || flag) {
+            //要做人脸核身
+            Map<String, Object> params = new HashMap<>();
+            params.put("idcard", imageUploadVO.getIdCard());
+            params.put("realname", userAXQInfoEntity.getUserName());
+            params.put("image", imageUploadVO.getBase64());
+            params.put("key", "6db21a71bee88af1eac38480c1574e2a");
+            String json = JuheServiceUtil.URLPost(JuHeURl, params);
+            ResultCode result = getResult(json);
+            if (result.code()==100) {
+                //人脸核身成功 把对应的照片保存下来
+                FileInfoEntity fileInfo = saveCompareImage(base);
+                fileInfo.setStep(imageUploadVO.getStep());
+                fileInfoMapper.insert(fileInfo);
+                userAXQInfoEntity.setCompareImgId(fileInfo.getId());
+                userAXQInfoMapper.updateById(userAXQInfoEntity);
+                redis.del(partyRedis);
+                return ResultCode.SUCCESS;
+            }
+            return ResultCode.FACEAUTH_FAIL;
+        } else {
+            //从官网获取
+            FaceEngine faceEngine = new FaceEngine(LIBPATH);
+            //激活引擎
+            int errorCode = faceEngine.activeOnline(APPID, SDKKEY);
+            if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
+                System.out.println("引擎激活失败");
+            }
+            ActiveFileInfo activeFileInfo = new ActiveFileInfo();
+            errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
+            if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
+                System.out.println("获取激活文件信息失败");
+            }
+            //引擎配置
+            EngineConfiguration engineConfiguration = new EngineConfiguration();
+            engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
+            engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
+            engineConfiguration.setDetectFaceMaxNum(10);
+            engineConfiguration.setDetectFaceScaleVal(16);
+            //功能配置
+            FunctionConfiguration functionConfiguration = new FunctionConfiguration();
+            functionConfiguration.setSupportAge(true);
+            functionConfiguration.setSupportFace3dAngle(true);
+            functionConfiguration.setSupportFaceDetect(true);
+            functionConfiguration.setSupportFaceRecognition(true);
+            functionConfiguration.setSupportGender(true);
+            functionConfiguration.setSupportLiveness(true);
+            functionConfiguration.setSupportIRLiveness(true);
+            engineConfiguration.setFunctionConfiguration(functionConfiguration);
+            //初始化引擎
+            errorCode = faceEngine.init(engineConfiguration);
+            if (errorCode != ErrorInfo.MOK.getValue()) {
+                System.out.println("初始化引擎失败");
+            }
+            //人脸检测
+            ImageInfo imageInfo = getRGBData(base);
+            List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
+            errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
+            System.out.println(faceInfoList);
+            //人脸属性检测
+            FunctionConfiguration configuration = new FunctionConfiguration();
+            configuration.setSupportFace3dAngle(true);
+            errorCode = faceEngine.process(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList, configuration);
+            //3D信息检测
+            List<Face3DAngle> face3DAngleList = new ArrayList<Face3DAngle>();
+            errorCode = faceEngine.getFace3DAngle(face3DAngleList);
+            //俯仰角
+            float pitch = Math.abs(face3DAngleList.get(0).getPitch());
+            //偏向角
+            float yaw = Math.abs(face3DAngleList.get(0).getYaw());
+            if (pitch > 10 || yaw > 10) {
+                //照片不符合标准
+                return ResultCode.DATA_UPDATE_ERROR;
+            }
+            //要做照片认证
+            //获取这个图片的特征
+            //特征提取
+            FaceFeature faceFeature = new FaceFeature();
+            errorCode = faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
+            //根据id查询到用户保存的照片
+            QueryWrapper<FileInfoEntity> fileInfoQw = new QueryWrapper<>();
+            fileInfoQw.eq("id", userAXQInfoEntity.getCompareImgId());
+            FileInfoEntity fileInfoEntity = fileInfoMapper.selectOne(fileInfoQw);
+            String filePath = fileInfoEntity.getPath();
+            File file = null;
+            try {
+                file = minioFileHandle.getFileWithPath(filePath);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            //人脸检测2
+            ImageInfo imageInfo2 = getRGBData(file);
+            List<FaceInfo> faceInfoList2 = new ArrayList<FaceInfo>();
+            errorCode = faceEngine.detectFaces(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo2.getImageFormat(), faceInfoList2);
+            System.out.println(faceInfoList2);
+            //特征提取2
+            FaceFeature faceFeature2 = new FaceFeature();
+            errorCode = faceEngine.extractFaceFeature(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo2.getImageFormat(), faceInfoList2.get(0), faceFeature2);
+            System.out.println("特征值大小:" + faceFeature2.getFeatureData().length);
+            //特征比对
+            FaceFeature targetFaceFeature = new FaceFeature();
+            targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
+            FaceFeature sourceFaceFeature = new FaceFeature();
+            sourceFaceFeature.setFeatureData(faceFeature2.getFeatureData());
+            FaceSimilar faceSimilar = new FaceSimilar();
+            errorCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature, faceSimilar);
+            System.out.println("相似度:" + faceSimilar.getScore());
+            //如果通过 上传文件 修改用户绑定id 如果没通过 返回失败 次数加1
+            if (faceSimilar.getScore() > 0.8) {
+                //人脸核身成功 把对应的照片保存下来
+                FileInfoEntity fileInfo = saveCompareImage(base);
+                fileInfo.setStep(imageUploadVO.getStep());
+                fileInfoMapper.insert(fileInfo);
+                userAXQInfoEntity.setCompareImgId(fileInfo.getId());
+                userAXQInfoMapper.updateById(userAXQInfoEntity);
+                redis.del(partyRedis);
+                base.delete();
+                file.delete();
+                return ResultCode.SUCCESS;
+            }
+            base.delete();
+            file.delete();
+            if (count == null) {
+                redis.set(partyRedis, 1, 30, TimeUnit.MINUTES);
+            } else {
+                redis.set(partyRedis, count + 1, 30, TimeUnit.MINUTES);
+            }
+            return ResultCode.FACEAUTH_FAIL;
+        }
+    }
+
+    private FileInfoEntity saveCompareImage(File base) {
+        FileHandleVo fileHandleVo = new FileHandleVo();
+        fileHandleVo.setFilePath(base.getPath());
+        fileHandleVo.setSourceFilePath("/compareImage/" + UUIDGenerator.uuid() +".jpeg");
+        fileHandleVo.setContentType("JPEG");
+        try {
+            minioFileHandle.uploadfilePath(fileHandleVo);
+        } catch (Exception e) {
+            throw new RuntimeException("照片保存到minio异常");
+        }
+        FileInfoEntity fileInfo = new FileInfoEntity();
+        fileInfo.setLoanNo("compareImage");
+        fileInfo.setFileName(fileHandleVo.getSourceFilePath().replace("/compareImage/",""));
+        fileInfo.setPath(fileHandleVo.getSourceFilePath().replaceFirst("/",""));
+        fileInfo.setFileType("7");
+        return fileInfo;
+    }
+
+
+    public ResultCode getResult(String json) {
+        //将人脸核身的结果返回
+        JsonObjectMapper jsonObjectMapper = new JsonObjectMapper();
+        JuheDomain juheEntity = jsonObjectMapper.readValue(json, JuheDomain.class);
+        ResultDomain result = juheEntity.getResult();
+        if (result.getRes() == 1) {
+            BigDecimal bigDecimal = new BigDecimal(85.0);
+            if (result.getScore().compareTo(bigDecimal) == 1 || result.getScore().compareTo(bigDecimal) == 0) {
+                return ResultCode.SUCCESS;
+            }
+            return ResultCode.FACEAUTH_FAIL;
+        }
+        if (result.getRes() == 2) {
+            String code = result.getCode();
+            if ("3003".equals(code)) {
+                //TODO 响应码
+                //人脸库中的照片检测不到人脸
+            }
+            if ("3004".equals(code)) {
+                //用户上传的照片检测不到人脸
+            }
+            if ("3005".equals(code)) {
+                //人脸比对失败
+            }
+        }
+        if (result.getRes() == 3) {
+            //身份证和姓名不匹配
+            return ResultCode.LIVE_VIDEO_INVALID;
+        }
+        return ResultCode.FACEAUTH_FAIL;
+    }
+}