ソースを参照

尝试三次和添加字段输出

yousongbo 19 時間 前
コミット
85e282e644

+ 46 - 60
suishenbang-common/src/main/java/com/dgtly/common/utils/http/HttpUtils.java

@@ -458,76 +458,62 @@ public class HttpUtils
      */
     public static String sendSSLGet(String url)
     {
-        StringBuilder result = new StringBuilder();
-        BufferedReader in = null;
-        try
-        {
-            String urlNameString = url;
-            log.info("sendSSLGet - {}", urlNameString);
-            SSLContext sc = SSLContext.getInstance("SSL");
-            sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
-            URL realUrl = new URL(urlNameString);
-
-            HttpsURLConnection connection = (HttpsURLConnection)realUrl.openConnection();
-            connection.setRequestProperty("accept", "*/*");
-            connection.setRequestProperty("connection", "Keep-Alive");
-            connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
-
-            connection.setSSLSocketFactory(sc.getSocketFactory());
-            connection.setHostnameVerifier(new TrustAnyHostnameVerifier());
-
-            connection.setConnectTimeout(10000);   // 连接超时 10s
-            connection.setReadTimeout(30000);      // 读取超时 30s
-
-            connection.connect();
-            in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-            String line;
-            while ((line = in.readLine()) != null)
-            {
-                result.append(line);
-            }
-            log.info("recv - {}", result);
-        }
-        catch(ConnectException e)
-        {
-            log.error("调用HttpUtils.sendGet ConnectException, url=" + url , e);
-
-            throw new BusinessException("调用HttpUtils.sendGet ConnectException, url=" + url  );
-        }
-        catch (SocketTimeoutException e)
-        {
-            log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url , e);
-
-            throw new BusinessException("调用HttpUtils.sendGet SocketTimeoutException, url=" + url  );
+        int maxRetry = 3;
+        Exception lastException = null;
 
-        }
-        catch (IOException e)
-        {
-            log.error("调用HttpUtils.sendGet IOException, url=" + url, e);
-
-            throw new BusinessException("调用HttpUtils.sendGet IOException, url=" + url  );
-        }
-        catch (Exception e)
-        {
-            log.error("调用HttpsUtil.sendGet Exception, url=" + url , e);
-
-            throw new BusinessException("调用HttpUtils.sendGet Exception, url=" + url  );
-        }
-        finally
+        for (int attempt = 1; attempt <= maxRetry; attempt++)
         {
+            StringBuilder result = new StringBuilder();
+            BufferedReader in = null;
             try
             {
-                if (in != null)
+                log.info("sendSSLGet - {} (第{}次尝试)", url, attempt);
+                SSLContext sc = SSLContext.getInstance("SSL");
+                sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
+                URL realUrl = new URL(url);
+
+                HttpsURLConnection connection = (HttpsURLConnection)realUrl.openConnection();
+                connection.setRequestProperty("accept", "*/*");
+                connection.setRequestProperty("connection", "Keep-Alive");
+                connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+
+                connection.setSSLSocketFactory(sc.getSocketFactory());
+                connection.setHostnameVerifier(new TrustAnyHostnameVerifier());
+
+                connection.connect();
+                in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+                String line;
+                while ((line = in.readLine()) != null)
                 {
-                    in.close();
+                    result.append(line);
                 }
+                log.info("sendSSLGet 成功 - url={}, 第{}次尝试", url, attempt);
+                log.info("recv - {}", result);
+                return result.toString();
             }
-            catch (Exception ex)
+            catch (Exception e)
             {
-                log.error("调用in.close Exception, url=" + url , ex);
+                lastException = e;
+                log.warn("sendSSLGet 第{}次尝试失败, url={}, 异常: {}", attempt, url, e.getMessage());
+            }
+            finally
+            {
+                try
+                {
+                    if (in != null)
+                    {
+                        in.close();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    log.error("调用in.close Exception, url=" + url, ex);
+                }
             }
         }
-        return result.toString();
+
+        log.error("sendSSLGet 重试{}次后仍然失败, url={}", maxRetry, url, lastException);
+        throw new BusinessException("调用HttpUtils.sendSSLGet失败,已重试" + maxRetry + "次, url=" + url);
     }
 
 

+ 10 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/CustomersExt.java

@@ -63,6 +63,16 @@ public class CustomersExt extends BaseEntity
 
     private  Date createTime;
 
+    private Integer customerStatus;
+
+    public Integer getCustomerStatus() {
+        return customerStatus;
+    }
+
+    public void setCustomerStatus(Integer customerStatus) {
+        this.customerStatus = customerStatus;
+    }
+
     @Override
     public Date getCreateTime() {
         return createTime;

+ 66 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/EsignCorpAuthSignRecord.java

@@ -0,0 +1,66 @@
+package com.dgtly.system.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @FileName: EsignCorpAuthSignRecord
+ * @Description: e签宝企业授权书签署状态记录实体
+ *
+ *   对应表:esign_corp_auth_sign_record
+ *   在调用 /corpAuthSign 接口成功返回 authId 后插入记录,
+ *   后续可通过 queryAuthResult 接口更新 status 字段。
+ *
+ *   status 枚举:
+ *     1 = 进行中(默认写入值)
+ *     2 = 授权成功
+ *     3 = 授权失败
+ *     4 = 取消授权
+ *
+ * @author: auto-generated
+ * @create: 2026-05-20
+ **/
+@Data
+public class EsignCorpAuthSignRecord {
+
+    /** 主键ID */
+    private Long id;
+
+    /**
+     * 授权流程ID(e签宝返回的 authId)
+     * 唯一索引,不可为空
+     */
+    private String authId;
+
+    /**
+     * 机构账号ID(e签宝 orgId / accountId)
+     * 对应请求参数中的 accountId
+     */
+    private String orgId;
+
+    /**
+     * 经销商编码(业务侧经销商编码,即 custome_code)
+     */
+    private String customeCode;
+
+    /**
+     * 经办人账号ID(e签宝 transactorAccountId)
+     */
+    private String creator;
+
+    /**
+     * 授权状态
+     * 1=进行中  2=授权成功  3=授权失败  4=取消授权
+     */
+    private Integer status;
+
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /** 更新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+}

+ 11 - 0
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/EsignController.java

@@ -68,6 +68,9 @@ public class EsignController extends ApiBaseController {
     private ICustomersCodeService customersService;
     @Autowired
     private ISysUserCustomerAuthorizationService authorizationService;
+
+    @Autowired
+    private IEsignCorpAuthSignRecordService iEsignCorpAuthSignRecordService;
     /**
      * @description: 经销商订单签收方法
      * 没有注册就注册,注册完就认证,然后再点击签署按钮,获取经销商用户id,对应主体id
@@ -810,6 +813,14 @@ public class EsignController extends ApiBaseController {
             for (SysUserExt sysUserExt:resultList) {
                 CustomersExt customersExt = customersExtService.selectCustomersExtById(sysUserExt.getOrgCode());
                 if (customersExt!=null){
+                    if (StringUtils.isNotEmpty(sysUserExt.getOrgCode())){
+                        EsignCorpAuthSignRecord esignCorpAuthSignRecord = iEsignCorpAuthSignRecordService.selectByCustomeCode(sysUserExt.getOrgCode());
+                        if (esignCorpAuthSignRecord != null){
+                            customersExt.setCustomerStatus(esignCorpAuthSignRecord.getStatus());
+                        }else {
+                            customersExt.setCustomerStatus(0);
+                        }
+                    }
                     customersExtList.add(customersExt);
                 }
             }