Commit 27c00a4bd9a1c6f98cd756c51fbb1876b5d115f4
1 parent
9975a942
feat(tax-doc): 支持系统数据ID传递并优化税务映射逻辑
- 修改 Builder 接口及其实现类,增加 systemDataId 参数支持 - 引入 ITaxPipelineMappingService服务用于查询现有映射关系- 在 CustomerBuilder 中根据 systemDataId 查询并设置客户ID - 扩展 TaxPipelineMappingCreate 模型以支持更新操作 - 实现 DynamicTaxPipelineMappingService 的 update 方法 - 调整 TaxPipelineMappingRepository 及其 XML 配置以区分更新状态与完整更新 -重构 TaxReceiver 和 TaxReceiveService以适配新的处理流程 - 在 recordMapping 方法中实现插入或更新税务映射记录的逻辑
Showing
13 changed files
with
91 additions
and
34 deletions
tax-boot/src/main/java/com/diligrp/tax/boot/receiver/TaxReceiver.java
| @@ -2,6 +2,8 @@ package com.diligrp.tax.boot.receiver; | @@ -2,6 +2,8 @@ package com.diligrp.tax.boot.receiver; | ||
| 2 | 2 | ||
| 3 | import com.diligrp.tax.boot.service.TaxReceiveService; | 3 | import com.diligrp.tax.boot.service.TaxReceiveService; |
| 4 | import com.diligrp.tax.central.domain.MessageContext; | 4 | import com.diligrp.tax.central.domain.MessageContext; |
| 5 | +import com.diligrp.tax.central.process.ProcessorChain; | ||
| 6 | +import com.diligrp.tax.central.type.SystemType; | ||
| 5 | import com.rabbitmq.client.Channel; | 7 | import com.rabbitmq.client.Channel; |
| 6 | import jakarta.annotation.Resource; | 8 | import jakarta.annotation.Resource; |
| 7 | import lombok.extern.slf4j.Slf4j; | 9 | import lombok.extern.slf4j.Slf4j; |
| @@ -15,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -15,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 15 | 17 | ||
| 16 | import java.io.IOException; | 18 | import java.io.IOException; |
| 17 | import java.nio.charset.StandardCharsets; | 19 | import java.nio.charset.StandardCharsets; |
| 20 | +import java.util.Map; | ||
| 18 | import java.util.Optional; | 21 | import java.util.Optional; |
| 19 | 22 | ||
| 20 | import static com.diligrp.tax.boot.queue.TaxAutoPush.*; | 23 | import static com.diligrp.tax.boot.queue.TaxAutoPush.*; |
| @@ -32,6 +35,9 @@ public class TaxReceiver { | @@ -32,6 +35,9 @@ public class TaxReceiver { | ||
| 32 | @Resource | 35 | @Resource |
| 33 | private TaxReceiveService taxReceiveService; | 36 | private TaxReceiveService taxReceiveService; |
| 34 | 37 | ||
| 38 | + @Resource | ||
| 39 | + private Map<SystemType, ProcessorChain> processorChainMap; | ||
| 40 | + | ||
| 35 | @RabbitListener(bindings = | 41 | @RabbitListener(bindings = |
| 36 | @QueueBinding( | 42 | @QueueBinding( |
| 37 | value = @Queue(value = NORMAL_QUEUE, autoDelete = "false"), | 43 | value = @Queue(value = NORMAL_QUEUE, autoDelete = "false"), |
| @@ -45,8 +51,9 @@ public class TaxReceiver { | @@ -45,8 +51,9 @@ public class TaxReceiver { | ||
| 45 | log.info("tax-agent收到消息:{}", content); | 51 | log.info("tax-agent收到消息:{}", content); |
| 46 | MessageContext ctx = null; | 52 | MessageContext ctx = null; |
| 47 | try { | 53 | try { |
| 48 | - ctx = taxReceiveService.messageHandle(content); | ||
| 49 | - taxReceiveService.recordMapping(ctx); | 54 | + ctx = taxReceiveService.messagePreHandle(content); |
| 55 | + var trans = processorChainMap.get(SystemType.from(ctx.getSystemType())).startProcess(ctx); | ||
| 56 | + taxReceiveService.recordMapping(trans); | ||
| 50 | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); | 57 | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| 51 | log.info("tax-agent消息处理成功:{}", content); | 58 | log.info("tax-agent消息处理成功:{}", content); |
| 52 | } catch (Exception e) { | 59 | } catch (Exception e) { |
tax-boot/src/main/java/com/diligrp/tax/boot/service/TaxReceiveService.java
| @@ -5,7 +5,7 @@ import com.diligrp.tax.central.domain.MessageContext; | @@ -5,7 +5,7 @@ import com.diligrp.tax.central.domain.MessageContext; | ||
| 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; | 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; |
| 6 | import com.diligrp.tax.central.model.TaxPipelineMappingCreate; | 6 | import com.diligrp.tax.central.model.TaxPipelineMappingCreate; |
| 7 | import com.diligrp.tax.central.model.TenantPipeline; | 7 | import com.diligrp.tax.central.model.TenantPipeline; |
| 8 | -import com.diligrp.tax.central.process.ProcessorChain; | 8 | +import com.diligrp.tax.central.model.TenantTaxPipelineMapping; |
| 9 | import com.diligrp.tax.central.service.ITaxPipelineMappingService; | 9 | import com.diligrp.tax.central.service.ITaxPipelineMappingService; |
| 10 | import com.diligrp.tax.central.service.ITenantTaxService; | 10 | import com.diligrp.tax.central.service.ITenantTaxService; |
| 11 | import com.diligrp.tax.central.type.DocumentType; | 11 | import com.diligrp.tax.central.type.DocumentType; |
| @@ -19,7 +19,6 @@ import org.springframework.transaction.annotation.Transactional; | @@ -19,7 +19,6 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 19 | 19 | ||
| 20 | import java.io.PrintWriter; | 20 | import java.io.PrintWriter; |
| 21 | import java.io.StringWriter; | 21 | import java.io.StringWriter; |
| 22 | -import java.util.Map; | ||
| 23 | import java.util.Optional; | 22 | import java.util.Optional; |
| 24 | 23 | ||
| 25 | /** | 24 | /** |
| @@ -31,17 +30,16 @@ import java.util.Optional; | @@ -31,17 +30,16 @@ import java.util.Optional; | ||
| 31 | public class TaxReceiveService { | 30 | public class TaxReceiveService { |
| 32 | 31 | ||
| 33 | @Resource | 32 | @Resource |
| 34 | - private Map<SystemType, ProcessorChain> processorChainMap; | ||
| 35 | - | ||
| 36 | - @Resource | ||
| 37 | private ITenantTaxService tenantTaxService; | 33 | private ITenantTaxService tenantTaxService; |
| 38 | 34 | ||
| 39 | @Resource | 35 | @Resource |
| 40 | private ITaxPipelineMappingService taxPipelineMappingService; | 36 | private ITaxPipelineMappingService taxPipelineMappingService; |
| 41 | 37 | ||
| 42 | 38 | ||
| 43 | - public MessageContext messageHandle(String content) { | 39 | + public MessageContext messagePreHandle(String content) { |
| 44 | MessageContext ctx = JsonUtils.fromJsonString(content, MessageContext.class); | 40 | MessageContext ctx = JsonUtils.fromJsonString(content, MessageContext.class); |
| 41 | + Long tenantId = tenantTaxService.getTenantId(ctx.getGroup(), ctx.getEntity()); | ||
| 42 | + ctx.setTenantId(tenantId); | ||
| 45 | DocumentType from = DocumentType.from(ctx.getDocumentType()); | 43 | DocumentType from = DocumentType.from(ctx.getDocumentType()); |
| 46 | SystemType system = SystemType.from(ctx.getSystemType()); | 44 | SystemType system = SystemType.from(ctx.getSystemType()); |
| 47 | Optional.of(system).filter(s -> s.documentTypes.contains(from)).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT)); | 45 | Optional.of(system).filter(s -> s.documentTypes.contains(from)).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.BUSINESS_MATCHES_ARE_INCORRECT)); |
| @@ -54,19 +52,31 @@ public class TaxReceiveService { | @@ -54,19 +52,31 @@ public class TaxReceiveService { | ||
| 54 | ctx.setTenantPipeline(pipeline); | 52 | ctx.setTenantPipeline(pipeline); |
| 55 | //获取租户id | 53 | //获取租户id |
| 56 | ctx.setTenantId(tenantTaxService.getTenantId(ctx.getGroup(), ctx.getEntity())); | 54 | ctx.setTenantId(tenantTaxService.getTenantId(ctx.getGroup(), ctx.getEntity())); |
| 57 | - return processorChainMap.get(SystemType.from(ctx.getSystemType())).startProcess(ctx); | 55 | + return ctx; |
| 58 | } | 56 | } |
| 59 | 57 | ||
| 60 | @Transactional | 58 | @Transactional |
| 61 | public void recordMapping(MessageContext messageContext) { | 59 | public void recordMapping(MessageContext messageContext) { |
| 62 | - TaxPipelineMappingCreate create = new TaxPipelineMappingCreate(); | ||
| 63 | - create.setTenantId(messageContext.getTenantId()); | ||
| 64 | - create.setPipelineId(messageContext.getTenantPipeline().getId()); | ||
| 65 | - create.setDocumentType(messageContext.getDocumentType()); | ||
| 66 | - create.setSystemDataId(messageContext.getSystemDataId()); | ||
| 67 | - create.setState(MappingStateType.SYNCED.value); | ||
| 68 | - create.setOriginData(messageContext.getMsgBody()); | ||
| 69 | - taxPipelineMappingService.insert(create); | 60 | + Optional<TenantTaxPipelineMapping> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataId(messageContext.getTenantPipeline().getTenantId(), messageContext.getTenantPipeline().getId(), messageContext.getDocumentType(), messageContext.getSystemDataId()); |
| 61 | + dbOptions.ifPresentOrElse( | ||
| 62 | + e -> { | ||
| 63 | + TaxPipelineMappingCreate create = new TaxPipelineMappingCreate(); | ||
| 64 | + create.setId(e.getId()); | ||
| 65 | + create.setTenantId(messageContext.getTenantId()); | ||
| 66 | + create.setOriginData(messageContext.getMsgBody()); | ||
| 67 | + taxPipelineMappingService.update(create); | ||
| 68 | + }, () -> { | ||
| 69 | + TaxPipelineMappingCreate create = new TaxPipelineMappingCreate(); | ||
| 70 | + create.setTenantId(messageContext.getTenantId()); | ||
| 71 | + create.setPipelineId(messageContext.getTenantPipeline().getId()); | ||
| 72 | + create.setDocumentType(messageContext.getDocumentType()); | ||
| 73 | + create.setSystemDataId(messageContext.getSystemDataId()); | ||
| 74 | + create.setPipelineDataId(messageContext.getPipelineDataId()); | ||
| 75 | + create.setState(MappingStateType.SYNCED.value); | ||
| 76 | + create.setOriginData(messageContext.getMsgBody()); | ||
| 77 | + taxPipelineMappingService.insert(create); | ||
| 78 | + }); | ||
| 79 | + | ||
| 70 | } | 80 | } |
| 71 | 81 | ||
| 72 | @Transactional | 82 | @Transactional |
tax-central/src/main/java/com/diligrp/tax/central/model/TaxPipelineMappingCreate.java
| @@ -16,6 +16,10 @@ import lombok.Setter; | @@ -16,6 +16,10 @@ import lombok.Setter; | ||
| 16 | @Valid | 16 | @Valid |
| 17 | public class TaxPipelineMappingCreate { | 17 | public class TaxPipelineMappingCreate { |
| 18 | /** | 18 | /** |
| 19 | + * id | ||
| 20 | + */ | ||
| 21 | + private Long id; | ||
| 22 | + /** | ||
| 19 | * 租户 ID | 23 | * 租户 ID |
| 20 | */ | 24 | */ |
| 21 | @NotNull(message = "租户ID不能为空") | 25 | @NotNull(message = "租户ID不能为空") |
tax-central/src/main/java/com/diligrp/tax/central/service/ITaxPipelineMappingService.java
| @@ -3,6 +3,7 @@ package com.diligrp.tax.central.service; | @@ -3,6 +3,7 @@ package com.diligrp.tax.central.service; | ||
| 3 | import com.diligrp.tax.central.domain.MessageContext; | 3 | import com.diligrp.tax.central.domain.MessageContext; |
| 4 | import com.diligrp.tax.central.model.TaxPipelineMappingCreate; | 4 | import com.diligrp.tax.central.model.TaxPipelineMappingCreate; |
| 5 | import com.diligrp.tax.central.model.TenantTaxPipelineMapping; | 5 | import com.diligrp.tax.central.model.TenantTaxPipelineMapping; |
| 6 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | 7 | ||
| 7 | import java.util.Optional; | 8 | import java.util.Optional; |
| 8 | 9 | ||
| @@ -25,4 +26,11 @@ public interface ITaxPipelineMappingService { | @@ -25,4 +26,11 @@ public interface ITaxPipelineMappingService { | ||
| 25 | * @param taxPipelineMappingCreate | 26 | * @param taxPipelineMappingCreate |
| 26 | */ | 27 | */ |
| 27 | void insert(TaxPipelineMappingCreate taxPipelineMappingCreate); | 28 | void insert(TaxPipelineMappingCreate taxPipelineMappingCreate); |
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 更新 | ||
| 32 | + * | ||
| 33 | + * @param taxPipelineMappingCreate 税务管道映射创建 | ||
| 34 | + */ | ||
| 35 | + void update(TaxPipelineMappingCreate taxPipelineMappingCreate); | ||
| 28 | } | 36 | } |
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/Builder.java
| @@ -21,9 +21,10 @@ public abstract class Builder<T extends BaseDocument> { | @@ -21,9 +21,10 @@ public abstract class Builder<T extends BaseDocument> { | ||
| 21 | /** | 21 | /** |
| 22 | * 建 | 22 | * 建 |
| 23 | * | 23 | * |
| 24 | - * @param body 身体 | 24 | + * @param body 身体 |
| 25 | * @param pipeline | 25 | * @param pipeline |
| 26 | + * @param systemDataId | ||
| 26 | * @return {@link T } | 27 | * @return {@link T } |
| 27 | */ | 28 | */ |
| 28 | - public abstract T build(String body, TenantPipeline pipeline); | 29 | + public abstract T build(String body, TenantPipeline pipeline, String systemDataId); |
| 29 | } | 30 | } |
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/CustomerBuilder.java
| @@ -5,10 +5,13 @@ import com.diligrp.tax.central.domain.document.kingdee.basic.item.Contact; | @@ -5,10 +5,13 @@ import com.diligrp.tax.central.domain.document.kingdee.basic.item.Contact; | ||
| 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; | 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; |
| 6 | import com.diligrp.tax.central.model.TenantPipeline; | 6 | import com.diligrp.tax.central.model.TenantPipeline; |
| 7 | import com.diligrp.tax.central.model.TenantPipelineConfig; | 7 | import com.diligrp.tax.central.model.TenantPipelineConfig; |
| 8 | +import com.diligrp.tax.central.model.TenantTaxPipelineMapping; | ||
| 9 | +import com.diligrp.tax.central.service.ITaxPipelineMappingService; | ||
| 8 | import com.diligrp.tax.central.type.DocumentType; | 10 | import com.diligrp.tax.central.type.DocumentType; |
| 9 | import com.diligrp.tax.central.type.TaxSystemType; | 11 | import com.diligrp.tax.central.type.TaxSystemType; |
| 10 | import com.diligrp.tax.central.utils.JsonUtils; | 12 | import com.diligrp.tax.central.utils.JsonUtils; |
| 11 | import com.diligrp.tax.doc.demarcate.Builder; | 13 | import com.diligrp.tax.doc.demarcate.Builder; |
| 14 | +import jakarta.annotation.Resource; | ||
| 12 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 13 | import org.springframework.stereotype.Component; | 16 | import org.springframework.stereotype.Component; |
| 14 | 17 | ||
| @@ -29,19 +32,25 @@ import java.util.stream.Stream; | @@ -29,19 +32,25 @@ import java.util.stream.Stream; | ||
| 29 | @Slf4j | 32 | @Slf4j |
| 30 | public class CustomerBuilder extends Builder<StandardCustomer> { | 33 | public class CustomerBuilder extends Builder<StandardCustomer> { |
| 31 | 34 | ||
| 35 | + @Resource | ||
| 36 | + private ITaxPipelineMappingService taxPipelineMappingService; | ||
| 37 | + | ||
| 38 | + | ||
| 32 | @Override | 39 | @Override |
| 33 | public DocumentType markDocument() { | 40 | public DocumentType markDocument() { |
| 34 | return DocumentType.CUSTOMER_INFO; | 41 | return DocumentType.CUSTOMER_INFO; |
| 35 | } | 42 | } |
| 36 | 43 | ||
| 37 | @Override | 44 | @Override |
| 38 | - public StandardCustomer build(String body, TenantPipeline pipeline) { | 45 | + public StandardCustomer build(String body, TenantPipeline pipeline, String systemDataId) { |
| 39 | StandardCustomer customer = JsonUtils.fromJsonString(body, StandardCustomer.class); | 46 | StandardCustomer customer = JsonUtils.fromJsonString(body, StandardCustomer.class); |
| 40 | Optional.ofNullable(customer.getContacts()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请完善联系人信息")); | 47 | Optional.ofNullable(customer.getContacts()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请完善联系人信息")); |
| 41 | - Optional.ofNullable(customer.getSystemDataId()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写系统数据ID")); | 48 | + Optional.ofNullable(systemDataId).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写系统数据ID")); |
| 42 | List<TenantPipelineConfig> list = pipeline.getTenantPipelineConfigs().get(markDocument()); | 49 | List<TenantPipelineConfig> list = pipeline.getTenantPipelineConfigs().get(markDocument()); |
| 43 | Optional.ofNullable(list).ifPresent(ts -> configureDefaultData(customer, ts)); | 50 | Optional.ofNullable(list).ifPresent(ts -> configureDefaultData(customer, ts)); |
| 44 | - //TODO 查询数据库的客户信息 如果存在 赋值id | 51 | + //查询数据库的客户信息 如果存在 赋值id |
| 52 | + Optional<TenantTaxPipelineMapping> dbOptions = taxPipelineMappingService.findByPipelineIdAndDocumentTypeAndSystemDataId(pipeline.getTenantId(), pipeline.getId(), markDocument().value, systemDataId); | ||
| 53 | + dbOptions.ifPresent(e -> customer.setCustomerId(e.getPipelineDataId())); | ||
| 45 | return customer; | 54 | return customer; |
| 46 | } | 55 | } |
| 47 | 56 |
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/ReceiptBuilder.java
| @@ -33,7 +33,7 @@ public class ReceiptBuilder extends Builder<ReceiptBill> { | @@ -33,7 +33,7 @@ public class ReceiptBuilder extends Builder<ReceiptBill> { | ||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | @Override | 35 | @Override |
| 36 | - public ReceiptBill build(String body, TenantPipeline pipeline) { | 36 | + public ReceiptBill build(String body, TenantPipeline pipeline, String systemDataId) { |
| 37 | ReceiptBill bill = JsonUtils.fromJsonString(body, ReceiptBill.class); | 37 | ReceiptBill bill = JsonUtils.fromJsonString(body, ReceiptBill.class); |
| 38 | Optional.ofNullable(bill.getReceiptItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目")); | 38 | Optional.ofNullable(bill.getReceiptItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目")); |
| 39 | bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); | 39 | bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); |
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/ReceivableBuilder.java
| 1 | package com.diligrp.tax.doc.demarcate.kingdee; | 1 | package com.diligrp.tax.doc.demarcate.kingdee; |
| 2 | 2 | ||
| 3 | -import com.diligrp.tax.central.domain.document.kingdee.bill.ReceiptBill; | ||
| 4 | import com.diligrp.tax.central.domain.document.kingdee.bill.ReceivableBill; | 3 | import com.diligrp.tax.central.domain.document.kingdee.bill.ReceivableBill; |
| 5 | -import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceiptItem; | ||
| 6 | import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceivableItem; | 4 | import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceivableItem; |
| 7 | import com.diligrp.tax.central.exception.TaxAgentServiceException; | 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; |
| 8 | import com.diligrp.tax.central.model.TenantPipeline; | 6 | import com.diligrp.tax.central.model.TenantPipeline; |
| @@ -10,7 +8,6 @@ import com.diligrp.tax.central.model.TenantPipelineConfig; | @@ -10,7 +8,6 @@ import com.diligrp.tax.central.model.TenantPipelineConfig; | ||
| 10 | import com.diligrp.tax.central.type.DocumentType; | 8 | import com.diligrp.tax.central.type.DocumentType; |
| 11 | import com.diligrp.tax.central.type.TaxSystemType; | 9 | import com.diligrp.tax.central.type.TaxSystemType; |
| 12 | import com.diligrp.tax.central.utils.JsonUtils; | 10 | import com.diligrp.tax.central.utils.JsonUtils; |
| 13 | -import com.diligrp.tax.central.utils.MappingUtils; | ||
| 14 | import com.diligrp.tax.doc.demarcate.Builder; | 11 | import com.diligrp.tax.doc.demarcate.Builder; |
| 15 | import org.springframework.stereotype.Component; | 12 | import org.springframework.stereotype.Component; |
| 16 | 13 | ||
| @@ -37,7 +34,7 @@ public class ReceivableBuilder extends Builder<ReceivableBill> { | @@ -37,7 +34,7 @@ public class ReceivableBuilder extends Builder<ReceivableBill> { | ||
| 37 | } | 34 | } |
| 38 | 35 | ||
| 39 | @Override | 36 | @Override |
| 40 | - public ReceivableBill build(String body, TenantPipeline pipeline) { | 37 | + public ReceivableBill build(String body, TenantPipeline pipeline, String systemDataId) { |
| 41 | ReceivableBill bill = JsonUtils.fromJsonString(body, ReceivableBill.class); | 38 | ReceivableBill bill = JsonUtils.fromJsonString(body, ReceivableBill.class); |
| 42 | Optional.ofNullable(bill.getReceivableItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目")); | 39 | Optional.ofNullable(bill.getReceivableItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目")); |
| 43 | bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); | 40 | bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); |
tax-doc/src/main/java/com/diligrp/tax/doc/demarcate/kingdee/RefundBuilder.java
| 1 | package com.diligrp.tax.doc.demarcate.kingdee; | 1 | package com.diligrp.tax.doc.demarcate.kingdee; |
| 2 | 2 | ||
| 3 | -import com.diligrp.tax.central.domain.document.kingdee.bill.ReceivableBill; | ||
| 4 | import com.diligrp.tax.central.domain.document.kingdee.bill.RefundBill; | 3 | import com.diligrp.tax.central.domain.document.kingdee.bill.RefundBill; |
| 5 | -import com.diligrp.tax.central.domain.document.kingdee.bill.item.ReceivableItem; | ||
| 6 | import com.diligrp.tax.central.domain.document.kingdee.bill.item.RefundItem; | 4 | import com.diligrp.tax.central.domain.document.kingdee.bill.item.RefundItem; |
| 7 | import com.diligrp.tax.central.exception.TaxAgentServiceException; | 5 | import com.diligrp.tax.central.exception.TaxAgentServiceException; |
| 8 | import com.diligrp.tax.central.model.TenantPipeline; | 6 | import com.diligrp.tax.central.model.TenantPipeline; |
| @@ -10,7 +8,6 @@ import com.diligrp.tax.central.model.TenantPipelineConfig; | @@ -10,7 +8,6 @@ import com.diligrp.tax.central.model.TenantPipelineConfig; | ||
| 10 | import com.diligrp.tax.central.type.DocumentType; | 8 | import com.diligrp.tax.central.type.DocumentType; |
| 11 | import com.diligrp.tax.central.type.TaxSystemType; | 9 | import com.diligrp.tax.central.type.TaxSystemType; |
| 12 | import com.diligrp.tax.central.utils.JsonUtils; | 10 | import com.diligrp.tax.central.utils.JsonUtils; |
| 13 | -import com.diligrp.tax.central.utils.MappingUtils; | ||
| 14 | import com.diligrp.tax.doc.demarcate.Builder; | 11 | import com.diligrp.tax.doc.demarcate.Builder; |
| 15 | import org.springframework.stereotype.Component; | 12 | import org.springframework.stereotype.Component; |
| 16 | 13 | ||
| @@ -37,7 +34,7 @@ public class RefundBuilder extends Builder<RefundBill> { | @@ -37,7 +34,7 @@ public class RefundBuilder extends Builder<RefundBill> { | ||
| 37 | } | 34 | } |
| 38 | 35 | ||
| 39 | @Override | 36 | @Override |
| 40 | - public RefundBill build(String body, TenantPipeline pipeline) { | 37 | + public RefundBill build(String body, TenantPipeline pipeline, String systemDataId) { |
| 41 | RefundBill bill = JsonUtils.fromJsonString(body, RefundBill.class); | 38 | RefundBill bill = JsonUtils.fromJsonString(body, RefundBill.class); |
| 42 | Optional.ofNullable(bill.getRefundItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目")); | 39 | Optional.ofNullable(bill.getRefundItems()).orElseThrow(() -> new TaxAgentServiceException(TaxSystemType.MISSING_BUSINESS_INFORMATION, "请填写收款项目")); |
| 43 | bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); | 40 | bill.setCreateTime(Optional.ofNullable(bill.getCreateTime()).orElse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); |
tax-doc/src/main/java/com/diligrp/tax/doc/process/kingdee/InitializeProcessor.java
| 1 | package com.diligrp.tax.doc.process.kingdee; | 1 | package com.diligrp.tax.doc.process.kingdee; |
| 2 | 2 | ||
| 3 | +import com.diligrp.tax.central.domain.BaseDocument; | ||
| 3 | import com.diligrp.tax.central.domain.MessageContext; | 4 | import com.diligrp.tax.central.domain.MessageContext; |
| 4 | import com.diligrp.tax.central.process.AbstractProcessor; | 5 | import com.diligrp.tax.central.process.AbstractProcessor; |
| 5 | import com.diligrp.tax.doc.context.DocumentContext; | 6 | import com.diligrp.tax.doc.context.DocumentContext; |
| @@ -23,7 +24,8 @@ public class InitializeProcessor extends AbstractProcessor { | @@ -23,7 +24,8 @@ public class InitializeProcessor extends AbstractProcessor { | ||
| 23 | @Override | 24 | @Override |
| 24 | public MessageContext process(MessageContext messageContext) { | 25 | public MessageContext process(MessageContext messageContext) { |
| 25 | Builder<?> builder = DocumentContext.CONTEXT.get(messageContext.getDocumentTypeEnum()); | 26 | Builder<?> builder = DocumentContext.CONTEXT.get(messageContext.getDocumentTypeEnum()); |
| 26 | - messageContext.setDocumentObject(builder.build(messageContext.getMsgBody(), messageContext.getTenantPipeline())); | 27 | + BaseDocument build = builder.build(messageContext.getMsgBody(), messageContext.getTenantPipeline(), messageContext.getSystemDataId()); |
| 28 | + messageContext.setDocumentObject(build); | ||
| 27 | return messageContext; | 29 | return messageContext; |
| 28 | } | 30 | } |
| 29 | } | 31 | } |
tax-storage/src/main/java/com/diligrp/tax/storage/repo/TaxPipelineMappingRepository.java
| @@ -25,7 +25,7 @@ public interface TaxPipelineMappingRepository { | @@ -25,7 +25,7 @@ public interface TaxPipelineMappingRepository { | ||
| 25 | * | 25 | * |
| 26 | * @param mapping 税务管道映射 | 26 | * @param mapping 税务管道映射 |
| 27 | */ | 27 | */ |
| 28 | - void update(TaxPipelineMapping mapping); | 28 | + void updateStatus(TaxPipelineMapping mapping); |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | * 按管道 ID 查找 | 31 | * 按管道 ID 查找 |
| @@ -56,4 +56,11 @@ public interface TaxPipelineMappingRepository { | @@ -56,4 +56,11 @@ public interface TaxPipelineMappingRepository { | ||
| 56 | * @param tableName 表名 | 56 | * @param tableName 表名 |
| 57 | */ | 57 | */ |
| 58 | void dropTenantMappingTable(@Param("tableName") String tableName); | 58 | void dropTenantMappingTable(@Param("tableName") String tableName); |
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 更新 | ||
| 62 | + * | ||
| 63 | + * @param taxPipelineMapping 税务管道映射 | ||
| 64 | + */ | ||
| 65 | + void update(TaxPipelineMapping taxPipelineMapping); | ||
| 59 | } | 66 | } |
tax-storage/src/main/java/com/diligrp/tax/storage/service/DynamicTaxPipelineMappingService.java
| @@ -88,4 +88,10 @@ public class DynamicTaxPipelineMappingService implements ITaxPipelineMappingServ | @@ -88,4 +88,10 @@ public class DynamicTaxPipelineMappingService implements ITaxPipelineMappingServ | ||
| 88 | TaxPipelineMapping taxPipelineMapping = JsonUtils.convertValue(taxPipelineMappingCreate, TaxPipelineMapping.class); | 88 | TaxPipelineMapping taxPipelineMapping = JsonUtils.convertValue(taxPipelineMappingCreate, TaxPipelineMapping.class); |
| 89 | taxPipelineMappingRepository.insert(taxPipelineMapping); | 89 | taxPipelineMappingRepository.insert(taxPipelineMapping); |
| 90 | } | 90 | } |
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public void update(TaxPipelineMappingCreate taxPipelineMappingCreate) { | ||
| 94 | + TaxPipelineMapping taxPipelineMapping = JsonUtils.convertValue(taxPipelineMappingCreate, TaxPipelineMapping.class); | ||
| 95 | + taxPipelineMappingRepository.update(taxPipelineMapping); | ||
| 96 | + } | ||
| 91 | } | 97 | } |
tax-storage/src/main/resources/com/diligrp/tax/storage/repo/TaxPipelineMappingRepository.xml
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | , #{state} | 19 | , #{state} |
| 20 | , #{errorMessage}) | 20 | , #{errorMessage}) |
| 21 | </insert> | 21 | </insert> |
| 22 | - <update id="update"> | 22 | + <update id="updateStatus"> |
| 23 | UPDATE | 23 | UPDATE |
| 24 | tax_pipeline_mapping_${tenantId} | 24 | tax_pipeline_mapping_${tenantId} |
| 25 | SET | 25 | SET |
| @@ -96,5 +96,14 @@ | @@ -96,5 +96,14 @@ | ||
| 96 | <update id="dropTenantMappingTable"> | 96 | <update id="dropTenantMappingTable"> |
| 97 | DROP TABLE IF EXISTS ${tableName} | 97 | DROP TABLE IF EXISTS ${tableName} |
| 98 | </update> | 98 | </update> |
| 99 | + <update id="update"> | ||
| 100 | + UPDATE | ||
| 101 | + tax_pipeline_mapping_${tenantId} | ||
| 102 | + SET | ||
| 103 | + origin_data = #{originData} | ||
| 104 | + , error_message = #{errorMessage} | ||
| 105 | + WHERE | ||
| 106 | + id = #{id} | ||
| 107 | + </update> | ||
| 99 | 108 | ||
| 100 | </mapper> | 109 | </mapper> |