From caa2b51bb4133f5a2e59eac242e744fb57f864a0 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 10 九月 2024 13:01:44 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java | 129 +++++++++++++++++-------------------------- 1 files changed, 51 insertions(+), 78 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 a851ff7..2cfd639 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 @@ -10,8 +10,6 @@ import org.apache.rocketmq.client.producer.SendResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import java.util.UUID; @@ -23,304 +21,279 @@ @Setter(onMethod_ = @Autowired) private RocketMQEnhanceTemplate rocketMQEnhanceTemplate; - private static final String TOPIC = "rocket_enhance"; + private static final String TOPIC = "charge_"; /** * 充电桩登录认证 */ - public SendResult onlineMessage(JSONObject jsonObject) { - OnlineMessage message = JSON.parseObject(jsonObject.toJSONString(),OnlineMessage.class); + public SendResult onlineMessage(OnlineMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.ONLINE); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.ONLINE, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.ONLINE, SendTagConstant.ONLINE, message); } /** * 充电桩心跳包 */ - public SendResult pingMessage(JSONObject jsonObject) { - PingMessage message = JSON.parseObject(jsonObject.toJSONString(),PingMessage.class); + public SendResult pingMessage(PingMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.PING); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.PING, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.PING, SendTagConstant.PING, message); } /** * 充电结束 */ - 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, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.END_CHARGE, SendTagConstant.END_CHARGE, 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()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.BILLING_MODE_VERIFY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.BILLING_MODE_VERIFY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.BILLING_MODE_VERIFY, SendTagConstant.BILLING_MODE_VERIFY, message); } /** * 充电桩计费模型请求 */ - public SendResult acquisitionBillingModeMessage(JSONObject jsonObject) { - AcquisitionBillingModeMessage message = JSON.parseObject(jsonObject.toJSONString(),AcquisitionBillingModeMessage.class); + public SendResult acquisitionBillingModeMessage(AcquisitionBillingModeMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.ACQUISITION_BILLING_MODE); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.ACQUISITION_BILLING_MODE, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.ACQUISITION_BILLING_MODE, SendTagConstant.ACQUISITION_BILLING_MODE, message); } /** * 上传实时监测数据 */ - public SendResult uploadRealTimeMonitoringDataMessage(JSONObject jsonObject) { - UploadRealTimeMonitoringDataMessage message = JSON.parseObject(jsonObject.toJSONString(),UploadRealTimeMonitoringDataMessage.class); + public SendResult uploadRealTimeMonitoringDataMessage(UploadRealTimeMonitoringDataMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA, SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA, message); } /** * 充电握手 */ - 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, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.CHARGING_HANDSHAKE, SendTagConstant.CHARGING_HANDSHAKE, 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()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.BMS_ABORT); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.BMS_ABORT, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.BMS_ABORT, SendTagConstant.BMS_ABORT, message); } /** * 充电阶段充电机中止 */ - public SendResult motorAbortMessage(JSONObject jsonObject) { - MotorAbortMessage message = JSON.parseObject(jsonObject.toJSONString(),MotorAbortMessage.class); + public SendResult motorAbortMessage(MotorAbortMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.MOTOR_ABORT); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.MOTOR_ABORT, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.MOTOR_ABORT, SendTagConstant.MOTOR_ABORT, message); } /** * 充电过程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()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION, SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION, message); } /** * 充电过程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()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.BMS_INFORMATION); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.BMS_INFORMATION, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.BMS_INFORMATION, SendTagConstant.BMS_INFORMATION, message); } /** * 充电桩主动申请启动充电 */ - public SendResult chargingPileStartsChargingMessage(JSONObject jsonObject) { - ChargingPileStartsChargingMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingPileStartsChargingMessage.class); + public SendResult chargingPileStartsChargingMessage(ChargingPileStartsChargingMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.CHARGING_PILE_STARTS_CHARGING); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.CHARGING_PILE_STARTS_CHARGING, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.CHARGING_PILE_STARTS_CHARGING, SendTagConstant.CHARGING_PILE_STARTS_CHARGING, message); } /** * 远程启机命令回复 */ - public SendResult platformStartChargingReplyMessage(JSONObject jsonObject) { - PlatformStartChargingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformStartChargingReplyMessage.class); + public SendResult platformStartChargingReplyMessage(PlatformStartChargingReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.PLATFORM_START_CHARGING_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.PLATFORM_START_CHARGING_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.PLATFORM_START_CHARGING_REPLY, SendTagConstant.PLATFORM_START_CHARGING_REPLY, message); } /** * 远程停机命令回复 */ - public SendResult platformStopChargingReplyMessage(JSONObject jsonObject) { - PlatformStopChargingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformStopChargingReplyMessage.class); + public SendResult platformStopChargingReplyMessage(PlatformStopChargingReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.PLATFORM_STOP_CHARGING_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.PLATFORM_STOP_CHARGING_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.PLATFORM_STOP_CHARGING_REPLY, SendTagConstant.PLATFORM_STOP_CHARGING_REPLY, message); } /** * 交易记录 */ - public SendResult transactionRecordMessage(JSONObject jsonObject) { - TransactionRecordMessage message = JSON.parseObject(jsonObject.toJSONString(),TransactionRecordMessage.class); + public SendResult transactionRecordMessage(TransactionRecordMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.TRANSACTION_RECORD); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.TRANSACTION_RECORD, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.TRANSACTION_RECORD, SendTagConstant.TRANSACTION_RECORD, message); } /** * 余额更新应答 */ - public SendResult updateBalanceReplyMessage(JSONObject jsonObject) { - UpdateBalanceReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),UpdateBalanceReplyMessage.class); + public SendResult updateBalanceReplyMessage(UpdateBalanceReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.UPDATE_BALANCE_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.UPDATE_BALANCE_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.UPDATE_BALANCE_REPLY, SendTagConstant.UPDATE_BALANCE_REPLY, message); } /** * 卡数据同步应答 */ - public SendResult synchronizeOfflineCardReplyMessage(JSONObject jsonObject) { - SynchronizeOfflineCardReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),SynchronizeOfflineCardReplyMessage.class); + public SendResult synchronizeOfflineCardReplyMessage(SynchronizeOfflineCardReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY, SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY, message); } /** * 离线卡数据清除应答 */ - public SendResult clearOfflineCardReplyMessage(JSONObject jsonObject) { - ClearOfflineCardReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),ClearOfflineCardReplyMessage.class); + public SendResult clearOfflineCardReplyMessage(ClearOfflineCardReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.CLEAR_OFFLINE_CARD_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.CLEAR_OFFLINE_CARD_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.CLEAR_OFFLINE_CARD_REPLY, SendTagConstant.CLEAR_OFFLINE_CARD_REPLY, message); } /** * 充电桩工作参数设置应答 */ - public SendResult workingParameterSettingReplyMessage(JSONObject jsonObject) { - WorkingParameterSettingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),WorkingParameterSettingReplyMessage.class); + public SendResult workingParameterSettingReplyMessage(WorkingParameterSettingReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.WORKING_PARAMETER_SETTING_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.WORKING_PARAMETER_SETTING_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.WORKING_PARAMETER_SETTING_REPLY, SendTagConstant.WORKING_PARAMETER_SETTING_REPLY, message); } /** * 对时设置 */ - public SendResult timingSettingMessage(JSONObject jsonObject) { - TimingSettingMessage message = JSON.parseObject(jsonObject.toJSONString(),TimingSettingMessage.class); + public SendResult timingSettingMessage(TimingSettingMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.TIMING_SETTING); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.TIMING_SETTING, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.TIMING_SETTING, SendTagConstant.TIMING_SETTING, message); } /** * 计费模型应答 */ - public SendResult setupBillingModelReplyMessage(JSONObject jsonObject) { - SetupBillingModelReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),SetupBillingModelReplyMessage.class); + public SendResult setupBillingModelReplyMessage(SetupBillingModelReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.SETUP_BILLING_MODEL_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.SETUP_BILLING_MODEL_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.SETUP_BILLING_MODEL_REPLY, SendTagConstant.SETUP_BILLING_MODEL_REPLY, message); } /** * 地锁数据上送(充电桩上送) */ - public SendResult groundLockRealTimeDataMessage(JSONObject jsonObject) { - GroundLockRealTimeDataMessage message = JSON.parseObject(jsonObject.toJSONString(),GroundLockRealTimeDataMessage.class); + public SendResult groundLockRealTimeDataMessage(GroundLockRealTimeDataMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.GROUND_LOCK_REAL_TIME_DATA); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.GROUND_LOCK_REAL_TIME_DATA, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.GROUND_LOCK_REAL_TIME_DATA, SendTagConstant.GROUND_LOCK_REAL_TIME_DATA, message); } /** * 充电桩返回数据(上行) */ - public SendResult chargingPileReturnsGroundLockDataMessage(JSONObject jsonObject) { - ChargingPileReturnsGroundLockDataMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingPileReturnsGroundLockDataMessage.class); + public SendResult chargingPileReturnsGroundLockDataMessage(ChargingPileReturnsGroundLockDataMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA, SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA, message); } /** * 远程重启应答 */ - public SendResult platformRestartReplyMessage(JSONObject jsonObject) { - PlatformRestartReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformRestartReplyMessage.class); + public SendResult platformRestartReplyMessage(PlatformRestartReplyMessage message) { // 设置业务key message.setKey(UUID.randomUUID().toString()); // 设置消息来源,便于查询 message.setSource(SendTagConstant.PLATFORM_RESTART_REPLY); - return rocketMQEnhanceTemplate.send(TOPIC, SendTagConstant.PLATFORM_RESTART_REPLY, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.PLATFORM_RESTART_REPLY, SendTagConstant.PLATFORM_RESTART_REPLY, message); } /** * 远程更新应答 */ - 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, message); + return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.PLATFORM_REMOTE_UPDATE_REPLY, SendTagConstant.PLATFORM_REMOTE_UPDATE_REPLY, message); } } \ No newline at end of file -- Gitblit v1.7.1