Commit 694924fe14377ec30c77d881371f447a7b827e18

Authored by zhangmeiyang
1 parent 0134403a

feat(kingdee):优化客户和单据构建逻辑并调整金蝶连接管理

- 修改 BaseCustomer 类中的字段访问权限为 protected,并注释掉 currency 字段
- 在 Builder 和具体实现类中增加对 TenantPipeline 的支持以配置默认数据
- 更新 CustomerBuilder、ReceiptBuilder 等类以通过反射方式设置对象属性
- 调整 KingDeeConnectionManager 返回 IdentifyInfo 而非 K3CloudApi 实例
- 修改 CustomerSender 及其他 Sender 类处理联系人信息的方式- 在 ProxyProcessor 和 InitializeProcessor 中传递 pipelineCode 参数
- 增加 ITenantTaxService 接口获取租户 ID 方法- 扩展 MessageContext 类新增 group、entity 和 pipelineCode 属性-优化 MappingUtils 工具类以支持父类字段映射
- 在 KingDeeHelper 中添加日志记录以便调试审核发送过程
Showing 26 changed files with 338 additions and 94 deletions
tax-boot/src/main/java/com/diligrp/tax/boot/receiver/TaxReceiver.java
... ... @@ -5,6 +5,7 @@ import com.diligrp.tax.central.process.ProcessorChain;
5 5 import com.diligrp.tax.central.type.StatusType;
6 6 import com.diligrp.tax.central.type.SystemType;
7 7 import com.diligrp.tax.central.utils.JsonUtils;
  8 +import com.diligrp.tax.storage.service.TenantTaxService;
8 9 import com.rabbitmq.client.Channel;
9 10 import jakarta.annotation.Resource;
10 11 import lombok.extern.slf4j.Slf4j;
... ... @@ -36,6 +37,9 @@ public class TaxReceiver {
36 37 @Resource
37 38 private Map<SystemType, ProcessorChain> processorChainMap;
38 39  
  40 + @Resource
  41 + private TenantTaxService tenantTaxService;
  42 +
39 43 @RabbitListener(bindings =
40 44 @QueueBinding(
41 45 value = @Queue(value = NORMAL_QUEUE, autoDelete = "false"),
... ... @@ -59,6 +63,7 @@ public class TaxReceiver {
59 63 }
60 64  
61 65 private void handle(MessageContext ctx) {
  66 + ctx.setTenantId(tenantTaxService.getTenantId(ctx.getGroup(), ctx.getEntity()));
62 67 MessageContext messageContext = processorChainMap.get(SystemType.from(ctx.getSystemType())).startProcess(ctx);
63 68 messageContext.setStatus(StatusType.SUCCESS.code);
64 69 //TODO write to db
... ...
tax-central/src/main/java/com/diligrp/tax/central/converter/impl/CustomerCountryConverter.java
... ... @@ -2,7 +2,6 @@ package com.diligrp.tax.central.converter.impl;
2 2  
3 3 import com.diligrp.tax.central.converter.IConverter;
4 4 import com.diligrp.tax.central.domain.mapping.kingdee.base.FCOUNTRY;
5   -import com.diligrp.tax.central.domain.mapping.kingdee.base.FTRADINGCURRID;
6 5 import org.springframework.stereotype.Component;
7 6  
8 7 import java.util.Objects;
... ...
tax-central/src/main/java/com/diligrp/tax/central/converter/impl/CustomerGroupConverter.java
1 1 package com.diligrp.tax.central.converter.impl;
2 2  
3 3 import com.diligrp.tax.central.converter.IConverter;
4   -import com.diligrp.tax.central.domain.mapping.kingdee.base.FContactId;
5 4 import com.diligrp.tax.central.domain.mapping.kingdee.base.FGroup;
6 5 import org.springframework.stereotype.Component;
7 6  
... ...
tax-central/src/main/java/com/diligrp/tax/central/converter/impl/StringConverter.java
... ... @@ -15,7 +15,7 @@ public class StringConverter implements IConverter&lt;String&gt; {
15 15 @Override
16 16 public String convert(Object source) {
17 17 if (Objects.isNull(source)) {
18   - return "";
  18 + return null;
19 19 }
20 20 return (String) source;
21 21 }
... ...
tax-central/src/main/java/com/diligrp/tax/central/domain/BaseMapping.java
1 1 package com.diligrp.tax.central.domain;
2 2  
3   -import com.diligrp.tax.central.model.TenantPipeline;
4 3 import lombok.Getter;
5 4 import lombok.Setter;
6 5  
... ...
tax-central/src/main/java/com/diligrp/tax/central/domain/MessageContext.java
... ... @@ -11,10 +11,22 @@ public class MessageContext {
11 11 */
12 12 private String thirdPartyCode;
13 13 /**
  14 + * 分组
  15 + */
  16 + private String group;
  17 + /**
  18 + * 实体
  19 + */
  20 + private String entity;
  21 + /**
14 22 * 租户 ID
15 23 */
16 24 private Long tenantId;
17 25 /**
  26 + * 租户账套编码
  27 + */
  28 + private String pipelineCode;
  29 + /**
18 30 * 消息信息
19 31 */
20 32 private String msgBody;
... ...
tax-central/src/main/java/com/diligrp/tax/central/domain/document/kingdee/BaseCustomer.java
... ... @@ -17,80 +17,80 @@ public abstract class BaseCustomer extends BaseDocument {
17 17 /**
18 18 * 系统数据 ID
19 19 */
20   - private String systemDataId;
21   - /**
22   - * 结算货币(FTRADINGCURRID)
23   - */
24   - @Converter(value = CustomerCurrencyConverter.class, targetField = "FTRADINGCURRID")
25   - private String currency;
  20 + protected String systemDataId;
  21 +// /**
  22 +// * 结算货币(FTRADINGCURRID)
  23 +// */
  24 +// @Converter(value = CustomerCurrencyConverter.class, targetField = "FTRADINGCURRID")
  25 +// protected String currency;
26 26 /**
27 27 * 客户 ID(FCUSTID)
28 28 */
29 29 @Converter(value = StringConverter.class, targetField = "FCUSTID")
30   - private String customerId;
  30 + protected String customerId;
31 31 /**
32 32 * 客户编号
33 33 */
34 34 @Converter(value = StringConverter.class, targetField = "FNumber")
35   - private String customerCode;
  35 + protected String customerCode;
36 36 /**
37 37 * 客户姓名(FName)
38 38 */
39 39 @Converter(value = StringConverter.class, targetField = "FName")
40   - private String customerName;
  40 + protected String customerName;
41 41 /**
42 42 * 客户简称(FShortName)
43 43 */
44 44 @Converter(value = StringConverter.class, targetField = "FShortName")
45   - private String customerShortName;
  45 + protected String customerShortName;
46 46 /**
47 47 * 客户发票抬头(FINVOICETITLE)
48 48 */
49 49 @Converter(value = StringConverter.class, targetField = "FINVOICETITLE")
50   - private String customerInvoiceTitle;
  50 + protected String customerInvoiceTitle;
51 51 /**
52 52 * 法人姓名(FLegalPerson)
53 53 */
54 54 @Converter(value = StringConverter.class, targetField = "FLegalPerson")
55   - private String legalPerson;
  55 + protected String legalPerson;
56 56 /**
57 57 * 证件号(FSOCIALCRECODE)
58 58 */
59 59 @Converter(value = StringConverter.class, targetField = "FSOCIALCRECODE")
60   - private String idNumber;
  60 + protected String idNumber;
61 61 /**
62 62 * 国家(FCOUNTRY)
63 63 */
64 64 @Converter(value = CustomerCountryConverter.class, targetField = "FCOUNTRY")
65   - private String country;
  65 + protected String country;
66 66 /**
67 67 * 区域组织(FPROVINCIAL)
68 68 */
69 69 @Converter(value = CustomerProvincialConverter.class, targetField = "FPROVINCIAL")
70   - private String provincial;
  70 + protected String provincial;
71 71 /**
72 72 * 地址(FADDRESS)
73 73 */
74 74 @Converter(value = StringConverter.class, targetField = "FADDRESS")
75   - private String address;
  75 + protected String address;
76 76 /**
77 77 * 注册地址(FRegisterAddress)
78 78 */
79 79 @Converter(value = StringConverter.class, targetField = "FRegisterAddress")
80   - private String registerAddress;
  80 + protected String registerAddress;
81 81 /**
82 82 * 客户分组-配置数据(FGroup)
83 83 */
84 84 @Converter(value = CustomerGroupConverter.class, targetField = "FGroup")
85   - private String customerGroup;
  85 + protected String customerGroup;
86 86 /**
87 87 * 创建组织(FCreateOrgId)
88 88 */
89 89 @Converter(value = CustomerCreateOrgConverter.class, targetField = "FCreateOrgId")
90   - private String customerCreateOrg;
  90 + protected String customerCreateOrg;
91 91 /**
92 92 * 使用组织
93 93 */
94 94 @Converter(value = CustomerUseOrgConverter.class, targetField = "FUseOrgId")
95   - private String customerUseOrg;
  95 + protected String customerUseOrg;
96 96 }
... ...
tax-central/src/main/java/com/diligrp/tax/central/domain/mapping/kingdee/CustomerMapping.java
... ... @@ -20,7 +20,7 @@ public class CustomerMapping extends BaseMapping {
20 20 private FUseOrgId FUseOrgId;
21 21 private String FShortName;
22 22 private FCOUNTRY FCOUNTRY;
23   - private FTRADINGCURRID FTRADINGCURRID;
  23 +// private FTRADINGCURRID FTRADINGCURRID;
24 24 private FPROVINCIAL FPROVINCIAL;
25 25 private String FADDRESS;
26 26 private FGroup FGroup;
... ... @@ -102,14 +102,14 @@ public class CustomerMapping extends BaseMapping {
102 102 this.FCOUNTRY = FCOUNTRY;
103 103 }
104 104  
105   - @JsonProperty("FTRADINGCURRID")
106   - public FTRADINGCURRID getFTRADINGCURRID() {
107   - return FTRADINGCURRID;
108   - }
109   -
110   - public void setFTRADINGCURRID(FTRADINGCURRID FTRADINGCURRID) {
111   - this.FTRADINGCURRID = FTRADINGCURRID;
112   - }
  105 +// @JsonProperty("FTRADINGCURRID")
  106 +// public FTRADINGCURRID getFTRADINGCURRID() {
  107 +// return FTRADINGCURRID;
  108 +// }
  109 +//
  110 +// public void setFTRADINGCURRID(FTRADINGCURRID FTRADINGCURRID) {
  111 +// this.FTRADINGCURRID = FTRADINGCURRID;
  112 +// }
113 113  
114 114 @JsonProperty("FPROVINCIAL")
115 115 public FPROVINCIAL getFPROVINCIAL() {
... ...
tax-central/src/main/java/com/diligrp/tax/central/manager/impl/KingDeeConnectionManager.java
... ... @@ -5,7 +5,6 @@ import com.diligrp.tax.central.model.TenantPipeline;
5 5 import com.diligrp.tax.central.type.SystemType;
6 6 import com.diligrp.tax.central.utils.JsonUtils;
7 7 import com.kingdee.bos.webapi.entity.IdentifyInfo;
8   -import com.kingdee.bos.webapi.sdk.K3CloudApi;
9 8 import org.springframework.stereotype.Component;
10 9  
11 10 /**
... ... @@ -14,15 +13,14 @@ import org.springframework.stereotype.Component;
14 13 * @Version: todo
15 14 */
16 15 @Component
17   -public class KingDeeConnectionManager extends AbstractConnectionManager<K3CloudApi> {
  16 +public class KingDeeConnectionManager extends AbstractConnectionManager<IdentifyInfo> {
18 17 @Override
19 18 public SystemType markSystemType() {
20 19 return SystemType.KING_DEE;
21 20 }
22 21  
23 22 @Override
24   - public K3CloudApi getConnection(TenantPipeline tenantPipeline) {
25   - IdentifyInfo identifyInfo = JsonUtils.convertValue(tenantPipeline.getParams(), IdentifyInfo.class);
26   - return new K3CloudApi(identifyInfo);
  23 + public IdentifyInfo getConnection(TenantPipeline tenantPipeline) {
  24 + return JsonUtils.convertValue(tenantPipeline.getParams(), IdentifyInfo.class);
27 25 }
28 26 }
... ...
tax-central/src/main/java/com/diligrp/tax/central/service/ITenantTaxService.java
... ... @@ -13,6 +13,15 @@ import java.util.List;
13 13 public interface ITenantTaxService {
14 14  
15 15 /**
  16 + * 获取租户 ID
  17 + *
  18 + * @param group 群
  19 + * @param entity 实体
  20 + * @return {@link Long }
  21 + */
  22 + Long getTenantId(String group,String entity);
  23 +
  24 + /**
16 25 * 列出所有启用管道
17 26 *
18 27 * @return {@link List }<{@link TenantPipeline }>
... ...
tax-central/src/main/java/com/diligrp/tax/central/type/TaxSystemType.java
... ... @@ -17,6 +17,7 @@ public enum TaxSystemType {
17 17 REMOTE_SERVICE_CALLS_ARE_EXCEPTIONAL(5006, "远程服务调用异常"),
18 18 INVALID_HTTP_REQUEST_PARAMS(5007, "无效的http请求参数"),
19 19 NO_MATCHING_SET_OF_ACCOUNTS_FOUND(5008, "未找到匹配账套"),
  20 + NO_TENANT_INFORMATION_FOUND(5009, "未找到匹配账套"),
20 21 ;
21 22 public final int code;
22 23 public final String message;
... ...
tax-central/src/main/java/com/diligrp/tax/central/utils/MappingUtils.java
... ... @@ -18,6 +18,7 @@ import java.util.HashMap;
18 18 import java.util.List;
19 19 import java.util.Map;
20 20 import java.util.function.Function;
  21 +import java.util.stream.Stream;
21 22  
22 23 /**
23 24 * @Author: zhangmeiyang
... ... @@ -64,8 +65,12 @@ public class MappingUtils {
64 65  
65 66 public static <T extends BaseDocument, R extends BaseMapping> R convertValue(T t, Class<R> clazz) {
66 67 Map<String, Object> map = new HashMap<>();
67   - Arrays.stream(t.getClass().getDeclaredFields()).filter(field -> field.isAnnotationPresent(Converter.class)).forEach(field -> configureField(t, field, map));
68   - Arrays.stream(t.getClass().getDeclaredFields()).filter(field -> field.isAnnotationPresent(SubConverter.class)).forEach(field -> configureSubField(t, field, map));
  68 + Field[] allFields = Stream.concat(
  69 + Arrays.stream(t.getClass().getDeclaredFields()),
  70 + Arrays.stream(t.getClass().getSuperclass().getDeclaredFields())
  71 + ).toArray(Field[]::new);
  72 + Arrays.stream(allFields).filter(field -> field.isAnnotationPresent(Converter.class)).forEach(field -> configureField(t, field, map));
  73 + Arrays.stream(allFields).filter(field -> field.isAnnotationPresent(SubConverter.class)).forEach(field -> configureSubField(t, field, map));
69 74 return JsonUtils.convertValue(map, clazz);
70 75 }
71 76 }
... ...
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/Builder.java
1 1 package com.diligrp.tax.doc.demarcate;
2 2  
3 3 import com.diligrp.tax.central.domain.BaseDocument;
  4 +import com.diligrp.tax.central.model.TenantPipeline;
4 5 import com.diligrp.tax.central.type.DocumentType;
5 6  
6 7 /**
... ... @@ -20,8 +21,9 @@ public abstract class Builder&lt;T extends BaseDocument&gt; {
20 21 /**
21 22 * 建
22 23 *
23   - * @param body 身体
  24 + * @param body 身体
  25 + * @param pipeline
24 26 * @return {@link T }
25 27 */
26   - public abstract T build(String body);
  28 + public abstract T build(String body, TenantPipeline pipeline);
27 29 }
... ...
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/CustomerBuilder.java
1 1 package com.diligrp.tax.doc.demarcate.kingdee;
2 2  
3 3 import com.diligrp.tax.central.domain.document.kingdee.basic.StandardCustomer;
  4 +import com.diligrp.tax.central.domain.document.kingdee.basic.item.Contact;
4 5 import com.diligrp.tax.central.exception.TaxAgentServiceException;
  6 +import com.diligrp.tax.central.model.TenantPipeline;
  7 +import com.diligrp.tax.central.model.TenantPipelineConfig;
5 8 import com.diligrp.tax.central.type.DocumentType;
6 9 import com.diligrp.tax.central.type.TaxSystemType;
7 10 import com.diligrp.tax.central.utils.JsonUtils;
8 11 import com.diligrp.tax.doc.demarcate.Builder;
  12 +import lombok.extern.slf4j.Slf4j;
9 13 import org.springframework.stereotype.Component;
10 14  
  15 +import java.lang.reflect.Field;
  16 +import java.util.Arrays;
  17 +import java.util.List;
  18 +import java.util.Map;
11 19 import java.util.Optional;
  20 +import java.util.stream.Collectors;
  21 +import java.util.stream.Stream;
12 22  
13 23 /**
14 24 * @Author: zhangmeiyang
... ... @@ -16,6 +26,7 @@ import java.util.Optional;
16 26 * @Version: todo
17 27 */
18 28 @Component
  29 +@Slf4j
19 30 public class CustomerBuilder extends Builder<StandardCustomer> {
20 31  
21 32 @Override
... ... @@ -24,13 +35,50 @@ public class CustomerBuilder extends Builder&lt;StandardCustomer&gt; {
24 35 }
25 36  
26 37 @Override
27   - public StandardCustomer build(String body) {
  38 + public StandardCustomer build(String body, TenantPipeline pipeline) {
28 39 StandardCustomer customer = JsonUtils.fromJsonString(body, StandardCustomer.class);
29 40 Optional.ofNullable(customer.getContacts()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请完善联系人信息"));
30   - Optional.ofNullable(customer.getSystemDataId()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写系统数据ID"));
31   - //TODO 获取币别
32   -
  41 +// Optional.ofNullable(customer.getSystemDataId()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写系统数据ID"));
  42 + List<TenantPipelineConfig> list = pipeline.getTenantPipelineConfigs().get(markDocument());
  43 + Optional.ofNullable(list).ifPresent(ts -> configureDefaultData(customer, ts));
33 44 //TODO 查询数据库的客户信息 如果存在 赋值id
34 45 return customer;
35 46 }
  47 +
  48 + private void configureDefaultData(StandardCustomer customer, List<TenantPipelineConfig> list) {
  49 + Map<String, String> kvMap = list.stream().collect(Collectors.toMap(TenantPipelineConfig::getConfigKey, TenantPipelineConfig::getConfigValue));
  50 + Field[] allFields = Stream.concat(
  51 + Arrays.stream(customer.getClass().getDeclaredFields()),
  52 + Arrays.stream(customer.getClass().getSuperclass().getDeclaredFields())
  53 + ).toArray(Field[]::new);
  54 + Arrays.stream(allFields).forEach(field -> reflectField(customer, field, kvMap));
  55 + List<Contact> refundItems = customer.getContacts();
  56 + refundItems.forEach(item -> {
  57 + Field[] declaredFields1 = item.getClass().getDeclaredFields();
  58 + Arrays.stream(declaredFields1).forEach(field -> reflectField(item, field, kvMap));
  59 + });
  60 + }
  61 +
  62 + public static void reflectField(StandardCustomer object, Field field, Map<String, String> kvMap) {
  63 + if (kvMap.containsKey(field.getName())) {
  64 + field.setAccessible(true);
  65 + try {
  66 + field.set(object, kvMap.get(field.getName()));
  67 + } catch (IllegalAccessException e) {
  68 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  69 + }
  70 + }
  71 + }
  72 +
  73 +
  74 + public static void reflectField(Contact object, Field field, Map<String, String> kvMap) {
  75 + if (kvMap.containsKey(field.getName())) {
  76 + field.setAccessible(true);
  77 + try {
  78 + field.set(object, kvMap.get(field.getName()));
  79 + } catch (IllegalAccessException e) {
  80 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  81 + }
  82 + }
  83 + }
36 84 }
... ...
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/ReceiptBuilder.java
1 1 package com.diligrp.tax.doc.demarcate.kingdee;
2 2  
3 3 import com.diligrp.tax.central.domain.document.kingdee.bill.ReceiptBill;
  4 +import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceiptItem;
4 5 import com.diligrp.tax.central.exception.TaxAgentServiceException;
  6 +import com.diligrp.tax.central.model.TenantPipeline;
  7 +import com.diligrp.tax.central.model.TenantPipelineConfig;
5 8 import com.diligrp.tax.central.type.DocumentType;
6 9 import com.diligrp.tax.central.type.TaxSystemType;
7 10 import com.diligrp.tax.central.utils.JsonUtils;
8 11 import com.diligrp.tax.doc.demarcate.Builder;
9 12 import org.springframework.stereotype.Component;
10 13  
  14 +import java.lang.reflect.Field;
11 15 import java.time.LocalDateTime;
12 16 import java.time.format.DateTimeFormatter;
  17 +import java.util.Arrays;
  18 +import java.util.List;
  19 +import java.util.Map;
13 20 import java.util.Optional;
  21 +import java.util.stream.Collectors;
14 22  
15 23 /**
16 24 * @Author: zhangmeiyang
... ... @@ -25,14 +33,46 @@ public class ReceiptBuilder extends Builder&lt;ReceiptBill&gt; {
25 33 }
26 34  
27 35 @Override
28   - public ReceiptBill build(String body) {
  36 + public ReceiptBill build(String body, TenantPipeline pipeline) {
29 37 ReceiptBill bill = JsonUtils.fromJsonString(body, ReceiptBill.class);
30   - Optional.ofNullable(bill.getReceiptItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION,"请填写收款项目"));
  38 + Optional.ofNullable(bill.getReceiptItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目"));
31 39 bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))));
32   - //TODO 获取币别
33   - //TODO 获取组织
34   - //TODO 部门转换
35   - //TODO 业务类型转换
  40 + List<TenantPipelineConfig> list = pipeline.getTenantPipelineConfigs().get(markDocument());
  41 + Optional.ofNullable(list).ifPresent(ts -> configureDefaultData(bill, ts));
36 42 return bill;
37 43 }
  44 +
  45 + private void configureDefaultData(ReceiptBill bill, List<TenantPipelineConfig> list) {
  46 + Map<String, String> kvMap = list.stream().collect(Collectors.toMap(TenantPipelineConfig::getConfigKey, TenantPipelineConfig::getConfigValue));
  47 + Field[] declaredFields = bill.getClass().getDeclaredFields();
  48 + Arrays.stream(declaredFields).forEach(field -> reflectField(bill, field, kvMap));
  49 + List<ReceiptItem> refundItems = bill.getReceiptItems();
  50 + refundItems.forEach(item -> {
  51 + Field[] declaredFields1 = item.getClass().getDeclaredFields();
  52 + Arrays.stream(declaredFields1).forEach(field -> reflectField(item, field, kvMap));
  53 + });
  54 + }
  55 +
  56 + public static void reflectField(ReceiptBill object, Field field, Map<String, String> kvMap) {
  57 + if (kvMap.containsKey(field.getName())) {
  58 + field.setAccessible(true);
  59 + try {
  60 + field.set(object, kvMap.get(field.getName()));
  61 + } catch (IllegalAccessException e) {
  62 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  63 + }
  64 + }
  65 + }
  66 +
  67 +
  68 + public static void reflectField(ReceiptItem object, Field field, Map<String, String> kvMap) {
  69 + if (kvMap.containsKey(field.getName())) {
  70 + field.setAccessible(true);
  71 + try {
  72 + field.set(object, kvMap.get(field.getName()));
  73 + } catch (IllegalAccessException e) {
  74 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  75 + }
  76 + }
  77 + }
38 78 }
... ...
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/ReceivableBuilder.java
1 1 package com.diligrp.tax.doc.demarcate.kingdee;
2 2  
  3 +import com.diligrp.tax.central.domain.document.kingdee.bill.ReceiptBill;
  4 +import com.diligrp.tax.central.domain.document.kingdee.bill.ReceivableBill;
  5 +import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceiptItem;
  6 +import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceivableItem;
3 7 import com.diligrp.tax.central.exception.TaxAgentServiceException;
  8 +import com.diligrp.tax.central.model.TenantPipeline;
  9 +import com.diligrp.tax.central.model.TenantPipelineConfig;
4 10 import com.diligrp.tax.central.type.DocumentType;
5 11 import com.diligrp.tax.central.type.TaxSystemType;
6 12 import com.diligrp.tax.central.utils.JsonUtils;
  13 +import com.diligrp.tax.central.utils.MappingUtils;
7 14 import com.diligrp.tax.doc.demarcate.Builder;
8   -import com.diligrp.tax.central.domain.document.kingdee.bill.ReceivableBill;
9 15 import org.springframework.stereotype.Component;
10 16  
  17 +import java.lang.reflect.Field;
11 18 import java.time.LocalDateTime;
12 19 import java.time.format.DateTimeFormatter;
  20 +import java.util.Arrays;
  21 +import java.util.List;
  22 +import java.util.Map;
13 23 import java.util.Optional;
  24 +import java.util.stream.Collectors;
14 25  
15 26 /**
16 27 * @Author: zhangmeiyang
... ... @@ -26,14 +37,47 @@ public class ReceivableBuilder extends Builder&lt;ReceivableBill&gt; {
26 37 }
27 38  
28 39 @Override
29   - public ReceivableBill build(String body) {
  40 + public ReceivableBill build(String body, TenantPipeline pipeline) {
30 41 ReceivableBill bill = JsonUtils.fromJsonString(body, ReceivableBill.class);
31   - Optional.ofNullable(bill.getReceivableItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION,"请填写收款项目"));
  42 + Optional.ofNullable(bill.getReceivableItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目"));
32 43 bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))));
33   - //TODO 获取币别
34   - //TODO 获取组织
35   - //TODO 部门转换
36   - //TODO 业务类型转换
  44 + List<TenantPipelineConfig> list = pipeline.getTenantPipelineConfigs().get(markDocument());
  45 + Optional.ofNullable(list).ifPresent(ts -> configureDefaultData(bill, ts));
  46 + //todo动态规则转换
37 47 return bill;
38 48 }
  49 +
  50 + private void configureDefaultData(ReceivableBill bill, List<TenantPipelineConfig> list) {
  51 + Map<String, String> kvMap = list.stream().collect(Collectors.toMap(TenantPipelineConfig::getConfigKey, TenantPipelineConfig::getConfigValue));
  52 + Field[] declaredFields = bill.getClass().getDeclaredFields();
  53 + Arrays.stream(declaredFields).forEach(field -> reflectField(bill, field, kvMap));
  54 + List<ReceivableItem> refundItems = bill.getReceivableItems();
  55 + refundItems.forEach(item -> {
  56 + Field[] declaredFields1 = item.getClass().getDeclaredFields();
  57 + Arrays.stream(declaredFields1).forEach(field -> reflectField(item, field, kvMap));
  58 + });
  59 + }
  60 +
  61 + public static void reflectField(ReceivableBill object, Field field, Map<String, String> kvMap) {
  62 + if (kvMap.containsKey(field.getName())) {
  63 + field.setAccessible(true);
  64 + try {
  65 + field.set(object, kvMap.get(field.getName()));
  66 + } catch (IllegalAccessException e) {
  67 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  68 + }
  69 + }
  70 + }
  71 +
  72 +
  73 + public static void reflectField(ReceivableItem object, Field field, Map<String, String> kvMap) {
  74 + if (kvMap.containsKey(field.getName())) {
  75 + field.setAccessible(true);
  76 + try {
  77 + field.set(object, kvMap.get(field.getName()));
  78 + } catch (IllegalAccessException e) {
  79 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  80 + }
  81 + }
  82 + }
39 83 }
... ...
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/RefundBuilder.java
1 1 package com.diligrp.tax.doc.demarcate.kingdee;
2 2  
  3 +import com.diligrp.tax.central.domain.document.kingdee.bill.ReceivableBill;
3 4 import com.diligrp.tax.central.domain.document.kingdee.bill.RefundBill;
  5 +import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceivableItem;
  6 +import com.diligrp.tax.central.domain.document.kingdee.bill.item.RefundItem;
4 7 import com.diligrp.tax.central.exception.TaxAgentServiceException;
  8 +import com.diligrp.tax.central.model.TenantPipeline;
  9 +import com.diligrp.tax.central.model.TenantPipelineConfig;
5 10 import com.diligrp.tax.central.type.DocumentType;
6 11 import com.diligrp.tax.central.type.TaxSystemType;
7 12 import com.diligrp.tax.central.utils.JsonUtils;
  13 +import com.diligrp.tax.central.utils.MappingUtils;
8 14 import com.diligrp.tax.doc.demarcate.Builder;
9 15 import org.springframework.stereotype.Component;
10 16  
  17 +import java.lang.reflect.Field;
11 18 import java.time.LocalDateTime;
12 19 import java.time.format.DateTimeFormatter;
  20 +import java.util.Arrays;
  21 +import java.util.List;
  22 +import java.util.Map;
13 23 import java.util.Optional;
  24 +import java.util.stream.Collectors;
14 25  
15 26 /**
16 27 * @Author: zhangmeiyang
... ... @@ -26,14 +37,47 @@ public class RefundBuilder extends Builder&lt;RefundBill&gt; {
26 37 }
27 38  
28 39 @Override
29   - public RefundBill build(String body) {
  40 + public RefundBill build(String body, TenantPipeline pipeline) {
30 41 RefundBill bill = JsonUtils.fromJsonString(body, RefundBill.class);
31 42 Optional.ofNullable(bill.getRefundItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目"));
32 43 bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))));
33   - //TODO 获取币别
34   - //TODO 获取组织
35   - //TODO 部门转换
36   - //TODO 业务类型转换
  44 + List<TenantPipelineConfig> list = pipeline.getTenantPipelineConfigs().get(markDocument());
  45 + Optional.ofNullable(list).ifPresent(ts -> configureDefaultData(bill, ts));
  46 + //todo动态规则转换
37 47 return bill;
38 48 }
  49 +
  50 + private void configureDefaultData(RefundBill bill, List<TenantPipelineConfig> list) {
  51 + Map<String, String> kvMap = list.stream().collect(Collectors.toMap(TenantPipelineConfig::getConfigKey, TenantPipelineConfig::getConfigValue));
  52 + Field[] declaredFields = bill.getClass().getDeclaredFields();
  53 + Arrays.stream(declaredFields).forEach(field -> reflectField(bill, field, kvMap));
  54 + List<RefundItem> refundItems = bill.getRefundItems();
  55 + refundItems.forEach(item -> {
  56 + Field[] declaredFields1 = item.getClass().getDeclaredFields();
  57 + Arrays.stream(declaredFields1).forEach(field -> reflectField(item, field, kvMap));
  58 + });
  59 + }
  60 +
  61 + public static void reflectField(RefundBill object, Field field, Map<String, String> kvMap) {
  62 + if (kvMap.containsKey(field.getName())) {
  63 + field.setAccessible(true);
  64 + try {
  65 + field.set(object, kvMap.get(field.getName()));
  66 + } catch (IllegalAccessException e) {
  67 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  68 + }
  69 + }
  70 + }
  71 +
  72 +
  73 + public static void reflectField(RefundItem object, Field field, Map<String, String> kvMap) {
  74 + if (kvMap.containsKey(field.getName())) {
  75 + field.setAccessible(true);
  76 + try {
  77 + field.set(object, kvMap.get(field.getName()));
  78 + } catch (IllegalAccessException e) {
  79 + throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT, e.getMessage());
  80 + }
  81 + }
  82 + }
39 83 }
... ...
tax-doc/src/main/java/com/diligrp/tax/doc/process/kingdee/InitializeProcessor.java
1 1 package com.diligrp.tax.doc.process.kingdee;
2 2  
  3 +import com.diligrp.tax.central.context.TenantStorageContext;
3 4 import com.diligrp.tax.central.domain.MessageContext;
4 5 import com.diligrp.tax.central.exception.TaxAgentServiceException;
  6 +import com.diligrp.tax.central.model.TenantPipeline;
5 7 import com.diligrp.tax.central.process.AbstractProcessor;
6 8 import com.diligrp.tax.central.type.DocumentType;
7 9 import com.diligrp.tax.central.type.SystemType;
... ... @@ -12,6 +14,8 @@ import lombok.extern.slf4j.Slf4j;
12 14 import org.springframework.core.annotation.Order;
13 15 import org.springframework.stereotype.Component;
14 16  
  17 +import java.util.Optional;
  18 +
15 19  
16 20 /**
17 21 * 初始化处理器
... ... @@ -31,8 +35,10 @@ public class InitializeProcessor extends AbstractProcessor {
31 35 if (!system.documentTypes.contains(from)) {
32 36 throw new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT);
33 37 }
  38 + Optional<TenantPipeline> option = TenantStorageContext.getTenantPipeline(messageContext.getTenantId(), system, messageContext.getPipelineCode());
  39 + TenantPipeline pipeline = option.orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.NO_MATCHING_SET_OF_ACCOUNTS_FOUND));
34 40 Builder<?> builder = DocumentContext.CONTEXT.get(from);
35   - messageContext.setDocumentObject(builder.build(messageContext.getMsgBody()));
  41 + messageContext.setDocumentObject(builder.build(messageContext.getMsgBody(),pipeline));
36 42 return messageContext;
37 43 }
38 44 }
... ...
tax-proxy/src/main/java/com/diligrp/tax/proxy/demarcate/Sender.java
... ... @@ -3,7 +3,7 @@ package com.diligrp.tax.proxy.demarcate;
3 3 import com.diligrp.tax.central.domain.BaseMapping;
4 4 import com.diligrp.tax.central.domain.BaseProxy;
5 5 import com.diligrp.tax.central.type.DocumentType;
6   -import com.kingdee.bos.webapi.sdk.K3CloudApi;
  6 +import com.kingdee.bos.webapi.entity.IdentifyInfo;
7 7  
8 8 /**
9 9 * @Author: zhangmeiyang
... ... @@ -22,8 +22,8 @@ public abstract class Sender&lt;T extends BaseProxy&gt; {
22 22 * 变换
23 23 *
24 24 * @param mappingObject 映射对象
25   - * @param connection
  25 + * @param identifyInfo
26 26 * @return {@link T }
27 27 */
28   - public abstract T send(BaseMapping mappingObject, K3CloudApi connection);
  28 + public abstract T send(BaseMapping mappingObject, IdentifyInfo identifyInfo);
29 29 }
... ...
tax-proxy/src/main/java/com/diligrp/tax/proxy/demarcate/kingdee/CustomerSender.java
... ... @@ -2,6 +2,7 @@ package com.diligrp.tax.proxy.demarcate.kingdee;
2 2  
3 3 import com.diligrp.tax.central.domain.BaseMapping;
4 4 import com.diligrp.tax.central.domain.mapping.kingdee.CustomerMapping;
  5 +import com.diligrp.tax.central.domain.mapping.kingdee.base.FContactId;
5 6 import com.diligrp.tax.central.domain.mapping.kingdee.base.FT_BD_CUSTLOCATION;
6 7 import com.diligrp.tax.central.domain.proxy.kingdee.CustomerProxy;
7 8 import com.diligrp.tax.central.exception.TaxAgentServiceException;
... ... @@ -35,22 +36,12 @@ public class CustomerSender extends Sender&lt;CustomerProxy&gt; {
35 36 }
36 37  
37 38 @Override
38   - public CustomerProxy send(BaseMapping mappingObject, K3CloudApi connection) {
  39 + public CustomerProxy send(BaseMapping mappingObject, IdentifyInfo identifyInfo) {
39 40 CustomerMapping mapping = (CustomerMapping) mappingObject;
40   - List<FT_BD_CUSTLOCATION> contacts = mapping.getFT_BD_CUSTLOCATION();
41   - contacts.forEach(contact -> {
42   - Map<String, Object> model = JsonUtils.convertValue(contact, new TypeReference<>() {
43   - });
44   - RepoRet<?> repoRet = KingDeeHelper.nonAuditSend(model, connection, "BD_CommonContact");
45   - SuccessEntity first = repoRet.getResult().getResponseStatus().getSuccessEntitys().getFirst();
46   - contact.getFContactId().setFNUMBER(first.getNumber());
47   - });
  41 + mapping.setFT_BD_CUSTLOCATION(handleContact(identifyInfo, mapping));
48 42 // 联系人新增
49   - Optional.ofNullable(mapping.getFCUSTID())
50   - .filter(e -> !e.isEmpty())
51   - .ifPresent(e -> KingDeeHelper.unAuditSend(e, connection, markDocument().value));
52   - RepoRet<?> repoRet = KingDeeHelper.auditSend(JsonUtils.convertValue(mapping, new TypeReference<>() {
53   - }), connection, markDocument().value);
  43 + Optional.ofNullable(mapping.getFCUSTID()).filter(e -> !e.isEmpty()).ifPresent(e -> KingDeeHelper.unAuditSend(e, new K3CloudApi(identifyInfo), markDocument().value));
  44 + RepoRet<?> repoRet = KingDeeHelper.auditSend(JsonUtils.convertValue(mapping, new TypeReference<>() {}), new K3CloudApi(identifyInfo), markDocument().value);
54 45 //联系人新增和更新完成
55 46 ArrayList<SuccessEntity> successEntity = repoRet.getResult().getResponseStatus().getSuccessEntitys();
56 47 if (successEntity.isEmpty()) {
... ... @@ -62,4 +53,25 @@ public class CustomerSender extends Sender&lt;CustomerProxy&gt; {
62 53 proxy.setThirdPartyCode(first.getNumber());
63 54 return proxy;
64 55 }
  56 +
  57 + private List<FT_BD_CUSTLOCATION> handleContact(IdentifyInfo identifyInfo, CustomerMapping mapping) {
  58 + List<FT_BD_CUSTLOCATION> contacts = mapping.getFT_BD_CUSTLOCATION();
  59 + return contacts.stream().map(contact -> customerConvert(contact,identifyInfo)).toList();
  60 + }
  61 +
  62 + private FT_BD_CUSTLOCATION customerConvert(FT_BD_CUSTLOCATION contact,IdentifyInfo identifyInfo) {
  63 + var customerLocation = new FT_BD_CUSTLOCATION();
  64 + customerLocation.setFBizAddress(contact.getFBizAddress());
  65 + customerLocation.setFCompanyType(contact.getFCompanyType());
  66 + customerLocation.setFMOBILEPHONE(contact.getFMOBILEPHONE());
  67 + customerLocation.setFName(contact.getFName());
  68 + Map<String, Object> model = JsonUtils.convertValue(customerLocation, new TypeReference<>() {});
  69 + RepoRet<?> repoRet = KingDeeHelper.nonAuditSend(model, new K3CloudApi(identifyInfo), "BD_CommonContact");
  70 + SuccessEntity first = repoRet.getResult().getResponseStatus().getSuccessEntitys().getFirst();
  71 + var res = new FT_BD_CUSTLOCATION();
  72 + FContactId fContactId = new FContactId();
  73 + fContactId.setFNUMBER(first.getId());
  74 + res.setFContactId(fContactId);
  75 + return res;
  76 + }
65 77 }
... ...
tax-proxy/src/main/java/com/diligrp/tax/proxy/demarcate/kingdee/ReceiptSender.java
... ... @@ -34,13 +34,14 @@ public class ReceiptSender extends Sender&lt;ReceiptProxy&gt; {
34 34 }
35 35  
36 36 @Override
37   - public ReceiptProxy send(BaseMapping mappingObject, K3CloudApi connection) {
  37 + public ReceiptProxy send(BaseMapping mappingObject, IdentifyInfo identifyInfo) {
38 38 ReceiptMapping mapping = (ReceiptMapping) mappingObject;
39   - List<Object> infos = KingDeeHelper.querySend(mapping, markDocument().value, connection);
  39 + List<Object> infos = KingDeeHelper.querySend(mapping, markDocument().value, new K3CloudApi(identifyInfo));
40 40 if (!infos.isEmpty()) {
41 41 throw new TaxAgentServiceException(TaxSystemType.REPEAT_SENDING);
42 42 }
43   - RepoRet<?> repoRet = KingDeeHelper.auditSend(JsonUtils.convertValue(mapping, new TypeReference<>() {}), connection, markDocument().value);
  43 + RepoRet<?> repoRet = KingDeeHelper.auditSend(JsonUtils.convertValue(mapping, new TypeReference<>() {
  44 + }), new K3CloudApi(identifyInfo), markDocument().value);
44 45 ArrayList<SuccessEntity> successEntity = repoRet.getResult().getResponseStatus().getSuccessEntitys();
45 46 if (successEntity.isEmpty()) {
46 47 throw new TaxAgentServiceException(TaxSystemType.REMOTE_SERVICE_CALLS_ARE_EXCEPTIONAL);
... ...
tax-proxy/src/main/java/com/diligrp/tax/proxy/demarcate/kingdee/ReceivableSender.java
... ... @@ -32,15 +32,15 @@ public class ReceivableSender extends Sender&lt;ReceivableProxy&gt; {
32 32 }
33 33  
34 34 @Override
35   - public ReceivableProxy send(BaseMapping mappingObject, K3CloudApi connection) {
  35 + public ReceivableProxy send(BaseMapping mappingObject, IdentifyInfo identifyInfo) {
36 36 ReceivableMapping mapping = (ReceivableMapping) mappingObject;
37   - List<Object> infos = KingDeeHelper.querySend(mapping, markDocument().value, connection);
  37 + List<Object> infos = KingDeeHelper.querySend(mapping, markDocument().value, new K3CloudApi(identifyInfo));
38 38 if (!infos.isEmpty()) {
39 39 throw new TaxAgentServiceException(TaxSystemType.REPEAT_SENDING);
40 40 }
41 41 Map<String, Object> model = JsonUtils.convertValue(mapping, new TypeReference<>() {
42 42 });
43   - RepoRet<?> repoRet = KingDeeHelper.auditSend(model, connection, markDocument().value);
  43 + RepoRet<?> repoRet = KingDeeHelper.auditSend(model, new K3CloudApi(identifyInfo), markDocument().value);
44 44 ArrayList<SuccessEntity> successEntity = repoRet.getResult().getResponseStatus().getSuccessEntitys();
45 45 if (successEntity.isEmpty()) {
46 46 throw new TaxAgentServiceException(TaxSystemType.REMOTE_SERVICE_CALLS_ARE_EXCEPTIONAL);
... ...
tax-proxy/src/main/java/com/diligrp/tax/proxy/demarcate/kingdee/RefundSender.java
... ... @@ -34,13 +34,14 @@ public class RefundSender extends Sender&lt;RefundProxy&gt; {
34 34 }
35 35  
36 36 @Override
37   - public RefundProxy send(BaseMapping mappingObject, K3CloudApi connection) {
  37 + public RefundProxy send(BaseMapping mappingObject, IdentifyInfo identifyInfo) {
38 38 RefundMapping mapping = (RefundMapping) mappingObject;
39   - List<Object> infos = KingDeeHelper.querySend(mapping, markDocument().value, connection);
  39 + List<Object> infos = KingDeeHelper.querySend(mapping, markDocument().value, new K3CloudApi(identifyInfo));
40 40 if (!infos.isEmpty()) {
41 41 throw new TaxAgentServiceException(TaxSystemType.REPEAT_SENDING);
42 42 }
43   - RepoRet<?> repoRet = KingDeeHelper.auditSend(JsonUtils.convertValue(mapping, new TypeReference<>() {}), connection, markDocument().value);
  43 + RepoRet<?> repoRet = KingDeeHelper.auditSend(JsonUtils.convertValue(mapping, new TypeReference<>() {
  44 + }), new K3CloudApi(identifyInfo), markDocument().value);
44 45 ArrayList<SuccessEntity> successEntity = repoRet.getResult().getResponseStatus().getSuccessEntitys();
45 46 if (successEntity.isEmpty()) {
46 47 throw new TaxAgentServiceException(TaxSystemType.REMOTE_SERVICE_CALLS_ARE_EXCEPTIONAL);
... ...
tax-proxy/src/main/java/com/diligrp/tax/proxy/helper/KingDeeHelper.java
... ... @@ -90,6 +90,7 @@ public class KingDeeHelper {
90 90 message.setIsAutoAdjustField(true);
91 91 var body = JsonUtils.toJsonString(message);
92 92 try {
  93 + log.info("kingdee auditSend: {}", body);
93 94 String res;
94 95 res = api.save(formId, body);
95 96 log.info("金蝶审核接口完成,formId={},res={}", formId, res);
... ...
tax-proxy/src/main/java/com/diligrp/tax/proxy/process/kingdee/ProxyProcessor.java
... ... @@ -12,6 +12,7 @@ import com.diligrp.tax.central.type.DocumentType;
12 12 import com.diligrp.tax.central.type.SystemType;
13 13 import com.diligrp.tax.central.type.TaxSystemType;
14 14 import com.diligrp.tax.proxy.context.ProxyContext;
  15 +import com.kingdee.bos.webapi.entity.IdentifyInfo;
15 16 import com.kingdee.bos.webapi.sdk.K3CloudApi;
16 17 import lombok.extern.slf4j.Slf4j;
17 18 import org.springframework.core.annotation.Order;
... ... @@ -32,11 +33,11 @@ public class ProxyProcessor extends AbstractProcessor {
32 33 public MessageContext process(MessageContext messageContext) {
33 34 DocumentType from = DocumentType.from(messageContext.getDocumentType());
34 35 SystemType systemType = SystemType.from(messageContext.getSystemType());
35   - Optional<TenantPipeline> option = TenantStorageContext.getTenantPipeline(messageContext.getTenantId(), systemType, from.value);
  36 + Optional<TenantPipeline> option = TenantStorageContext.getTenantPipeline(messageContext.getTenantId(), systemType, messageContext.getPipelineCode());
36 37 TenantPipeline pipeline = option.orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.NO_MATCHING_SET_OF_ACCOUNTS_FOUND));
37 38 AbstractConnectionManager<?> abstractConnectionManager = ConnectionContext.CONNECTION_MAP.get(systemType);
38   - K3CloudApi connection = (K3CloudApi) abstractConnectionManager.getConnection(pipeline);
39   - BaseProxy send = ProxyContext.CONTEXT.get(from).send(messageContext.getMappingObject(), connection);
  39 + IdentifyInfo identifyInfo = (IdentifyInfo) abstractConnectionManager.getConnection(pipeline);
  40 + BaseProxy send = ProxyContext.CONTEXT.get(from).send(messageContext.getMappingObject(), identifyInfo);
40 41 messageContext.setProxyObject(send);
41 42 return messageContext;
42 43 }
... ...
tax-storage/src/main/java/com/diligrp/tax/storage/service/TenantTaxService.java
1 1 package com.diligrp.tax.storage.service;
2 2  
3 3 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.diligrp.tax.central.exception.TaxAgentServiceException;
4 5 import com.diligrp.tax.central.model.TenantPipeline;
5 6 import com.diligrp.tax.central.model.TenantPipelineConfig;
6 7 import com.diligrp.tax.central.service.ITenantTaxService;
7 8 import com.diligrp.tax.central.type.SystemType;
  9 +import com.diligrp.tax.central.type.TaxSystemType;
8 10 import com.diligrp.tax.central.utils.JsonUtils;
9 11 import com.diligrp.tax.storage.domain.TaxPipeline;
10 12 import com.diligrp.tax.storage.domain.TaxPipelineConfig;
  13 +import com.diligrp.tax.storage.domain.TaxTenant;
11 14 import com.diligrp.tax.storage.repo.TaxPipelineConfigRepository;
12 15 import com.diligrp.tax.storage.repo.TaxPipelineRepository;
  16 +import com.diligrp.tax.storage.repo.TaxTenantRepository;
13 17 import com.diligrp.tax.storage.type.StateType;
14 18 import jakarta.annotation.Resource;
15 19 import org.springframework.stereotype.Service;
16 20  
17 21 import java.util.List;
  22 +import java.util.Optional;
18 23  
19 24 /**
20 25 * @Author: zhangmeiyang
... ... @@ -25,12 +30,24 @@ import java.util.List;
25 30 public class TenantTaxService implements ITenantTaxService {
26 31  
27 32 @Resource
  33 + private TaxTenantRepository taxTenantRepository;
  34 +
  35 + @Resource
28 36 private TaxPipelineRepository taxPipelineRepository;
29 37  
30 38 @Resource
31 39 private TaxPipelineConfigRepository taxPipelineConfigRepository;
32 40  
33 41 @Override
  42 + public Long getTenantId(String group, String entity) {
  43 + LambdaQueryWrapper<TaxTenant> queryWrapper = new LambdaQueryWrapper<>();
  44 + queryWrapper.eq(TaxTenant::getGroup, group);
  45 + queryWrapper.eq(TaxTenant::getEntity, entity);
  46 + TaxTenant taxTenant = taxTenantRepository.selectOne(queryWrapper);
  47 + return Optional.ofNullable(taxTenant).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.NO_TENANT_INFORMATION_FOUND)).getId();
  48 + }
  49 +
  50 + @Override
34 51 public List<TenantPipeline> listAllEnablePipeline() {
35 52 LambdaQueryWrapper<TaxPipeline> queryWrapper = new LambdaQueryWrapper<>();
36 53 queryWrapper.eq(TaxPipeline::getState, StateType.ENABLE.value);
... ...