From 675e7fcf4952bde3cfc3fc45ad4103aec834e33f Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期二, 10 九月 2024 18:18:11 +0800
Subject: [PATCH] mq修改,充电桩硬件联调,业务逻辑处理

---
 ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java
index f629ed1..7125512 100644
--- a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java
+++ b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java
@@ -51,7 +51,11 @@
     @PostMapping(value = "/message")
     public AjaxResult<String> message(@RequestBody JSONObject jsonObject) throws IOException {
         log.info("接收到消息中转:{}",jsonObject);
-        JSONObject content = jsonObject.getJSONObject("content");
+        JSONObject content = jsonObject.getJSONObject("notify_data").getJSONObject("body").getJSONObject("content");
+        JSONObject header = jsonObject.getJSONObject("notify_data").getJSONObject("header");
+        String deviceId = header.getString("device_id"); // 设备id
+        String nodeId = header.getString("node_id"); // 设备编号
+        String productId = header.getString("product_id"); // 产品id
         String service_id = content.getString("service_id");
         log.info("服务id:{}",service_id);
         SendResult sendResult;
@@ -66,7 +70,7 @@
                 OnlineReply onlineReply = new OnlineReply();
                 onlineReply.setCharging_pile_code(onlineMessage.getCharging_pile_code());
                 onlineReply.setOnline_result(0);
-                result = iotMessageProduce.sendMessage(onlineReply.getCharging_pile_code(), ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply));
+                result = iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply));
                 log.info("充电桩登录认证-返回结果:{}",result);
                 break;
             case SendTagConstant.PING:
@@ -77,7 +81,7 @@
                 pong.setCharging_pile_code(pingMessage.getCharging_pile_code());
                 pong.setCharging_gun_code(pingMessage.getCharging_gun_code());
                 pong.setCharging_gun_status(0);
-                result = iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong));
+                result = iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong));
                 log.info("充电桩心跳包-返回结果:{}",result);
                 break;
             case SendTagConstant.END_CHARGE:
@@ -110,7 +114,7 @@
                         billingModeVerifyReply.setBilling_model_result(1);
                     }
                 }
-                iotMessageProduce.sendMessage(billingModeVerifyReply.getCharging_pile_code(), ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply));
+                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply));
                 break;
             case SendTagConstant.ACQUISITION_BILLING_MODE:
                 AcquisitionBillingModeMessage acquisitionBillingModeMessage = JSON.parseObject(jsonObject.toJSONString(),AcquisitionBillingModeMessage.class);
@@ -123,7 +127,7 @@
                 StrategyUtil.setStrategyPrice(strategyPrice,acquisitionBillingModeReply);
                 // 时段设置
                 StrategyUtil.setTime(accountingStrategyDetails,acquisitionBillingModeReply);
-                iotMessageProduce.sendMessage(acquisitionBillingModeReply.getCharging_pile_code(), ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply));
+                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply));
                 break;
             case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA:
                 UploadRealTimeMonitoringDataMessage uploadRealTimeMonitoringDataMessage = JSON.parseObject(jsonObject.toJSONString(),UploadRealTimeMonitoringDataMessage.class);
@@ -134,6 +138,10 @@
                 ChargingHandshakeMessage chargingHandshakeMessage = JSON.parseObject(jsonObject.toJSONString(),ChargingHandshakeMessage.class);
                 sendResult = enhanceProduce.chargingHandshakeMessage(chargingHandshakeMessage);
                 // 响应硬件
+                break;
+            case SendTagConstant.PARAMETER_SETTING:
+                ParameterSettingMessage parameterSettingMessage = JSON.parseObject(jsonObject.toJSONString(),ParameterSettingMessage.class);
+                sendResult = enhanceProduce.parameterSettingMessage(parameterSettingMessage);
                 break;
             case SendTagConstant.BMS_ABORT:
                 BmsAbortMessage bmsAbortMessage = JSON.parseObject(jsonObject.toJSONString(),BmsAbortMessage.class);
@@ -176,7 +184,7 @@
                 ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord();
                 confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number());
                 confirmTransactionRecord.setConfirm_result(0);
-                iotMessageProduce.sendMessage(confirmTransactionRecord.getTransaction_serial_number(), ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord));
+                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord));
                 break;
             case SendTagConstant.UPDATE_BALANCE_REPLY:
                 UpdateBalanceReplyMessage updateBalanceReplyMessage = JSON.parseObject(jsonObject.toJSONString(),UpdateBalanceReplyMessage.class);
@@ -205,7 +213,7 @@
                 TimingSettingReply timingSettingReply = new TimingSettingReply();
                 timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code());
                 timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date()));
-                iotMessageProduce.sendMessage(timingSettingReply.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply));
+                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply));
                 break;
             case SendTagConstant.SETUP_BILLING_MODEL_REPLY:
                 SetupBillingModelReplyMessage setupBillingModelReplyMessage = JSON.parseObject(jsonObject.toJSONString(),SetupBillingModelReplyMessage.class);

--
Gitblit v1.7.1