Commit cd296c8d12d9cba514c80620c836b581aef3a07a
1 parent
0a44d560
feat(tax): 添加账套状态验证功能
- 在PipelineDO中新增state字段用于存储账套状态 - 在StateType中添加of方法用于状态值转换 - 在TaxReceiveService中添加租户账套有效性验证逻辑 - 添加ACCOUNTS_IS_NOT_ENABLED错误类型定义 - 移除TenantService中的状态过滤条件以支持所有状态查询
Showing
5 changed files
with
17 additions
and
2 deletions
tax-boot/src/main/java/com/diligrp/tax/boot/service/TaxReceiveService.java
| @@ -15,6 +15,7 @@ import com.diligrp.tax.central.type.MappingStateType; | @@ -15,6 +15,7 @@ import com.diligrp.tax.central.type.MappingStateType; | ||
| 15 | import com.diligrp.tax.central.type.SystemType; | 15 | import com.diligrp.tax.central.type.SystemType; |
| 16 | import com.diligrp.tax.central.type.TaxSystemType; | 16 | import com.diligrp.tax.central.type.TaxSystemType; |
| 17 | import com.diligrp.tax.central.utils.JsonUtils; | 17 | import com.diligrp.tax.central.utils.JsonUtils; |
| 18 | +import com.diligrp.tax.storage.type.StateType; | ||
| 18 | import jakarta.annotation.Resource; | 19 | import jakarta.annotation.Resource; |
| 19 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 20 | import org.springframework.transaction.annotation.Transactional; | 21 | import org.springframework.transaction.annotation.Transactional; |
| @@ -60,11 +61,15 @@ public class TaxReceiveService { | @@ -60,11 +61,15 @@ public class TaxReceiveService { | ||
| 60 | ctx.setPipelineDO(pipelineDO); | 61 | ctx.setPipelineDO(pipelineDO); |
| 61 | //获取租户id | 62 | //获取租户id |
| 62 | ctx.setTenantId(tenantService.getTenantId(ctx.getGroup(), ctx.getEntity())); | 63 | ctx.setTenantId(tenantService.getTenantId(ctx.getGroup(), ctx.getEntity())); |
| 64 | + //验证租户账套是否有效 | ||
| 65 | + Optional.of(pipelineDO) | ||
| 66 | + .filter(p -> StateType.of(p.getState()) == StateType.ENABLE) | ||
| 67 | + .orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.ACCOUNTS_IS_NOT_ENABLED)); | ||
| 63 | } | 68 | } |
| 64 | 69 | ||
| 65 | @Transactional | 70 | @Transactional |
| 66 | public void recordMapping(MessageContext messageContext) { | 71 | public void recordMapping(MessageContext messageContext) { |
| 67 | - Optional<PipelineMappingDO> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(messageContext.getPipelineDO().getTenantId(), messageContext.getPipelineDO().getId(), messageContext.getDocumentType(), messageContext.getSystemDataId(),messageContext.getPipelineDataId()); | 72 | + Optional<PipelineMappingDO> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(messageContext.getPipelineDO().getTenantId(), messageContext.getPipelineDO().getId(), messageContext.getDocumentType(), messageContext.getSystemDataId(), messageContext.getPipelineDataId()); |
| 68 | dbOptions.ifPresentOrElse( | 73 | dbOptions.ifPresentOrElse( |
| 69 | e -> { | 74 | e -> { |
| 70 | PipelineMappingCreateDO create = new PipelineMappingCreateDO(); | 75 | PipelineMappingCreateDO create = new PipelineMappingCreateDO(); |
tax-central/src/main/java/com/diligrp/tax/central/model/PipelineDO.java
tax-central/src/main/java/com/diligrp/tax/central/type/TaxSystemType.java
| @@ -20,6 +20,7 @@ public enum TaxSystemType { | @@ -20,6 +20,7 @@ public enum TaxSystemType { | ||
| 20 | NO_MATCHING_SET_OF_ACCOUNTS_FOUND(5008, "未找到匹配账套"), | 20 | NO_MATCHING_SET_OF_ACCOUNTS_FOUND(5008, "未找到匹配账套"), |
| 21 | NO_TENANT_INFORMATION_FOUND(5009, "未找到匹配账套"), | 21 | NO_TENANT_INFORMATION_FOUND(5009, "未找到匹配账套"), |
| 22 | PARAMETER_IS_NOT_PARSED_CORRECTLY(5010, "参数解析不正确"), | 22 | PARAMETER_IS_NOT_PARSED_CORRECTLY(5010, "参数解析不正确"), |
| 23 | + ACCOUNTS_IS_NOT_ENABLED(5011, "账套未启用"), | ||
| 23 | ; | 24 | ; |
| 24 | public final int code; | 25 | public final int code; |
| 25 | public final String message; | 26 | public final String message; |
tax-storage/src/main/java/com/diligrp/tax/storage/service/TenantService.java
| @@ -87,7 +87,6 @@ public class TenantService implements ITenantService { | @@ -87,7 +87,6 @@ public class TenantService implements ITenantService { | ||
| 87 | LambdaQueryWrapper<Pipeline> queryWrapper = new LambdaQueryWrapper<>(); | 87 | LambdaQueryWrapper<Pipeline> queryWrapper = new LambdaQueryWrapper<>(); |
| 88 | queryWrapper.eq(Pipeline::getCode, pipelineCode); | 88 | queryWrapper.eq(Pipeline::getCode, pipelineCode); |
| 89 | queryWrapper.eq(Pipeline::getTenantId, tenantId); | 89 | queryWrapper.eq(Pipeline::getTenantId, tenantId); |
| 90 | - queryWrapper.eq(Pipeline::getState, StateType.ENABLE.value); | ||
| 91 | return Optional.ofNullable(pipelineRepository.selectOne(queryWrapper)).map(taxPipeline -> { | 90 | return Optional.ofNullable(pipelineRepository.selectOne(queryWrapper)).map(taxPipeline -> { |
| 92 | PipelineDO pipelineDO = JsonUtils.convertValue(taxPipeline, PipelineDO.class); | 91 | PipelineDO pipelineDO = JsonUtils.convertValue(taxPipeline, PipelineDO.class); |
| 93 | pipelineDO.setSystemTypeEnum(SystemType.from(taxPipeline.getSystemType())); | 92 | pipelineDO.setSystemTypeEnum(SystemType.from(taxPipeline.getSystemType())); |
tax-storage/src/main/java/com/diligrp/tax/storage/type/StateType.java
| @@ -8,4 +8,13 @@ public enum StateType { | @@ -8,4 +8,13 @@ public enum StateType { | ||
| 8 | StateType(int value) { | 8 | StateType(int value) { |
| 9 | this.value = value; | 9 | this.value = value; |
| 10 | } | 10 | } |
| 11 | + | ||
| 12 | + public static StateType of(int value) { | ||
| 13 | + for (StateType stateType : values()) { | ||
| 14 | + if (stateType.value == value) { | ||
| 15 | + return stateType; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + throw new IllegalArgumentException("Invalid value: " + value); | ||
| 19 | + } | ||
| 11 | } | 20 | } |