Commit c29bc71d051802511a1d92041203493be35d7ac6
1 parent
fab6c9ab
refactor(storage):重构租户管道配置相关类包结构和依赖关系
- 将 ConnectionIdentity 接口从 storage 包移动到 central 包 - 将 RestoreTenantEvent 和 RestoreTenantEventListener 移动到 central 包并更新引用 -重命名 TaxPipelineConfigVO 为 TenantPipelineConfig 并调整字段注释 - 更新 TenantPipeline 类的包路径和依赖引用 - 引入 ITenantTaxService 接口及其实现类 TenantTaxService - 调整 TenantStorageContext 中的依赖注入和服务调用方式 - 删除旧的 TaxPipelineService 和 TaxPipelineConfigService 依赖 - 新增 listAllEnablePipeline 和 listByPipelineId 方法实现数据转换逻辑
Showing
9 changed files
with
167 additions
and
41 deletions
tax-storage/src/main/java/com/diligrp/tax/storage/context/TenantStorageContext.java renamed to tax-central/src/main/java/com/diligrp/tax/central/context/TenantStorageContext.java
| 1 | -package com.diligrp.tax.storage.context; | |
| 1 | +package com.diligrp.tax.central.context; | |
| 2 | 2 | |
| 3 | +import com.diligrp.tax.central.model.TenantPipeline; | |
| 4 | +import com.diligrp.tax.central.model.TenantPipelineConfig; | |
| 5 | +import com.diligrp.tax.central.service.ITenantTaxService; | |
| 3 | 6 | import com.diligrp.tax.central.type.SystemType; |
| 4 | -import com.diligrp.tax.storage.model.vo.TaxPipelineVO; | |
| 5 | -import com.diligrp.tax.storage.service.TaxPipelineConfigService; | |
| 6 | -import com.diligrp.tax.storage.service.TaxPipelineService; | |
| 7 | 7 | import jakarta.annotation.Resource; |
| 8 | 8 | import org.springframework.stereotype.Component; |
| 9 | 9 | |
| ... | ... | @@ -23,14 +23,11 @@ import java.util.stream.Collectors; |
| 23 | 23 | public class TenantStorageContext { |
| 24 | 24 | |
| 25 | 25 | @Resource |
| 26 | - private TaxPipelineService taxPipelineService; | |
| 27 | - | |
| 28 | - @Resource | |
| 29 | - private TaxPipelineConfigService taxPipelineConfigService; | |
| 26 | + private ITenantTaxService tenantTaxService; | |
| 30 | 27 | |
| 31 | 28 | private static final ConcurrentHashMap<Long, Map<SystemType, Map<String, TenantPipeline>>> TENANT_PIPELINE_MAP = new ConcurrentHashMap<>(); |
| 32 | 29 | |
| 33 | - public Optional<TenantPipeline> getTenantPipeline(Long tenantId, SystemType systemType, String pipelineCode) { | |
| 30 | + public static Optional<TenantPipeline> getTenantPipeline(Long tenantId, SystemType systemType, String pipelineCode) { | |
| 34 | 31 | AtomicReference<TenantPipeline> pipeline = new AtomicReference<>(); |
| 35 | 32 | Map<SystemType, Map<String, TenantPipeline>> tenantPipelineMap = TENANT_PIPELINE_MAP.get(tenantId); |
| 36 | 33 | Optional.ofNullable(tenantPipelineMap).ifPresent(map -> { |
| ... | ... | @@ -44,16 +41,16 @@ public class TenantStorageContext { |
| 44 | 41 | |
| 45 | 42 | |
| 46 | 43 | public void loadTenantPipeline() { |
| 47 | - List<TaxPipelineVO> taxPipelineVOS = taxPipelineService.listAllEnablePipeline(); | |
| 44 | + List<TenantPipeline> taxPipelineVOS = tenantTaxService.listAllEnablePipeline(); | |
| 48 | 45 | Optional.ofNullable(taxPipelineVOS).ifPresent(pipelines -> { |
| 49 | 46 | Map<Long, Map<SystemType, Map<String, TenantPipeline>>> tenantPipelineMap = pipelines.stream() |
| 50 | 47 | .collect(Collectors.groupingBy( |
| 51 | - TaxPipelineVO::getTenantId, | |
| 48 | + TenantPipeline::getTenantId, | |
| 52 | 49 | Collectors.groupingBy( |
| 53 | - e -> SystemType.from(e.getSystemCode()), | |
| 50 | + TenantPipeline::getSystemType, | |
| 54 | 51 | Collectors.toMap( |
| 55 | - TaxPipelineVO::getCode, | |
| 56 | - this::convert, | |
| 52 | + TenantPipeline::getCode, | |
| 53 | + this::loadConfig, | |
| 57 | 54 | (existing, replacement) -> existing |
| 58 | 55 | ) |
| 59 | 56 | ) |
| ... | ... | @@ -64,12 +61,9 @@ public class TenantStorageContext { |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | 63 | |
| 67 | - private TenantPipeline convert(TaxPipelineVO taxPipelineVO) { | |
| 68 | - return TenantPipeline.builder() | |
| 69 | - .code(taxPipelineVO.getCode()) | |
| 70 | - .name(taxPipelineVO.getName()) | |
| 71 | - .params(taxPipelineVO.getParams()) | |
| 72 | - .taxPipelineConfigs(taxPipelineConfigService.listByPipelineId(taxPipelineVO.getId())) | |
| 73 | - .build(); | |
| 64 | + private TenantPipeline loadConfig(TenantPipeline tenantPipeline) { | |
| 65 | + List<TenantPipelineConfig> list = tenantTaxService.listByPipelineId(tenantPipeline.getId()); | |
| 66 | + tenantPipeline.setTenantPipelineConfigs(list); | |
| 67 | + return tenantPipeline; | |
| 74 | 68 | } |
| 75 | 69 | } | ... | ... |
tax-storage/src/main/java/com/diligrp/tax/storage/event/RestoreTenantEvent.java renamed to tax-central/src/main/java/com/diligrp/tax/central/event/RestoreTenantEvent.java
tax-storage/src/main/java/com/diligrp/tax/storage/event/RestoreTenantEventListener.java renamed to tax-central/src/main/java/com/diligrp/tax/central/event/RestoreTenantEventListener.java
| 1 | -package com.diligrp.tax.storage.event; | |
| 1 | +package com.diligrp.tax.central.event; | |
| 2 | 2 | |
| 3 | -import com.diligrp.tax.storage.context.TenantStorageContext; | |
| 3 | +import com.diligrp.tax.central.context.TenantStorageContext; | |
| 4 | 4 | import jakarta.annotation.Resource; |
| 5 | 5 | import org.springframework.context.event.EventListener; |
| 6 | 6 | import org.springframework.stereotype.Component; | ... | ... |
tax-storage/src/main/java/com/diligrp/tax/storage/context/ConnectionIdentity.java renamed to tax-central/src/main/java/com/diligrp/tax/central/interfaces/ConnectionIdentity.java
tax-storage/src/main/java/com/diligrp/tax/storage/context/TenantPipeline.java renamed to tax-central/src/main/java/com/diligrp/tax/central/model/TenantPipeline.java
| 1 | -package com.diligrp.tax.storage.context; | |
| 1 | +package com.diligrp.tax.central.model; | |
| 2 | 2 | |
| 3 | +import com.diligrp.tax.central.interfaces.ConnectionIdentity; | |
| 4 | +import com.diligrp.tax.central.type.SystemType; | |
| 3 | 5 | import com.diligrp.tax.central.utils.JsonUtils; |
| 4 | -import com.diligrp.tax.storage.model.vo.TaxPipelineConfigVO; | |
| 5 | 6 | import com.kingdee.bos.webapi.entity.IdentifyInfo; |
| 6 | 7 | import lombok.Builder; |
| 7 | 8 | import lombok.Getter; |
| ... | ... | @@ -19,10 +20,13 @@ import java.util.Map; |
| 19 | 20 | @Getter |
| 20 | 21 | @Builder |
| 21 | 22 | public class TenantPipeline implements ConnectionIdentity<IdentifyInfo> { |
| 23 | + private Long id; | |
| 24 | + private Long tenantId; | |
| 25 | + private SystemType systemType; | |
| 22 | 26 | private String name; |
| 23 | 27 | private String code; |
| 24 | 28 | private Map<String, Object> params; |
| 25 | - private List<TaxPipelineConfigVO> taxPipelineConfigs; | |
| 29 | + private List<TenantPipelineConfig> tenantPipelineConfigs; | |
| 26 | 30 | |
| 27 | 31 | @Override |
| 28 | 32 | public IdentifyInfo getIdentity() { | ... | ... |
tax-central/src/main/java/com/diligrp/tax/central/model/TenantPipelineConfig.java
0 → 100644
| 1 | +package com.diligrp.tax.central.model; | |
| 2 | + | |
| 3 | +import lombok.Getter; | |
| 4 | +import lombok.Setter; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @Author: zhangmeiyang | |
| 10 | + * @CreateTime: 2025-11-06 14:25 | |
| 11 | + * @Version: todo | |
| 12 | + */ | |
| 13 | +@Getter | |
| 14 | +@Setter | |
| 15 | +public class TenantPipelineConfig { | |
| 16 | + /** | |
| 17 | + * id | |
| 18 | + */ | |
| 19 | + private Long id; | |
| 20 | + /** | |
| 21 | + * 管道 ID | |
| 22 | + */ | |
| 23 | + private Long pipelineId; | |
| 24 | + /** | |
| 25 | + * 文档类型 | |
| 26 | + */ | |
| 27 | + private String documentType; | |
| 28 | + /** | |
| 29 | + * 配置键 | |
| 30 | + */ | |
| 31 | + private String configKey; | |
| 32 | + /** | |
| 33 | + * 配置值 | |
| 34 | + */ | |
| 35 | + private String configValue; | |
| 36 | + /** | |
| 37 | + * 创建时间 | |
| 38 | + */ | |
| 39 | + private LocalDateTime createdTime; | |
| 40 | + /** | |
| 41 | + * 修改时间 | |
| 42 | + */ | |
| 43 | + private LocalDateTime modifiedTime; | |
| 44 | +} | ... | ... |
tax-central/src/main/java/com/diligrp/tax/central/service/ITenantTaxService.java
0 → 100644
| 1 | +package com.diligrp.tax.central.service; | |
| 2 | + | |
| 3 | +import com.diligrp.tax.central.model.TenantPipeline; | |
| 4 | +import com.diligrp.tax.central.model.TenantPipelineConfig; | |
| 5 | + | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @Author: zhangmeiyang | |
| 10 | + * @CreateTime: 2025-11-06 14:20 | |
| 11 | + * @Version: todo | |
| 12 | + */ | |
| 13 | +public interface ITenantTaxService { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 列出所有启用管道 | |
| 17 | + * | |
| 18 | + * @return {@link List }<{@link TenantPipeline }> | |
| 19 | + */ | |
| 20 | + List<TenantPipeline> listAllEnablePipeline(); | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 按管道 ID 列出 | |
| 24 | + * | |
| 25 | + * @param pipelineId 管道 ID | |
| 26 | + * @return {@link List }<{@link TenantPipelineConfig }> | |
| 27 | + */ | |
| 28 | + List<TenantPipelineConfig> listByPipelineId(Long pipelineId); | |
| 29 | +} | ... | ... |
tax-storage/src/main/java/com/diligrp/tax/storage/model/vo/TaxPipelineConfigVO.java
| ... | ... | @@ -9,25 +9,33 @@ import java.time.LocalDateTime; |
| 9 | 9 | @Getter |
| 10 | 10 | @Setter |
| 11 | 11 | public class TaxPipelineConfigVO { |
| 12 | - | |
| 12 | + /** | |
| 13 | + * id | |
| 14 | + */ | |
| 13 | 15 | private Long id; |
| 14 | - | |
| 15 | - | |
| 16 | + /** | |
| 17 | + * 管道 ID | |
| 18 | + */ | |
| 16 | 19 | private Long pipelineId; |
| 17 | - | |
| 18 | - | |
| 20 | + /** | |
| 21 | + * 文档类型 | |
| 22 | + */ | |
| 19 | 23 | private String documentType; |
| 20 | - | |
| 21 | - | |
| 24 | + /** | |
| 25 | + * 配置键 | |
| 26 | + */ | |
| 22 | 27 | private String configKey; |
| 23 | - | |
| 24 | - | |
| 28 | + /** | |
| 29 | + * 配置值 | |
| 30 | + */ | |
| 25 | 31 | private String configValue; |
| 26 | - | |
| 27 | - | |
| 32 | + /** | |
| 33 | + * 创建时间 | |
| 34 | + */ | |
| 28 | 35 | private LocalDateTime createdTime; |
| 29 | - | |
| 30 | - | |
| 36 | + /** | |
| 37 | + * 修改时间 | |
| 38 | + */ | |
| 31 | 39 | private LocalDateTime modifiedTime; |
| 32 | 40 | |
| 33 | 41 | } | ... | ... |
tax-storage/src/main/java/com/diligrp/tax/storage/service/TenantTaxService.java
0 → 100644
| 1 | +package com.diligrp.tax.storage.service; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 4 | +import com.diligrp.tax.central.model.TenantPipeline; | |
| 5 | +import com.diligrp.tax.central.model.TenantPipelineConfig; | |
| 6 | +import com.diligrp.tax.central.service.ITenantTaxService; | |
| 7 | +import com.diligrp.tax.central.utils.JsonUtils; | |
| 8 | +import com.diligrp.tax.storage.domain.TaxPipeline; | |
| 9 | +import com.diligrp.tax.storage.domain.TaxPipelineConfig; | |
| 10 | +import com.diligrp.tax.storage.repo.TaxPipelineConfigRepository; | |
| 11 | +import com.diligrp.tax.storage.repo.TaxPipelineRepository; | |
| 12 | +import com.diligrp.tax.storage.type.StateType; | |
| 13 | +import jakarta.annotation.Resource; | |
| 14 | +import org.springframework.stereotype.Service; | |
| 15 | + | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * @Author: zhangmeiyang | |
| 20 | + * @CreateTime: 2025-11-06 14:32 | |
| 21 | + * @Version: todo | |
| 22 | + */ | |
| 23 | +@Service | |
| 24 | +public class TenantTaxService implements ITenantTaxService { | |
| 25 | + | |
| 26 | + @Resource | |
| 27 | + private TaxPipelineRepository taxPipelineRepository; | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private TaxPipelineConfigRepository taxPipelineConfigRepository; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public List<TenantPipeline> listAllEnablePipeline() { | |
| 34 | + LambdaQueryWrapper<TaxPipeline> queryWrapper = new LambdaQueryWrapper<>(); | |
| 35 | + queryWrapper.eq(TaxPipeline::getState, StateType.ENABLE.value); | |
| 36 | + List<TaxPipeline> taxPipelines = taxPipelineRepository.selectList(queryWrapper); | |
| 37 | + return taxPipelines.stream().map(taxPipeline -> JsonUtils.convertValue(taxPipeline, TenantPipeline.class)).toList(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public List<TenantPipelineConfig> listByPipelineId(Long pipelineId) { | |
| 42 | + LambdaQueryWrapper<TaxPipelineConfig> queryWrapper = new LambdaQueryWrapper<>(); | |
| 43 | + queryWrapper.eq(TaxPipelineConfig::getPipelineId, pipelineId); | |
| 44 | + List<TaxPipelineConfig> taxPipelineConfigs = taxPipelineConfigRepository.selectList(queryWrapper); | |
| 45 | + return taxPipelineConfigs.stream().map(taxPipelineConfig -> JsonUtils.convertValue(taxPipelineConfig, TenantPipelineConfig.class)).toList(); | |
| 46 | + } | |
| 47 | +} | ... | ... |