From 3244b550596e0330031b3f4547356927df83b0ad Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 19 五月 2025 11:48:35 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java | 171 +++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 118 insertions(+), 53 deletions(-) diff --git a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java index 762cdbd..43f8fdf 100644 --- a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java +++ b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java @@ -2,15 +2,16 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.integration.api.model.ErrorMessage; +import com.ruoyi.integration.api.model.ParameterSetting; +import com.ruoyi.integration.api.model.QrCodeDeliveryReply; +import com.ruoyi.integration.api.model.SecurityDetection; import com.ruoyi.integration.iotda.constant.SendTagConstant; import com.ruoyi.integration.rocket.model.*; import com.ruoyi.integration.rocket.util.RocketMQEnhanceTemplate; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.rocketmq.client.producer.DefaultMQProducer; import org.apache.rocketmq.client.producer.SendResult; -import org.apache.rocketmq.common.message.Message; -import org.apache.rocketmq.remoting.common.RemotingHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -25,12 +26,12 @@ private RocketMQEnhanceTemplate rocketMQEnhanceTemplate; private static final String TOPIC = "charge_"; + private static final String TOPIC_JIANGUAN = "jianguan_"; /** * 充电桩登录认证 */ - public SendResult onlineMessage(JSONObject jsonObject) { - OnlineMessage message = JSON.parseObject(jsonObject.toJSONString(),OnlineMessage.class); + public SendResult onlineMessage(OnlineMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -41,8 +42,7 @@ /** * 充电桩心跳包 */ - public SendResult pingMessage(JSONObject jsonObject) { - PingMessage message = JSON.parseObject(jsonObject.toJSONString(),PingMessage.class); + public SendResult pingMessage(PingMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -52,20 +52,28 @@ /** * 充电结束 */ - public SendResult endChargeMessage(JSONObject jsonObject) { - PingMessage message = JSON.parseObject(jsonObject.toJSONString(),PingMessage.class); + public SendResult endChargeMessage(EndChargeMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.END_CHARGE); return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.END_CHARGE, SendTagConstant.END_CHARGE, message); } + /** + * 错误报文 + */ + public SendResult errorMessageMessage(ErrorMessageMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.ERROR_MESSAGE); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.ERROR_MESSAGE, SendTagConstant.ERROR_MESSAGE, message); + } /** * 计费模型验证请求 */ - public SendResult billingModeVerifyMessage(JSONObject jsonObject) { - BillingModeVerifyMessage message = JSON.parseObject(jsonObject.toJSONString(),BillingModeVerifyMessage.class); + public SendResult billingModeVerifyMessage(BillingModeVerifyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -76,8 +84,7 @@ /** * 充电桩计费模型请求 */ - public SendResult acquisitionBillingModeMessage(JSONObject jsonObject) { - AcquisitionBillingModeMessage message = JSON.parseObject(jsonObject.toJSONString(),AcquisitionBillingModeMessage.class); + public SendResult acquisitionBillingModeMessage(AcquisitionBillingModeMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -88,8 +95,7 @@ /** * 上传实时监测数据 */ - public SendResult uploadRealTimeMonitoringDataMessage(JSONObject jsonObject) { - UploadRealTimeMonitoringDataMessage message = JSON.parseObject(jsonObject.toJSONString(),UploadRealTimeMonitoringDataMessage.class); + public SendResult uploadRealTimeMonitoringDataMessage(UploadRealTimeMonitoringDataMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -100,20 +106,28 @@ /** * 充电握手 */ - public SendResult chargingHandshakeMessage(JSONObject jsonObject) { - ChargingHandshakeMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingHandshakeMessage.class); + public SendResult chargingHandshakeMessage(ChargingHandshakeMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.CHARGING_HANDSHAKE); return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.CHARGING_HANDSHAKE, SendTagConstant.CHARGING_HANDSHAKE, message); } + /** + * 参数设置 + */ + public SendResult parameterSettingMessage(ParameterSettingMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.PARAMETER_SETTING); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.PARAMETER_SETTING, SendTagConstant.PARAMETER_SETTING, message); + } /** * 充电阶段BMS中止 */ - public SendResult bmsAbortMessage(JSONObject jsonObject) { - BmsAbortMessage message = JSON.parseObject(jsonObject.toJSONString(),BmsAbortMessage.class); + public SendResult bmsAbortMessage(BmsAbortMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -124,8 +138,7 @@ /** * 充电阶段充电机中止 */ - public SendResult motorAbortMessage(JSONObject jsonObject) { - MotorAbortMessage message = JSON.parseObject(jsonObject.toJSONString(),MotorAbortMessage.class); + public SendResult motorAbortMessage(MotorAbortMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -136,8 +149,7 @@ /** * 充电过程BMS需求、充电机输出 */ - public SendResult bmsDemandAndChargerExportationMessage(JSONObject jsonObject) { - BmsDemandAndChargerExportationMessage message = JSON.parseObject(jsonObject.toJSONString(),BmsDemandAndChargerExportationMessage.class); + public SendResult bmsDemandAndChargerExportationMessage(BmsDemandAndChargerExportationMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -148,8 +160,7 @@ /** * 充电过程BMS信息 */ - public SendResult bmsInformationMessage(JSONObject jsonObject) { - BmsInformationMessage message = JSON.parseObject(jsonObject.toJSONString(),BmsInformationMessage.class); + public SendResult bmsInformationMessage(BmsInformationMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -160,8 +171,7 @@ /** * 充电桩主动申请启动充电 */ - public SendResult chargingPileStartsChargingMessage(JSONObject jsonObject) { - ChargingPileStartsChargingMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingPileStartsChargingMessage.class); + public SendResult chargingPileStartsChargingMessage(ChargingPileStartsChargingMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -172,8 +182,7 @@ /** * 远程启机命令回复 */ - public SendResult platformStartChargingReplyMessage(JSONObject jsonObject) { - PlatformStartChargingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformStartChargingReplyMessage.class); + public SendResult platformStartChargingReplyMessage(PlatformStartChargingReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -184,8 +193,7 @@ /** * 远程停机命令回复 */ - public SendResult platformStopChargingReplyMessage(JSONObject jsonObject) { - PlatformStopChargingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformStopChargingReplyMessage.class); + public SendResult platformStopChargingReplyMessage(PlatformStopChargingReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -196,8 +204,7 @@ /** * 交易记录 */ - public SendResult transactionRecordMessage(JSONObject jsonObject) { - TransactionRecordMessage message = JSON.parseObject(jsonObject.toJSONString(),TransactionRecordMessage.class); + public SendResult transactionRecordMessage(TransactionRecordMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -208,8 +215,7 @@ /** * 余额更新应答 */ - public SendResult updateBalanceReplyMessage(JSONObject jsonObject) { - UpdateBalanceReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),UpdateBalanceReplyMessage.class); + public SendResult updateBalanceReplyMessage(UpdateBalanceReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -220,8 +226,7 @@ /** * 卡数据同步应答 */ - public SendResult synchronizeOfflineCardReplyMessage(JSONObject jsonObject) { - SynchronizeOfflineCardReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),SynchronizeOfflineCardReplyMessage.class); + public SendResult synchronizeOfflineCardReplyMessage(SynchronizeOfflineCardReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -232,8 +237,7 @@ /** * 离线卡数据清除应答 */ - public SendResult clearOfflineCardReplyMessage(JSONObject jsonObject) { - ClearOfflineCardReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),ClearOfflineCardReplyMessage.class); + public SendResult clearOfflineCardReplyMessage(ClearOfflineCardReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -244,8 +248,7 @@ /** * 充电桩工作参数设置应答 */ - public SendResult workingParameterSettingReplyMessage(JSONObject jsonObject) { - WorkingParameterSettingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),WorkingParameterSettingReplyMessage.class); + public SendResult workingParameterSettingReplyMessage(WorkingParameterSettingReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -256,8 +259,7 @@ /** * 对时设置 */ - public SendResult timingSettingMessage(JSONObject jsonObject) { - TimingSettingMessage message = JSON.parseObject(jsonObject.toJSONString(),TimingSettingMessage.class); + public SendResult timingSettingMessage(TimingSettingMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -268,8 +270,7 @@ /** * 计费模型应答 */ - public SendResult setupBillingModelReplyMessage(JSONObject jsonObject) { - SetupBillingModelReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),SetupBillingModelReplyMessage.class); + public SendResult setupBillingModelReplyMessage(SetupBillingModelReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -280,8 +281,7 @@ /** * 地锁数据上送(充电桩上送) */ - public SendResult groundLockRealTimeDataMessage(JSONObject jsonObject) { - GroundLockRealTimeDataMessage message = JSON.parseObject(jsonObject.toJSONString(),GroundLockRealTimeDataMessage.class); + public SendResult groundLockRealTimeDataMessage(GroundLockRealTimeDataMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -292,8 +292,7 @@ /** * 充电桩返回数据(上行) */ - public SendResult chargingPileReturnsGroundLockDataMessage(JSONObject jsonObject) { - ChargingPileReturnsGroundLockDataMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingPileReturnsGroundLockDataMessage.class); + public SendResult chargingPileReturnsGroundLockDataMessage(ChargingPileReturnsGroundLockDataMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -304,8 +303,7 @@ /** * 远程重启应答 */ - public SendResult platformRestartReplyMessage(JSONObject jsonObject) { - PlatformRestartReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformRestartReplyMessage.class); + public SendResult platformRestartReplyMessage(PlatformRestartReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 @@ -316,12 +314,79 @@ /** * 远程更新应答 */ - public SendResult platformRemoteUpdateReplyMessage(JSONObject jsonObject) { - PlatformRemoteUpdateReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformRemoteUpdateReplyMessage.class); + public SendResult platformRemoteUpdateReplyMessage(PlatformRemoteUpdateReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.PLATFORM_REMOTE_UPDATE_REPLY); return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.PLATFORM_REMOTE_UPDATE_REPLY, SendTagConstant.PLATFORM_REMOTE_UPDATE_REPLY, message); } + + /** + * 二维码下发应答 + */ + public SendResult qrCodeDeliveryReplyMessage(QrCodeDeliveryReplyMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.QR_CODE_DELIVERY_REPLY); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.QR_CODE_DELIVERY_REPLY, SendTagConstant.QR_CODE_DELIVERY_REPLY, message); + } + + /** + * 安全监测 + */ + public SendResult securityDetectionMessage(SecurityDetectionMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.SECURITY_DETECTION); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.SECURITY_DETECTION, SendTagConstant.SECURITY_DETECTION, message); + } + + /** + * 充电桩登录认证 + */ + public SendResult chargingMessage(ChargingMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.CHARGING_MESSAGE); + + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.CHARGING_MESSAGE, SendTagConstant.CHARGING_MESSAGE, message); + } + /** + * 监管平台推送充电设备接口状态 + */ + public SendResult gunStatusMessage(ChargingMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.GUN_STATUS); + + return rocketMQEnhanceTemplate.send(TOPIC_JIANGUAN+SendTagConstant.GUN_STATUS, SendTagConstant.GUN_STATUS, message); + } + /** + * 监管平台推送充电订单信息 + */ + public SendResult orderInfoMessage(ChargingMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.ORDER_INFO); + + return rocketMQEnhanceTemplate.send(TOPIC_JIANGUAN+SendTagConstant.ORDER_INFO, SendTagConstant.ORDER_INFO, message); + } + /** + * 监管平台推送充电订单状态 + */ + public SendResult orderStatusMessage(ChargingMessage message) { + // 设置业务key + message.setKey(UUID.randomUUID().toString()); + // 设置消息来源,便于查询 + message.setSource(SendTagConstant.ORDER_STATUS); + + return rocketMQEnhanceTemplate.send(TOPIC_JIANGUAN+SendTagConstant.ORDER_STATUS, SendTagConstant.ORDER_STATUS, message); + } + } \ No newline at end of file -- Gitblit v1.7.1