Commit 80c081ac6afd5235d4ea132e0fec9e4d94498e73
1 parent
fd9b641c
refactor(sender): 优化映射验证逻辑并增强日志记录
- 使用 Optional 简化空值检查逻辑 - 在查询金蝶接口后增加结果日志输出 - 引入 JsonUtils 工具类序列化日志内容 - 添加 Slf4j 注解以支持结构化日志记录 - 重构条件判断避免嵌套判空操作
Showing
1 changed file
with
9 additions
and
4 deletions
tax-proxy/src/main/java/com/diligrp/tax/proxy/demarcate/Sender.java
| ... | ... | @@ -5,17 +5,21 @@ import com.diligrp.tax.central.domain.BaseProxy; |
| 5 | 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; |
| 6 | 6 | import com.diligrp.tax.central.type.DocumentType; |
| 7 | 7 | import com.diligrp.tax.central.type.TaxSystemType; |
| 8 | +import com.diligrp.tax.central.utils.JsonUtils; | |
| 8 | 9 | import com.diligrp.tax.proxy.helper.KingDeeHelper; |
| 9 | 10 | import com.kingdee.bos.webapi.entity.IdentifyInfo; |
| 10 | 11 | import com.kingdee.bos.webapi.sdk.K3CloudApi; |
| 12 | +import lombok.extern.slf4j.Slf4j; | |
| 11 | 13 | |
| 12 | 14 | import java.util.List; |
| 15 | +import java.util.Optional; | |
| 13 | 16 | |
| 14 | 17 | /** |
| 15 | 18 | * @Author: zhangmeiyang |
| 16 | 19 | * @CreateTime: 2025-11-03 17:55 |
| 17 | 20 | * @Version: todo |
| 18 | 21 | */ |
| 22 | +@Slf4j | |
| 19 | 23 | public abstract class Sender<T extends BaseProxy> { |
| 20 | 24 | /** |
| 21 | 25 | * 标记文档 |
| ... | ... | @@ -39,11 +43,12 @@ public abstract class Sender<T extends BaseProxy> { |
| 39 | 43 | * @param mapping 映射 |
| 40 | 44 | */ |
| 41 | 45 | protected void validMapping(IdentifyInfo identifyInfo, BaseMapping mapping) { |
| 42 | - if (!mapping.getVerifyInformation().isEmpty() && !mapping.getReturnKeys().isEmpty()){ | |
| 46 | + Optional.ofNullable(mapping.getVerifyInformation()).filter(e -> !e.isEmpty()).ifPresent(f -> { | |
| 43 | 47 | List<Object> infos = KingDeeHelper.querySend(mapping, markDocument().value, new K3CloudApi(identifyInfo)); |
| 44 | - if (!infos.isEmpty()) { | |
| 48 | + Optional.ofNullable(infos).filter(e -> !e.isEmpty()).ifPresent(g -> { | |
| 49 | + log.info("kingdee query result:{}", JsonUtils.toJsonString(g)); | |
| 45 | 50 | throw new TaxAgentServiceException(TaxSystemType.REPEAT_SENDING); |
| 46 | - } | |
| 47 | - } | |
| 51 | + }); | |
| 52 | + }); | |
| 48 | 53 | } |
| 49 | 54 | } | ... | ... |