Преглед изворни кода

feat(交通银行):ocr识别

liutao пре 1 месец
родитељ
комит
8643203e53

+ 49 - 41
src/main/java/com/inkasso/factoring/creditmanagement/service/impl/SupplierInfoServiceImpl.java

@@ -323,10 +323,11 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
             zxCountBig = zxCount;
             stCountBig = stCount;
         } else {
+            int num = 1;
             //判定没名字超过4个字  就是公司
             if (stockName.length() > 4) {
                 //公司循环找出大股东
-                findBig(cPartner.getCreditCode(), comprehensiveRiskInvestigationId, existEnterprise);
+                findBig(cPartner.getCreditCode(), comprehensiveRiskInvestigationId, existEnterprise,num);
                 sxCountBig = existEnterprise.getSxCountBig();
                 zxCountBig = existEnterprise.getZxCountBig();
                 stCountBig = existEnterprise.getStCountBig();
@@ -1135,48 +1136,55 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
         return flag;
     }
 
-    private void findBig(String creditCode, Long comprehensiveRiskInvestigationId, Enterprise enterprise) {
-        // 股东信息 工商登记
-        String pubStockUrl = pubStock + "?socialCreditCode=" + creditCode + "&comprehensiveRiskInvestigationId=" + comprehensiveRiskInvestigationId;
-        ResponseJson forObject;
-        try {
-            forObject = restTemplate.getForObject(pubStockUrl, ResponseJson.class);
-        } catch (Exception e) {
-            throw new ServiceException(CodeUtil.FAIL, "网络异常,请稍后重试!");
-        }
-        if (forObject != null) {
-            JSONObject jsonObject = new JSONObject(forObject.getData());
-            List<CRegStock> list = jsonObject.getBeanList("list", CRegStock.class);
-            CRegStock cRegStock = list.stream().map(r -> {
-                String stockPercent = r.getStockPercent();
-                stockPercent = stockPercent.replace("%", "");
-                double percent = Double.valueOf(stockPercent);
-                r.setPercent(percent);
-                return r;
-            }).max(Comparator.comparing(CRegStock::getPercent)).get();
-            String cRegStockStockName = cRegStock.getStockName();
-            if (cRegStockStockName.length() > 4) {
-                findBig(cRegStock.getCreditCode(), comprehensiveRiskInvestigationId, enterprise);
-            } else {
-                //大股东 763-董监高风险扫描
-                enterprise.setMajorShareholders(cRegStock.getStockName());
-                String bigDongjiangaoRisksUrl = dongjiangaoRisks + "?socialCreditCode=" + creditCode + "&personName=" + cRegStockStockName;
-                ResponseJson bigDongjiangaoRisksObject;
-                try {
-                    bigDongjiangaoRisksObject = restTemplate.getForObject(bigDongjiangaoRisksUrl, ResponseJson.class);
-                } catch (Exception e) {
-                    throw new ServiceException(CodeUtil.FAIL, "网络异常,请稍后重试!");
+    private void findBig(String creditCode, Long comprehensiveRiskInvestigationId, Enterprise enterprise, int num) {
+        if(num < 5){
+            num ++;
+            // 股东信息 工商登记
+            String pubStockUrl = pubStock + "?socialCreditCode=" + creditCode + "&comprehensiveRiskInvestigationId=" + comprehensiveRiskInvestigationId;
+            ResponseJson forObject;
+            try {
+                forObject = restTemplate.getForObject(pubStockUrl, ResponseJson.class);
+            } catch (Exception e) {
+                throw new ServiceException(CodeUtil.FAIL, "网络异常,请稍后重试!");
+            }
+            if (forObject != null) {
+                JSONObject jsonObject = new JSONObject(forObject.getData());
+                List<CRegStock> list = jsonObject.getBeanList("list", CRegStock.class);
+                CRegStock cRegStock = list.stream().map(r -> {
+                    String stockPercent = r.getStockPercent();
+                    stockPercent = stockPercent.replace("%", "");
+                    double percent = Double.valueOf(stockPercent);
+                    r.setPercent(percent);
+                    return r;
+                }).max(Comparator.comparing(CRegStock::getPercent)).get();
+                String cRegStockStockName = cRegStock.getStockName();
+                if (cRegStockStockName.length() > 4) {
+                    findBig(cRegStock.getCreditCode(), comprehensiveRiskInvestigationId, enterprise, num);
+                } else {
+                    //大股东 763-董监高风险扫描
+                    enterprise.setMajorShareholders(cRegStock.getStockName());
+                    String bigDongjiangaoRisksUrl = dongjiangaoRisks + "?socialCreditCode=" + creditCode + "&personName=" + cRegStockStockName;
+                    ResponseJson bigDongjiangaoRisksObject;
+                    try {
+                        bigDongjiangaoRisksObject = restTemplate.getForObject(bigDongjiangaoRisksUrl, ResponseJson.class);
+                    } catch (Exception e) {
+                        throw new ServiceException(CodeUtil.FAIL, "网络异常,请稍后重试!");
+                    }
+                    JSONObject bigDongjiangaoRisks = new JSONObject(bigDongjiangaoRisksObject.getData());
+                    Integer sxCountBig = bigDongjiangaoRisks.getInt("sxCount");
+                    Integer zxCountBig = bigDongjiangaoRisks.getInt("zxCount");
+                    Integer stCountBig = bigDongjiangaoRisks.getInt("stCount");
+                    Long dongjiangaoRiskBigId = bigDongjiangaoRisks.getLong("id");
+                    enterprise.setcDongjiangaoRiskBigId(dongjiangaoRiskBigId);
+                    enterprise.setSxCountBig(sxCountBig);
+                    enterprise.setZxCountBig(zxCountBig);
+                    enterprise.setStCountBig(stCountBig);
                 }
-                JSONObject bigDongjiangaoRisks = new JSONObject(bigDongjiangaoRisksObject.getData());
-                Integer sxCountBig = bigDongjiangaoRisks.getInt("sxCount");
-                Integer zxCountBig = bigDongjiangaoRisks.getInt("zxCount");
-                Integer stCountBig = bigDongjiangaoRisks.getInt("stCount");
-                Long dongjiangaoRiskBigId = bigDongjiangaoRisks.getLong("id");
-                enterprise.setcDongjiangaoRiskBigId(dongjiangaoRiskBigId);
-                enterprise.setSxCountBig(sxCountBig);
-                enterprise.setZxCountBig(zxCountBig);
-                enterprise.setStCountBig(stCountBig);
             }
+        }else {
+            enterprise.setSxCountBig(0);
+            enterprise.setZxCountBig(0);
+            enterprise.setStCountBig(0);
         }
     }
 }