瀏覽代碼

人脸核身上传图片修改

tongfeng 2 年之前
父節點
當前提交
e50f2836fd

+ 6 - 4
eladmin-system/src/main/java/me/zhengjie/application/bank/controller/BankAuthController.java

@@ -5,12 +5,10 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import me.zhengjie.annotation.rest.AnonymousGetMapping;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.application.bank.BaseController;
-import me.zhengjie.application.bank.controller.vo.BankLoginVO;
-import me.zhengjie.application.bank.controller.vo.FileInfoVO;
-import me.zhengjie.application.bank.controller.vo.FileUploadVO;
-import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
+import me.zhengjie.application.bank.controller.vo.*;
 import me.zhengjie.application.bank.service.BankLoginService;
 import me.zhengjie.application.bank.service.FileInfoService;
 import me.zhengjie.base.ResponseDTO;
@@ -22,6 +20,8 @@ import me.zhengjie.base.util.StatusEnum.StepStatusEnum;
 import me.zhengjie.base.util.TencentServiceUtil;
 import me.zhengjie.dao.mybatis.UserAXQInfoRepository;
 import me.zhengjie.dao.mybatis.entity.UserAXQInfoEntity;
+import me.zhengjie.domain.notary.NotaryDomain;
+import me.zhengjie.domain.notary.impl.NotaryDomainImpl;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -139,6 +140,7 @@ public class BankAuthController extends BaseController {
             String ocrName = HandwritingUtil.getHandwritingText(type, image.getBase64());
             log.info("手写签名为:" + ocrName);
             UserAXQInfoEntity entity = userAXQInfoRepository.getUserAXQInfoWithIdcard(image.getIdCard());
+            log.info(ocrName);
             if (!ocrName.equals(entity.getUserName())) {
                 return ResponseDTO.error(ResultCode.HANDWRITING_FAIL);
             }

+ 32 - 0
eladmin-system/src/main/java/me/zhengjie/application/bank/controller/BankNotarizeController.java

@@ -1,9 +1,11 @@
 package me.zhengjie.application.bank.controller;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.arcsoft.face.*;
 import com.arcsoft.face.enums.ErrorInfo;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -24,8 +26,11 @@ import me.zhengjie.base.util.BeanCopyUtils;
 import me.zhengjie.base.util.FileUploadUtil;
 import me.zhengjie.base.util.UUIDGenerator;
 import me.zhengjie.base.util.tencent.h5face.SdkTest;
+import me.zhengjie.dao.mybatis.ContractOrderRepository;
 import me.zhengjie.dao.mybatis.OrderFileRepository;
+import me.zhengjie.dao.mybatis.ThirdPartyInterfaceRepository;
 import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
+import me.zhengjie.dao.mybatis.entity.ThirdPartyInterfaceEntity;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.validation.annotation.Validated;
@@ -34,6 +39,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 @Validated
 @RestController
 @RequestMapping("${fqgz.bank.app.url-prefix}")
@@ -46,6 +53,7 @@ public class BankNotarizeController extends BaseController {
 	private final BankNotarizeService bankNotarizeService;
 	private final TencentHumanFaceVerify faceVerify;
 	private final SmsTemplateService smsTemplateService;
+	private final ThirdPartyInterfaceRepository thirdPartyInterfaceRepository;
 	private final RedisTemplate<String, String> redisTemplate;
 
 	/**
@@ -221,6 +229,30 @@ public class BankNotarizeController extends BaseController {
 		errorCode = faceEngine.unInit();
 		return ResponseDTO.success();
 	}
+	@RequestMapping("/isFaceCompare")
+	public ResponseDTO<?> isFaceCompare(@RequestBody String json){
+		// 这里需要先判断公证员是否在线
+		JSONObject jsonObj = JSONObject.parseObject(json);
+		String userName = jsonObj.getString("userName");
+		String idCard = jsonObj.getString("idCard");
+		String businessNo = jsonObj.getString("businessNo");
+		if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(idCard)) {
+			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
+		}
+		ResponseDTO<?> result = bankNotarizeService.onlineNotary(businessNo);
+		if (!result.isSuccess()) {
+			return result;
+		}
+		//判断传入的当事人 是否做过人脸核身
+		QueryWrapper<ThirdPartyInterfaceEntity> thirdPartyInterfaceEntityQueryWrapper = new QueryWrapper<>();
+		thirdPartyInterfaceEntityQueryWrapper.eq("business_no",businessNo).eq("name",userName).eq("id_card",idCard).eq("type","face_compare");
+		List<ThirdPartyInterfaceEntity> list = thirdPartyInterfaceRepository.getList(thirdPartyInterfaceEntityQueryWrapper);
+		if (CollectionUtil.isEmpty(list)){
+			return ResponseDTO.error(ResultCode.RESULT_DATA_NONE);
+		}
+		return ResponseDTO.success();
+	}
+
 
 	/**
 	 * 银行客户经理的人脸照片比对

+ 1 - 9
eladmin-system/src/main/java/me/zhengjie/base/file/AbstractFileHandle.java

@@ -14,20 +14,12 @@ public abstract class AbstractFileHandle implements FileHandle, ApplicationConte
 	@Value("${app.minio.preview:https://fqgz.flowbb.cn}")
 	protected String appMinioPreview;
 
-	private static final String APPMINIOPREVIEW = "https://fqgz.flowbb.cn";
-
 	ApplicationContext applicationContext;
 
 	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
 		this.applicationContext = applicationContext;
 		// 设置应用
-		FileHandle fileHandle=null;
-		if (APPMINIOPREVIEW.equals(appMinioPreview)){
-			fileHandle = applicationContext.getBean(FaceMinioFileHandle.class);
-		}else {
-			fileHandle = applicationContext.getBean(MinioFileHandle.class);
-		}
-
+		FileHandle fileHandle = applicationContext.getBean(FileHandle.class);
 		FileUploadUtil.setFileHandle(fileHandle);
 	}
 	/**

+ 0 - 174
eladmin-system/src/main/java/me/zhengjie/base/file/FaceMinioFileHandle.java

@@ -1,174 +0,0 @@
-package me.zhengjie.base.file;
-
-import cn.hutool.core.io.IoUtil;
-import io.minio.MinioClient;
-import io.minio.ObjectStat;
-import io.minio.PutObjectOptions;
-import lombok.extern.slf4j.Slf4j;
-import me.zhengjie.base.config.AppConfigInfo;
-import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
-import me.zhengjie.dao.mybatis.mapper.FileInfoMapper;
-import org.apache.commons.io.FileUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import java.io.*;
-
-@Slf4j
-@Primary
-@Component
-public class FaceMinioFileHandle extends AbstractFileHandle {
-	// minio的连接bucketName
-	@Value("mytest")
-	private String bucketName;
-	// 设置连接minio的url
-	@Value("http://124.222.192.60:9000")
-	public String appMinioUrl;
-	// minio的连接accesskey
-	@Value("minioadmin")
-	public String appMinioAccesskey;
-	// minio的连接secretkey
-	@Value("minioadmin")
-	public String appMinioSecretkey;
-
-	@Autowired
-	public FileInfoMapper fileInfoMapper;
-
-	private MinioClient minioClient;
-
-	@PostConstruct
-	private void init() throws Exception {
-		try {
-			if (minioClient == null) {
-				log.info("minioClient create start");
-				minioClient = new MinioClient(appMinioUrl, appMinioAccesskey, appMinioSecretkey);
-				log.info("minioClient create end");
-				// 判断桶是否已经存在
-				log.info("开始创建minio的:");
-				createBucket();
-			}
-		} catch (Exception e) {
-			log.error("连接MinIO服务器异常:{}", e);
-			throw e;
-		}
-	}
-
-	/**
-	 * @Title: createBucket
-	 * @Description: (创建bucket)
-	 * @author humuyu [bucketName] 桶名
-	 */
-	public void createBucket() {
-		try {
-			if (!minioClient.bucketExists(bucketName)) {
-				minioClient.makeBucket(bucketName);
-			}
-		} catch (Exception e) {
-			log.error("创建桶失败:{}", e);
-		}
-	}
-
-	/**
-	 * 通过流上传文件
-	 *
-	 * @param bucketName  存储桶
-	 * @param objectName  文件对象
-	 * @param inputStream 文件流
-	 */
-	public void uploadFileStream(FileHandleVo file) throws Exception {
-		int fileSize = file.getInputStream().available();
-		PutObjectOptions options = new PutObjectOptions(fileSize, -1);
-		options.setContentType(file.getContentType());
-		minioClient.putObject(bucketName, file.getFilePath(), file.getInputStream(), options);
-	}
-
-	public void uploadfilePath(FileHandleVo file) throws Exception {
-		InputStream is = new FileInputStream(file.getFilePath());
-		long size = is.available();
-		PutObjectOptions options = new PutObjectOptions(size, -1);
-		options.setContentType(file.getContentType());
-		minioClient.putObject(bucketName, file.getSourceFilePath(), is, options);
-		if (is != null) {
-			is.close();
-		}
-//
-	}
-
-	public InputStream getObject(String objectName) throws Exception {
-		return minioClient.getObject(bucketName, objectName);
-	}
-
-	/**
-	 * @param bucketName bucket名称
-	 * @param objectName ⽂件名称
-	 * @param expires    过期时间 <=7
-	 * @return url
-	 * @Title: getObjectURL
-	 * @Description: (获取 ⽂ 件外链) [bucketName 桶名, objectName 文件名, expires 时间<=1小时]
-	 */
-	public String getObjectUrl(String keyName) throws Exception {
-		return minioClient.presignedGetObject(bucketName, keyName, 3600);
-	}
-
-	/**
-	 * 自定义url
-	 * 
-	 * @param fileKey 文件的
-	 * @return
-	 */
-	public String getCustomUrl(String fileKey, String filePath) {
-		try {
-			// return fileHandle.getPreviewUrl(fileKey);
-			InputStream input = minioClient.getObject(bucketName, fileKey);
-			byte[] b = IoUtil.readBytes(input);
-			String uploadPath = AppConfigInfo.APP_UPLOAD_PATH;
-			if (!uploadPath.endsWith("/")) {
-				uploadPath = uploadPath + "/";
-			}
-			String transferFilePath = uploadPath + filePath;
-			FileUtils.writeByteArrayToFile(new File(transferFilePath), b);
-			return appMinioPreview +"/image/"+ filePath;
-		} catch (Exception e) {
-			log.error("图片预览失败:" + e.getLocalizedMessage());
-			return null;
-		}
-	}
-
-	/**
-	 * 根据文件路径从minio获取文件
-	 * @param filePath
-	 * @return
-	 * @throws Exception
-	 */
-	public File getFileWithPath(String filePath) throws Exception {
-		InputStream inputStream = minioClient.getObject(bucketName, filePath);
-		File file = File.createTempFile("compare",".jpeg");
-		file.deleteOnExit();
-		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();
-		InputStream inputStream = this.getObject(path);
-		// 这里已经关闭流,不需要手动关闭
-		return IoUtil.readBytes(inputStream);
-	}
-
-	public long getSize(String keyName) throws Exception {
-		ObjectStat stat = minioClient.statObject(bucketName, keyName);
-		long length = stat.length();
-		return length;
-	}
-}

文件差異過大導致無法顯示
+ 3 - 1
eladmin-system/src/main/java/me/zhengjie/base/util/HandwritingUtil.java


+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/base/util/TencentServiceUtil.java

@@ -355,7 +355,7 @@ public class TencentServiceUtil {
      * 图片压缩
      * @throws Exception
      */
-    private static String compressImage(String filePath) throws  Exception{
+    public static String compressImage(String filePath) throws  Exception{
         File input = new File(filePath);
         BufferedImage image = ImageIO.read(input);
 

+ 19 - 9
eladmin-system/src/main/java/me/zhengjie/dao/mybatis/ThirdPartyInterfaceRepository.java

@@ -1,22 +1,17 @@
 package me.zhengjie.dao.mybatis;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
 import me.zhengjie.application.admin.controller.vo.FaceCompareRsp;
-import me.zhengjie.base.ResultCode;
-import me.zhengjie.base.file.FaceMinioFileHandle;
 import me.zhengjie.base.util.BeanCopyUtils;
-import me.zhengjie.dao.mybatis.entity.ContractOrderEntity;
+import me.zhengjie.base.util.tencent.utils.HttpClientUtil;
 import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
 import me.zhengjie.dao.mybatis.entity.ThirdPartyInterfaceEntity;
-import me.zhengjie.dao.mybatis.mapper.ContractOrderMapper;
 import me.zhengjie.dao.mybatis.mapper.FileInfoMapper;
 import me.zhengjie.dao.mybatis.mapper.ThirdPartyInterfaceMapper;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Component;
-import org.springframework.util.ObjectUtils;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -27,7 +22,7 @@ import java.util.List;
 public class ThirdPartyInterfaceRepository {
     private final ThirdPartyInterfaceMapper thirdPartyInterfaceMapper;
     private final FileInfoMapper fileInfoMapper;
-    private final FaceMinioFileHandle minioFileHandle;
+
 
 
 
@@ -45,7 +40,7 @@ public class ThirdPartyInterfaceRepository {
             FileInfoEntity fileInfoEntity = fileInfoMapper.selectById(fileId);
             String previewUrl = null;
             try {
-                previewUrl = minioFileHandle.getPreviewUrl(fileInfoEntity.getPath());
+                previewUrl = getPreview(fileInfoEntity.getPath());
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
@@ -55,7 +50,22 @@ public class ThirdPartyInterfaceRepository {
         return faceCompareRspList;
     }
 
+    public String getPreview(String fileKey) {
+        JSONObject params = new JSONObject();
+        params.put("fileKey", fileKey);
+        HttpClientUtil httpClientUtil = new HttpClientUtil();
+        String xmlData = httpClientUtil.doPost("http://192.168.0.140:8831/sp/upload/getPreview",params.toString(),"utf-8");
+        System.err.println(xmlData);
+        JSONObject result = JSONObject.parseObject(xmlData);
+        String url = result.getString("url");
+        return url;
+    }
+
     public ThirdPartyInterfaceEntity getOne(QueryWrapper<ThirdPartyInterfaceEntity> thirdPartyInterfaceEntityQueryWrapper) {
         return thirdPartyInterfaceMapper.selectOne(thirdPartyInterfaceEntityQueryWrapper);
     }
+
+    public List<ThirdPartyInterfaceEntity> getList(QueryWrapper<ThirdPartyInterfaceEntity> thirdPartyInterfaceEntityQueryWrapper) {
+        return thirdPartyInterfaceMapper.selectList(thirdPartyInterfaceEntityQueryWrapper);
+    }
 }

+ 56 - 26
eladmin-system/src/main/java/me/zhengjie/domain/notary/impl/NotaryDomainImpl.java

@@ -1,5 +1,6 @@
 package me.zhengjie.domain.notary.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.arcsoft.face.*;
 import com.arcsoft.face.enums.DetectMode;
 import com.arcsoft.face.enums.DetectOrient;
@@ -9,10 +10,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 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;
+import me.zhengjie.base.util.tencent.utils.HttpClientUtil;
 import me.zhengjie.base.util.tencent.utils.Img2Base64Util;
 import me.zhengjie.dao.mybatis.ThirdPartyInterfaceRepository;
 import me.zhengjie.dao.mybatis.entity.*;
@@ -23,9 +23,9 @@ 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;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
@@ -43,7 +43,6 @@ 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;
 
@@ -120,9 +119,7 @@ public class NotaryDomainImpl implements NotaryDomain {
             log.info("base64转图片异常");
             return ResultCode.FACEAUTH_FAIL;
         }
-        FileInfoEntity fileInfo = saveCompareImage(base);
-        fileInfoMapper.insert(fileInfo);
-
+        FileInfoEntity fileInfo = uploadFile(base64);
         boolean redisFlag = (count != null && count >= 2);
         if (ObjectUtils.isEmpty(id) || redisFlag) {
             //要做人脸核身
@@ -230,8 +227,7 @@ public class NotaryDomainImpl implements NotaryDomain {
             //说明是客户经理
             if (sysUserEntity.getCompareImgId() == null || redisFlag) {
                 //说明客户经理需要做人脸核身
-                FileInfoEntity fileInfo = saveCompareImage(base);
-                fileInfoMapper.insert(fileInfo);
+                FileInfoEntity fileInfo = uploadFile(base64);
                 ThirdPartyInterfaceEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
                 thirdPartyInterfaceEntity.setFileId(fileInfo.getId() + "");
                 thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
@@ -252,8 +248,7 @@ public class NotaryDomainImpl implements NotaryDomain {
             }
         } else if (ObjectUtils.isEmpty(compareImageId) || redisFlag) {
             //说明当事人需要做人脸核身
-            FileInfoEntity fileInfo = saveCompareImage(base);
-            fileInfoMapper.insert(fileInfo);
+            FileInfoEntity fileInfo = uploadFile(base64);
             ThirdPartyInterfaceEntity thirdPartyInterfaceEntity = JuheServiceUtil.URLPost(idCard, nickName, base64);
             thirdPartyInterfaceEntity.setFileId(fileInfo.getId() + "");
             thirdPartyInterfaceEntity.setBusinessNo(compareImageDomain.getBusinessNo());
@@ -313,11 +308,13 @@ public class NotaryDomainImpl implements NotaryDomain {
         //激活引擎
         int errorCode = faceEngine.activeOnline(APPID, SDKKEY);
         if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
+            base.delete();
             throw new RuntimeException("引擎激活失败");
         }
         ActiveFileInfo activeFileInfo = new ActiveFileInfo();
         errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
         if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
+            base.delete();
             throw new RuntimeException("获取激活文件信息失败");
         }
         //引擎配置
@@ -339,6 +336,7 @@ public class NotaryDomainImpl implements NotaryDomain {
         //初始化引擎
         errorCode = faceEngine.init(engineConfiguration);
         if (errorCode != ErrorInfo.MOK.getValue()) {
+            base.delete();
             throw new RuntimeException("初始化引擎失败");
         }
         //人脸检测
@@ -360,6 +358,7 @@ public class NotaryDomainImpl implements NotaryDomain {
         if (pitch > 10 || yaw > 10) {
             //照片不符合标准
             log.info("图片不符合标准");
+            base.delete();
             return false;
         }
         //特征提取
@@ -372,9 +371,12 @@ public class NotaryDomainImpl implements NotaryDomain {
         String filePath = fileInfoEntity.getPath();
         File file = null;
         try {
-            file = minioFileHandle.getFileWithPath(filePath);
+            file = getFileWithPath(filePath);
         } catch (Exception e) {
             throw new RuntimeException(e);
+        }finally {
+            base.delete();
+            file.delete();
         }
         //人脸检测2
         ImageInfo imageInfo2 = getRGBData(file);
@@ -393,6 +395,8 @@ public class NotaryDomainImpl implements NotaryDomain {
         //如果通过 上传文件 修改用户绑定id 如果没通过 返回null证明失败了
         if (faceSimilar.getScore() > 0.8) {
             log.info("人脸照片比对通过");
+            base.delete();
+            file.delete();
             return true;
         }
         if (count == null) {
@@ -401,24 +405,50 @@ public class NotaryDomainImpl implements NotaryDomain {
             redis.set(redisCount, count + 1, 30, TimeUnit.MINUTES);
         }
         log.info("人脸照片比对未通过");
-        ;
+        base.delete();
+        file.delete();
         return false;
     }
 
-    private FileInfoEntity saveCompareImage(File base) {
-        FileHandleVo fileHandleVo = new FileHandleVo();
-        fileHandleVo.setFilePath(base.getPath());
-        fileHandleVo.setSourceFilePath("/face/" + base.getName());
-        fileHandleVo.setContentType("image/jpeg");
-        try {
-            minioFileHandle.uploadfilePath(fileHandleVo);
-        } catch (Exception e) {
-            throw new RuntimeException("照片保存到minio异常");
-        }
+
+    /**
+     * 上传对比照片到minio
+     * @param base64
+     */
+    public FileInfoEntity uploadFile(String base64){
+        JSONObject params = new JSONObject();
+        params.put("base64", base64);
+        HttpClientUtil httpClientUtil = new HttpClientUtil();
+        String xmlData = httpClientUtil.doPost("http://192.168.0.140:8831/sp/upload/uploadFaceImage",params.toString(),"utf-8");
+        JSONObject result = JSONObject.parseObject(xmlData);
+        String s =  result.getString("imagePath");
+        String[] split = s.split("/");
         FileInfoEntity fileInfo = new FileInfoEntity();
-        fileInfo.setLoanNo("face");
-        fileInfo.setFileName(base.getName());
-        fileInfo.setPath(fileInfo.getLoanNo() + "/" + base.getName());
+        fileInfo.setLoanNo(split[0]);
+        fileInfo.setFileName(split[split.length-1]);
+        fileInfo.setPath(s);
+        fileInfoMapper.insert(fileInfo);
         return fileInfo;
     }
+
+    /**
+     * 获取人脸照片比对的预览图
+     * @param fileKey
+     * @return
+     */
+
+    /**
+     *根据路径获取文件
+     */
+    public File getFileWithPath(String fileKey){
+        JSONObject params = new JSONObject();
+        params.put("fileKey", fileKey);
+        HttpClientUtil httpClientUtil = new HttpClientUtil();
+        String xmlData = httpClientUtil.doPost("http://192.168.0.140:8831/sp/upload/getFile",params.toString(),"utf-8");
+        System.err.println(xmlData);
+        JSONObject result = JSONObject.parseObject(xmlData);
+        File file = result.getObject("file", File.class);
+        return file;
+    }
+
 }