|
@@ -1,29 +1,17 @@
|
|
|
package com.zhongzheng.modules.tencentcloud.service.impl;
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tencentcloudapi.common.Credential;
|
|
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
|
|
-import com.tencentcloudapi.common.profile.HttpProfile;
|
|
|
-import com.tencentcloudapi.faceid.v20180301.FaceidClient;
|
|
|
-import com.tencentcloudapi.faceid.v20180301.models.DetectAuthRequest;
|
|
|
-import com.tencentcloudapi.faceid.v20180301.models.DetectAuthResponse;
|
|
|
-import com.tencentcloudapi.faceid.v20180301.models.GetDetectInfoRequest;
|
|
|
-import com.tencentcloudapi.faceid.v20180301.models.GetDetectInfoResponse;
|
|
|
import com.tencentcloudapi.iai.v20200303.IaiClient;
|
|
|
import com.tencentcloudapi.iai.v20200303.models.CompareFaceRequest;
|
|
|
import com.tencentcloudapi.iai.v20200303.models.CompareFaceResponse;
|
|
|
import com.tencentcloudapi.ocr.v20181119.OcrClient;
|
|
|
-import com.tencentcloudapi.ocr.v20181119.models.IDCardOCRRequest;
|
|
|
-import com.tencentcloudapi.ocr.v20181119.models.IDCardOCRResponse;
|
|
|
-import com.tencentcloudapi.ocr.v20181119.models.VatInvoiceOCRRequest;
|
|
|
-import com.tencentcloudapi.ocr.v20181119.models.VatInvoiceOCRResponse;
|
|
|
+import com.tencentcloudapi.ocr.v20181119.models.*;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
-import com.zhongzheng.common.utils.DateUtils;
|
|
|
-import com.zhongzheng.common.utils.file.ImageUtils;
|
|
|
import com.zhongzheng.modules.alioss.bo.OssRequest;
|
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.base.bo.UserProfileFit;
|
|
@@ -32,22 +20,17 @@ import com.zhongzheng.modules.base.service.IUserProfileService;
|
|
|
import com.zhongzheng.modules.base.vo.UserProfileVo;
|
|
|
import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
|
|
|
import com.zhongzheng.modules.tencentcloud.bo.InvoiceQueryBo;
|
|
|
-import com.zhongzheng.modules.tencentcloud.service.IFaceService;
|
|
|
-import com.zhongzheng.modules.user.service.IUserOcrService;
|
|
|
+import com.zhongzheng.modules.tencentcloud.service.IFaceOcrService;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
-import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import springfox.documentation.spring.web.json.Json;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
-public class FaceServiceImpl implements IFaceService {
|
|
|
+public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
|
|
|
@Value("${tencent.cloud.SecretId}")
|
|
|
private String SecretId;
|
|
@@ -163,10 +146,20 @@ public class FaceServiceImpl implements IFaceService {
|
|
|
req.setIsPdf(true);
|
|
|
req.setImageUrl(ossHost+"/"+bo.getImageUrl());
|
|
|
VatInvoiceOCRResponse resp = client.VatInvoiceOCR(req);
|
|
|
+ TextVatInvoice[] textArr = resp.getVatInvoiceInfos();
|
|
|
+ Map<String,String> rs = new HashMap<>();
|
|
|
+ for(TextVatInvoice text : textArr){
|
|
|
+ if(text.getName().equals("发票代码")){
|
|
|
+ rs.put("invoiceCode",text.getValue());
|
|
|
+ }
|
|
|
+ if(text.getName().equals("发票号码")){
|
|
|
+ rs.put("invoiceNum",text.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rs;
|
|
|
}catch (TencentCloudSDKException e){
|
|
|
System.out.println("错误"+e.getMessage());
|
|
|
}
|
|
|
-
|
|
|
return null;
|
|
|
}
|
|
|
}
|