Guos 2 days ago
parent
commit
5fe8f14313
1 changed files with 46 additions and 38 deletions
  1. 46 38
      fs-common/src/main/java/com/fs/common/utils/txocr/TxOcrClient.java

+ 46 - 38
fs-common/src/main/java/com/fs/common/utils/txocr/TxOcrClient.java

@@ -32,6 +32,13 @@ public class TxOcrClient  {
 
     private static final String YPLS = "药品零售";
 
+
+    /**
+     * 身份证识别
+     * @param name
+     * @param idNumber
+     * @return
+     */
     public static IdCardVerificationResponse IdCardVerification(String name, String idNumber) {
         IdCardVerificationResponse map = new IdCardVerificationResponse();
         try {
@@ -54,6 +61,7 @@ public class TxOcrClient  {
         }
         return map;
     }
+
     /**
      * 医疗器械url识别
      * @return
@@ -63,9 +71,8 @@ public class TxOcrClient  {
         return null;
     }
 
-
     /**
-     * 营业执照识别
+     * 营业执照识别(监听使用后续关闭掉)
      * @param imageUrl
      * @return
      */
@@ -113,42 +120,6 @@ public class TxOcrClient  {
         return null;
     }
 
-    /**
-     * 药品经营许可证识别(有概率识别不准)
-     * @param imageUrl
-     * @return
-     */
-    public static String enterpriseLicenseOCR(String imageUrl){
-        try{
-            Credential cred = new Credential("AKIDviPyMZbRp24udCcpqjQxHOK4cx88ze6N", "97tVwEJE81sY0StDPPGukQ2ZvkU3QceY");
-            HttpProfile httpProfile = new HttpProfile();
-            httpProfile.setEndpoint("ocr.tencentcloudapi.com");
-            ClientProfile clientProfile = new ClientProfile();
-            clientProfile.setHttpProfile(httpProfile);
-            OcrClient client = new OcrClient(cred, "", clientProfile);
-            EnterpriseLicenseOCRRequest req = new EnterpriseLicenseOCRRequest();
-            req.setImageUrl(imageUrl);
-            EnterpriseLicenseOCRResponse resp = client.EnterpriseLicenseOCR(req);
-            Optional<EnterpriseLicenseInfo> jyfw = Arrays.stream(resp.getEnterpriseLicenseInfos())
-                    .filter(enterpriseLicenseInfo -> enterpriseLicenseInfo.getName().equals("经营范围")).findAny();
-            if(!jyfw.isPresent()){
-                return null;
-            }
-            AtomicReference<String> value = new AtomicReference<>();
-                    Arrays.stream(resp.getEnterpriseLicenseInfos()).forEach(enterpriseLicenseInfo -> {
-                String name = enterpriseLicenseInfo.getName();
-                if(name.equals("经营范围")){
-                    value.set(enterpriseLicenseInfo.getValue());
-                }
-            });
-            log.info("许可证书OCR请求识别成功!结果是:{}",AbstractModel.toJsonString(resp));
-            return value.get();
-        } catch (TencentCloudSDKException e) {
-            log.info("证书识别失败!异常信息是:{}",e.toString());
-        }
-        return null;
-    }
-
     /**
      * BizLicenseOCR
      * 本接口支持快速精准识别营业执照上的字段,包括统一社会信用代码、公司名称、主体类型、法定代表人、注册资本、组成形式、成立日期、营业期限和经营范围等字段。
@@ -207,6 +178,43 @@ public class TxOcrClient  {
         return result;
     }
 
+
+    /**
+     * 药品经营许可证识别(有概率识别不准)
+     * @param imageUrl
+     * @return
+     */
+    public static String enterpriseLicenseOCR(String imageUrl){
+        try{
+            Credential cred = new Credential("AKIDviPyMZbRp24udCcpqjQxHOK4cx88ze6N", "97tVwEJE81sY0StDPPGukQ2ZvkU3QceY");
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("ocr.tencentcloudapi.com");
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+            OcrClient client = new OcrClient(cred, "", clientProfile);
+            EnterpriseLicenseOCRRequest req = new EnterpriseLicenseOCRRequest();
+            req.setImageUrl(imageUrl);
+            EnterpriseLicenseOCRResponse resp = client.EnterpriseLicenseOCR(req);
+            Optional<EnterpriseLicenseInfo> jyfw = Arrays.stream(resp.getEnterpriseLicenseInfos())
+                    .filter(enterpriseLicenseInfo -> enterpriseLicenseInfo.getName().equals("经营范围")).findAny();
+            if(!jyfw.isPresent()){
+                return null;
+            }
+            AtomicReference<String> value = new AtomicReference<>();
+            Arrays.stream(resp.getEnterpriseLicenseInfos()).forEach(enterpriseLicenseInfo -> {
+                String name = enterpriseLicenseInfo.getName();
+                if(name.equals("经营范围")){
+                    value.set(enterpriseLicenseInfo.getValue());
+                }
+            });
+            log.info("许可证书OCR请求识别成功!结果是:{}",AbstractModel.toJsonString(resp));
+            return value.get();
+        } catch (TencentCloudSDKException e) {
+            log.info("证书识别失败!异常信息是:{}",e.toString());
+        }
+        return null;
+    }
+
     /**
      * EnterpriseLicenseOCR
      * 本接口支持智能化识别各类企业登记证书、许可证书、企业执照、三证合一类证书,结构化输出统一社会信用代码、公司名称、法定代表人、公司地址、注册资金、企业类型、经营范围、成立日期、有效期、开办资金、经费来源、举办单位等关键字段。