Commit a716b5efe092749f3e98fce6a04b63d694f431b4

Authored by zhangmeiyang
1 parent 8f99bf48

feat(utils): 增强JsonPath解析工具类功能

- 修改parse方法返回类型为Object并增加空值校验
- 新增parseString方法用于安全字符串转换
- 在MappingUtils中替换使用新的parseString方法
- 新增YongYouConnectionManager实现类
- 实现系统类型标记和连接获取基础逻辑
tax-central/src/main/java/com/diligrp/tax/central/manager/impl/YongYouConnectionManager.java 0 → 100644
  1 +package com.diligrp.tax.central.manager.impl;
  2 +
  3 +import com.diligrp.tax.central.manager.AbstractConnectionManager;
  4 +import com.diligrp.tax.central.model.TenantPipeline;
  5 +import com.diligrp.tax.central.type.SystemType;
  6 +import com.kingdee.bos.webapi.entity.IdentifyInfo;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * @Author: zhangmeiyang
  11 + * @CreateTime: 2025-11-06 14:59
  12 + * @Version: todo
  13 + */
  14 +@Component
  15 +public class YongYouConnectionManager extends AbstractConnectionManager<Object> {
  16 + @Override
  17 + public SystemType markSystemType() {
  18 + return SystemType.YONG_YOU;
  19 + }
  20 +
  21 + @Override
  22 + public IdentifyInfo getConnection(TenantPipeline tenantPipeline) {
  23 + return null;
  24 + }
  25 +}
... ...
tax-central/src/main/java/com/diligrp/tax/central/utils/JsonPathUtils.java
... ... @@ -16,10 +16,17 @@ import java.util.Optional;
16 16 */
17 17 public class JsonPathUtils {
18 18  
19   - public static String parse(String httpResult, String dataPath) {
  19 + public static Object parse(String httpResult, String dataPath) {
20 20 Optional.ofNullable(httpResult).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.REMOTE_SERVICE_CALLS_ARE_EXCEPTIONAL));
21 21 Optional.ofNullable(dataPath).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.PARAMETER_IS_NOT_PARSED_CORRECTLY));
22   - return JsonPath.read(httpResult, dataPath).toString();
  22 + return JsonPath.read(httpResult, dataPath);
  23 + }
  24 +
  25 + public static String parseString(String httpResult, String dataPath) {
  26 + Optional.ofNullable(httpResult).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.REMOTE_SERVICE_CALLS_ARE_EXCEPTIONAL));
  27 + Optional.ofNullable(dataPath).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.PARAMETER_IS_NOT_PARSED_CORRECTLY));
  28 + var res = JsonPath.read(httpResult, dataPath);
  29 + return Optional.ofNullable(res).map(Object::toString).orElse("");
23 30 }
24 31  
25 32 /**
... ... @@ -54,6 +61,4 @@ public class JsonPathUtils {
54 61 dataPathMap.forEach((k, v) -> res.put(k, JsonPath.read(httpResult, v)));
55 62 return res;
56 63 }
57   -
58   -
59 64 }
... ...
tax-central/src/main/java/com/diligrp/tax/central/utils/MappingUtils.java
... ... @@ -106,7 +106,7 @@ public class MappingUtils {
106 106 });
107 107 params.put(remoteParam.getField(), value);
108 108 var result = SingletonHttpClient.instance().postBody(remoteAddress, params);
109   - String remoteValue = JsonPathUtils.parse(result, remoteParam.getDataPath());
  109 + String remoteValue = JsonPathUtils.parseString(result, remoteParam.getDataPath());
110 110 field.set(object, remoteValue);
111 111 }
112 112 }
... ...