Browse Source

fix(app): 修复查询印章列表相关问题

- 优化了印章列表查询逻辑,增加了对空值的检查
- 修复了 orgCode 错误的问题
-优化了异常处理,提高了代码的健壮性
SheepHy 1 day ago
parent
commit
f12baef500

+ 16 - 12
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/esign/seal/SealDemo.java

@@ -167,18 +167,22 @@ public class SealDemo {
      * 查询企业内部印章
      */
 
-    public static EsignHttpResponse orgOwnSealList(String orgId) throws EsignDemoException {
-        int pageNum=1;
-        int pageSize=10;
-        String apiaddr="/v3/seals/org-own-seal-list?orgId="+orgId+"&pageNum="+pageNum+"&pageSize="+pageSize;
-        //请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
-        String jsonParm=null;
-        //请求方法
-        EsignRequestType requestType= EsignRequestType.GET;
-        //生成签名鉴权方式的的header
-        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
-        //发起接口请求
-        return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
+    public static EsignHttpResponse orgOwnSealList(String orgId) {
+        try {
+            int pageNum=1;
+            int pageSize=10;
+            String apiaddr="/v3/seals/org-own-seal-list?orgId="+orgId+"&pageNum="+pageNum+"&pageSize="+pageSize;
+            //请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
+            String jsonParm=null;
+            //请求方法
+            EsignRequestType requestType= EsignRequestType.GET;
+            //生成签名鉴权方式的的header
+            Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
+            //发起接口请求
+            return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
     }
 
     /**

+ 9 - 9
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/ESignServiceImpl.java

@@ -15,7 +15,10 @@ import org.jeecg.modules.app.esign.fileAndTemplate.FileDemo;
 import org.jeecg.modules.app.esign.sign.SignDemo;
 import org.jeecg.modules.app.service.IESignService;
 import org.jeecg.modules.system.app.dto.AppContractInfoDTO;
-import org.jeecg.modules.system.app.entity.*;
+import org.jeecg.modules.system.app.entity.AppContractInfo;
+import org.jeecg.modules.system.app.entity.AppContractSign;
+import org.jeecg.modules.system.app.entity.AppOrder;
+import org.jeecg.modules.system.app.entity.FamilyMembers;
 import org.jeecg.modules.system.app.mapper.*;
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.mapper.SysDepartMapper;
@@ -509,7 +512,7 @@ public class ESignServiceImpl implements IESignService {
         List<SealInfoDTO> sealInfoDTOLists = new ArrayList<>();
         List<SysDepart> sysDeparts = sysDepartMapper.selectList(Wrappers.<SysDepart>lambdaQuery().like(SysDepart::getOrgCode, orgCode));
         sysDeparts.forEach(sysDepart -> {
-            try {
+            if(sysDepart.getEsignOrgId() != null){
                 // 调用API获取响应
                 EsignHttpResponse response = orgOwnSealList(sysDepart.getEsignOrgId());
 
@@ -520,7 +523,9 @@ public class ESignServiceImpl implements IESignService {
                 if (!result.has("data")) {
                     throw new JeecgBootException("响应数据中缺少'data'字段");
                 }
-
+                if(result.get("code").getAsInt() != 0){
+                    return;
+                }
                 JsonObject data = result.getAsJsonObject("data");
 
                 if (!data.has("seals")) {
@@ -538,7 +543,7 @@ public class ESignServiceImpl implements IESignService {
                 }
                 List<SealInfoDTO> sealInfoDTOList = gson.fromJson(filteredSeals, new TypeToken<List<SealInfoDTO>>(){}.getType());
                 sealInfoDTOList.forEach(a ->{
-                    a.setOrgCode(orgCode);
+                    a.setOrgCode(sysDepart.getOrgCode());
                     try {
                         // 调用接口获取授权信息
                         EsignHttpResponse response1 = orgSealsExternalAuth(sysDepart.getEsignOrgId(), a.getSealId());
@@ -582,11 +587,6 @@ public class ESignServiceImpl implements IESignService {
                     }
                 });
                 sealInfoDTOLists.addAll(sealInfoDTOList);
-
-            } catch (JsonSyntaxException e) {
-                throw new JeecgBootException("JSON解析失败: " + e.getMessage(), e);
-            } catch (Exception e) {
-                throw new JeecgBootException("获取印章列表失败: " + e.getMessage(), e);
             }
         });
         return sealInfoDTOLists;