Commit 0134403a8966b9d0611adf520d2860fe054547d5
1 parent
a285a3c8
refactor(tax): 调整租户配置加载逻辑与时间类型- 将 TaxPipelineConfig 中的时间类型从 Instant 改为 LocalDateTime
- 移除 TenantPipeline 的 @Builder 注解并调整 tenantPipelineConfigs 类型为 List 结构 - TenantStorageContext 实现 CommandLineRunner 接口以支持启动时加载配置 - 在 TenantTaxService 中补充 systemType 字段的设置逻辑- 添加 log 支持便于调试信息输出
Showing
4 changed files
with
18 additions
and
15 deletions
tax-central/src/main/java/com/diligrp/tax/central/context/TenantStorageContext.java
| @@ -7,8 +7,10 @@ import com.diligrp.tax.central.service.ITenantTaxService; | @@ -7,8 +7,10 @@ import com.diligrp.tax.central.service.ITenantTaxService; | ||
| 7 | import com.diligrp.tax.central.type.DocumentType; | 7 | import com.diligrp.tax.central.type.DocumentType; |
| 8 | import com.diligrp.tax.central.type.SystemType; | 8 | import com.diligrp.tax.central.type.SystemType; |
| 9 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 10 | +import lombok.extern.slf4j.Slf4j; | ||
| 10 | import org.springframework.beans.factory.DisposableBean; | 11 | import org.springframework.beans.factory.DisposableBean; |
| 11 | import org.springframework.beans.factory.InitializingBean; | 12 | import org.springframework.beans.factory.InitializingBean; |
| 13 | +import org.springframework.boot.CommandLineRunner; | ||
| 12 | import org.springframework.context.ApplicationEventPublisher; | 14 | import org.springframework.context.ApplicationEventPublisher; |
| 13 | import org.springframework.stereotype.Component; | 15 | import org.springframework.stereotype.Component; |
| 14 | 16 | ||
| @@ -24,8 +26,9 @@ import java.util.stream.Collectors; | @@ -24,8 +26,9 @@ import java.util.stream.Collectors; | ||
| 24 | * @CreateTime: 2025-11-06 10:53 | 26 | * @CreateTime: 2025-11-06 10:53 |
| 25 | * @Version: todo | 27 | * @Version: todo |
| 26 | */ | 28 | */ |
| 29 | +@Slf4j | ||
| 27 | @Component | 30 | @Component |
| 28 | -public class TenantStorageContext implements InitializingBean, DisposableBean { | 31 | +public class TenantStorageContext implements CommandLineRunner { |
| 29 | 32 | ||
| 30 | @Resource | 33 | @Resource |
| 31 | private ITenantTaxService tenantTaxService; | 34 | private ITenantTaxService tenantTaxService; |
| @@ -66,17 +69,13 @@ public class TenantStorageContext implements InitializingBean, DisposableBean { | @@ -66,17 +69,13 @@ public class TenantStorageContext implements InitializingBean, DisposableBean { | ||
| 66 | 69 | ||
| 67 | private TenantPipeline loadConfig(TenantPipeline tenantPipeline) { | 70 | private TenantPipeline loadConfig(TenantPipeline tenantPipeline) { |
| 68 | List<TenantPipelineConfig> list = tenantTaxService.listByPipelineId(tenantPipeline.getId()); | 71 | List<TenantPipelineConfig> list = tenantTaxService.listByPipelineId(tenantPipeline.getId()); |
| 69 | - tenantPipeline.setTenantPipelineConfigs(list.stream().collect(Collectors.toMap(k -> DocumentType.from(k.getDocumentType()), v -> v))); | 72 | + Map<DocumentType, List<TenantPipelineConfig>> collect = list.stream().collect(Collectors.groupingBy(k -> DocumentType.from(k.getDocumentType()), Collectors.toList())); |
| 73 | + tenantPipeline.setTenantPipelineConfigs(collect); | ||
| 70 | return tenantPipeline; | 74 | return tenantPipeline; |
| 71 | } | 75 | } |
| 72 | 76 | ||
| 73 | @Override | 77 | @Override |
| 74 | - public void destroy() throws Exception { | ||
| 75 | - | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - @Override | ||
| 79 | - public void afterPropertiesSet() throws Exception { | 78 | + public void run(String... args) throws Exception { |
| 80 | publisher.publishEvent(new RestoreTenantEvent(this)); | 79 | publisher.publishEvent(new RestoreTenantEvent(this)); |
| 81 | } | 80 | } |
| 82 | } | 81 | } |
tax-central/src/main/java/com/diligrp/tax/central/model/TenantPipeline.java
| @@ -2,10 +2,10 @@ package com.diligrp.tax.central.model; | @@ -2,10 +2,10 @@ package com.diligrp.tax.central.model; | ||
| 2 | 2 | ||
| 3 | import com.diligrp.tax.central.type.DocumentType; | 3 | import com.diligrp.tax.central.type.DocumentType; |
| 4 | import com.diligrp.tax.central.type.SystemType; | 4 | import com.diligrp.tax.central.type.SystemType; |
| 5 | -import lombok.Builder; | ||
| 6 | import lombok.Getter; | 5 | import lombok.Getter; |
| 7 | import lombok.Setter; | 6 | import lombok.Setter; |
| 8 | 7 | ||
| 8 | +import java.util.List; | ||
| 9 | import java.util.Map; | 9 | import java.util.Map; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| @@ -15,7 +15,6 @@ import java.util.Map; | @@ -15,7 +15,6 @@ import java.util.Map; | ||
| 15 | */ | 15 | */ |
| 16 | @Setter | 16 | @Setter |
| 17 | @Getter | 17 | @Getter |
| 18 | -@Builder | ||
| 19 | public class TenantPipeline { | 18 | public class TenantPipeline { |
| 20 | private Long id; | 19 | private Long id; |
| 21 | private Long tenantId; | 20 | private Long tenantId; |
| @@ -23,5 +22,5 @@ public class TenantPipeline { | @@ -23,5 +22,5 @@ public class TenantPipeline { | ||
| 23 | private String name; | 22 | private String name; |
| 24 | private String code; | 23 | private String code; |
| 25 | private Map<String, Object> params; | 24 | private Map<String, Object> params; |
| 26 | - private Map<DocumentType, TenantPipelineConfig> tenantPipelineConfigs; | 25 | + private Map<DocumentType, List<TenantPipelineConfig>> tenantPipelineConfigs; |
| 27 | } | 26 | } |
tax-storage/src/main/java/com/diligrp/tax/storage/domain/TaxPipelineConfig.java
| @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | import lombok.Getter; | 7 | import lombok.Getter; |
| 8 | import lombok.Setter; | 8 | import lombok.Setter; |
| 9 | 9 | ||
| 10 | -import java.time.Instant; | 10 | +import java.time.LocalDateTime; |
| 11 | 11 | ||
| 12 | @Getter | 12 | @Getter |
| 13 | @Setter | 13 | @Setter |
| @@ -29,9 +29,9 @@ public class TaxPipelineConfig { | @@ -29,9 +29,9 @@ public class TaxPipelineConfig { | ||
| 29 | private String configValue; | 29 | private String configValue; |
| 30 | 30 | ||
| 31 | @TableField(value = "created_time") | 31 | @TableField(value = "created_time") |
| 32 | - private Instant createdTime; | 32 | + private LocalDateTime createdTime; |
| 33 | 33 | ||
| 34 | @TableField(value = "modified_time") | 34 | @TableField(value = "modified_time") |
| 35 | - private Instant modifiedTime; | 35 | + private LocalDateTime modifiedTime; |
| 36 | 36 | ||
| 37 | } | 37 | } |
tax-storage/src/main/java/com/diligrp/tax/storage/service/TenantTaxService.java
| @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 4 | import com.diligrp.tax.central.model.TenantPipeline; | 4 | import com.diligrp.tax.central.model.TenantPipeline; |
| 5 | import com.diligrp.tax.central.model.TenantPipelineConfig; | 5 | import com.diligrp.tax.central.model.TenantPipelineConfig; |
| 6 | import com.diligrp.tax.central.service.ITenantTaxService; | 6 | import com.diligrp.tax.central.service.ITenantTaxService; |
| 7 | +import com.diligrp.tax.central.type.SystemType; | ||
| 7 | import com.diligrp.tax.central.utils.JsonUtils; | 8 | import com.diligrp.tax.central.utils.JsonUtils; |
| 8 | import com.diligrp.tax.storage.domain.TaxPipeline; | 9 | import com.diligrp.tax.storage.domain.TaxPipeline; |
| 9 | import com.diligrp.tax.storage.domain.TaxPipelineConfig; | 10 | import com.diligrp.tax.storage.domain.TaxPipelineConfig; |
| @@ -34,7 +35,11 @@ public class TenantTaxService implements ITenantTaxService { | @@ -34,7 +35,11 @@ public class TenantTaxService implements ITenantTaxService { | ||
| 34 | LambdaQueryWrapper<TaxPipeline> queryWrapper = new LambdaQueryWrapper<>(); | 35 | LambdaQueryWrapper<TaxPipeline> queryWrapper = new LambdaQueryWrapper<>(); |
| 35 | queryWrapper.eq(TaxPipeline::getState, StateType.ENABLE.value); | 36 | queryWrapper.eq(TaxPipeline::getState, StateType.ENABLE.value); |
| 36 | List<TaxPipeline> taxPipelines = taxPipelineRepository.selectList(queryWrapper); | 37 | List<TaxPipeline> taxPipelines = taxPipelineRepository.selectList(queryWrapper); |
| 37 | - return taxPipelines.stream().map(taxPipeline -> JsonUtils.convertValue(taxPipeline, TenantPipeline.class)).toList(); | 38 | + return taxPipelines.stream().map(taxPipeline -> { |
| 39 | + TenantPipeline pipeline = JsonUtils.convertValue(taxPipeline, TenantPipeline.class); | ||
| 40 | + pipeline.setSystemType(SystemType.from(taxPipeline.getSystemCode())); | ||
| 41 | + return pipeline; | ||
| 42 | + }).toList(); | ||
| 38 | } | 43 | } |
| 39 | 44 | ||
| 40 | @Override | 45 | @Override |