Commit 8f99bf48220d257124be14c2b4c14293558038d7
1 parent
93a3cc03
refactor(mapping): 调整管道映射查询方法参数
- 修改 findByPipelineIdAndDocumentTypeAndSystemDataId 方法签名,移除 pipelineDataId 参数 - 新增 findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId 方法用于精确查询 - 更新接口和实现类中的方法定义与调用 - 补充数据库查询语句和 XML 配置文件的对应修改 - 在 TaxReceiveService 中使用新的精确查询方法替换原有调用 - 设置默认状态为 SYNCED 以确保数据一致性
Showing
6 changed files
with
61 additions
and
4 deletions
tax-boot/src/main/java/com/diligrp/tax/boot/service/TaxReceiveService.java
| ... | ... | @@ -62,7 +62,7 @@ public class TaxReceiveService { |
| 62 | 62 | |
| 63 | 63 | @Transactional |
| 64 | 64 | public void recordMapping(MessageContext messageContext) { |
| 65 | - Optional<TenantTaxPipelineMapping> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataId(messageContext.getTenantPipeline().getTenantId(), messageContext.getTenantPipeline().getId(), messageContext.getDocumentType(), messageContext.getSystemDataId(),messageContext.getPipelineDataId()); | |
| 65 | + Optional<TenantTaxPipelineMapping> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(messageContext.getTenantPipeline().getTenantId(), messageContext.getTenantPipeline().getId(), messageContext.getDocumentType(), messageContext.getSystemDataId(),messageContext.getPipelineDataId()); | |
| 66 | 66 | dbOptions.ifPresentOrElse( |
| 67 | 67 | e -> { |
| 68 | 68 | TaxPipelineMappingCreate create = new TaxPipelineMappingCreate(); | ... | ... |
tax-central/src/main/java/com/diligrp/tax/central/service/ITaxPipelineMappingService.java
| ... | ... | @@ -17,7 +17,19 @@ public interface ITaxPipelineMappingService { |
| 17 | 17 | * @param pipelineDataId |
| 18 | 18 | * @return {@link Optional }<{@link TenantTaxPipelineMapping }> |
| 19 | 19 | */ |
| 20 | - Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataId(Long tenantId, Long pipelineId, String documentType, String systemDataId, String pipelineDataId); | |
| 20 | + Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(Long tenantId, Long pipelineId, String documentType, String systemDataId, String pipelineDataId); | |
| 21 | + | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 按管道 ID 和文档类型以及系统数据 ID 查找 | |
| 25 | + * | |
| 26 | + * @param tenantId 租户 ID | |
| 27 | + * @param pipelineId 管道 ID | |
| 28 | + * @param documentType 文档类型 | |
| 29 | + * @param systemDataId 系统数据 ID | |
| 30 | + * @return {@link Optional }<{@link TenantTaxPipelineMapping }> | |
| 31 | + */ | |
| 32 | + Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataId(Long tenantId, Long pipelineId, String documentType, String systemDataId); | |
| 21 | 33 | |
| 22 | 34 | /** |
| 23 | 35 | * 插入 | ... | ... |
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/CustomerBuilder.java
| ... | ... | @@ -52,7 +52,7 @@ public class CustomerBuilder extends Builder<StandardCustomer> { |
| 52 | 52 | List<TenantPipelineConfig> list = taxTenantService.listByPipelineIdAndDocumentType(pipeline.getId(), markDocument().value); |
| 53 | 53 | Optional.ofNullable(list).ifPresent(ts -> configureDefaultData(customer, ts)); |
| 54 | 54 | //查询数据库的客户信息 如果存在 赋值id |
| 55 | - Optional<TenantTaxPipelineMapping> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataId(pipeline.getTenantId(), pipeline.getId(), markDocument().value, systemDataId, messageContext.getPipelineDataId()); | |
| 55 | + Optional<TenantTaxPipelineMapping> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataId(pipeline.getTenantId(), pipeline.getId(), markDocument().value, systemDataId); | |
| 56 | 56 | dbOptions.ifPresent(e -> { |
| 57 | 57 | customer.setCustomerId(e.getPipelineDataId()); |
| 58 | 58 | customer.setSystemDataId(e.getSystemDataId()); | ... | ... |
tax-storage/src/main/java/com/diligrp/tax/storage/repo/TaxPipelineMappingRepository.java
| ... | ... | @@ -44,6 +44,15 @@ public interface TaxPipelineMappingRepository { |
| 44 | 44 | Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataId(TaxPipelineMapping mapping); |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | + * 通过管道ID、文档类型以及系统数据ID和管道数据ID查找 | |
| 48 | + * | |
| 49 | + * @param taxPipelineMapping 税收管道映射 | |
| 50 | + * @return {@link Optional }<{@link TenantTaxPipelineMapping }> | |
| 51 | + */ | |
| 52 | + Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(TaxPipelineMapping taxPipelineMapping); | |
| 53 | + | |
| 54 | + | |
| 55 | + /** | |
| 47 | 56 | * 创建租户映射表 |
| 48 | 57 | * |
| 49 | 58 | * @param tableName 表名 |
| ... | ... | @@ -63,4 +72,5 @@ public interface TaxPipelineMappingRepository { |
| 63 | 72 | * @param taxPipelineMapping 税务管道映射 |
| 64 | 73 | */ |
| 65 | 74 | void update(TaxPipelineMapping taxPipelineMapping); |
| 75 | + | |
| 66 | 76 | } | ... | ... |
tax-storage/src/main/java/com/diligrp/tax/storage/service/DynamicTaxPipelineMappingService.java
| ... | ... | @@ -69,7 +69,7 @@ public class DynamicTaxPipelineMappingService implements ITaxPipelineMappingServ |
| 69 | 69 | * @return {@link Optional }<{@link TenantTaxPipelineMapping }> |
| 70 | 70 | */ |
| 71 | 71 | @Override |
| 72 | - public Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataId(Long tenantId, Long pipelineId, String documentType, String systemDataId, String pipelineDataId) { | |
| 72 | + public Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(Long tenantId, Long pipelineId, String documentType, String systemDataId, String pipelineDataId) { | |
| 73 | 73 | Optional.ofNullable(tenantId).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "租户ID不能为空")); |
| 74 | 74 | Optional.ofNullable(pipelineId).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "管道ID不能为空")); |
| 75 | 75 | Optional.ofNullable(documentType).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "文档类型不能为空")); |
| ... | ... | @@ -82,6 +82,21 @@ public class DynamicTaxPipelineMappingService implements ITaxPipelineMappingServ |
| 82 | 82 | taxPipelineMapping.setSystemDataId(systemDataId); |
| 83 | 83 | taxPipelineMapping.setPipelineDataId(pipelineDataId); |
| 84 | 84 | taxPipelineMapping.setState(MappingStateType.SYNCED.value); |
| 85 | + return taxPipelineMappingRepository.findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(taxPipelineMapping); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public Optional<TenantTaxPipelineMapping> findByPipelineIdAndDocumentTypeAndSystemDataId(Long tenantId, Long pipelineId, String documentType, String systemDataId) { | |
| 90 | + Optional.ofNullable(tenantId).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "租户ID不能为空")); | |
| 91 | + Optional.ofNullable(pipelineId).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "管道ID不能为空")); | |
| 92 | + Optional.ofNullable(documentType).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "文档类型不能为空")); | |
| 93 | + Optional.ofNullable(systemDataId).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "系统数据不能为空")); | |
| 94 | + TaxPipelineMapping taxPipelineMapping = new TaxPipelineMapping(); | |
| 95 | + taxPipelineMapping.setTenantId(tenantId); | |
| 96 | + taxPipelineMapping.setPipelineId(pipelineId); | |
| 97 | + taxPipelineMapping.setDocumentType(documentType); | |
| 98 | + taxPipelineMapping.setSystemDataId(systemDataId); | |
| 99 | + taxPipelineMapping.setState(MappingStateType.SYNCED.value); | |
| 85 | 100 | return taxPipelineMappingRepository.findByPipelineIdAndDocumentTypeAndSystemDataId(taxPipelineMapping); |
| 86 | 101 | } |
| 87 | 102 | ... | ... |
tax-storage/src/main/resources/com/diligrp/tax/storage/repo/TaxPipelineMappingRepository.xml
| ... | ... | @@ -66,6 +66,26 @@ |
| 66 | 66 | AND pipeline_id = #{pipelineId} |
| 67 | 67 | AND document_type = #{documentType} |
| 68 | 68 | AND system_data_id = #{systemDataId} |
| 69 | + </select> | |
| 70 | + <select id="findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId" | |
| 71 | + resultType="com.diligrp.tax.central.model.TenantTaxPipelineMapping"> | |
| 72 | + SELECT | |
| 73 | + id | |
| 74 | + , pipeline_id | |
| 75 | + , document_type | |
| 76 | + , system_data_id | |
| 77 | + , pipeline_data_id | |
| 78 | + , origin_data | |
| 79 | + , state | |
| 80 | + , created_Time | |
| 81 | + , modified_Time | |
| 82 | + FROM | |
| 83 | + tax_pipeline_mapping_${tenantId} | |
| 84 | + WHERE | |
| 85 | + 1 = 1 | |
| 86 | + AND pipeline_id = #{pipelineId} | |
| 87 | + AND document_type = #{documentType} | |
| 88 | + AND system_data_id = #{systemDataId} | |
| 69 | 89 | AND pipeline_data_id = #{pipelineDataId} |
| 70 | 90 | </select> |
| 71 | 91 | ... | ... |