Commit 626c40ad94916e91d32446935c54966f0984b2de
1 parent
b80e0bc9
feat(adopt): 引入消息接收与转换模块
Showing
9 changed files
with
112 additions
and
4 deletions
tax-adopt/src/main/java/com/diligrp/tax/adopt/AdoptConfig.java
0 → 100644
| 1 | +package com.diligrp.tax.adopt; | |
| 2 | + | |
| 3 | +import org.springframework.context.annotation.ComponentScan; | |
| 4 | +import org.springframework.context.annotation.Configuration; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * @author lvqi | |
| 8 | + */ | |
| 9 | +@Configuration | |
| 10 | +@ComponentScan(basePackages = "com.diligrp.tax.adopt") | |
| 11 | +public class AdoptConfig { | |
| 12 | +} | ... | ... |
tax-adopt/src/main/java/com/diligrp/tax/adopt/api/AdoptMessageController.java
0 → 100644
| 1 | +package com.diligrp.tax.adopt.api; | |
| 2 | + | |
| 3 | +import com.diligrp.tax.adopt.model.ReceiveMessageCO; | |
| 4 | +import com.diligrp.tax.adopt.service.AdoptMessageService; | |
| 5 | +import com.diligrp.tax.central.message.Message; | |
| 6 | +import lombok.AllArgsConstructor; | |
| 7 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 8 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 10 | +import org.springframework.web.bind.annotation.RestController; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * @author lvqi | |
| 14 | + */ | |
| 15 | +@RestController | |
| 16 | +@RequestMapping("/tax/tenant/adopt") | |
| 17 | +@AllArgsConstructor | |
| 18 | +public class AdoptMessageController { | |
| 19 | + | |
| 20 | + private final AdoptMessageService adoptMessageService; | |
| 21 | + | |
| 22 | + | |
| 23 | + @PostMapping("/message") | |
| 24 | + public Message<?> receiveMessage(@RequestBody ReceiveMessageCO receiveMessageCO) { | |
| 25 | + adoptMessageService.convertMessage(receiveMessageCO); | |
| 26 | + return Message.success(); | |
| 27 | + } | |
| 28 | +} | ... | ... |
tax-adopt/src/main/java/com/diligrp/tax/adopt/model/ReceiveMessageCO.java
| 1 | 1 | package com.diligrp.tax.adopt.model; |
| 2 | 2 | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 3 | 5 | import java.util.Map; |
| 4 | 6 | |
| 5 | 7 | /** |
| 6 | 8 | * @author lvqi |
| 7 | 9 | */ |
| 8 | - | |
| 10 | +@Data | |
| 9 | 11 | public class ReceiveMessageCO { |
| 10 | 12 | |
| 11 | 13 | /** |
| ... | ... | @@ -24,6 +26,8 @@ public class ReceiveMessageCO { |
| 24 | 26 | * 租户账套编码 |
| 25 | 27 | */ |
| 26 | 28 | private String pipelineCode; |
| 29 | + | |
| 30 | + private String businessCode; | |
| 27 | 31 | /** |
| 28 | 32 | * 消息信息 |
| 29 | 33 | */ | ... | ... |
tax-adopt/src/main/java/com/diligrp/tax/adopt/service/AdoptMessageService.java
0 → 100644
tax-adopt/src/main/java/com/diligrp/tax/adopt/service/impl/AdoptMessageServiceImpl.java
0 → 100644
| 1 | +package com.diligrp.tax.adopt.service.impl; | |
| 2 | + | |
| 3 | +import com.diligrp.tax.adopt.model.ReceiveMessageCO; | |
| 4 | +import com.diligrp.tax.adopt.service.AdoptMessageService; | |
| 5 | +import com.diligrp.tax.central.exception.TaxAgentServiceException; | |
| 6 | +import com.diligrp.tax.central.model.PipelineBusinessKeyword; | |
| 7 | +import com.diligrp.tax.central.service.ITaxPipelineBusinessKeywordService; | |
| 8 | +import com.diligrp.tax.central.utils.AdoptUtils; | |
| 9 | +import com.diligrp.tax.central.utils.JsonUtils; | |
| 10 | +import lombok.AllArgsConstructor; | |
| 11 | +import org.springframework.amqp.rabbit.core.RabbitTemplate; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.util.CollectionUtils; | |
| 14 | + | |
| 15 | +import java.util.List; | |
| 16 | +import java.util.Map; | |
| 17 | + | |
| 18 | +import static com.diligrp.tax.central.queue.TaxAutoPush.NORMAL_EXCHANGE; | |
| 19 | +import static com.diligrp.tax.central.queue.TaxAutoPush.NORMAL_ROUTING; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * @author lvqi | |
| 23 | + */ | |
| 24 | +@Service | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class AdoptMessageServiceImpl implements AdoptMessageService { | |
| 27 | + | |
| 28 | + private final ITaxPipelineBusinessKeywordService taxPipelineBusinessKeywordService; | |
| 29 | + private final RabbitTemplate rabbitTemplate; | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public void convertMessage(ReceiveMessageCO receiveMessageCO) { | |
| 33 | + // 查询配置信息 | |
| 34 | + List<PipelineBusinessKeyword> pipelineBusinessKeywords = taxPipelineBusinessKeywordService.queryByTenantAndPipelineAndBusiness(receiveMessageCO.getGroup(), | |
| 35 | + receiveMessageCO.getEntity(), receiveMessageCO.getPipelineCode(), receiveMessageCO.getBusinessCode()); | |
| 36 | + if (CollectionUtils.isEmpty(pipelineBusinessKeywords)) { | |
| 37 | + throw new TaxAgentServiceException("未找到配置信息"); | |
| 38 | + } | |
| 39 | + Map<String, Object> msgBody = receiveMessageCO.getMsgBody(); | |
| 40 | + String json = JsonUtils.toJsonString(msgBody); | |
| 41 | + Map<String, Object> map = AdoptUtils.handleAdopt(pipelineBusinessKeywords, json); | |
| 42 | + receiveMessageCO.setMsgBody(map); | |
| 43 | + // 发送mq | |
| 44 | + String messageJson = JsonUtils.toJsonString(receiveMessageCO); | |
| 45 | + rabbitTemplate.convertAndSend(NORMAL_EXCHANGE, NORMAL_ROUTING, messageJson); | |
| 46 | + } | |
| 47 | +} | ... | ... |
tax-boot/pom.xml
| ... | ... | @@ -26,6 +26,11 @@ |
| 26 | 26 | </dependency> |
| 27 | 27 | <dependency> |
| 28 | 28 | <groupId>com.diligrp</groupId> |
| 29 | + <artifactId>tax-adopt</artifactId> | |
| 30 | + <version>${revision}</version> | |
| 31 | + </dependency> | |
| 32 | + <dependency> | |
| 33 | + <groupId>com.diligrp</groupId> | |
| 29 | 34 | <artifactId>tax-proxy</artifactId> |
| 30 | 35 | <version>${revision}</version> |
| 31 | 36 | </dependency> | ... | ... |
tax-boot/src/main/java/com/diligrp/tax/boot/TaxApplication.java
| 1 | 1 | package com.diligrp.tax.boot; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import com.diligrp.tax.adopt.AdoptConfig; | |
| 4 | 5 | import com.diligrp.tax.central.CentralConfig; |
| 5 | 6 | import com.diligrp.tax.central.process.Processor; |
| 6 | 7 | import com.diligrp.tax.central.process.ProcessorChain; |
| ... | ... | @@ -25,7 +26,7 @@ import java.util.concurrent.ConcurrentHashMap; |
| 25 | 26 | |
| 26 | 27 | @SpringBootApplication |
| 27 | 28 | @EnableDiscoveryClient |
| 28 | -@Import({CentralConfig.class, ConvConfig.class, OrderConfig.class, ProxyConfig.class, StorageConfig.class}) | |
| 29 | +@Import({CentralConfig.class, ConvConfig.class, OrderConfig.class, ProxyConfig.class, StorageConfig.class,AdoptConfig.class}) | |
| 29 | 30 | public class TaxApplication { |
| 30 | 31 | public static void main(String[] args) { |
| 31 | 32 | SpringApplication.run(TaxApplication.class, args); | ... | ... |
tax-boot/src/main/java/com/diligrp/tax/boot/receiver/TaxReceiver.java
tax-boot/src/main/java/com/diligrp/tax/boot/queue/TaxAutoPush.java renamed to tax-central/src/main/java/com/diligrp/tax/central/queue/TaxAutoPush.java