|
@@ -507,86 +507,90 @@ public class ESignServiceImpl implements IESignService {
|
|
|
|
|
|
@Override
|
|
|
public List<SealInfoDTO> orgOwnSeal(String orgCode) {
|
|
|
- AppSite appSite = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getOrgCode, orgCode));
|
|
|
- try {
|
|
|
- // 调用API获取响应
|
|
|
- EsignHttpResponse response = orgOwnSealList(appSite.getEsignOrgId());
|
|
|
+ List<SealInfoDTO> sealInfoDTOLists = new ArrayList<>();
|
|
|
+ List<AppSite> appSites = appSiteMapper.selectList(Wrappers.<AppSite>lambdaQuery().like(AppSite::getOrgCode, orgCode));
|
|
|
+ appSites.forEach(appSite -> {
|
|
|
+ try {
|
|
|
+ // 调用API获取响应
|
|
|
+ EsignHttpResponse response = orgOwnSealList(appSite.getEsignOrgId());
|
|
|
|
|
|
- // 解析JSON响应
|
|
|
- JsonObject result = gson.fromJson(response.getBody(), JsonObject.class);
|
|
|
+ // 解析JSON响应
|
|
|
+ JsonObject result = gson.fromJson(response.getBody(), JsonObject.class);
|
|
|
|
|
|
- // 验证数据结构
|
|
|
- if (!result.has("data")) {
|
|
|
- throw new JeecgBootException("响应数据中缺少'data'字段");
|
|
|
- }
|
|
|
+ // 验证数据结构
|
|
|
+ if (!result.has("data")) {
|
|
|
+ throw new JeecgBootException("响应数据中缺少'data'字段");
|
|
|
+ }
|
|
|
|
|
|
- JsonObject data = result.getAsJsonObject("data");
|
|
|
+ JsonObject data = result.getAsJsonObject("data");
|
|
|
|
|
|
- if (!data.has("seals")) {
|
|
|
- throw new JeecgBootException("响应数据中缺少'seals'字段");
|
|
|
- }
|
|
|
- // 原始数据
|
|
|
- JsonArray seals = data.getAsJsonArray("seals");
|
|
|
-
|
|
|
- JsonArray filteredSeals = new JsonArray();
|
|
|
- for (JsonElement element : seals) {
|
|
|
- JsonObject seal = element.getAsJsonObject();
|
|
|
- if ("PUBLIC".equals(seal.get("sealBizType").getAsString())) {
|
|
|
- filteredSeals.add(seal);
|
|
|
+ if (!data.has("seals")) {
|
|
|
+ throw new JeecgBootException("响应数据中缺少'seals'字段");
|
|
|
}
|
|
|
- }
|
|
|
- List<SealInfoDTO> sealInfoDTOList = gson.fromJson(filteredSeals, new TypeToken<List<SealInfoDTO>>(){}.getType());
|
|
|
- sealInfoDTOList.forEach(a ->{
|
|
|
- a.setOrgCode(orgCode);
|
|
|
- try {
|
|
|
- // 调用接口获取授权信息
|
|
|
- EsignHttpResponse response1 = orgSealsExternalAuth(appSite.getEsignOrgId(), a.getSealId());
|
|
|
- JsonObject result1 = gson.fromJson(response1.getBody(), JsonObject.class);
|
|
|
-
|
|
|
- // 检查 data 字段
|
|
|
- if (!result1.has("data")) {
|
|
|
- log.warn("授权信息中缺少 data 字段");
|
|
|
- a.setIsStatus(false);
|
|
|
- return;
|
|
|
+ // 原始数据
|
|
|
+ JsonArray seals = data.getAsJsonArray("seals");
|
|
|
+
|
|
|
+ JsonArray filteredSeals = new JsonArray();
|
|
|
+ for (JsonElement element : seals) {
|
|
|
+ JsonObject seal = element.getAsJsonObject();
|
|
|
+ if ("PUBLIC".equals(seal.get("sealBizType").getAsString())) {
|
|
|
+ filteredSeals.add(seal);
|
|
|
}
|
|
|
+ }
|
|
|
+ List<SealInfoDTO> sealInfoDTOList = gson.fromJson(filteredSeals, new TypeToken<List<SealInfoDTO>>(){}.getType());
|
|
|
+ sealInfoDTOList.forEach(a ->{
|
|
|
+ a.setOrgCode(orgCode);
|
|
|
+ try {
|
|
|
+ // 调用接口获取授权信息
|
|
|
+ EsignHttpResponse response1 = orgSealsExternalAuth(appSite.getEsignOrgId(), a.getSealId());
|
|
|
+ JsonObject result1 = gson.fromJson(response1.getBody(), JsonObject.class);
|
|
|
+
|
|
|
+ // 检查 data 字段
|
|
|
+ if (!result1.has("data")) {
|
|
|
+ log.warn("授权信息中缺少 data 字段");
|
|
|
+ a.setIsStatus(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- JsonObject data1 = result1.getAsJsonObject("data");
|
|
|
- if (!data1.has("sealAuthorizedInfos")) {
|
|
|
- log.warn("授权信息中缺少 sealAuthorizedInfos 字段");
|
|
|
- a.setIsStatus(false);
|
|
|
- return;
|
|
|
- }
|
|
|
+ JsonObject data1 = result1.getAsJsonObject("data");
|
|
|
+ if (!data1.has("sealAuthorizedInfos")) {
|
|
|
+ log.warn("授权信息中缺少 sealAuthorizedInfos 字段");
|
|
|
+ a.setIsStatus(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // 遍历授权信息列表
|
|
|
- JsonArray sealAuthorizedInfos = data1.getAsJsonArray("sealAuthorizedInfos");
|
|
|
- boolean isValid = false;
|
|
|
+ // 遍历授权信息列表
|
|
|
+ JsonArray sealAuthorizedInfos = data1.getAsJsonArray("sealAuthorizedInfos");
|
|
|
+ boolean isValid = false;
|
|
|
|
|
|
- for (JsonElement element : sealAuthorizedInfos) {
|
|
|
- JsonObject info = element.getAsJsonObject();
|
|
|
- String expireReason = info.get("expireReasonDescription").getAsString();
|
|
|
- String status = info.get("statusDescription").getAsString();
|
|
|
+ for (JsonElement element : sealAuthorizedInfos) {
|
|
|
+ JsonObject info = element.getAsJsonObject();
|
|
|
+ String expireReason = info.get("expireReasonDescription").getAsString();
|
|
|
+ String status = info.get("statusDescription").getAsString();
|
|
|
|
|
|
- if ("未失效".equals(expireReason) && "正常".equals(status)) {
|
|
|
- isValid = true;
|
|
|
- break;
|
|
|
+ if ("未失效".equals(expireReason) && "正常".equals(status)) {
|
|
|
+ isValid = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 设置 isStatus 字段
|
|
|
- a.setIsStatus(isValid);
|
|
|
+ // 设置 isStatus 字段
|
|
|
+ a.setIsStatus(isValid);
|
|
|
|
|
|
- } catch (EsignDemoException | JsonSyntaxException e) {
|
|
|
- log.error("处理印章授权状态失败,sealId: {}", a.getSealId(), e);
|
|
|
- a.setIsStatus(false);
|
|
|
- }
|
|
|
- });
|
|
|
- return sealInfoDTOList;
|
|
|
+ } catch (EsignDemoException | JsonSyntaxException e) {
|
|
|
+ log.error("处理印章授权状态失败,sealId: {}", a.getSealId(), e);
|
|
|
+ a.setIsStatus(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ sealInfoDTOLists.addAll(sealInfoDTOList);
|
|
|
|
|
|
- } catch (JsonSyntaxException e) {
|
|
|
- throw new JeecgBootException("JSON解析失败: " + e.getMessage(), e);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new JeecgBootException("获取印章列表失败: " + e.getMessage(), e);
|
|
|
- }
|
|
|
+ } catch (JsonSyntaxException e) {
|
|
|
+ throw new JeecgBootException("JSON解析失败: " + e.getMessage(), e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new JeecgBootException("获取印章列表失败: " + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return sealInfoDTOLists;
|
|
|
}
|
|
|
|
|
|
@Override
|