Commit ee14bcb04e85eb854459c12192122b9e2952fd93
1 parent
bb1d2690
refactor(system): 重构系统类型字段命名及验证逻辑
- 将 systemCode 字段统一更名为 systemType - 修改 SystemType 枚举验证方法名 validateSystemCode 为 validateSystemType - 更新 PipelineDO 中 systemType 字段类型为 systemTypeEnum - 调整 TenantService 中获取管道信息时的系统类型转换逻辑 - 优化 PipelineMappingRepository 接口参数传递方式和 SQL 查询条件 - 增加 MyBatis Plus 分页插件配置支持 - 引入 mybatis-plus-jsqlparser 依赖以增强 SQL 解析能力 - 完善租户查询逻辑,增加异常处理和 ID 设置机制
Showing
16 changed files
with
74 additions
and
38 deletions
pom.xml
| @@ -45,6 +45,11 @@ | @@ -45,6 +45,11 @@ | ||
| 45 | <version>${mybatis-plus.version}</version> | 45 | <version>${mybatis-plus.version}</version> |
| 46 | </dependency> | 46 | </dependency> |
| 47 | <dependency> | 47 | <dependency> |
| 48 | + <groupId>com.baomidou</groupId> | ||
| 49 | + <artifactId>mybatis-plus-jsqlparser</artifactId> | ||
| 50 | + <version>${mybatis-plus.version}</version> | ||
| 51 | + </dependency> | ||
| 52 | + <dependency> | ||
| 48 | <groupId>org.springframework.boot</groupId> | 53 | <groupId>org.springframework.boot</groupId> |
| 49 | <artifactId>spring-boot-dependencies</artifactId> | 54 | <artifactId>spring-boot-dependencies</artifactId> |
| 50 | <version>${spring-boot.version}</version> | 55 | <version>${spring-boot.version}</version> |
tax-adopt/src/main/java/com/diligrp/tax/adopt/service/impl/AdoptMessageServiceImpl.java
| @@ -61,7 +61,7 @@ public class AdoptMessageServiceImpl implements AdoptMessageService { | @@ -61,7 +61,7 @@ public class AdoptMessageServiceImpl implements AdoptMessageService { | ||
| 61 | receiveMessageCO.setMsgBody(map); | 61 | receiveMessageCO.setMsgBody(map); |
| 62 | } | 62 | } |
| 63 | Optional<PipelineDO> byTenantAndPipelineCode = tenantService.findByTenantAndPipelineCode(receiveMessageCO.getGroup(), receiveMessageCO.getEntity(), receiveMessageCO.getPipelineCode()); | 63 | Optional<PipelineDO> byTenantAndPipelineCode = tenantService.findByTenantAndPipelineCode(receiveMessageCO.getGroup(), receiveMessageCO.getEntity(), receiveMessageCO.getPipelineCode()); |
| 64 | - byTenantAndPipelineCode.ifPresent(tenantPipeline -> receiveMessageCO.setSystemType(tenantPipeline.getSystemType().code)); | 64 | + byTenantAndPipelineCode.ifPresent(tenantPipeline -> receiveMessageCO.setSystemType(tenantPipeline.getSystemTypeEnum().code)); |
| 65 | // 发送mq | 65 | // 发送mq |
| 66 | String messageJson = JsonUtils.toJsonString(receiveMessageCO); | 66 | String messageJson = JsonUtils.toJsonString(receiveMessageCO); |
| 67 | rabbitTemplate.convertAndSend(NORMAL_EXCHANGE, NORMAL_ROUTING, messageJson); | 67 | rabbitTemplate.convertAndSend(NORMAL_EXCHANGE, NORMAL_ROUTING, messageJson); |
| @@ -88,7 +88,7 @@ public class AdoptMessageServiceImpl implements AdoptMessageService { | @@ -88,7 +88,7 @@ public class AdoptMessageServiceImpl implements AdoptMessageService { | ||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | private static ReceiveMessageCO getReceiveMessageCO(String group, String entity, String pipelineCode, String documentType, Map<String, Object> map, PipelineDO pipelineDO) { | 90 | private static ReceiveMessageCO getReceiveMessageCO(String group, String entity, String pipelineCode, String documentType, Map<String, Object> map, PipelineDO pipelineDO) { |
| 91 | - var msgBody = switch (pipelineDO.getSystemType()) { | 91 | + var msgBody = switch (pipelineDO.getSystemTypeEnum()) { |
| 92 | case KING_DEE -> kingdeeMap(map); | 92 | case KING_DEE -> kingdeeMap(map); |
| 93 | case YONG_YOU -> throw new TaxAgentServiceException(TaxSystemType.ABNORMAL_PARAMETERS, "未支持的系统形式"); | 93 | case YONG_YOU -> throw new TaxAgentServiceException(TaxSystemType.ABNORMAL_PARAMETERS, "未支持的系统形式"); |
| 94 | }; | 94 | }; |
| @@ -98,7 +98,7 @@ public class AdoptMessageServiceImpl implements AdoptMessageService { | @@ -98,7 +98,7 @@ public class AdoptMessageServiceImpl implements AdoptMessageService { | ||
| 98 | receiveMessageCO.setGroup(group); | 98 | receiveMessageCO.setGroup(group); |
| 99 | receiveMessageCO.setEntity(entity); | 99 | receiveMessageCO.setEntity(entity); |
| 100 | receiveMessageCO.setPipelineCode(pipelineCode); | 100 | receiveMessageCO.setPipelineCode(pipelineCode); |
| 101 | - receiveMessageCO.setSystemType(pipelineDO.getSystemType().code); | 101 | + receiveMessageCO.setSystemType(pipelineDO.getSystemTypeEnum().code); |
| 102 | receiveMessageCO.setDocumentType(documentType); | 102 | receiveMessageCO.setDocumentType(documentType); |
| 103 | receiveMessageCO.setMsgBody(msgBody); | 103 | receiveMessageCO.setMsgBody(msgBody); |
| 104 | return receiveMessageCO; | 104 | return receiveMessageCO; |
tax-central/src/main/java/com/diligrp/tax/central/context/TenantStorageContext.java
| @@ -45,7 +45,7 @@ public class TenantStorageContext { | @@ -45,7 +45,7 @@ public class TenantStorageContext { | ||
| 45 | public void loadTenantPipeline() { | 45 | public void loadTenantPipeline() { |
| 46 | List<PipelineDO> taxPipelineDOVOS = tenantService.listAllEnablePipeline(); | 46 | List<PipelineDO> taxPipelineDOVOS = tenantService.listAllEnablePipeline(); |
| 47 | Optional.ofNullable(taxPipelineDOVOS).ifPresent(pipelines -> { | 47 | Optional.ofNullable(taxPipelineDOVOS).ifPresent(pipelines -> { |
| 48 | - var tenantPipelineMap = pipelines.stream().collect(Collectors.groupingBy(PipelineDO::getTenantId, Collectors.groupingBy(PipelineDO::getSystemType, Collectors.toMap(PipelineDO::getCode, e -> e)))); | 48 | + var tenantPipelineMap = pipelines.stream().collect(Collectors.groupingBy(PipelineDO::getTenantId, Collectors.groupingBy(PipelineDO::getSystemTypeEnum, Collectors.toMap(PipelineDO::getCode, e -> e)))); |
| 49 | TENANT_PIPELINE_MAP.clear(); | 49 | TENANT_PIPELINE_MAP.clear(); |
| 50 | TENANT_PIPELINE_MAP.putAll(tenantPipelineMap); | 50 | TENANT_PIPELINE_MAP.putAll(tenantPipelineMap); |
| 51 | }); | 51 | }); |
tax-central/src/main/java/com/diligrp/tax/central/model/PipelineDO.java
| @@ -16,7 +16,7 @@ import java.util.Map; | @@ -16,7 +16,7 @@ import java.util.Map; | ||
| 16 | public class PipelineDO { | 16 | public class PipelineDO { |
| 17 | private Long id; | 17 | private Long id; |
| 18 | private Long tenantId; | 18 | private Long tenantId; |
| 19 | - private SystemType systemType; | 19 | + private SystemType systemTypeEnum; |
| 20 | private String name; | 20 | private String name; |
| 21 | private String code; | 21 | private String code; |
| 22 | private Map<String, Object> params; | 22 | private Map<String, Object> params; |
tax-central/src/main/java/com/diligrp/tax/central/type/SystemType.java
| @@ -28,7 +28,7 @@ public enum SystemType { | @@ -28,7 +28,7 @@ public enum SystemType { | ||
| 28 | throw new IllegalArgumentException("Invalid SystemType code: " + code); | 28 | throw new IllegalArgumentException("Invalid SystemType code: " + code); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | - public static void validateSystemCode(String code){ | 31 | + public static void validateSystemType(String code){ |
| 32 | for (SystemType systemType : SystemType.values()){ | 32 | for (SystemType systemType : SystemType.values()){ |
| 33 | if (systemType.code.equals(code)){ | 33 | if (systemType.code.equals(code)){ |
| 34 | return; | 34 | return; |
tax-storage/pom.xml
| @@ -26,6 +26,10 @@ | @@ -26,6 +26,10 @@ | ||
| 26 | <artifactId>mybatis-plus-spring-boot3-starter</artifactId> | 26 | <artifactId>mybatis-plus-spring-boot3-starter</artifactId> |
| 27 | </dependency> | 27 | </dependency> |
| 28 | <dependency> | 28 | <dependency> |
| 29 | + <groupId>com.baomidou</groupId> | ||
| 30 | + <artifactId>mybatis-plus-jsqlparser</artifactId> | ||
| 31 | + </dependency> | ||
| 32 | + <dependency> | ||
| 29 | <groupId>org.springframework.boot</groupId> | 33 | <groupId>org.springframework.boot</groupId> |
| 30 | <artifactId>spring-boot-starter-aop</artifactId> | 34 | <artifactId>spring-boot-starter-aop</artifactId> |
| 31 | </dependency> | 35 | </dependency> |
tax-storage/src/main/java/com/diligrp/tax/storage/StorageConfig.java
| 1 | package com.diligrp.tax.storage; | 1 | package com.diligrp.tax.storage; |
| 2 | 2 | ||
| 3 | +import com.baomidou.mybatisplus.annotation.DbType; | ||
| 4 | +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | ||
| 5 | +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; | ||
| 3 | import org.mybatis.spring.annotation.MapperScan; | 6 | import org.mybatis.spring.annotation.MapperScan; |
| 7 | +import org.springframework.context.annotation.Bean; | ||
| 4 | import org.springframework.context.annotation.ComponentScan; | 8 | import org.springframework.context.annotation.ComponentScan; |
| 5 | import org.springframework.context.annotation.Configuration; | 9 | import org.springframework.context.annotation.Configuration; |
| 6 | 10 | ||
| @@ -13,4 +17,15 @@ import org.springframework.context.annotation.Configuration; | @@ -13,4 +17,15 @@ import org.springframework.context.annotation.Configuration; | ||
| 13 | @ComponentScan(basePackages = "com.diligrp.tax.storage") | 17 | @ComponentScan(basePackages = "com.diligrp.tax.storage") |
| 14 | @MapperScan(basePackages = "com.diligrp.tax.storage.repo") | 18 | @MapperScan(basePackages = "com.diligrp.tax.storage.repo") |
| 15 | public class StorageConfig { | 19 | public class StorageConfig { |
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 添加分页插件 | ||
| 23 | + */ | ||
| 24 | + @Bean | ||
| 25 | + public MybatisPlusInterceptor mybatisPlusInterceptor() { | ||
| 26 | + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); | ||
| 27 | + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加 | ||
| 28 | + // 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType | ||
| 29 | + return interceptor; | ||
| 30 | + } | ||
| 16 | } | 31 | } |
tax-storage/src/main/java/com/diligrp/tax/storage/domain/Pipeline.java
| @@ -27,8 +27,8 @@ public class Pipeline { | @@ -27,8 +27,8 @@ public class Pipeline { | ||
| 27 | @TableField("tenant_id") | 27 | @TableField("tenant_id") |
| 28 | private Long tenantId; | 28 | private Long tenantId; |
| 29 | 29 | ||
| 30 | - @TableField("system_code") | ||
| 31 | - private String systemCode; | 30 | + @TableField("system_type") |
| 31 | + private String systemType; | ||
| 32 | 32 | ||
| 33 | @TableField("name") | 33 | @TableField("name") |
| 34 | private String name; | 34 | private String name; |
tax-storage/src/main/java/com/diligrp/tax/storage/model/co/PipelineCO.java
| @@ -39,7 +39,7 @@ public class PipelineCO { | @@ -39,7 +39,7 @@ public class PipelineCO { | ||
| 39 | * 账套类型 | 39 | * 账套类型 |
| 40 | */ | 40 | */ |
| 41 | @NotEmpty(groups = {Valid.Create.class}) | 41 | @NotEmpty(groups = {Valid.Create.class}) |
| 42 | - private String systemCode; | 42 | + private String systemType; |
| 43 | /** | 43 | /** |
| 44 | * 账套名字 | 44 | * 账套名字 |
| 45 | */ | 45 | */ |
tax-storage/src/main/java/com/diligrp/tax/storage/model/co/TenantCO.java
| @@ -18,7 +18,6 @@ public class TenantCO extends PageQuery { | @@ -18,7 +18,6 @@ public class TenantCO extends PageQuery { | ||
| 18 | /** | 18 | /** |
| 19 | * id | 19 | * id |
| 20 | */ | 20 | */ |
| 21 | - @NotNull(groups = {Valid.Update.class, Valid.Delete.class, Valid.Read.class}) | ||
| 22 | private Long id; | 21 | private Long id; |
| 23 | /** | 22 | /** |
| 24 | * 名字 | 23 | * 名字 |
tax-storage/src/main/java/com/diligrp/tax/storage/model/vo/PipelineVO.java
tax-storage/src/main/java/com/diligrp/tax/storage/repo/PipelineMappingRepository.java
| @@ -3,6 +3,7 @@ package com.diligrp.tax.storage.repo; | @@ -3,6 +3,7 @@ package com.diligrp.tax.storage.repo; | ||
| 3 | import com.baomidou.mybatisplus.core.metadata.IPage; | 3 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 5 | import com.diligrp.tax.central.model.PipelineMappingDO; | 5 | import com.diligrp.tax.central.model.PipelineMappingDO; |
| 6 | +import com.diligrp.tax.storage.domain.PipelineMapping; | ||
| 6 | import org.apache.ibatis.annotations.Param; | 7 | import org.apache.ibatis.annotations.Param; |
| 7 | import org.springframework.stereotype.Repository; | 8 | import org.springframework.stereotype.Repository; |
| 8 | 9 | ||
| @@ -17,30 +18,31 @@ public interface PipelineMappingRepository { | @@ -17,30 +18,31 @@ public interface PipelineMappingRepository { | ||
| 17 | * | 18 | * |
| 18 | * @param mapping 税务管道映射 | 19 | * @param mapping 税务管道映射 |
| 19 | */ | 20 | */ |
| 20 | - void insert(com.diligrp.tax.storage.domain.PipelineMapping mapping); | 21 | + void insert(PipelineMapping mapping); |
| 21 | 22 | ||
| 22 | /** | 23 | /** |
| 23 | * 更新 | 24 | * 更新 |
| 24 | * | 25 | * |
| 25 | * @param mapping 税务管道映射 | 26 | * @param mapping 税务管道映射 |
| 26 | */ | 27 | */ |
| 27 | - void updateStatus(com.diligrp.tax.storage.domain.PipelineMapping mapping); | 28 | + void updateStatus(@Param("mapping") PipelineMapping mapping, @Param("tenantId") Long tenantId); |
| 28 | 29 | ||
| 29 | /** | 30 | /** |
| 30 | * 按管道 ID 查找 | 31 | * 按管道 ID 查找 |
| 31 | * | 32 | * |
| 32 | * @param mapping 税务管道映射 | 33 | * @param mapping 税务管道映射 |
| 33 | - * @return {@link List }<{@link com.diligrp.tax.storage.domain.PipelineMapping }> | 34 | + * @param page 页 |
| 35 | + * @return {@link List }<{@link PipelineMapping }> | ||
| 34 | */ | 36 | */ |
| 35 | - Page<PipelineMappingDO> findByPipelineIdAndState(com.diligrp.tax.storage.domain.PipelineMapping mapping, IPage<?> page); | 37 | + Page<PipelineMappingDO> findByPipelineIdAndState(@Param("mapping")PipelineMapping mapping,@Param("page") IPage<?> page); |
| 36 | 38 | ||
| 37 | /** | 39 | /** |
| 38 | * 按管道 ID 和系统数据 ID 查找 | 40 | * 按管道 ID 和系统数据 ID 查找 |
| 39 | * | 41 | * |
| 40 | * @param mapping 映射 | 42 | * @param mapping 映射 |
| 41 | - * @return {@link Optional }<{@link com.diligrp.tax.storage.domain.PipelineMapping }> | 43 | + * @return {@link Optional }<{@link PipelineMapping }> |
| 42 | */ | 44 | */ |
| 43 | - Optional<PipelineMappingDO> findByPipelineIdAndDocumentTypeAndSystemDataId(com.diligrp.tax.storage.domain.PipelineMapping mapping); | 45 | + Optional<PipelineMappingDO> findByPipelineIdAndDocumentTypeAndSystemDataId(PipelineMapping mapping); |
| 44 | 46 | ||
| 45 | /** | 47 | /** |
| 46 | * 通过管道ID、文档类型以及系统数据ID和管道数据ID查找 | 48 | * 通过管道ID、文档类型以及系统数据ID和管道数据ID查找 |
| @@ -48,7 +50,7 @@ public interface PipelineMappingRepository { | @@ -48,7 +50,7 @@ public interface PipelineMappingRepository { | ||
| 48 | * @param pipelineMapping 税收管道映射 | 50 | * @param pipelineMapping 税收管道映射 |
| 49 | * @return {@link Optional }<{@link PipelineMappingDO }> | 51 | * @return {@link Optional }<{@link PipelineMappingDO }> |
| 50 | */ | 52 | */ |
| 51 | - Optional<PipelineMappingDO> findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(com.diligrp.tax.storage.domain.PipelineMapping pipelineMapping); | 53 | + Optional<PipelineMappingDO> findByPipelineIdAndDocumentTypeAndSystemDataIdAndPipelineDataId(PipelineMapping pipelineMapping); |
| 52 | 54 | ||
| 53 | 55 | ||
| 54 | /** | 56 | /** |
| @@ -70,6 +72,6 @@ public interface PipelineMappingRepository { | @@ -70,6 +72,6 @@ public interface PipelineMappingRepository { | ||
| 70 | * | 72 | * |
| 71 | * @param pipelineMapping 税务管道映射 | 73 | * @param pipelineMapping 税务管道映射 |
| 72 | */ | 74 | */ |
| 73 | - void update(com.diligrp.tax.storage.domain.PipelineMapping pipelineMapping); | 75 | + void update(PipelineMapping pipelineMapping); |
| 74 | 76 | ||
| 75 | } | 77 | } |
tax-storage/src/main/java/com/diligrp/tax/storage/service/PipelineMappingService.java
| 1 | package com.diligrp.tax.storage.service; | 1 | package com.diligrp.tax.storage.service; |
| 2 | 2 | ||
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 4 | import com.diligrp.tax.central.exception.TaxAgentServiceException; | 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; |
| 5 | import com.diligrp.tax.central.model.PipelineMappingCreateDO; | 6 | import com.diligrp.tax.central.model.PipelineMappingCreateDO; |
| @@ -10,8 +11,10 @@ import com.diligrp.tax.central.type.MappingStateType; | @@ -10,8 +11,10 @@ import com.diligrp.tax.central.type.MappingStateType; | ||
| 10 | import com.diligrp.tax.central.type.TaxSystemType; | 11 | import com.diligrp.tax.central.type.TaxSystemType; |
| 11 | import com.diligrp.tax.central.utils.JsonUtils; | 12 | import com.diligrp.tax.central.utils.JsonUtils; |
| 12 | import com.diligrp.tax.storage.domain.PipelineMapping; | 13 | import com.diligrp.tax.storage.domain.PipelineMapping; |
| 14 | +import com.diligrp.tax.storage.domain.Tenant; | ||
| 13 | import com.diligrp.tax.storage.model.co.PipelineMappingCO; | 15 | import com.diligrp.tax.storage.model.co.PipelineMappingCO; |
| 14 | import com.diligrp.tax.storage.repo.PipelineMappingRepository; | 16 | import com.diligrp.tax.storage.repo.PipelineMappingRepository; |
| 17 | +import com.diligrp.tax.storage.repo.TenantRepository; | ||
| 15 | import jakarta.annotation.Resource; | 18 | import jakarta.annotation.Resource; |
| 16 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
| 17 | import org.springframework.transaction.annotation.Transactional; | 20 | import org.springframework.transaction.annotation.Transactional; |
| @@ -31,6 +34,9 @@ public class PipelineMappingService implements IPipelineMappingService { | @@ -31,6 +34,9 @@ public class PipelineMappingService implements IPipelineMappingService { | ||
| 31 | @Resource | 34 | @Resource |
| 32 | private PipelineMappingRepository pipelineMappingRepository; | 35 | private PipelineMappingRepository pipelineMappingRepository; |
| 33 | 36 | ||
| 37 | + @Resource | ||
| 38 | + private TenantRepository tenantRepository; | ||
| 39 | + | ||
| 34 | private static final String DEFAULT_PIPELINE_MAPPING_TABLE_NAME = "pipeline_mapping_"; | 40 | private static final String DEFAULT_PIPELINE_MAPPING_TABLE_NAME = "pipeline_mapping_"; |
| 35 | 41 | ||
| 36 | /** | 42 | /** |
| @@ -52,11 +58,16 @@ public class PipelineMappingService implements IPipelineMappingService { | @@ -52,11 +58,16 @@ public class PipelineMappingService implements IPipelineMappingService { | ||
| 52 | * @return {@link List }<{@link PipelineMappingDO }> | 58 | * @return {@link List }<{@link PipelineMappingDO }> |
| 53 | */ | 59 | */ |
| 54 | public Page<PipelineMappingDO> findTenantPipelineData(PipelineMappingCO pipelineMappingCO) { | 60 | public Page<PipelineMappingDO> findTenantPipelineData(PipelineMappingCO pipelineMappingCO) { |
| 55 | - Optional.ofNullable(pipelineMappingCO.getTenantId()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "租户ID不能为空")); | 61 | + LambdaQueryWrapper<Tenant> queryWrapper = new LambdaQueryWrapper<>(); |
| 62 | + queryWrapper.eq(Tenant::getGroup, pipelineMappingCO.getGroup()); | ||
| 63 | + queryWrapper.eq(Tenant::getEntity, pipelineMappingCO.getEntity()); | ||
| 64 | + Tenant tenant = Optional.ofNullable(tenantRepository.selectOne(queryWrapper)).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.NO_TENANT_INFORMATION_FOUND)); | ||
| 56 | Optional.ofNullable(pipelineMappingCO.getPipelineId()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "管道ID不能为空")); | 65 | Optional.ofNullable(pipelineMappingCO.getPipelineId()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "管道ID不能为空")); |
| 66 | + pipelineMappingCO.setTenantId(tenant.getId()); | ||
| 67 | + pipelineMappingCO.setState(MappingStateType.SYNCED.value); | ||
| 57 | Page<PipelineMappingDO> page = new Page<>(pipelineMappingCO.getPageNumber(), pipelineMappingCO.getPageSize()); | 68 | Page<PipelineMappingDO> page = new Page<>(pipelineMappingCO.getPageNumber(), pipelineMappingCO.getPageSize()); |
| 58 | PipelineMapping pipelineMapping = JsonUtils.convertValue(pipelineMappingCO, PipelineMapping.class); | 69 | PipelineMapping pipelineMapping = JsonUtils.convertValue(pipelineMappingCO, PipelineMapping.class); |
| 59 | - return pipelineMappingRepository.findByPipelineIdAndState(pipelineMapping, page); | 70 | + return pipelineMappingRepository.findByPipelineIdAndState(pipelineMapping,page); |
| 60 | } | 71 | } |
| 61 | 72 | ||
| 62 | /** | 73 | /** |
tax-storage/src/main/java/com/diligrp/tax/storage/service/PipelineService.java
| @@ -50,7 +50,7 @@ public class PipelineService { | @@ -50,7 +50,7 @@ public class PipelineService { | ||
| 50 | throw new TaxAgentServiceException(TaxSystemType.ABNORMAL_PARAMETERS,"当前账套编码已存在"); | 50 | throw new TaxAgentServiceException(TaxSystemType.ABNORMAL_PARAMETERS,"当前账套编码已存在"); |
| 51 | }); | 51 | }); |
| 52 | pipelineCO.setTenantId(tenant.getId()); | 52 | pipelineCO.setTenantId(tenant.getId()); |
| 53 | - SystemType.validateSystemCode(pipelineCO.getSystemCode()); | 53 | + SystemType.validateSystemType(pipelineCO.getSystemType()); |
| 54 | Pipeline pipeline = JsonUtils.convertValue(pipelineCO, Pipeline.class); | 54 | Pipeline pipeline = JsonUtils.convertValue(pipelineCO, Pipeline.class); |
| 55 | pipeline.setState(StateType.ENABLE.value); | 55 | pipeline.setState(StateType.ENABLE.value); |
| 56 | pipelineRepository.insert(pipeline); | 56 | pipelineRepository.insert(pipeline); |
| @@ -64,7 +64,7 @@ public class PipelineService { | @@ -64,7 +64,7 @@ public class PipelineService { | ||
| 64 | */ | 64 | */ |
| 65 | @Transactional | 65 | @Transactional |
| 66 | public void update(PipelineCO pipelineCO) { | 66 | public void update(PipelineCO pipelineCO) { |
| 67 | - SystemType.validateSystemCode(pipelineCO.getSystemCode()); | 67 | + Optional.ofNullable(pipelineCO.getSystemType()).ifPresent(SystemType::validateSystemType); |
| 68 | Pipeline pipeline = JsonUtils.convertValue(pipelineCO, Pipeline.class); | 68 | Pipeline pipeline = JsonUtils.convertValue(pipelineCO, Pipeline.class); |
| 69 | pipelineRepository.updateById(pipeline); | 69 | pipelineRepository.updateById(pipeline); |
| 70 | } | 70 | } |
tax-storage/src/main/java/com/diligrp/tax/storage/service/TenantService.java
| @@ -66,12 +66,12 @@ public class TenantService implements ITenantService { | @@ -66,12 +66,12 @@ public class TenantService implements ITenantService { | ||
| 66 | */ | 66 | */ |
| 67 | @Override | 67 | @Override |
| 68 | public List<PipelineDO> listAllEnablePipeline() { | 68 | public List<PipelineDO> listAllEnablePipeline() { |
| 69 | - LambdaQueryWrapper<com.diligrp.tax.storage.domain.Pipeline> queryWrapper = new LambdaQueryWrapper<>(); | ||
| 70 | - queryWrapper.eq(com.diligrp.tax.storage.domain.Pipeline::getState, StateType.ENABLE.value); | ||
| 71 | - List<com.diligrp.tax.storage.domain.Pipeline> pipelines = pipelineRepository.selectList(queryWrapper); | ||
| 72 | - return pipelines.stream().map(taxPipeline -> { | ||
| 73 | - PipelineDO pipelineDO = JsonUtils.convertValue(taxPipeline, PipelineDO.class); | ||
| 74 | - pipelineDO.setSystemType(SystemType.from(taxPipeline.getSystemCode())); | 69 | + LambdaQueryWrapper<Pipeline> queryWrapper = new LambdaQueryWrapper<>(); |
| 70 | + queryWrapper.eq(Pipeline::getState, StateType.ENABLE.value); | ||
| 71 | + List<Pipeline> pipelines = pipelineRepository.selectList(queryWrapper); | ||
| 72 | + return pipelines.stream().map(pipeline -> { | ||
| 73 | + PipelineDO pipelineDO = JsonUtils.convertValue(pipeline, PipelineDO.class); | ||
| 74 | + pipelineDO.setSystemTypeEnum(SystemType.from(pipeline.getSystemType())); | ||
| 75 | return pipelineDO; | 75 | return pipelineDO; |
| 76 | }).toList(); | 76 | }).toList(); |
| 77 | } | 77 | } |
| @@ -89,7 +89,7 @@ public class TenantService implements ITenantService { | @@ -89,7 +89,7 @@ public class TenantService implements ITenantService { | ||
| 89 | queryWrapper.eq(Pipeline::getTenantId, tenantId); | 89 | queryWrapper.eq(Pipeline::getTenantId, tenantId); |
| 90 | return Optional.ofNullable(pipelineRepository.selectOne(queryWrapper)).map(taxPipeline -> { | 90 | return Optional.ofNullable(pipelineRepository.selectOne(queryWrapper)).map(taxPipeline -> { |
| 91 | PipelineDO pipelineDO = JsonUtils.convertValue(taxPipeline, PipelineDO.class); | 91 | PipelineDO pipelineDO = JsonUtils.convertValue(taxPipeline, PipelineDO.class); |
| 92 | - pipelineDO.setSystemType(SystemType.from(taxPipeline.getSystemCode())); | 92 | + pipelineDO.setSystemTypeEnum(SystemType.from(taxPipeline.getSystemType())); |
| 93 | return pipelineDO; | 93 | return pipelineDO; |
| 94 | }); | 94 | }); |
| 95 | } | 95 | } |
| @@ -117,7 +117,7 @@ public class TenantService implements ITenantService { | @@ -117,7 +117,7 @@ public class TenantService implements ITenantService { | ||
| 117 | LambdaQueryWrapper<Tenant> queryWrapper = new LambdaQueryWrapper<>(); | 117 | LambdaQueryWrapper<Tenant> queryWrapper = new LambdaQueryWrapper<>(); |
| 118 | queryWrapper.eq(Tenant::getGroup, group); | 118 | queryWrapper.eq(Tenant::getGroup, group); |
| 119 | queryWrapper.eq(Tenant::getEntity, entity); | 119 | queryWrapper.eq(Tenant::getEntity, entity); |
| 120 | - Tenant tenant = Optional.ofNullable(tenantRepository.selectOne(queryWrapper)).orElseThrow(() -> new TaxAgentServiceException("未找到租户信息")); | 120 | + Tenant tenant = Optional.ofNullable(tenantRepository.selectOne(queryWrapper)).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.INCORRECT_BUSINESS_PROCESSES,"未找到租户信息")); |
| 121 | return JsonUtils.convertValue(tenant, TenantVO.class); | 121 | return JsonUtils.convertValue(tenant, TenantVO.class); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| @@ -141,6 +141,8 @@ public class TenantService implements ITenantService { | @@ -141,6 +141,8 @@ public class TenantService implements ITenantService { | ||
| 141 | */ | 141 | */ |
| 142 | @Transactional | 142 | @Transactional |
| 143 | public void updateTenant(TenantCO tenantCO) { | 143 | public void updateTenant(TenantCO tenantCO) { |
| 144 | + TenantVO tenant1 = getTenant(tenantCO.getGroup(), tenantCO.getEntity()); | ||
| 145 | + tenantCO.setId(tenant1.getId()); | ||
| 144 | Tenant tenant = JsonUtils.convertValue(tenantCO, Tenant.class); | 146 | Tenant tenant = JsonUtils.convertValue(tenantCO, Tenant.class); |
| 145 | tenantRepository.updateById(tenant); | 147 | tenantRepository.updateById(tenant); |
| 146 | } | 148 | } |
tax-storage/src/main/resources/com/diligrp/tax/storage/repo/PipelineMappingRepository.xml
| @@ -23,9 +23,9 @@ | @@ -23,9 +23,9 @@ | ||
| 23 | UPDATE | 23 | UPDATE |
| 24 | pipeline_mapping_${tenantId} | 24 | pipeline_mapping_${tenantId} |
| 25 | SET | 25 | SET |
| 26 | - state = #{state} | 26 | + state = #{mapping.state} |
| 27 | WHERE | 27 | WHERE |
| 28 | - id = #{id} | 28 | + id = #{mapping.id} |
| 29 | </update> | 29 | </update> |
| 30 | <select id="findByPipelineIdAndState" resultType="com.diligrp.tax.central.model.PipelineMappingDO"> | 30 | <select id="findByPipelineIdAndState" resultType="com.diligrp.tax.central.model.PipelineMappingDO"> |
| 31 | SELECT | 31 | SELECT |
| @@ -39,13 +39,11 @@ | @@ -39,13 +39,11 @@ | ||
| 39 | , created_Time | 39 | , created_Time |
| 40 | , modified_Time | 40 | , modified_Time |
| 41 | FROM | 41 | FROM |
| 42 | - pipeline_mapping_${tenantId} | 42 | + pipeline_mapping_${mapping.tenantId} |
| 43 | WHERE | 43 | WHERE |
| 44 | 1=1 | 44 | 1=1 |
| 45 | - AND pipeline_id = #{pipelineId} | ||
| 46 | - <if test="state != null"> | ||
| 47 | - AND state = #{state} | ||
| 48 | - </if> | 45 | + AND pipeline_id = #{mapping.pipelineId} |
| 46 | + AND state = #{mapping.state} | ||
| 49 | </select> | 47 | </select> |
| 50 | <select id="findByPipelineIdAndDocumentTypeAndSystemDataId" | 48 | <select id="findByPipelineIdAndDocumentTypeAndSystemDataId" |
| 51 | resultType="com.diligrp.tax.central.model.PipelineMappingDO"> | 49 | resultType="com.diligrp.tax.central.model.PipelineMappingDO"> |