From 3692245745acc6474a6eca51640016947c3ac957 Mon Sep 17 00:00:00 2001
From: andy <1042025947@qq.com>
Date: Tue, 8 Apr 2025 11:46:39 +0800
Subject: [PATCH] 1
---
.idea/.gitignore | 0
.idea/cloud-battery-manage.iml | 2 ++
.idea/compiler.xml | 36 +++++++++++++++++++
.idea/encodings.xml | 19 ++++++++++
.idea/jarRepositories.xml | 35 ++++++++++++++++++
.idea/misc.xml | 12 +++++++
.idea/vcs.xml | 6 ++++
.../mqtt/enums/RequestFunctionTypesEnum.java | 3 +-
.../message/handle/RequestMessageService.java | 22 +++++++++---
9 files changed, 129 insertions(+), 6 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/cloud-battery-manage.iml
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/jarRepositories.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/vcs.xml
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/cloud-battery-manage.iml b/.idea/cloud-battery-manage.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/.idea/cloud-battery-manage.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..58593ed
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..cbf76af
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..f44d6d0
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..fe05825
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/enums/RequestFunctionTypesEnum.java b/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/enums/RequestFunctionTypesEnum.java
index ddc4ae5..53c1727 100644
--- a/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/enums/RequestFunctionTypesEnum.java
+++ b/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/enums/RequestFunctionTypesEnum.java
@@ -30,7 +30,8 @@ public enum RequestFunctionTypesEnum {
FUN_PREORDER("preOrder", "preOrderResponse", "站端预约订单"),
FUN_ORDERBYPLATENUM("orderByPlateNum", "orderByPlateNumResponse", "站端用车牌号查询订单"),
FUN_CANCELORDER("cancelOrder", "cancelOrderResponse", "站端取消订单"),
- FUN_STARTSWAP("BatterySwapReq", "BatterySwapResponse", "站端回复开始换电");
+ FUN_STARTSWAP("BatterySwapReq", "BatterySwapResponse", "站端回复开始换电"),
+ FUN_STRATEGY_INFO("strategyInfo", "strategyInfoResponse", "站端查询充电策略");
String function;
String reFunction;
diff --git a/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/handle/RequestMessageService.java b/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/handle/RequestMessageService.java
index e8a0655..77d68da 100644
--- a/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/handle/RequestMessageService.java
+++ b/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/handle/RequestMessageService.java
@@ -1,12 +1,10 @@
package com.evotech.hd.cloud.mqtt.message.handle;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
import java.util.stream.Stream;
import cn.hutool.core.util.StrUtil;
+import com.evotech.hd.cloud.mqtt.message.processor.MqttMessageRequestExchangeProcessor;
import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.*;
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.*;
@@ -16,8 +14,11 @@ import com.evotech.hd.common.core.entity.wechat.WechatUser;
import com.evotech.hd.common.redis.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -69,6 +70,9 @@ public class RequestMessageService {
private OrderSwapBatteryService orderSwapBatteryService;
@Resource
private RedisUtil redisUtil;
+ @Autowired
+ private ApplicationContext applicationContext;
+
@Async("taskExecutor")
public void request(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
switch (Objects.requireNonNull(RequestFunctionTypesEnum.getFunctionType(header.getFunction()))) {
@@ -96,8 +100,16 @@ public class RequestMessageService {
BatterySwapResponse battery = JSONUtil.toBean(dataBody, BatterySwapResponse.class);
handlStartSwap(topic,header,battery);
break;
-
default:
+ Map mqttMessageRequestExchangeProcessorMap = applicationContext.getBeansOfType(MqttMessageRequestExchangeProcessor.class);
+ if(CollectionUtils.isEmpty(mqttMessageRequestExchangeProcessorMap)){
+ log.error("mqttRequestExchangeProcessorMap is empty, 没有找到当前的请求信息, 请求接口{}, 请求参数{}", JSONUtil.toJsonStr(header), JSONUtil.toJsonStr(dataBody));
+ }
+ for (MqttMessageRequestExchangeProcessor processor : mqttMessageRequestExchangeProcessorMap.values()) {
+ if(processor.accept(header.getFunction())){
+ processor.exchange(topic, header, dataBody);
+ }
+ }
break;
}