From 24327690417c5ac4e31aa52702fbed3dc31621d1 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Sat, 17 Jun 2023 09:59:43 +0800 Subject: [PATCH 01/11] =?UTF-8?q?1.=E5=88=9B=E5=BB=BA=E6=96=B0=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logpm/factory/snm/controller/PanFactoryDataController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 92ee6f8d7..bb83523fd 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -171,6 +171,7 @@ public class PanFactoryDataController extends BladeController { public R sendOrderStatus(@RequestBody OrderStatusDTO orderStatusDTO) { log.info("############sendOrderStatus: 请求参数{}",orderStatusDTO); try{ + log.info("新分支"); R r = factoryDataService.handleStatusData(orderStatusDTO); return r; }catch (CustomerException e){ From c99c25c1227d836a6d6bde825aa1fb3899838616 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Sat, 17 Jun 2023 14:48:36 +0800 Subject: [PATCH 02/11] =?UTF-8?q?1.=E6=8F=90=E4=BA=A4mq=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RabbitConstant.java | 50 +---------- .../springblade/common/utils/CommonUtil.java | 5 ++ blade-service/logpm-factory/pom.xml | 8 +- .../factory/config/RabbitMqConfiguration.java | 87 +++++++++++++------ .../receiver/DirectQueueOneHandler.java | 61 ++++++++----- .../controller/PanFactoryDataController.java | 27 +++++- .../logpm/factory/snm/dto/OrderInfoDTO.java | 3 +- .../impl/PanFactoryDataServiceImpl.java | 7 +- .../src/main/resources/application.yml | 25 ++++-- 9 files changed, 158 insertions(+), 115 deletions(-) diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java index 6d22799d6..a11b5bd4b 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java @@ -6,53 +6,11 @@ package org.springblade.common.constant; * @author yangkai.shen */ public interface RabbitConstant { - /** - * 直接模式1 - */ - String DIRECT_MODE_QUEUE_ONE = "queue.direct.1"; - /** - * 队列2 - */ - String QUEUE_TWO = "queue.2"; + //订单状态消息队列配置 + String ORDER_STATUS_QUEUE = "order_status_queue"; + String ORDER_STATUS_EXCHANGE = "order_status_exchange"; + String ORDER_STATUS_ROUTING = "order_status_routing"; - /** - * 队列3 - */ - String QUEUE_THREE = "3.queue"; - /** - * 分列模式 - */ - String FANOUT_MODE_QUEUE = "fanout.mode"; - - /** - * 主题模式 - */ - String TOPIC_MODE_QUEUE = "topic.mode"; - - /** - * 路由1 - */ - String TOPIC_ROUTING_KEY_ONE = "queue.#"; - - /** - * 路由2 - */ - String TOPIC_ROUTING_KEY_TWO = "*.queue"; - - /** - * 路由3 - */ - String TOPIC_ROUTING_KEY_THREE = "3.queue"; - - /** - * 延迟队列 - */ - String DELAY_QUEUE = "delay.queue"; - - /** - * 延迟队列交换器 - */ - String DELAY_MODE_QUEUE = "delay.mode"; } diff --git a/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java b/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java index 3bd699c93..9432d8745 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java +++ b/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java @@ -25,6 +25,7 @@ import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Random; import java.util.TimeZone; +import java.util.UUID; /** * 通用工具类 @@ -91,4 +92,8 @@ public class CommonUtil { } + public static String getUUID(){ + return UUID.randomUUID().toString().replace("-", ""); + } + } diff --git a/blade-service/logpm-factory/pom.xml b/blade-service/logpm-factory/pom.xml index 5677d0d6f..9e830d9f2 100644 --- a/blade-service/logpm-factory/pom.xml +++ b/blade-service/logpm-factory/pom.xml @@ -76,10 +76,10 @@ xxl-job-core - - - - + + org.springframework.boot + spring-boot-starter-amqp + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index 41615f918..3a0b5bc9f 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -1,43 +1,70 @@ package com.logpm.factory.config; +import com.alibaba.nacos.shaded.com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.RabbitConstant; +import org.springframework.amqp.core.*; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + /** * RabbitMQ配置,主要是配置队列,如果提前存在该队列,可以省略本配置类 * * @author yangkai.shen */ -//@Slf4j -//@Configuration(proxyBeanMethods = false) +@Slf4j +@Configuration public class RabbitMqConfiguration { -// @Bean -// public RabbitTemplate rabbitTemplate() { -// CachingConnectionFactory connectionFactory = new CachingConnectionFactory(); -// connectionFactory.setPublisherConfirms(true); -// connectionFactory.setPublisherReturns(true); -// RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); -// rabbitTemplate.setMandatory(true); -// rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> log.info("消息发送成功:correlationData({}),ack({}),cause({})", correlationData, ack, cause)); -// rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> log.info("消息丢失:exchange({}),route({}),replyCode({}),replyText({}),message:{}", exchange, routingKey, replyCode, replyText, message)); -// return rabbitTemplate; -// } + @Bean + public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){ + RabbitTemplate template = new RabbitTemplate(); + template.setConnectionFactory(connectionFactory); + template.setMandatory(true); + template.setConfirmCallback(new RabbitTemplate.ConfirmCallback() { + @Override + public void confirm(CorrelationData correlationData, boolean b, String s) { + System.out.println("确认回调-相关数据:"+correlationData); + System.out.println("确认回调-确认情况:"+b); + System.out.println("确认回调-原因:"+s); + } + }); + + template.setReturnsCallback(new RabbitTemplate.ReturnsCallback() { + @Override + public void returnedMessage(ReturnedMessage returnedMessage) { + System.out.println("返回回调-消息:"+returnedMessage.getMessage()); + System.out.println("返回回调-回应码:"+returnedMessage.getReplyCode()); + System.out.println("返回回调-回应信息:"+returnedMessage.getReplyText()); + System.out.println("返回回调-交换机:"+returnedMessage.getExchange()); + System.out.println("返回回调-路由键:"+returnedMessage.getRoutingKey()); + } + }); + return template; + } /** * 延迟队列 */ -// @Bean -// public Queue delayQueue() { -// return new Queue(RabbitConstant.DIRECT_MODE_QUEUE_ONE, true); -// } + @Bean + public Queue delayQueue() { + return new Queue(RabbitConstant.ORDER_STATUS_QUEUE, true); + } /** * 延迟队列交换器, x-delayed-type 和 x-delayed-message 固定 */ -// @Bean -// public CustomExchange delayExchange() { -// Map args = Maps.newHashMap(); -// args.put("x-delayed-type", "direct"); -// return new CustomExchange("TestDirectExchange", "x-delayed-message", true, false, args); -// } + @Bean + public CustomExchange delayExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.ORDER_STATUS_EXCHANGE, "x-delayed-message", true, false, args); + } /** * 延迟队列绑定自定义交换器 @@ -45,9 +72,15 @@ public class RabbitMqConfiguration { * @param delayQueue 队列 * @param delayExchange 延迟交换器 */ -// @Bean -// public Binding delayBinding(Queue delayQueue, CustomExchange delayExchange) { -// return BindingBuilder.bind(delayQueue).to(delayExchange).with("TestDirectRouting").noargs(); -// } + @Bean + public Binding delayBinding(Queue delayQueue, CustomExchange delayExchange) { + return BindingBuilder.bind(delayQueue).to(delayExchange).with(RabbitConstant.ORDER_STATUS_ROUTING).noargs(); + } + + + @Bean + DirectExchange lonelyDirectExchange() { + return new DirectExchange("lonelyDirectExchange"); + } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java index 9c644acab..a4d353a97 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java @@ -1,30 +1,51 @@ package com.logpm.factory.receiver; +import com.logpm.factory.snm.dto.OrderInfoDTO; +import com.logpm.factory.snm.service.IPanFactoryDataService; +import com.rabbitmq.client.Channel; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.RabbitConstant; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.rabbit.annotation.RabbitHandler; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.Map; + + /** * 直接队列1 处理器 * * @author yangkai.shen */ -//@Slf4j -//@RabbitListener(queues = RabbitConstant.DIRECT_MODE_QUEUE_ONE) -//@Component +@Slf4j +@RabbitListener(queues = RabbitConstant.ORDER_STATUS_QUEUE) +@Component public class DirectQueueOneHandler { -// @RabbitHandler -// public void directHandlerManualAck(PanFactoryOrderDTO factoryOrderDTO, Message message, Channel channel) { -// // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 -// final long deliveryTag = message.getMessageProperties().getDeliveryTag(); -// try { -// log.info("直接队列1,手动ACK,接收消息:{}", factoryOrderDTO); -// //通知 MQ 消息已被成功消费,可以ACK了 -// channel.basicAck(deliveryTag, false); -// } catch (IOException e) { -// try { -// // 处理失败,重新压入MQ -// channel.basicRecover(); -// } catch (IOException e1) { -// e1.printStackTrace(); -// } -// } -// } + @Autowired + private IPanFactoryDataService panFactoryDataService; + + @RabbitHandler + public void directHandlerManualAck(Map map, Message message, Channel channel) { + // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 + final long deliveryTag = message.getMessageProperties().getDeliveryTag(); + try { + log.info("直接队列1,手动ACK,接收消息:{}", map); + OrderInfoDTO orderInfoDTO = (OrderInfoDTO) map.get("messageData"); + + panFactoryDataService.handleData(orderInfoDTO); + + channel.basicAck(deliveryTag, false); + } catch (IOException e) { + try { + // 处理失败,重新压入MQ + channel.basicRecover(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index bb83523fd..7aa4b7f23 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -30,15 +30,17 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; +import org.springblade.common.constant.RabbitConstant; import org.springblade.common.exception.CustomerException; +import org.springblade.common.utils.CommonUtil; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; +import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.List; +import java.util.*; /** * 皮阿诺数据 控制器 @@ -59,6 +61,7 @@ public class PanFactoryDataController extends BladeController { private final IPanFactoryDataService factoryDataService; private final IAsyncDataService syncDataService; private final IPanOrderStatusLogService panOrderStatusLogService; + private RabbitTemplate rabbitTemplate; // @ResponseBody // @PostMapping("/token") @@ -152,8 +155,24 @@ public class PanFactoryDataController extends BladeController { public R sendOrders(@Validated @RequestBody OrderInfoDTO orderInfoDTO) { log.info("############sendOrders: 请求参数{}",orderInfoDTO); try{ - R r = factoryDataService.handleData(orderInfoDTO); - return r; + + //先保存原始请求数据 + PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); + panOrderStatusLog.setArgs(JSONObject.toJSONString(orderInfoDTO)); + panOrderStatusLog.setStatus(1); + panOrderStatusLog.setType(1); + panOrderStatusLogService.save(panOrderStatusLog); + + Map map=new HashMap<>(); + map.put("messageId", CommonUtil.getUUID()); + map.put("messageData",orderInfoDTO); + map.put("createTime",new Date().getTime()); + //将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange + rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); + + +// R r = factoryDataService.handleData(orderInfoDTO); + return R.success("调用成功"); }catch (CustomerException e){ log.error(e.message,e); return R.fail(e.code,e.message); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderInfoDTO.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderInfoDTO.java index f3b519335..365f29449 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderInfoDTO.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderInfoDTO.java @@ -20,6 +20,7 @@ import lombok.Data; import org.springblade.core.tool.utils.StringUtil; import javax.validation.constraints.NotEmpty; +import java.io.Serializable; /** * PHP传过来的OrderInfo @@ -28,7 +29,7 @@ import javax.validation.constraints.NotEmpty; * @since 2023-06-12 */ @Data -public class OrderInfoDTO { +public class OrderInfoDTO implements Serializable { private static final long serialVersionUID = 1L; @NotEmpty(message = "客户订单号不能为空") diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java index c7afdf565..bf87967a0 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java @@ -95,12 +95,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { @Override public R handleData(OrderInfoDTO orderInfoDTO) throws CustomerException { - //先保存原始请求数据 - PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); - panOrderStatusLog.setArgs(JSONObject.toJSONString(orderInfoDTO)); - panOrderStatusLog.setStatus(1); - panOrderStatusLog.setType(1); - panOrderStatusLogService.save(panOrderStatusLog); + String orderNo = orderInfoDTO.getOrderNo(); diff --git a/blade-service/logpm-factory/src/main/resources/application.yml b/blade-service/logpm-factory/src/main/resources/application.yml index ed6606aa2..d9fdd481a 100644 --- a/blade-service/logpm-factory/src/main/resources/application.yml +++ b/blade-service/logpm-factory/src/main/resources/application.yml @@ -35,14 +35,25 @@ logging: spring: main: allow-circular-references: true + #rabbitmq配置 -# rabbitmq: -# host: 192.168.2.100 -# port: 5672 -# username: admin -# password: admin -# #虚拟host 可以不设置,使用server默认host -# virtual-host: / + rabbitmq: + host: 192.168.2.100 + port: 5672 + username: admin + password: admin + #虚拟host 可以不设置,使用server默认host + virtual-host: / + #确认消息已发送到队列(Queue) + publisher-returns: true + publisher-confirm-type: correlated + # 手动提交消息 + listener: + simple: + acknowledge-mode: manual + direct: + acknowledge-mode: manual + xxl: job: accessToken: '' From 0f4310a00aa14b24ce6d80a225944131df6c5c92 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Mon, 19 Jun 2023 14:23:45 +0800 Subject: [PATCH 03/11] =?UTF-8?q?1.mq=E6=8E=A5=E6=94=B6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/logpm/factory/config/RabbitMqConfiguration.java | 8 ++++---- .../com/logpm/factory/receiver/DirectQueueOneHandler.java | 2 +- .../factory/snm/controller/PanFactoryDataController.java | 2 ++ .../snm/service/impl/PanFactoryDataServiceImpl.java | 2 -- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index 3a0b5bc9f..a2cc7b1f3 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -78,9 +78,9 @@ public class RabbitMqConfiguration { } - @Bean - DirectExchange lonelyDirectExchange() { - return new DirectExchange("lonelyDirectExchange"); - } +// @Bean +// DirectExchange lonelyDirectExchange() { +// return new DirectExchange("lonelyDirectExchange"); +// } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java index a4d353a97..b0c160c96 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java @@ -42,7 +42,7 @@ public class DirectQueueOneHandler { } catch (IOException e) { try { // 处理失败,重新压入MQ - channel.basicRecover(); + channel.basicReject(deliveryTag,true); } catch (IOException e1) { e1.printStackTrace(); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 7aa4b7f23..433f91757 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -170,6 +170,8 @@ public class PanFactoryDataController extends BladeController { //将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); + panOrderStatusLog.setStatus(0); + panOrderStatusLogService.saveOrUpdate(panOrderStatusLog); // R r = factoryDataService.handleData(orderInfoDTO); return R.success("调用成功"); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java index bf87967a0..d1422e92e 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java @@ -147,8 +147,6 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { String message = payload.getString("data"); if(code.equals(1)){ logger.info("##########handleData: 物流状态传递成功"); - panOrderStatusLog.setStatus(0); - panOrderStatusLogService.saveOrUpdate(panOrderStatusLog); }else{ return R.fail(400,message); } From 92dffaf5a38a6506065ef4f6cabf11a01a523095 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Mon, 19 Jun 2023 15:35:41 +0800 Subject: [PATCH 04/11] =?UTF-8?q?1.mq=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../factory/config/RabbitMqConfiguration.java | 22 +++++++++++++++---- .../controller/PanFactoryDataController.java | 6 ++--- .../impl/PanFactoryDataServiceImpl.java | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index a2cc7b1f3..0d9cb8945 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -1,12 +1,16 @@ package com.logpm.factory.config; import com.alibaba.nacos.shaded.com.google.common.collect.Maps; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.logpm.factory.snm.entity.PanOrderStatusLog; +import com.logpm.factory.snm.service.IPanOrderStatusLogService; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; import org.springframework.amqp.core.*; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -21,6 +25,9 @@ import java.util.Map; @Configuration public class RabbitMqConfiguration { + @Autowired + private IPanOrderStatusLogService panOrderStatusLogService; + @Bean public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){ RabbitTemplate template = new RabbitTemplate(); @@ -32,6 +39,13 @@ public class RabbitMqConfiguration { System.out.println("确认回调-相关数据:"+correlationData); System.out.println("确认回调-确认情况:"+b); System.out.println("确认回调-原因:"+s); + //修改处理日志为已处理 + Long id = Long.parseLong(correlationData.getId()); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("status",0) + .eq("id",id); + panOrderStatusLogService.update(updateWrapper); + } }); @@ -78,9 +92,9 @@ public class RabbitMqConfiguration { } -// @Bean -// DirectExchange lonelyDirectExchange() { -// return new DirectExchange("lonelyDirectExchange"); -// } + @Bean + DirectExchange lonelyDirectExchange() { + return new DirectExchange("lonelyDirectExchange"); + } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 433f91757..f1cce3197 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -35,6 +35,7 @@ import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; +import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -168,10 +169,7 @@ public class PanFactoryDataController extends BladeController { map.put("messageData",orderInfoDTO); map.put("createTime",new Date().getTime()); //将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange - rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); - - panOrderStatusLog.setStatus(0); - panOrderStatusLogService.saveOrUpdate(panOrderStatusLog); + rabbitTemplate.convertAndSend("lonelyDirectExchange", RabbitConstant.ORDER_STATUS_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); // R r = factoryDataService.handleData(orderInfoDTO); return R.success("调用成功"); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java index d1422e92e..6ab85b8cd 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java @@ -131,7 +131,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { //请求参数 logger.info("##############handleData: 推送包件状态请求参数 {}",s); //处理逻辑 - String result = HttpRequest.post(panFactoryProperties.getUrl()+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=HUITONG_MID_RECEIVE") + String result = HttpRequest.post(panFactoryProperties.getUrl()+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=OPEN&interfaceCode=HUITONG_MID_RECEIVE") .header("Authorization","Bearer "+panToken) .header("Content-Type","application/json") .body(s).timeout(5 * 1000) From 06a06d8ef1b428a4e96cc30f7d57541156e31e7e Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Mon, 19 Jun 2023 17:57:51 +0800 Subject: [PATCH 05/11] =?UTF-8?q?1.mq=E6=8E=A5=E6=94=B6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E8=B4=B9=E8=80=85=E9=87=8D=E8=AF=95=E4=B8=89?= =?UTF-8?q?=E6=AC=A1=EF=BC=8C=E4=B8=89=E6=AC=A1=E5=A4=B1=E8=B4=A5=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=86=99=E5=85=A5=E9=94=99=E8=AF=AF=E9=98=9F=E5=88=97?= =?UTF-8?q?=EF=BC=8C=E9=94=99=E8=AF=AF=E9=98=9F=E5=88=97=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RabbitConstant.java | 10 +++ .../factory/config/RabbitMqConfiguration.java | 82 ++++++++++++++----- .../receiver/DirectQueueOneHandler.java | 48 +++++++---- .../factory/receiver/ErrorQueueHandler.java | 56 +++++++++++++ .../controller/PanFactoryDataController.java | 26 ++++-- .../logpm/factory/snm/dto/OrderStatusDTO.java | 3 +- .../impl/PanFactoryDataServiceImpl.java | 30 +++---- .../src/main/resources/application.yml | 8 ++ 8 files changed, 201 insertions(+), 62 deletions(-) create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java index a11b5bd4b..7c50d6039 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java @@ -6,6 +6,11 @@ package org.springblade.common.constant; * @author yangkai.shen */ public interface RabbitConstant { + //消费失败队列 + String ERROR_QUEUE = "error_queue"; + String ERROR_EXCHANGE = "error_exchange"; + String ERROR_ROUTING = "error_routing"; + //订单状态消息队列配置 String ORDER_STATUS_QUEUE = "order_status_queue"; @@ -13,4 +18,9 @@ public interface RabbitConstant { String ORDER_STATUS_ROUTING = "order_status_routing"; + String OPEN_ORDER_QUEUE = "open_order_queue"; + String OPEN_ORDER_EXCHANGE = "open_order_exchange"; + String OPEN_ORDER_ROUTING = "open_order_routing"; + + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index 0d9cb8945..4b4ef3eb8 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -1,16 +1,14 @@ package com.logpm.factory.config; import com.alibaba.nacos.shaded.com.google.common.collect.Maps; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.logpm.factory.snm.entity.PanOrderStatusLog; -import com.logpm.factory.snm.service.IPanOrderStatusLogService; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; import org.springframework.amqp.core.*; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.amqp.rabbit.retry.MessageRecoverer; +import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -25,9 +23,6 @@ import java.util.Map; @Configuration public class RabbitMqConfiguration { - @Autowired - private IPanOrderStatusLogService panOrderStatusLogService; - @Bean public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){ RabbitTemplate template = new RabbitTemplate(); @@ -39,13 +34,19 @@ public class RabbitMqConfiguration { System.out.println("确认回调-相关数据:"+correlationData); System.out.println("确认回调-确认情况:"+b); System.out.println("确认回调-原因:"+s); - //修改处理日志为已处理 - Long id = Long.parseLong(correlationData.getId()); - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.set("status",0) - .eq("id",id); - panOrderStatusLogService.update(updateWrapper); - +// Long id = Long.parseLong(correlationData.getId()); +// UpdateWrapper updateWrapper = new UpdateWrapper<>(); +// if(b){ +// //修改处理日志为已处理 +// updateWrapper.set("status",0) +// .eq("id",id); +// +// }else{ +// //修改处理日志为已处理 +// updateWrapper.set("status",2) +// .eq("id",id); +// } +// panOrderStatusLogService.update(updateWrapper); } }); @@ -62,11 +63,35 @@ public class RabbitMqConfiguration { return template; } + @Bean + public DirectExchange errorMessageExchange(){ + return new DirectExchange(RabbitConstant.ERROR_EXCHANGE); + } + @Bean + public Queue errorQueue(){ + return new Queue(RabbitConstant.ERROR_QUEUE, true); + } + @Bean + public Binding errorBinding(Queue errorQueue, DirectExchange errorMessageExchange){ + return BindingBuilder.bind(errorQueue).to(errorMessageExchange).with(RabbitConstant.ERROR_ROUTING); + } + + /** + * 消费失败队列 + * @param rabbitTemplate + * @return + */ + @Bean + public MessageRecoverer republishMessageRecoverer(RabbitTemplate rabbitTemplate){ + return new RepublishMessageRecoverer(rabbitTemplate, RabbitConstant.ERROR_EXCHANGE, RabbitConstant.ERROR_ROUTING); + } + + /** * 延迟队列 */ @Bean - public Queue delayQueue() { + public Queue orderStatusQueue() { return new Queue(RabbitConstant.ORDER_STATUS_QUEUE, true); } @@ -74,7 +99,7 @@ public class RabbitMqConfiguration { * 延迟队列交换器, x-delayed-type 和 x-delayed-message 固定 */ @Bean - public CustomExchange delayExchange() { + public CustomExchange orderStatusExchange() { Map args = Maps.newHashMap(); args.put("x-delayed-type", "direct"); return new CustomExchange(RabbitConstant.ORDER_STATUS_EXCHANGE, "x-delayed-message", true, false, args); @@ -83,12 +108,12 @@ public class RabbitMqConfiguration { /** * 延迟队列绑定自定义交换器 * - * @param delayQueue 队列 - * @param delayExchange 延迟交换器 + * @param orderStatusQueue 队列 + * @param orderStatusExchange 延迟交换器 */ @Bean - public Binding delayBinding(Queue delayQueue, CustomExchange delayExchange) { - return BindingBuilder.bind(delayQueue).to(delayExchange).with(RabbitConstant.ORDER_STATUS_ROUTING).noargs(); + public Binding orderStatusBinding(Queue orderStatusQueue, CustomExchange orderStatusExchange) { + return BindingBuilder.bind(orderStatusQueue).to(orderStatusExchange).with(RabbitConstant.ORDER_STATUS_ROUTING).noargs(); } @@ -97,4 +122,21 @@ public class RabbitMqConfiguration { return new DirectExchange("lonelyDirectExchange"); } + @Bean + public Queue openOrderQueue() { + return new Queue(RabbitConstant.OPEN_ORDER_QUEUE, true); + } + + @Bean + public CustomExchange openOrderExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.OPEN_ORDER_EXCHANGE, "x-delayed-message", true, false, args); + } + + @Bean + public Binding openOrderBinding(Queue openOrderQueue, CustomExchange openOrderExchange) { + return BindingBuilder.bind(openOrderQueue).to(openOrderExchange).with(RabbitConstant.OPEN_ORDER_ROUTING).noargs(); + } + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java index b0c160c96..ae470d29c 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java @@ -5,6 +5,8 @@ import com.logpm.factory.snm.service.IPanFactoryDataService; import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; +import org.springblade.common.exception.CustomerException; +import org.springblade.core.tool.api.R; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; @@ -21,7 +23,7 @@ import java.util.Map; * @author yangkai.shen */ @Slf4j -@RabbitListener(queues = RabbitConstant.ORDER_STATUS_QUEUE) +@RabbitListener(queues = RabbitConstant.OPEN_ORDER_QUEUE) @Component public class DirectQueueOneHandler { @@ -29,23 +31,37 @@ public class DirectQueueOneHandler { private IPanFactoryDataService panFactoryDataService; @RabbitHandler - public void directHandlerManualAck(Map map, Message message, Channel channel) { + public void orderStatusHandlerManualAck(Map map, Message message, Channel channel) throws IOException { // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 final long deliveryTag = message.getMessageProperties().getDeliveryTag(); - try { - log.info("直接队列1,手动ACK,接收消息:{}", map); - OrderInfoDTO orderInfoDTO = (OrderInfoDTO) map.get("messageData"); - - panFactoryDataService.handleData(orderInfoDTO); - - channel.basicAck(deliveryTag, false); - } catch (IOException e) { - try { - // 处理失败,重新压入MQ - channel.basicReject(deliveryTag,true); - } catch (IOException e1) { - e1.printStackTrace(); - } + log.info("##################我进入这里了"); + + int i = 1/0; + OrderInfoDTO orderInfoDTO = (OrderInfoDTO) map.get("messageData"); + String orderNo = orderInfoDTO.getOrderNo(); + R r = panFactoryDataService.handleData(orderInfoDTO); + int code = r.getCode(); + if(code == 400 || code == 200){ + log.info("##################orderStatusHandlerManualAck: 该条数据不用处理 orderNo={}",orderNo); + channel.basicAck(deliveryTag,true); + }else{ + throw new CustomerException(code,r.getMsg()); } + +// try { +// log.info("直接队列1,手动ACK,接收消息:{}", map); +// OrderInfoDTO orderInfoDTO = (OrderInfoDTO) map.get("messageData"); +// +// +// +// channel.basicAck(deliveryTag, false); +// } catch (IOException e) { +// try { +// // 处理失败,重新压入MQ +// channel.basicReject(deliveryTag,true); +// } catch (IOException e1) { +// e1.printStackTrace(); +// } +// } } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java new file mode 100644 index 000000000..8ad34241e --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java @@ -0,0 +1,56 @@ +package com.logpm.factory.receiver; + +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.logpm.factory.snm.entity.PanOrderStatusLog; +import com.logpm.factory.snm.service.IPanOrderStatusLogService; +import com.rabbitmq.client.Channel; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.RabbitConstant; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.rabbit.annotation.RabbitHandler; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.Map; + + +/** + * 直接队列1 处理器 + * + * @author yangkai.shen + */ +@Slf4j +@RabbitListener(queues = RabbitConstant.ERROR_QUEUE) +@Component +public class ErrorQueueHandler { + + @Autowired + private IPanOrderStatusLogService panOrderStatusLogService; + + @RabbitHandler + public void orderStatusHandlerManualAck(Map map, Message message, Channel channel) { + // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 + final long deliveryTag = message.getMessageProperties().getDeliveryTag(); + try { + Long logId = (Long) map.get("logId"); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("status",2) + .eq("id",logId); + boolean updateFlag = panOrderStatusLogService.update(updateWrapper); + if(updateFlag){ + channel.basicAck(deliveryTag, false); + }else{ + channel.basicReject(deliveryTag,true); + } + } catch (IOException e) { + try { + // 处理失败,重新压入MQ + channel.basicReject(deliveryTag,true); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index f1cce3197..82773a71e 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -166,10 +166,11 @@ public class PanFactoryDataController extends BladeController { Map map=new HashMap<>(); map.put("messageId", CommonUtil.getUUID()); + map.put("logId", panOrderStatusLog.getId()); map.put("messageData",orderInfoDTO); map.put("createTime",new Date().getTime()); - //将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange - rabbitTemplate.convertAndSend("lonelyDirectExchange", RabbitConstant.ORDER_STATUS_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); + //将消息携带绑定键值 + rabbitTemplate.convertAndSend(RabbitConstant.OPEN_ORDER_EXCHANGE, RabbitConstant.OPEN_ORDER_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); // R r = factoryDataService.handleData(orderInfoDTO); return R.success("调用成功"); @@ -190,9 +191,24 @@ public class PanFactoryDataController extends BladeController { public R sendOrderStatus(@RequestBody OrderStatusDTO orderStatusDTO) { log.info("############sendOrderStatus: 请求参数{}",orderStatusDTO); try{ - log.info("新分支"); - R r = factoryDataService.handleStatusData(orderStatusDTO); - return r; + + //先保存原始请求数据 + PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); + panOrderStatusLog.setArgs(JSONObject.toJSONString(orderStatusDTO)); + panOrderStatusLog.setStatus(1); + panOrderStatusLog.setType(2); + panOrderStatusLogService.save(panOrderStatusLog); + + Map map=new HashMap<>(); + map.put("messageId", CommonUtil.getUUID()); + map.put("logId", panOrderStatusLog.getId()); + map.put("messageData",orderStatusDTO); + map.put("createTime",new Date().getTime()); + //将消息携带绑定键值 + rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); + +// R r = factoryDataService.handleStatusData(orderStatusDTO); + return R.success("调用成功"); }catch (CustomerException e){ log.error(e.message,e); return R.fail(e.code,e.message); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderStatusDTO.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderStatusDTO.java index 084f7d865..852b4f929 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderStatusDTO.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/dto/OrderStatusDTO.java @@ -20,6 +20,7 @@ import lombok.Data; import org.springblade.core.tool.utils.StringUtil; import javax.validation.constraints.NotEmpty; +import java.io.Serializable; /** * OrderStatus @@ -28,7 +29,7 @@ import javax.validation.constraints.NotEmpty; * @since 2023-06-12 */ @Data -public class OrderStatusDTO { +public class OrderStatusDTO implements Serializable { private static final long serialVersionUID = 1L; @NotEmpty(message = "派车单号不能为空") diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java index 6ab85b8cd..8d4196e51 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java @@ -10,7 +10,6 @@ import com.logpm.factory.snm.bean.Resp; import com.logpm.factory.snm.dto.OrderInfoDTO; import com.logpm.factory.snm.dto.OrderStatusDTO; import com.logpm.factory.snm.entity.PanFactoryOrder; -import com.logpm.factory.snm.entity.PanOrderStatusLog; import com.logpm.factory.snm.entity.PanPackageInfo; import com.logpm.factory.snm.service.IPanFactoryDataService; import com.logpm.factory.snm.service.IPanFactoryOrderService; @@ -25,6 +24,7 @@ import org.springblade.common.exception.CustomerException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.Map; @@ -91,12 +91,10 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { // return factoryTokenVO; // } - + @Transactional @Override public R handleData(OrderInfoDTO orderInfoDTO) throws CustomerException { - - String orderNo = orderInfoDTO.getOrderNo(); //根据客户订单号去查询WMS装车清单号 @@ -115,7 +113,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { //判断数据是都已存在 if(!orderInfoDTO.verifyData()){ logger.info("#############handleData: 数据不齐全 orderInfoDTO={}",orderInfoDTO); - return R.fail(400,"数据不齐全"); + return R.fail(405,"数据不齐全"); } //拼接参数 @@ -148,26 +146,20 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { if(code.equals(1)){ logger.info("##########handleData: 物流状态传递成功"); }else{ - return R.fail(400,message); + return R.fail(405,message); } }else{ - return R.fail(400,"返回格式有误:"+result); + return R.fail(405,"返回格式有误:"+result); } return Resp.success("SUCCESS"); } + @Transactional @Override public R handleStatusData(OrderStatusDTO orderStatusDTO) throws CustomerException { - //先保存原始请求数据 - PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); - panOrderStatusLog.setArgs(JSONObject.toJSONString(orderStatusDTO)); - panOrderStatusLog.setStatus(1); - panOrderStatusLog.setType(2); - panOrderStatusLogService.save(panOrderStatusLog); - String status = orderStatusDTO.getStatus(); - if("2".equals(status)||"4".equals(status)||"5".equals(status)||"8".equals(status)||"9".equals(status)){ + if("2".equals(status)||"5".equals(status)||"8".equals(status)||"9".equals(status)){ logger.info("#############handleStatusData: 当前数据的状态不推送 status={}",status); return Resp.fail(400,"当前数据的状态不推送"); } @@ -201,7 +193,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { //判断数据是都已存在 if(!orderStatusDTO.verifyData()){ logger.info("#############handleStatusData: 数据不齐全 orderStatusDTO={}",orderStatusDTO); - return Resp.fail(400,"数据不齐全"); + return Resp.fail(405,"数据不齐全"); } //拼接参数 @@ -233,13 +225,11 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { String message = payload.getString("data"); if(code.equals(1)){ logger.info("##########handleStatusData: 物流状态传递成功"); - panOrderStatusLog.setStatus(0); - panOrderStatusLogService.saveOrUpdate(panOrderStatusLog); }else{ - return Resp.fail(400,message); + return Resp.fail(405,message); } }else{ - return Resp.fail(400,"返回格式有误:"+result); + return Resp.fail(405,"返回格式有误:"+result); } return Resp.success("SUCCESS"); } diff --git a/blade-service/logpm-factory/src/main/resources/application.yml b/blade-service/logpm-factory/src/main/resources/application.yml index d9fdd481a..3eb7313f3 100644 --- a/blade-service/logpm-factory/src/main/resources/application.yml +++ b/blade-service/logpm-factory/src/main/resources/application.yml @@ -51,8 +51,16 @@ spring: listener: simple: acknowledge-mode: manual + retry: + enabled: true # 开启消费者失败重试 + initial-interval: 1000 # 初识的失败等待时长为1秒 + multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval + max-attempts: 3 # 最大重试次数 + stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false direct: acknowledge-mode: manual + template: + mandatory: true xxl: job: From d966b6da4dce02ac51babe69beebc7025eef4ac9 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 20 Jun 2023 17:49:42 +0800 Subject: [PATCH 06/11] =?UTF-8?q?1.mq=E6=8E=A5=E6=94=B6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RabbitConstant.java | 5 ++++ .../factory/config/RabbitMqConfiguration.java | 19 ++++++++++++ .../factory/receiver/ErrorQueueHandler.java | 4 +-- ...eOneHandler.java => OpenOrderHandler.java} | 29 +++++-------------- .../controller/PanFactoryDataController.java | 2 ++ .../src/main/resources/application.yml | 3 +- 6 files changed, 37 insertions(+), 25 deletions(-) rename blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/{DirectQueueOneHandler.java => OpenOrderHandler.java} (67%) diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java index 7c50d6039..2fc1f0f38 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java @@ -23,4 +23,9 @@ public interface RabbitConstant { String OPEN_ORDER_ROUTING = "open_order_routing"; + String DEAL_WITH_QUEUE = "deal_with_queue"; + String DEAL_WITH_EXCHANGE = "deal_with_exchange"; + String DEAL_WITH_ROUTING = "deal_with_routing"; + + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index 4b4ef3eb8..ee86d4d42 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -139,4 +139,23 @@ public class RabbitMqConfiguration { return BindingBuilder.bind(openOrderQueue).to(openOrderExchange).with(RabbitConstant.OPEN_ORDER_ROUTING).noargs(); } + + @Bean + public Queue dealWithQueue() { + return new Queue(RabbitConstant.DEAL_WITH_QUEUE, true); + } + + @Bean + public CustomExchange dealWithExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.DEAL_WITH_EXCHANGE, "x-delayed-message", true, false, args); + } + + @Bean + public Binding dealWithBinding(Queue dealWithQueue, CustomExchange dealWithExchange) { + return BindingBuilder.bind(dealWithQueue).to(dealWithExchange).with(RabbitConstant.DEAL_WITH_ROUTING).noargs(); + } + + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java index 8ad34241e..208643ffc 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java @@ -17,9 +17,9 @@ import java.util.Map; /** - * 直接队列1 处理器 + * 异常消息队列 处理器 * - * @author yangkai.shen + * @author zhy */ @Slf4j @RabbitListener(queues = RabbitConstant.ERROR_QUEUE) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OpenOrderHandler.java similarity index 67% rename from blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java rename to blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OpenOrderHandler.java index ae470d29c..bb1787d7e 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DirectQueueOneHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OpenOrderHandler.java @@ -25,43 +25,28 @@ import java.util.Map; @Slf4j @RabbitListener(queues = RabbitConstant.OPEN_ORDER_QUEUE) @Component -public class DirectQueueOneHandler { +public class OpenOrderHandler { @Autowired private IPanFactoryDataService panFactoryDataService; + private Integer retryCount = 1; + @RabbitHandler - public void orderStatusHandlerManualAck(Map map, Message message, Channel channel) throws IOException { + public void openOrderStatusHandler(Map map, Message message, Channel channel) throws IOException { // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 final long deliveryTag = message.getMessageProperties().getDeliveryTag(); - log.info("##################我进入这里了"); - - int i = 1/0; + String msg = new String(message.getBody()); + log.info("##################我进入这里了 retryCount={}",retryCount++); OrderInfoDTO orderInfoDTO = (OrderInfoDTO) map.get("messageData"); String orderNo = orderInfoDTO.getOrderNo(); R r = panFactoryDataService.handleData(orderInfoDTO); int code = r.getCode(); if(code == 400 || code == 200){ - log.info("##################orderStatusHandlerManualAck: 该条数据不用处理 orderNo={}",orderNo); + log.info("##################openOrderStatusHandler: 该条数据不用处理 orderNo={}",orderNo); channel.basicAck(deliveryTag,true); }else{ throw new CustomerException(code,r.getMsg()); } - -// try { -// log.info("直接队列1,手动ACK,接收消息:{}", map); -// OrderInfoDTO orderInfoDTO = (OrderInfoDTO) map.get("messageData"); -// -// -// -// channel.basicAck(deliveryTag, false); -// } catch (IOException e) { -// try { -// // 处理失败,重新压入MQ -// channel.basicReject(deliveryTag,true); -// } catch (IOException e1) { -// e1.printStackTrace(); -// } -// } } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 82773a71e..85ac72f3f 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -206,6 +206,8 @@ public class PanFactoryDataController extends BladeController { map.put("createTime",new Date().getTime()); //将消息携带绑定键值 rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); + rabbitTemplate.convertAndSend(RabbitConstant.DEAL_WITH_EXCHANGE, RabbitConstant.DEAL_WITH_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); + // R r = factoryDataService.handleStatusData(orderStatusDTO); return R.success("调用成功"); diff --git a/blade-service/logpm-factory/src/main/resources/application.yml b/blade-service/logpm-factory/src/main/resources/application.yml index 3eb7313f3..cf42bc689 100644 --- a/blade-service/logpm-factory/src/main/resources/application.yml +++ b/blade-service/logpm-factory/src/main/resources/application.yml @@ -50,7 +50,8 @@ spring: # 手动提交消息 listener: simple: - acknowledge-mode: manual + acknowledge-mode: auto + default-requeue-rejected: false retry: enabled: true # 开启消费者失败重试 initial-interval: 1000 # 初识的失败等待时长为1秒 From 137434eb0c06d6de2dae0e20b85c24d6d588344e Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Sat, 24 Jun 2023 12:31:32 +0800 Subject: [PATCH 07/11] =?UTF-8?q?1.mq=E6=8E=A5=E6=94=B6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E5=AD=98=E5=85=A5=E5=9C=A8=E5=BA=93=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BF=A1=E6=81=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/IDistributionParcelListClient.java | 10 +- .../IDistributionStockArticleClient.java | 6 +- .../logpm/oldproject/entity/OrderEntity.java | 155 ++++++++++++++++++ .../feign/IAdvanceDetailClient.java | 9 + .../logpm/oldproject/feign/IOrderClient.java | 43 +++++ .../vo/DistributionParcelListEntityVO.java | 67 ++++++++ .../feign/DistributionParcelListClient.java | 16 ++ .../feign/DistributionStockArticleClient.java | 10 ++ blade-service/logpm-factory/pom.xml | 6 + .../factory/receiver/DealWithDataHandler.java | 70 ++++++++ .../controller/PanFactoryDataController.java | 6 +- .../snm/service/IPanFactoryDataService.java | 3 + .../impl/PanFactoryDataServiceImpl.java | 103 +++++++++++- .../oldproject/feign/AdvanceDetailClient.java | 14 ++ .../logpm/oldproject/feign/OrderClient.java | 44 +++++ .../mapper/AdvanceDetailMapper.java | 4 + .../oldproject/mapper/AdvanceDetailMapper.xml | 23 ++- .../logpm/oldproject/mapper/OrderMapper.java | 31 ++++ .../logpm/oldproject/mapper/OrderMapper.xml | 7 + .../service/IAdvanceDetailService.java | 7 + .../oldproject/service/IOrderService.java | 11 ++ .../impl/AdvanceDetailServiceImpl.java | 15 ++ .../service/impl/OrderServiceImpl.java | 25 +++ 23 files changed, 676 insertions(+), 9 deletions(-) create mode 100644 blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/OrderEntity.java create mode 100644 blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java create mode 100644 blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/vo/DistributionParcelListEntityVO.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java index 5b2b38963..ba7f33a9e 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java @@ -16,12 +16,15 @@ */ package com.logpm.distribution.feign; -import org.springblade.core.mp.support.BladePage; import com.logpm.distribution.entity.DistributionParcelListEntity; +import org.springblade.core.mp.support.BladePage; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + /** * 在库订单包件清单 Feign接口类 * @@ -46,4 +49,9 @@ public interface IDistributionParcelListClient { @GetMapping(TOP) BladePage top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); + @GetMapping(API_PREFIX+"/findByPacketBarCode") + DistributionParcelListEntity findByPacketBarCode(String unitNo); + + @GetMapping(API_PREFIX+"/addBatch") + boolean addBatch(@RequestBody List parcelListEntityList); } diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java index 125dde48d..c13476c35 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java @@ -16,10 +16,12 @@ */ package com.logpm.distribution.feign; -import org.springblade.core.mp.support.BladePage; import com.logpm.distribution.entity.DistributionStockArticleEntity; +import org.springblade.core.mp.support.BladePage; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** @@ -46,4 +48,6 @@ public interface IDistributionStockArticleClient { @GetMapping(TOP) BladePage top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); + @PostMapping(API_PREFIX + "/addData") + Long addData(@RequestBody DistributionStockArticleEntity distributionStockArticleEntity); } diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/OrderEntity.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/OrderEntity.java new file mode 100644 index 000000000..d338be7d3 --- /dev/null +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/OrderEntity.java @@ -0,0 +1,155 @@ +package com.logpm.oldproject.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@TableName("ht_order") +@ApiModel(value = "Order对象", description = "订单信息") +public class OrderEntity { + + @TableId( + value = "id", + type = IdType.AUTO + ) + private Integer id; + + private Integer test; + + @ApiModelProperty(value = "订单号") + @TableField("number") + private String number; + + @ApiModelProperty(value = "服务号") + @TableField("servicenum") + private String servicenum; + + @ApiModelProperty(value = "仓库id") + @TableField("warehouse_id") + private Integer warehouseId; + + @ApiModelProperty(value = "货区id") + @TableField("cargo_id") + private Integer cargoId; + + @ApiModelProperty(value = "货架id") + @TableField("shelf_id") + private Integer shelfId; + + @ApiModelProperty(value = "货位id") + @TableField("location_id") + private String locationId; + + @ApiModelProperty(value = "订单来源") + @TableField("source") + private String source; + + @ApiModelProperty(value = "紧急程度:0=正常,1=加急") + @TableField("emergency") + private Integer emergency; + + @ApiModelProperty(value = "订单自编号") + @TableField("selfnumber") + private String selfnumber; + + @ApiModelProperty(value = "客户姓名") + @TableField("contact") + private String contact; + + @ApiModelProperty(value = "联系方式") + @TableField("phone") + private String phone; + + @ApiModelProperty(value = "收货地址") + @TableField("address") + private String address; + + @ApiModelProperty(value = "上门提货:0=否,1=是") + @TableField("door") + private Integer door; + + @ApiModelProperty(value = "总订单数量【未使用】") + @TableField("total") + private Integer total; + + @ApiModelProperty(value = "付款方式") + @TableField("payment") + private String payment; + + @ApiModelProperty(value = "入库状态") + @TableField("status") + private Integer status; + + @ApiModelProperty(value = "入库数量【未使用】") + @TableField("in_num") + private Integer inNum; + + @ApiModelProperty(value = "装车数量【未使用】") + @TableField("trans_num") + private Integer transNum; + + @ApiModelProperty(value = "分拣数量【未使用】") + @TableField("sorting") + private Integer sorting; + + @ApiModelProperty(value = "出库数量【未使用】") + @TableField("out_num") + private Integer outNum; + + @ApiModelProperty(value = "配送数量【未使用】") + @TableField("delive_num") + private Integer deliveNum; + + @ApiModelProperty(value = "签收数量【未使用】") + @TableField("sign_num") + private Integer signNum; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private Date createTime; + + @ApiModelProperty(value = "修改时间") + @TableField("update_time") + private Date updateTime; + + @ApiModelProperty(value = "删除时间") + @TableField("delete_time") + private Integer deleteTime; + + @ApiModelProperty(value = "创建人") + @TableField("administrators_id") + private Integer administratorsId; + + @ApiModelProperty(value = "是否异常") + @TableField("abnormal") + private Integer abnormal; + + @ApiModelProperty(value = "寄件人") + @TableField("sender") + private String sender; + + @ApiModelProperty(value = "寄件人电话") + @TableField("sender_tel") + private String senderTel; + + @ApiModelProperty(value = "寄件人地址") + @TableField("sender_address") + private String senderAddress; + + @ApiModelProperty(value = "上架状态:0未上架,1已上架,2部分上架,3已下架") + @TableField("on_shelf_type") + private Integer onShelfType; + + @ApiModelProperty(value = "旧id") + @TableField("old_id") + private Integer oldId; + + +} diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceDetailClient.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceDetailClient.java index 6a37d05fc..ec3198c37 100644 --- a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceDetailClient.java +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceDetailClient.java @@ -17,12 +17,14 @@ package com.logpm.oldproject.feign; import com.logpm.oldproject.entity.AdvanceDetailEntity; +import com.logpm.oldproject.vo.DistributionParcelListEntityVO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; import java.util.Map; /** @@ -66,4 +68,11 @@ public interface IAdvanceDetailClient { */ @GetMapping(API_PREFIX + "/getSupplyData") Map getSupplyData(@RequestParam String unitNo); + + @GetMapping(API_PREFIX + "/getOneByUnitNo") + AdvanceDetailEntity getOneByUnitNo(@RequestParam String unitNo); + + @GetMapping(API_PREFIX + "/getListByOrderSelfNum") + List getListByOrderSelfNum(@RequestParam String orderSelfNum); + } diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java new file mode 100644 index 000000000..2725b5fae --- /dev/null +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.oldproject.feign; + +import com.logpm.oldproject.entity.OrderEntity; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * 订单 Feign接口类 + * + * @author zhy + * @since 2023-06-24 + */ +@FeignClient( + value = "logpm-old-project" +) +public interface IOrderClient { + + String API_PREFIX = "/client"; + + @GetMapping(API_PREFIX + "/getOrderByOrderSelfNum") + List getOrderByOrderSelfNum(@RequestParam String orderSelfNum); + + +} diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/vo/DistributionParcelListEntityVO.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/vo/DistributionParcelListEntityVO.java new file mode 100644 index 000000000..eff4d0a1a --- /dev/null +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/vo/DistributionParcelListEntityVO.java @@ -0,0 +1,67 @@ +package com.logpm.oldproject.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class DistributionParcelListEntityVO { + + @ApiModelProperty(value = "仓库") + private String warehouse; + /** + * 状态 + */ + @ApiModelProperty(value = "状态") + private Integer conditions; + /** + * 包条码 + */ + @ApiModelProperty(value = "包条码") + private String packetBarCode; + /** + * 货位信息 + */ + @ApiModelProperty(value = "货位信息") + private String goodsAllocation; + /** + * 所在托盘 + */ + @ApiModelProperty(value = "所在托盘") + private String pallet; + /** + * 一级品 + */ + @ApiModelProperty(value = "一级品") + private String firsts; + /** + * 二级品 + */ + @ApiModelProperty(value = "二级品") + private String second; + /** + * 三级品 + */ + @ApiModelProperty(value = "三级品") + private String thirdProduct; + /** + * 物料 + */ + @ApiModelProperty(value = "物料") + private String material; + /** + * 数量 + */ + @ApiModelProperty(value = "数量") + private Integer quantity; + /** + * 车次号 + */ + @ApiModelProperty(value = "车次号") + private String trainNumber; + /** + * 在库订单ID + */ + @ApiModelProperty(value = "在库订单ID") + private String stockArticleId; + +} diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java index 7252708ce..25ea5fc26 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java @@ -16,6 +16,7 @@ */ package com.logpm.distribution.feign; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import lombok.AllArgsConstructor; import org.springblade.core.mp.support.BladePage; @@ -27,6 +28,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; +import java.util.List; + /** * 在库订单包件清单 Feign实现类 * @@ -50,4 +53,17 @@ public class DistributionParcelListClient implements IDistributionParcelListClie return BladePage.of(page); } + @Override + @GetMapping(API_PREFIX+"/findByPacketBarCode") + public DistributionParcelListEntity findByPacketBarCode(String unitNo) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("packet_bar_code",unitNo); + return distributionParcelListService.getOne(queryWrapper); + } + + @Override + public boolean addBatch(List parcelListEntityList) { + return distributionParcelListService.saveBatch(parcelListEntityList); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java index 353567e33..03637f1f4 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java @@ -50,4 +50,14 @@ public class DistributionStockArticleClient implements IDistributionStockArticle return BladePage.of(page); } + @Override + public Long addData(DistributionStockArticleEntity distributionStockArticleEntity) { + boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); + if(saveFlag){ + return distributionStockArticleEntity.getId(); + }else{ + return 0L; + } + } + } diff --git a/blade-service/logpm-factory/pom.xml b/blade-service/logpm-factory/pom.xml index 9e830d9f2..e77c72afa 100644 --- a/blade-service/logpm-factory/pom.xml +++ b/blade-service/logpm-factory/pom.xml @@ -80,6 +80,12 @@ org.springframework.boot spring-boot-starter-amqp + + org.springblade + logpm-distribution-api + 3.1.0.RELEASE + compile + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java new file mode 100644 index 000000000..5c7314161 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java @@ -0,0 +1,70 @@ +package com.logpm.factory.receiver; + +import com.logpm.factory.snm.dto.OrderStatusDTO; +import com.logpm.factory.snm.service.IPanFactoryDataService; +import com.logpm.oldproject.feign.IAdvanceDetailClient; +import com.rabbitmq.client.Channel; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.RabbitConstant; +import org.springblade.common.exception.CustomerException; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.rabbit.annotation.RabbitHandler; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.Map; + + +/** + * 获取订单数据 处理器 + * + * @author yangkai.shen + */ +@Slf4j +@RabbitListener(queues = RabbitConstant.DEAL_WITH_QUEUE) +@Component +public class DealWithDataHandler { + + @Autowired + private IAdvanceDetailClient advanceDetailClient; + @Autowired + private IPanFactoryDataService panFactoryDataService; + + private Integer retryCount = 1; + + @RabbitHandler + public void dealWithDataHandler(Map map, Message message, Channel channel) throws IOException { + // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 + final long deliveryTag = message.getMessageProperties().getDeliveryTag(); + log.info("##################我进入这里了 retryCount={}",retryCount++); + OrderStatusDTO orderStatusDTO = (OrderStatusDTO) map.get("messageData"); + String status = orderStatusDTO.getStatus(); + String unitNo = orderStatusDTO.getUnitNo(); + if("4".equals(status)){ + //继续判断是否到达目的仓 + String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id + //查询destinationWarehouse logiBillNo plantId数据 + Map supplyData = advanceDetailClient.getSupplyData(unitNo); + String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id + if(StringUtil.isBlank(currentWarehouseId)||StringUtil.isBlank(destinationWarehouseId)){ + log.warn("##############dealWithDataHandler: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId); + throw new CustomerException(405,"仓库数据有误"); + }else{ + if(!currentWarehouseId.equals(destinationWarehouseId)){ + log.info("##############dealWithDataHandler: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId); + channel.basicAck(deliveryTag,false); + }else{ + //真正的处理需要的数据 + panFactoryDataService.handleDataToPlatform(unitNo); + } + } + + }else{ + log.info("##############dealWithDataHandler: 不用处理的状态 status={}",status); + channel.basicAck(deliveryTag,false); + } + } +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 85ac72f3f..f47057ded 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -202,11 +202,13 @@ public class PanFactoryDataController extends BladeController { Map map=new HashMap<>(); map.put("messageId", CommonUtil.getUUID()); map.put("logId", panOrderStatusLog.getId()); + map.put("type", "Push"); map.put("messageData",orderStatusDTO); map.put("createTime",new Date().getTime()); //将消息携带绑定键值 - rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); - rabbitTemplate.convertAndSend(RabbitConstant.DEAL_WITH_EXCHANGE, RabbitConstant.DEAL_WITH_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); + rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); + map.put("type", "DealWith"); + rabbitTemplate.convertAndSend(RabbitConstant.DEAL_WITH_EXCHANGE, RabbitConstant.DEAL_WITH_ROUTING,map); // R r = factoryDataService.handleStatusData(orderStatusDTO); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanFactoryDataService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanFactoryDataService.java index 09bd2788a..003238c1d 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanFactoryDataService.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanFactoryDataService.java @@ -14,4 +14,7 @@ public interface IPanFactoryDataService { R handleData(OrderInfoDTO orderInfoDTO); R handleStatusData(OrderStatusDTO orderStatusDTO); + + void handleDataToPlatform(String unitNo); + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java index 8d4196e51..66b22e945 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java @@ -1,10 +1,15 @@ package com.logpm.factory.snm.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.alibaba.nacos.shaded.com.google.gson.GsonBuilder; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; +import com.logpm.distribution.feign.IDistributionParcelListClient; +import com.logpm.distribution.feign.IDistributionStockArticleClient; import com.logpm.factory.props.PanFactoryProperties; import com.logpm.factory.snm.bean.Resp; import com.logpm.factory.snm.dto.OrderInfoDTO; @@ -15,8 +20,14 @@ import com.logpm.factory.snm.service.IPanFactoryDataService; import com.logpm.factory.snm.service.IPanFactoryOrderService; import com.logpm.factory.snm.service.IPanOrderStatusLogService; import com.logpm.factory.snm.service.IPanPackageInfoService; +import com.logpm.oldproject.entity.AdvanceDetailEntity; +import com.logpm.oldproject.entity.AdvanceEntity; +import com.logpm.oldproject.entity.OrderEntity; +import com.logpm.oldproject.feign.IAdvanceClient; import com.logpm.oldproject.feign.IAdvanceDetailClient; +import com.logpm.oldproject.feign.IOrderClient; import com.logpm.oldproject.feign.IWarehouseClient; +import com.logpm.oldproject.vo.DistributionParcelListEntityVO; import lombok.AllArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,9 +37,7 @@ import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; @AllArgsConstructor @Service @@ -47,6 +56,11 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { private final IPanFactoryOrderService panFactoryOrderService; private final IAdvanceDetailClient advanceDetailClient; private final IWarehouseClient warehouseClient; + private final IOrderClient orderClient; + private final IAdvanceClient advanceClient; + + private final IDistributionParcelListClient distributionParcelListClient; + private final IDistributionStockArticleClient distributionStockArticleClient; // @Override // public FactoryTokenVO getToken(String corpId, String appKey, String appSecret) throws NoSuchAlgorithmException { @@ -234,7 +248,6 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { return Resp.success("SUCCESS"); } - private String getPanToken(){ Map map = new HashMap<>(); map.put("client_id",panFactoryProperties.getClientId()); @@ -260,4 +273,86 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { } + @Transactional + @Override + public void handleDataToPlatform(String unitNo) { + logger.info("############handleDataToPlatform: 处理数据到platform unitNo={}",unitNo); + //先查询包件是否已存入到新系统数据库 + DistributionParcelListEntity distributionParcelListEntity = distributionParcelListClient.findByPacketBarCode(unitNo); + if(Objects.isNull(distributionParcelListEntity)){ + //未找到包件信息那就去新增 + //1.根据包条码去老系统数据库找到对应的包条信息 + AdvanceDetailEntity advanceDetailEntity = advanceDetailClient.getOneByUnitNo(unitNo); + if(Objects.isNull(advanceDetailEntity)){ + logger.warn("#################handleDataToPlatform: 未找到对应的包条信息 unitNo={}",unitNo); + throw new CustomerException(405,"未找到对应的包条信息"); + } + //2.根据包条信息拿到订单信息 + String orderSelfNum = advanceDetailEntity.getOrderSelfNum();//订单自编码 + //2.1如果订单信息出现两条,就正序排列取时间最早的一条,并在存入platform的时候打上标记 + List orderEntityList = orderClient.getOrderByOrderSelfNum(orderSelfNum); + AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderSelfNum); + if(Objects.isNull(advanceEntity)){ + logger.warn("#################handleDataToPlatform: 未找到对应的订单信息 orderSelfNum={}",orderSelfNum); + throw new CustomerException(405,"未找到对应的订单信息"); + } + int size = orderEntityList.size();//数据数量 + if(size < 1){ + logger.warn("#################handleDataToPlatform: 未找到对应的订单信息 orderSelfNum={}",orderSelfNum); + throw new CustomerException(405,"未找到对应的订单信息"); + } + OrderEntity orderEntity = orderEntityList.get(0); + Integer warehouseId = orderEntity.getWarehouseId();//仓库id + //根据仓库id查询仓库 + String warehouseName = warehouseClient.selectNameById(warehouseId); + + DistributionStockArticleEntity distributionStockArticleEntity = new DistributionStockArticleEntity(); + distributionStockArticleEntity.setServiceNumber(orderEntity.getServicenum()); + distributionStockArticleEntity.setOrderSelfNumbering(orderEntity.getSelfnumber()); + distributionStockArticleEntity.setMallName(advanceEntity.getStoreName()); + distributionStockArticleEntity.setDescriptionGoods(advanceEntity.getFirstPackName()); + distributionStockArticleEntity.setWarehouse(warehouseName); + distributionStockArticleEntity.setWarehouseEntryTime(null);//TODO 入库时间没找到 + distributionStockArticleEntity.setStoreTime(0);//TODO + distributionStockArticleEntity.setTotalNumber(advanceEntity.getTotal()); + distributionStockArticleEntity.setHandQuantity(0);//TODO + distributionStockArticleEntity.setCompleteSet(1);//TODO + distributionStockArticleEntity.setBrand(advanceEntity.getType()); + distributionStockArticleEntity.setTypeService(orderEntity.getDoor()); + distributionStockArticleEntity.setCustomerName(orderEntity.getContact()); + distributionStockArticleEntity.setCustomerTelephone(orderEntity.getPhone()); + distributionStockArticleEntity.setCustomerAddress(orderEntity.getAddress()); + distributionStockArticleEntity.setGenre(2); + distributionStockArticleEntity.setState(2); + if(size > 1){ + distributionStockArticleEntity.setReserve1("multiple"); + } + Long id = distributionStockArticleClient.addData(distributionStockArticleEntity); + if(id == 0){ + logger.warn("#################handleDataToPlatform: 保存订单信息失败 orderSelfNum={}",orderSelfNum); + throw new CustomerException(405,"保存订单信息失败"); + } + //通过订单自编号查询包件信息 + List detailList = advanceDetailClient.getListByOrderSelfNum(orderSelfNum); + + List parcelListEntityList = new ArrayList<>(); + for (DistributionParcelListEntityVO vo:detailList){ + DistributionParcelListEntity entity = new DistributionParcelListEntity(); + BeanUtil.copyProperties(vo,entity); + entity.setStockArticleId(id+""); + parcelListEntityList.add(entity); + } + boolean b = distributionParcelListClient.addBatch(parcelListEntityList); + if(!b){ + logger.warn("#################handleDataToPlatform: 保存包件信息失败 orderSelfNum={}",orderSelfNum); + throw new CustomerException(405,"保存包件信息失败"); + } + + logger.info("#################handleDataToPlatform: 数据处理完成"); + }else{ + //已存在包件信息那就不处理 + logger.info("#################handleDataToPlatform: 包件信息已存在,不用处理 unitNo={}",unitNo); + } + } + } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/AdvanceDetailClient.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/AdvanceDetailClient.java index 60097cf6e..c62a7d50a 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/AdvanceDetailClient.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/AdvanceDetailClient.java @@ -18,12 +18,14 @@ package com.logpm.oldproject.feign; import com.logpm.oldproject.entity.AdvanceDetailEntity; import com.logpm.oldproject.service.IAdvanceDetailService; +import com.logpm.oldproject.vo.DistributionParcelListEntityVO; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; +import java.util.List; import java.util.Map; /** @@ -66,4 +68,16 @@ public class AdvanceDetailClient implements IAdvanceDetailClient { return map; } + @Override + @GetMapping(API_PREFIX + "/getOneByUnitNo") + public AdvanceDetailEntity getOneByUnitNo(String unitNo) { + //查询对应的包件信息 + return advanceDetailService.getOneByUnitNo(unitNo); + } + + @Override + public List getListByOrderSelfNum(String orderSelfNum) { + return advanceDetailService.getListByOrderSelfNum(orderSelfNum); + } + } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java new file mode 100644 index 000000000..be6e55042 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.oldproject.feign; + +import com.logpm.oldproject.entity.OrderEntity; +import com.logpm.oldproject.service.IOrderService; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; + +/** + * order Feign实现类 + * + * @author zhy + * @since 2023-06-24 + */ +@ApiIgnore() +@RestController +@AllArgsConstructor +public class OrderClient implements IOrderClient { + + private IOrderService orderService; + + @Override + public List getOrderByOrderSelfNum(String orderSelfNum) { + return orderService.getOrderByOrderSelfNum(orderSelfNum); + } +} diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.java index d4f3eb109..c37da4ec0 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.java @@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.oldproject.entity.AdvanceDetailEntity; import com.logpm.oldproject.vo.AdvanceDetailVO; +import com.logpm.oldproject.vo.DistributionParcelListEntityVO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -50,4 +51,7 @@ public interface AdvanceDetailMapper extends BaseMapper { Boolean addAll(@Param("param") AdvanceDetailEntity advanceDetailEntity); Map getSupplyData(@Param("unitNo") String unitNo); + + List getListByOrderSelfNum(@Param("orderSelfNum") String orderSelfNum); + } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.xml b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.xml index 5f3f110ae..2598c9b97 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.xml +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/AdvanceDetailMapper.xml @@ -78,7 +78,8 @@ + + + diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java new file mode 100644 index 000000000..4fc4849f1 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.oldproject.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.oldproject.entity.OrderEntity; + +/** + * 订单 Mapper 接口 + * + * @author zhy + * @since 2023-06-24 + */ +public interface OrderMapper extends BaseMapper { + + +} diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml new file mode 100644 index 000000000..ebb7cb43e --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IAdvanceDetailService.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IAdvanceDetailService.java index a17098c74..ef9ea212a 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IAdvanceDetailService.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IAdvanceDetailService.java @@ -17,7 +17,9 @@ package com.logpm.oldproject.service; import com.logpm.oldproject.entity.AdvanceDetailEntity; +import com.logpm.oldproject.vo.DistributionParcelListEntityVO; +import java.util.List; import java.util.Map; /** @@ -32,4 +34,9 @@ public interface IAdvanceDetailService { Boolean addAdvanceDetail(AdvanceDetailEntity advanceDetailEntity); Map getSupplyData(String unitNo); + + AdvanceDetailEntity getOneByUnitNo(String unitNo); + + List getListByOrderSelfNum(String orderSelfNum); + } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java new file mode 100644 index 000000000..ba76f2798 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java @@ -0,0 +1,11 @@ +package com.logpm.oldproject.service; + +import com.logpm.oldproject.entity.OrderEntity; + +import java.util.List; + +public interface IOrderService { + + List getOrderByOrderSelfNum(String orderSelfNum); + +} diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/AdvanceDetailServiceImpl.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/AdvanceDetailServiceImpl.java index 2d4257d82..fbc6f6779 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/AdvanceDetailServiceImpl.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/AdvanceDetailServiceImpl.java @@ -16,12 +16,15 @@ */ package com.logpm.oldproject.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.logpm.oldproject.entity.AdvanceDetailEntity; import com.logpm.oldproject.mapper.AdvanceDetailMapper; import com.logpm.oldproject.service.IAdvanceDetailService; +import com.logpm.oldproject.vo.DistributionParcelListEntityVO; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Map; /** @@ -49,5 +52,17 @@ public class AdvanceDetailServiceImpl implements IAdvanceDetailService { return map; } + @Override + public AdvanceDetailEntity getOneByUnitNo(String unitNo) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("unitNo",unitNo); + return advanceDetailMapper.selectOne(queryWrapper); + } + + @Override + public List getListByOrderSelfNum(String orderSelfNum) { + return advanceDetailMapper.getListByOrderSelfNum(orderSelfNum); + } + } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java new file mode 100644 index 000000000..c6fee8115 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java @@ -0,0 +1,25 @@ +package com.logpm.oldproject.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.oldproject.entity.OrderEntity; +import com.logpm.oldproject.mapper.OrderMapper; +import com.logpm.oldproject.service.IOrderService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@AllArgsConstructor +public class OrderServiceImpl implements IOrderService { + + private OrderMapper orderMapper; + + @Override + public List getOrderByOrderSelfNum(String orderSelfNum) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("selfnumber",orderSelfNum) + .orderByAsc("create_time"); + return orderMapper.selectList(queryWrapper); + } +} From 8ae06e25b2c1b5f1ea6d45e2b21046cfbe1ab4d3 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Sat, 24 Jun 2023 12:43:06 +0800 Subject: [PATCH 08/11] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E7=9A=AE=E9=98=BF?= =?UTF-8?q?=E8=AF=BA=20=E6=95=B0=E6=8D=AE=E6=8E=A8=E9=80=81=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=95=B0=E6=8D=AE=202.=E5=A2=9E=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=AE=E9=98=BF=E8=AF=BA=E6=95=B0=E6=8D=AE=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=8E=A5=E5=8F=A3=E8=AE=A2=E5=8D=95=E8=87=AA=E7=BC=96?= =?UTF-8?q?=E5=8F=B7=E9=87=8D=E5=A4=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/logpm/factory/snm/bean/Resp.java | 12 +++++++++++- .../snm/controller/PanFactoryDataController.java | 14 +++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/bean/Resp.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/bean/Resp.java index 8ff501472..3e7383b06 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/bean/Resp.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/bean/Resp.java @@ -7,13 +7,23 @@ import org.springblade.core.tool.api.R; public class Resp extends R { private String orderNo; + private String deliveryNumber; - public static Resp successOrderNo(String orderNo,String msg){ + public static Resp successOrderNo(String orderNo,String deliveryNumber,String msg){ Resp resp = new Resp(); resp.setMsg(msg); resp.setCode(1); resp.setSuccess(true); resp.setOrderNo(orderNo); + resp.setDeliveryNumber(deliveryNumber); + return resp; + } + + public static Resp fail(int code,String message){ + Resp resp = new Resp(); + resp.setMsg(message); + resp.setCode(code); + resp.setSuccess(false); return resp; } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 92ee6f8d7..3c134eaaf 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -18,6 +18,7 @@ package com.logpm.factory.snm.controller; import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.factory.snm.bean.Resp; import com.logpm.factory.snm.dto.*; @@ -39,6 +40,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * 皮阿诺数据 控制器 @@ -106,6 +108,16 @@ public class PanFactoryDataController extends BladeController { panOrderStatusLog.setType(3); panOrderStatusLogService.save(panOrderStatusLog); + //判断数据是否已存入 + String orderNo = factoryOrderDTO.getOrderNo(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("order_no",orderNo); + PanFactoryOrder one = factoryOrderService.getOne(queryWrapper); + if(!Objects.isNull(one)){ + log.warn("############data: 订单数据已存在 orderNo={}",orderNo); + return Resp.fail(400,"订单数据已存在"); + } + PanFactoryOrder factoryOrder = new PanFactoryOrder(); BeanUtil.copyProperties(factoryOrderDTO,factoryOrder); factoryOrder.setCorpid(corpId); @@ -141,7 +153,7 @@ public class PanFactoryDataController extends BladeController { //开启异步线程处理数据 syncDataService.handlerPanDataToHt(); - return Resp.successOrderNo(factoryOrder.getOrderNo(),"SUCCESS"); + return Resp.successOrderNo(factoryOrder.getOrderNo(),factoryOrder.getDeliveryNumber(),"SUCCESS"); } From c3df130e0b608d1da3ac63735f68f1ae16b5f077 Mon Sep 17 00:00:00 2001 From: kilo Date: Sun, 25 Jun 2023 10:59:15 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E9=A2=84=E7=BA=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basicdata/feign/IBasicdataGoodsAreaClient.java | 2 +- .../entity/DistributionReservationEntity.java | 10 +++++----- .../controller/BasicdataWarehouseController.java | 3 ++- .../controller/DistributionReservationController.java | 1 - .../mapper/DistributionReservationMapper.xml | 2 +- .../impl/DistributionReservationServiceImpl.java | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAreaClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAreaClient.java index 4a0b333f1..388e48ea3 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAreaClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAreaClient.java @@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam; ) public interface IBasicdataGoodsAreaClient { - String API_PREFIX = "/client"; + String API_PREFIX = "goodsArea/client"; String TOP = API_PREFIX + "/top"; /** diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationEntity.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationEntity.java index 36486ba95..cac2448ed 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationEntity.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionReservationEntity.java @@ -119,11 +119,11 @@ public class DistributionReservationEntity extends TenantEntity { */ @ApiModelProperty(value = "备注") private String remarks; - /** - * 预约单编号,系统构建生成 - */ - @ApiModelProperty(value = "预约单编号") - private String reservationId; +// /** +// * 预约单编号,系统构建生成 +// */ +// @ApiModelProperty(value = "预约单编号") +// private String reservationId; /** * 时段 */ diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataWarehouseController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataWarehouseController.java index 89303f9f3..f2186145a 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataWarehouseController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataWarehouseController.java @@ -30,6 +30,7 @@ import javax.validation.Valid; import org.springblade.core.secure.BladeUser; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -84,6 +85,7 @@ public class BasicdataWarehouseController extends BladeController { qw .apply(startDate != null,"date_format (start_date,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')",startDate) .apply(endDate != null,"date_format (end_date,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')",endDate); + qw.lambda().eq(BasicdataWarehouseEntity::getTenantId, AuthUtil.getTenantId()); IPage page = warehouseService.page(Condition.getPage(query), qw); // IPage pages = warehouseService.page(Condition.getPage(query), Condition.getQueryWrapper(warehouseWarehouse, BasicdataWarehouseEntity.class)); return R.data(page); @@ -97,7 +99,6 @@ public class BasicdataWarehouseController extends BladeController { @ApiOperation(value = "分页", notes = "传入warehouseWarehouse") public R> listName(String name) { List pages = warehouseService.pageListName(name); - return R.data(pages); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionReservationController.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionReservationController.java index 069c15c9e..d605bafee 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionReservationController.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionReservationController.java @@ -100,7 +100,6 @@ public class DistributionReservationController extends BladeController { @ApiOperationSupport(order = 4) @ApiOperation(value = "新增", notes = "传入distrbutionReservation") public R save(@Valid @RequestBody DistributionReservationDTO distributionReservationDTO) { - boolean result = reservationService.insertReservation(distributionReservationDTO); return R.status(result); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml index c61a98f70..40c283da8 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml @@ -28,7 +28,7 @@ - + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java index 5e8969b91..37d42f40f 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java @@ -205,6 +205,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl Date: Sun, 25 Jun 2023 12:49:21 +0800 Subject: [PATCH 10/11] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E6=A2=A6=E5=A4=A9?= =?UTF-8?q?=E5=B7=A5=E5=8E=82=E5=AF=B9=E6=8E=A5=E6=95=B0=E6=8D=AE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../factory/snm/entity/MtFactoryOrder.java | 81 ++++++++++++ .../snm/entity/MtFactoryOrderMain.java | 57 ++++++++ .../factory/snm/entity/MtPackageInfo.java | 54 ++++++++ ...rderStatusLog.java => OrderStatusLog.java} | 8 +- .../controller/MtFactoryDataController.java | 124 ++++++++++++++++++ .../factory/mt/dto/MtFactoryDataDTO.java | 18 +++ .../factory/mt/dto/MtFactoryOrderDTO.java | 18 +++ .../factory/mt/dto/MtPackageInfoDTO.java | 10 ++ .../controller/PanFactoryDataController.java | 6 +- .../snm/mapper/MtFactoryOrderMainMapper.java | 7 + .../snm/mapper/MtFactoryOrderMainMapper.xml | 20 +++ ...gMapper.java => OrderStatusLogMapper.java} | 4 +- ...LogMapper.xml => OrderStatusLogMapper.xml} | 2 +- .../snm/service/IMtFactoryDataService.java | 12 ++ .../service/IMtFactoryOrderMainService.java | 8 ++ .../snm/service/IOrderStatusLogService.java | 8 ++ .../service/IPanOrderStatusLogService.java | 8 -- .../impl/MtFactoryDataServiceImpl.java | 39 ++++++ .../impl/MtFactoryOrderMainServiceImpl.java | 15 +++ .../impl/OrderStatusLogServiceImpl.java | 19 +++ .../impl/PanFactoryDataServiceImpl.java | 10 +- .../impl/PanOrderStatusLogServiceImpl.java | 19 --- 22 files changed, 506 insertions(+), 41 deletions(-) create mode 100644 blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrder.java create mode 100644 blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrderMain.java create mode 100644 blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtPackageInfo.java rename blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/{PanOrderStatusLog.java => OrderStatusLog.java} (62%) create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/controller/MtFactoryDataController.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryDataDTO.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryOrderDTO.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtPackageInfoDTO.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.xml rename blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/{PanOrderStatusLogMapper.java => OrderStatusLogMapper.java} (88%) rename blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/{PanOrderStatusLogMapper.xml => OrderStatusLogMapper.xml} (93%) create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryDataService.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryOrderMainService.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IOrderStatusLogService.java delete mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanOrderStatusLogService.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryDataServiceImpl.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryOrderMainServiceImpl.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/OrderStatusLogServiceImpl.java delete mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanOrderStatusLogServiceImpl.java diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrder.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrder.java new file mode 100644 index 000000000..9ae20bf49 --- /dev/null +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrder.java @@ -0,0 +1,81 @@ +package com.logpm.factory.snm.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +@Data +@TableName("mt_factory_order") +@ApiModel(value = "MtFactoryOrder对象", description = "梦天工厂订单") +@EqualsAndHashCode(callSuper = true) +public class MtFactoryOrder extends BaseEntity { + + @JsonProperty("总单编号") + @ApiModelProperty(value = "总单编号") + private String mainOrderCode; + + @JsonProperty("订单编号") + @ApiModelProperty(value = "订单编号") + private String orderCode; + + @JsonProperty("客户姓名") + @ApiModelProperty(value = "客户姓名") + private String customName; + + @JsonProperty("客户电话") + @ApiModelProperty(value = "客户电话") + private String customPhone; + + @JsonProperty("客户地址") + @ApiModelProperty(value = "客户地址") + private String customAddress; + + @JsonProperty("经销商编号") + @ApiModelProperty(value = "经销商编码") + private String dealerCode; + + @JsonProperty("经销商名称") + @ApiModelProperty(value = "经销商名称") + private String dealerName; + + @JsonProperty("专卖店编号") + @ApiModelProperty(value = "专卖店编号") + private String exclusiveCode; + + @JsonProperty("专卖店名称") + @ApiModelProperty(value = "专卖店名称") + private String exclusiveName; + + @JsonProperty("收货人") + @ApiModelProperty(value = "收货人") + private String consignee; + + @JsonProperty("收货人电话") + @ApiModelProperty(value = "收货人电话") + private String consigneePhone; + + @JsonProperty("收货地址") + @ApiModelProperty(value = "收货人地址") + private String consigneeAddress; + + @JsonProperty("出库方式") + @ApiModelProperty(value = "出库方式") + private String outboundType; + + @JsonProperty("品牌") + @ApiModelProperty(value = "品牌") + private String brand; + + @JsonProperty("生产单号") + @ApiModelProperty(value = "生产单号") + private String produceOrderCode; + + @JsonProperty("包件数") + @ApiModelProperty(value = "包件数") + private String quantity; + +} diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrderMain.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrderMain.java new file mode 100644 index 000000000..7f778932e --- /dev/null +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtFactoryOrderMain.java @@ -0,0 +1,57 @@ +package com.logpm.factory.snm.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +@Data +@TableName("mt_factory_order_main") +@ApiModel(value = "MtFactoryOrderMain对象", description = "梦天工厂订单主对象") +@EqualsAndHashCode(callSuper = true) +public class MtFactoryOrderMain extends BaseEntity { + + @JsonProperty("发货单编号") + @ApiModelProperty(value = "发货单编号") + private String invoiceOrderCode; + + @JsonProperty("中心仓编号") + @ApiModelProperty(value = "中心仓编号") + private String centerWarehouseCode; + + @JsonProperty("中心仓") + @ApiModelProperty(value = "中心仓") + private String centerWarehouseName; + + @JsonProperty("仓库类型") + @ApiModelProperty(value = "仓库类型") + private String warehouseType; + + @JsonProperty("送货车号") + @ApiModelProperty(value = "送货车号") + private String sendCarNumber; + + @JsonProperty("送货司机") + @ApiModelProperty(value = "送货车司机") + private String sendCarDriver; + + @JsonProperty("送货司机电话") + @ApiModelProperty(value = "送货车司机电话") + private String sendCarDriverPhone; + + @JsonProperty("确认发车人") + @ApiModelProperty(value = "确认发车人") + private String reallyMan; + + @JsonProperty("确认发车时间") + @ApiModelProperty(value = "确认发车时间") + private String reallyDate; + + @JsonProperty("备注") + @ApiModelProperty(value = "备注") + private String remark; + +} diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtPackageInfo.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtPackageInfo.java new file mode 100644 index 000000000..1d7c812ad --- /dev/null +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/MtPackageInfo.java @@ -0,0 +1,54 @@ +package com.logpm.factory.snm.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +@Data +@TableName("mt_package_info") +@ApiModel(value = "MtPackageInfo对象", description = "梦天工厂包件信息") +@EqualsAndHashCode(callSuper = true) +public class MtPackageInfo extends BaseEntity { + + + @JsonProperty("出库人") + @ApiModelProperty(value = "出库人") + private String outboundMan; + + @JsonProperty("出库时间") + @ApiModelProperty(value = "出库时间") + private String outboundDate; + + @JsonProperty("包装编号") + @ApiModelProperty(value = "包装编号") + private String packageCode; + + @JsonProperty("包装类型") + @ApiModelProperty(value = "包装类型") + private String packageType; + + @JsonProperty("大类") + @ApiModelProperty(value = "大类") + private String bigType; + + @JsonProperty("小类") + @ApiModelProperty(value = "小类") + private String smallType; + + @JsonProperty("油漆颜色") + @ApiModelProperty(value = "油漆颜色") + private String color; + + @JsonProperty("型号") + @ApiModelProperty(value = "型号") + private String model; + + @JsonProperty("门扇尺寸") + @ApiModelProperty(value = "尺寸") + private String size; + +} diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanOrderStatusLog.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/OrderStatusLog.java similarity index 62% rename from blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanOrderStatusLog.java rename to blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/OrderStatusLog.java index 9367fde74..e6474eac4 100644 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/PanOrderStatusLog.java +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/snm/entity/OrderStatusLog.java @@ -7,13 +7,15 @@ import lombok.EqualsAndHashCode; import org.springblade.core.mp.base.BaseEntity; @Data -@TableName("pan_order_status_log") -@ApiModel(value = "PanOrderStatusLog对象", description = "皮艾诺订单状态日志") +@TableName("order_status_log") +@ApiModel(value = "OrderStatusLog对象", description = "工厂订单状态日志") @EqualsAndHashCode(callSuper = true) -public class PanOrderStatusLog extends BaseEntity { +public class OrderStatusLog extends BaseEntity { private String args; private Integer type; + private String brand;//品牌 + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/controller/MtFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/controller/MtFactoryDataController.java new file mode 100644 index 000000000..b153d4b44 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/controller/MtFactoryDataController.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.factory.mt.controller; + +import com.alibaba.fastjson.JSONObject; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.factory.mt.dto.MtFactoryDataDTO; +import com.logpm.factory.snm.bean.Resp; +import com.logpm.factory.snm.entity.OrderStatusLog; +import com.logpm.factory.snm.service.IMtFactoryDataService; +import com.logpm.factory.snm.service.IOrderStatusLogService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; + +/** + * 梦天数据 控制器 + * + * @author zhy + * @since 2023-06-06 + */ +@Log4j2 +@RestController +@AllArgsConstructor +@RequestMapping("/factory/mt") +@Api(value = "工厂数据", tags = "工厂数据接口") +public class MtFactoryDataController extends BladeController { + + private final IOrderStatusLogService orderStatusLogService; + private final IMtFactoryDataService mtFactoryDataService; + + /** + * 工厂数据推送接口 + */ + @ResponseBody + @PostMapping("/data") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "通常数据推送", notes = "传入factoryOrderDTO") + public R data(@Validated @RequestBody MtFactoryDataDTO mtFactoryDataDTO, HttpServletRequest request) { + log.info("############data: "); + String corpId = request.getHeader("corpId"); + + //先保存原始请求数据 + OrderStatusLog orderStatusLog = new OrderStatusLog(); + orderStatusLog.setArgs(JSONObject.toJSONString(mtFactoryDataDTO)); + orderStatusLog.setStatus(1); + orderStatusLog.setType(3); + orderStatusLog.setBrand("梦天"); + orderStatusLogService.save(orderStatusLog); + + //数据存入数据库 + boolean flag = mtFactoryDataService.dealWithData(mtFactoryDataDTO); + + +// //判断数据是否已存入 +// String orderNo = factoryOrderDTO.getOrderNo(); +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("order_no",orderNo); +// PanFactoryOrder one = factoryOrderService.getOne(queryWrapper); +// if(!Objects.isNull(one)){ +// log.warn("############data: 订单数据已存在 orderNo={}",orderNo); +// return Resp.fail(400,"订单数据已存在"); +// } +// +// PanFactoryOrder factoryOrder = new PanFactoryOrder(); +// BeanUtil.copyProperties(factoryOrderDTO,factoryOrder); +// factoryOrder.setCorpid(corpId); +// //保存订单数据 +// factoryOrderService.save(factoryOrder); +// +// List packageInfos = factoryOrderDTO.getORDER_ATTRIBUTES(); +// +// for (PanPackageInfoDTO dto:packageInfos){ +// PanPackageInfo packageInfo = new PanPackageInfo(); +// BeanUtil.copyProperties(dto,packageInfo); +// packageInfo.setOrderId(factoryOrder.getId()); +// //保存包件信息数据 +// //因为需要先保存包件明细需要包件的id +// packageInfoService.save(packageInfo); +// +// //再存入包件明细 +// List PanPackagelist = new ArrayList<>(); +// List order_attributes_line = dto.getORDER_ATTRIBUTES_LINE(); +// for (PanPackageListDTO panPackageListDTO:order_attributes_line){ +// PanPackageList panPackageList = new PanPackageList(); +// BeanUtil.copyProperties(panPackageListDTO,panPackageList); +// panPackageList.setPackageId(packageInfo.getId()); +// PanPackagelist.add(panPackageList); +// } +// packageListService.saveBatch(PanPackagelist); +// } +// +// //修改保存数据的状态 +// panOrderStatusLog.setStatus(0); +// panOrderStatusLogService.saveOrUpdate(panOrderStatusLog); +// +// //开启异步线程处理数据 +// syncDataService.handlerPanDataToHt(); + + return Resp.fail(400,"fail"); + } + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryDataDTO.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryDataDTO.java new file mode 100644 index 000000000..a737cd87d --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryDataDTO.java @@ -0,0 +1,18 @@ +package com.logpm.factory.mt.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.logpm.factory.snm.entity.MtFactoryOrderMain; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.ArrayList; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class MtFactoryDataDTO extends MtFactoryOrderMain { + + @JsonProperty("发货单明细") + private List orderList = new ArrayList<>(); + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryOrderDTO.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryOrderDTO.java new file mode 100644 index 000000000..cc59e95a2 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtFactoryOrderDTO.java @@ -0,0 +1,18 @@ +package com.logpm.factory.mt.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.logpm.factory.snm.entity.MtFactoryOrder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.ArrayList; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class MtFactoryOrderDTO extends MtFactoryOrder { + + @JsonProperty("包装明细") + private List packageInfos = new ArrayList<>(); + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtPackageInfoDTO.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtPackageInfoDTO.java new file mode 100644 index 000000000..35eef1c9a --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/dto/MtPackageInfoDTO.java @@ -0,0 +1,10 @@ +package com.logpm.factory.mt.dto; + +import com.logpm.factory.snm.entity.MtPackageInfo; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class MtPackageInfoDTO extends MtPackageInfo { +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 3c134eaaf..b425f7564 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -23,7 +23,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.factory.snm.bean.Resp; import com.logpm.factory.snm.dto.*; import com.logpm.factory.snm.entity.PanFactoryOrder; -import com.logpm.factory.snm.entity.PanOrderStatusLog; +import com.logpm.factory.snm.entity.OrderStatusLog; import com.logpm.factory.snm.entity.PanPackageInfo; import com.logpm.factory.snm.entity.PanPackageList; import com.logpm.factory.snm.service.*; @@ -60,7 +60,7 @@ public class PanFactoryDataController extends BladeController { private final IPanPackageListService packageListService; private final IPanFactoryDataService factoryDataService; private final IAsyncDataService syncDataService; - private final IPanOrderStatusLogService panOrderStatusLogService; + private final IOrderStatusLogService panOrderStatusLogService; // @ResponseBody // @PostMapping("/token") @@ -102,7 +102,7 @@ public class PanFactoryDataController extends BladeController { String corpId = request.getHeader("corpId"); //先保存原始请求数据 - PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); + OrderStatusLog panOrderStatusLog = new OrderStatusLog(); panOrderStatusLog.setArgs(JSONObject.toJSONString(factoryOrderDTO)); panOrderStatusLog.setStatus(1); panOrderStatusLog.setType(3); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.java new file mode 100644 index 000000000..5be6cb8c7 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.java @@ -0,0 +1,7 @@ +package com.logpm.factory.snm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factory.snm.entity.MtFactoryOrderMain; + +public interface MtFactoryOrderMainMapper extends BaseMapper { +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.xml b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.xml new file mode 100644 index 000000000..5093c771a --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/MtFactoryOrderMainMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/PanOrderStatusLogMapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/OrderStatusLogMapper.java similarity index 88% rename from blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/PanOrderStatusLogMapper.java rename to blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/OrderStatusLogMapper.java index 231109f40..04b6b31b1 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/PanOrderStatusLogMapper.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/OrderStatusLogMapper.java @@ -17,7 +17,7 @@ package com.logpm.factory.snm.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.logpm.factory.snm.entity.PanOrderStatusLog; +import com.logpm.factory.snm.entity.OrderStatusLog; /** * 工厂推送数据接口日志 Mapper 接口 @@ -25,7 +25,7 @@ import com.logpm.factory.snm.entity.PanOrderStatusLog; * @author zhy * @since 2023-03-28 */ -public interface PanOrderStatusLogMapper extends BaseMapper { +public interface OrderStatusLogMapper extends BaseMapper { } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/PanOrderStatusLogMapper.xml b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/OrderStatusLogMapper.xml similarity index 93% rename from blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/PanOrderStatusLogMapper.xml rename to blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/OrderStatusLogMapper.xml index ce887dc99..3e4056f86 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/PanOrderStatusLogMapper.xml +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/mapper/OrderStatusLogMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryDataService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryDataService.java new file mode 100644 index 000000000..f0d37d1ce --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryDataService.java @@ -0,0 +1,12 @@ +package com.logpm.factory.snm.service; + +import com.logpm.factory.mt.dto.MtFactoryDataDTO; + +/** + * 工厂推送数据接口 + */ +public interface IMtFactoryDataService { + + boolean dealWithData(MtFactoryDataDTO mtFactoryDataDTO); + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryOrderMainService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryOrderMainService.java new file mode 100644 index 000000000..e44d9a8b2 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IMtFactoryOrderMainService.java @@ -0,0 +1,8 @@ +package com.logpm.factory.snm.service; + +import com.logpm.factory.snm.entity.MtFactoryOrderMain; +import org.springblade.core.mp.base.BaseService; + +public interface IMtFactoryOrderMainService extends BaseService { + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IOrderStatusLogService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IOrderStatusLogService.java new file mode 100644 index 000000000..2c0de1db6 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IOrderStatusLogService.java @@ -0,0 +1,8 @@ +package com.logpm.factory.snm.service; + +import com.logpm.factory.snm.entity.OrderStatusLog; +import org.springblade.core.mp.base.BaseService; + +public interface IOrderStatusLogService extends BaseService { + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanOrderStatusLogService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanOrderStatusLogService.java deleted file mode 100644 index d4c4bf09b..000000000 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/IPanOrderStatusLogService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.logpm.factory.snm.service; - -import com.logpm.factory.snm.entity.PanOrderStatusLog; -import org.springblade.core.mp.base.BaseService; - -public interface IPanOrderStatusLogService extends BaseService { - -} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryDataServiceImpl.java new file mode 100644 index 000000000..ca983967d --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryDataServiceImpl.java @@ -0,0 +1,39 @@ +package com.logpm.factory.snm.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.factory.mt.dto.MtFactoryDataDTO; +import com.logpm.factory.snm.entity.MtFactoryOrderMain; +import com.logpm.factory.snm.service.IMtFactoryDataService; +import com.logpm.factory.snm.service.IMtFactoryOrderMainService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Objects; + +@Slf4j +@Service +@AllArgsConstructor +public class MtFactoryDataServiceImpl implements IMtFactoryDataService { + + private final IMtFactoryOrderMainService mtFactoryOrderMainService; + + @Transactional + @Override + public boolean dealWithData(MtFactoryDataDTO mtFactoryDataDTO) { + log.info("#############dealWithData: 处理梦天工厂数据 开始"); + String invoiceOrderCode = mtFactoryDataDTO.getInvoiceOrderCode();//发货单编码 + //先判断该发货单编码是否已经存在 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("invoice_order_code",invoiceOrderCode); + MtFactoryOrderMain mtFactoryOrderMain = mtFactoryOrderMainService.getOne(queryWrapper); + if(Objects.isNull(mtFactoryOrderMain)){ + + } + + + + return false; + } +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryOrderMainServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryOrderMainServiceImpl.java new file mode 100644 index 000000000..cc557b5bb --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/MtFactoryOrderMainServiceImpl.java @@ -0,0 +1,15 @@ +package com.logpm.factory.snm.service.impl; + +import com.logpm.factory.snm.entity.MtFactoryOrderMain; +import com.logpm.factory.snm.mapper.MtFactoryOrderMainMapper; +import com.logpm.factory.snm.service.IMtFactoryOrderMainService; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +@AllArgsConstructor +@Service +public class MtFactoryOrderMainServiceImpl extends BaseServiceImpl implements IMtFactoryOrderMainService { + + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/OrderStatusLogServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/OrderStatusLogServiceImpl.java new file mode 100644 index 000000000..305b4ec25 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/OrderStatusLogServiceImpl.java @@ -0,0 +1,19 @@ +package com.logpm.factory.snm.service.impl; + +import com.logpm.factory.snm.entity.OrderStatusLog; +import com.logpm.factory.snm.mapper.OrderStatusLogMapper; +import com.logpm.factory.snm.service.IOrderStatusLogService; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +@AllArgsConstructor +@Service +public class OrderStatusLogServiceImpl extends BaseServiceImpl implements IOrderStatusLogService { + + private static final Logger logger = LoggerFactory.getLogger(OrderStatusLogServiceImpl.class); + + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java index 79b7d6542..a1b97bd6b 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java @@ -10,11 +10,11 @@ import com.logpm.factory.snm.bean.Resp; import com.logpm.factory.snm.dto.OrderInfoDTO; import com.logpm.factory.snm.dto.OrderStatusDTO; import com.logpm.factory.snm.entity.PanFactoryOrder; -import com.logpm.factory.snm.entity.PanOrderStatusLog; +import com.logpm.factory.snm.entity.OrderStatusLog; import com.logpm.factory.snm.entity.PanPackageInfo; import com.logpm.factory.snm.service.IPanFactoryDataService; import com.logpm.factory.snm.service.IPanFactoryOrderService; -import com.logpm.factory.snm.service.IPanOrderStatusLogService; +import com.logpm.factory.snm.service.IOrderStatusLogService; import com.logpm.factory.snm.service.IPanPackageInfoService; import com.logpm.oldproject.feign.IAdvanceDetailClient; import com.logpm.oldproject.feign.IWarehouseClient; @@ -42,7 +42,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { private final IPanFactoryOrderService factoryOrderService; private final PanFactoryProperties panFactoryProperties; - private final IPanOrderStatusLogService panOrderStatusLogService; + private final IOrderStatusLogService panOrderStatusLogService; private final IPanPackageInfoService panPackageInfoService; private final IPanFactoryOrderService panFactoryOrderService; private final IAdvanceDetailClient advanceDetailClient; @@ -96,7 +96,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { public R handleData(OrderInfoDTO orderInfoDTO) throws CustomerException { //先保存原始请求数据 - PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); + OrderStatusLog panOrderStatusLog = new OrderStatusLog(); panOrderStatusLog.setArgs(JSONObject.toJSONString(orderInfoDTO)); panOrderStatusLog.setStatus(1); panOrderStatusLog.setType(1); @@ -167,7 +167,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { public R handleStatusData(OrderStatusDTO orderStatusDTO) throws CustomerException { //先保存原始请求数据 - PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); + OrderStatusLog panOrderStatusLog = new OrderStatusLog(); panOrderStatusLog.setArgs(JSONObject.toJSONString(orderStatusDTO)); panOrderStatusLog.setStatus(1); panOrderStatusLog.setType(2); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanOrderStatusLogServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanOrderStatusLogServiceImpl.java deleted file mode 100644 index c69058c1a..000000000 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanOrderStatusLogServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.logpm.factory.snm.service.impl; - -import com.logpm.factory.snm.entity.PanOrderStatusLog; -import com.logpm.factory.snm.mapper.PanOrderStatusLogMapper; -import com.logpm.factory.snm.service.IPanOrderStatusLogService; -import lombok.AllArgsConstructor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -@AllArgsConstructor -@Service -public class PanOrderStatusLogServiceImpl extends BaseServiceImpl implements IPanOrderStatusLogService { - - private static final Logger logger = LoggerFactory.getLogger(PanOrderStatusLogServiceImpl.class); - - -} From 80ba91f12d32ce902bfb5e0c7129714cbdfc3e79 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Sun, 25 Jun 2023 13:11:02 +0800 Subject: [PATCH 11/11] =?UTF-8?q?1.=E5=90=88=E5=B9=B6mq=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/logpm/factory/receiver/ErrorQueueHandler.java | 10 +++++----- .../snm/controller/PanFactoryDataController.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java index 208643ffc..8410156ec 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java @@ -1,8 +1,8 @@ package com.logpm.factory.receiver; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.logpm.factory.snm.entity.PanOrderStatusLog; -import com.logpm.factory.snm.service.IPanOrderStatusLogService; +import com.logpm.factory.snm.entity.OrderStatusLog; +import com.logpm.factory.snm.service.IOrderStatusLogService; import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; @@ -27,7 +27,7 @@ import java.util.Map; public class ErrorQueueHandler { @Autowired - private IPanOrderStatusLogService panOrderStatusLogService; + private IOrderStatusLogService orderStatusLogService; @RabbitHandler public void orderStatusHandlerManualAck(Map map, Message message, Channel channel) { @@ -35,10 +35,10 @@ public class ErrorQueueHandler { final long deliveryTag = message.getMessageProperties().getDeliveryTag(); try { Long logId = (Long) map.get("logId"); - UpdateWrapper updateWrapper = new UpdateWrapper<>(); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.set("status",2) .eq("id",logId); - boolean updateFlag = panOrderStatusLogService.update(updateWrapper); + boolean updateFlag = orderStatusLogService.update(updateWrapper); if(updateFlag){ channel.basicAck(deliveryTag, false); }else{ diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 01eb8801d..0746f1dc9 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -172,7 +172,7 @@ public class PanFactoryDataController extends BladeController { try{ //先保存原始请求数据 - PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); + OrderStatusLog panOrderStatusLog = new OrderStatusLog(); panOrderStatusLog.setArgs(JSONObject.toJSONString(orderInfoDTO)); panOrderStatusLog.setStatus(1); panOrderStatusLog.setType(1); @@ -207,7 +207,7 @@ public class PanFactoryDataController extends BladeController { try{ //先保存原始请求数据 - PanOrderStatusLog panOrderStatusLog = new PanOrderStatusLog(); + OrderStatusLog panOrderStatusLog = new OrderStatusLog(); panOrderStatusLog.setArgs(JSONObject.toJSONString(orderStatusDTO)); panOrderStatusLog.setStatus(1); panOrderStatusLog.setType(2);