| | |
| | | package com.ruoyi.integration.rocket.produce; |
| | | |
| | | import com.ruoyi.integration.rocket.test.MemberMessage; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.integration.iotda.enums.SendTagMenu; |
| | | 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.SendResult; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | | @RestController |
| | |
| | | @Setter(onMethod_ = @Autowired) |
| | | private RocketMQEnhanceTemplate rocketMQEnhanceTemplate; |
| | | |
| | | private static final String topic = "rocket_enhance"; |
| | | private static final String tag = "member"; |
| | | private static final String TOPIC = "rocket_enhance"; |
| | | |
| | | /** |
| | | * 发送实体消息 |
| | | * 充电桩登录认证 |
| | | */ |
| | | @GetMapping("/member") |
| | | public SendResult member() { |
| | | String key = UUID.randomUUID().toString(); |
| | | MemberMessage message = new MemberMessage(); |
| | | public SendResult onlineMessage(JSONObject jsonObject) { |
| | | OnlineMessage message = JSON.parseObject(jsonObject.toJSONString(),OnlineMessage.class); |
| | | // 设置业务key |
| | | message.setKey(key); |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource("MEMBER"); |
| | | // 业务消息内容 |
| | | message.setUserName("Java日知录"); |
| | | message.setBirthday(LocalDate.now()); |
| | | message.setSource(SendTagMenu.ONLINE.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.ONLINE.getValue(), message); |
| | | } |
| | | |
| | | return rocketMQEnhanceTemplate.send(topic, tag, message); |
| | | /** |
| | | * 充电桩心跳包 |
| | | */ |
| | | public SendResult pingMessage(JSONObject jsonObject) { |
| | | PingMessage message = JSON.parseObject(jsonObject.toJSONString(),PingMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.PING.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.PING.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 计费模型验证请求 |
| | | */ |
| | | public SendResult billingModeVerifyMessage(JSONObject jsonObject) { |
| | | BillingModeVerifyMessage message = JSON.parseObject(jsonObject.toJSONString(),BillingModeVerifyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.BILLING_MODE_VERIFY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.BILLING_MODE_VERIFY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电桩计费模型请求 |
| | | */ |
| | | public SendResult acquisitionBillingModeMessage(JSONObject jsonObject) { |
| | | AcquisitionBillingModeMessage message = JSON.parseObject(jsonObject.toJSONString(),AcquisitionBillingModeMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.ACQUISITION_BILLING_MODE.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.ACQUISITION_BILLING_MODE.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 上传实时监测数据 |
| | | */ |
| | | public SendResult uploadRealTimeMonitoringDataMessage(JSONObject jsonObject) { |
| | | UploadRealTimeMonitoringDataMessage message = JSON.parseObject(jsonObject.toJSONString(),UploadRealTimeMonitoringDataMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.UPLOAD_REAL_TIME_MONITORING_DATA.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.UPLOAD_REAL_TIME_MONITORING_DATA.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电握手 |
| | | */ |
| | | public SendResult chargingHandshakeMessage(JSONObject jsonObject) { |
| | | ChargingHandshakeMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingHandshakeMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.CHARGING_HANDSHAKE.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.CHARGING_HANDSHAKE.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电阶段BMS中止 |
| | | */ |
| | | public SendResult bmsAbortMessage(JSONObject jsonObject) { |
| | | BmsAbortMessage message = JSON.parseObject(jsonObject.toJSONString(),BmsAbortMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.BMS_ABORT.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.BMS_ABORT.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电阶段充电机中止 |
| | | */ |
| | | public SendResult motorAbortMessage(JSONObject jsonObject) { |
| | | MotorAbortMessage message = JSON.parseObject(jsonObject.toJSONString(),MotorAbortMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.MOTOR_ABORT.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.MOTOR_ABORT.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电过程BMS需求、充电机输出 |
| | | */ |
| | | public SendResult bmsDemandAndChargerExportationMessage(JSONObject jsonObject) { |
| | | BmsDemandAndChargerExportationMessage message = JSON.parseObject(jsonObject.toJSONString(),BmsDemandAndChargerExportationMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.BMS_DEMAND_AND_CHARGER_EXPORTATION.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.BMS_DEMAND_AND_CHARGER_EXPORTATION.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电过程BMS信息 |
| | | */ |
| | | public SendResult bmsInformationMessage(JSONObject jsonObject) { |
| | | BmsInformationMessage message = JSON.parseObject(jsonObject.toJSONString(),BmsInformationMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.BMS_INFORMATION.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.BMS_INFORMATION.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电桩主动申请启动充电 |
| | | */ |
| | | public SendResult chargingPileStartsChargingMessage(JSONObject jsonObject) { |
| | | ChargingPileStartsChargingMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingPileStartsChargingMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.CHARGING_PILE_STARTS_CHARGING.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.CHARGING_PILE_STARTS_CHARGING.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 远程启机命令回复 |
| | | */ |
| | | public SendResult platformStartChargingReplyMessage(JSONObject jsonObject) { |
| | | PlatformStartChargingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformStartChargingReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.PLATFORM_START_CHARGING_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.PLATFORM_START_CHARGING_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 远程停机命令回复 |
| | | */ |
| | | public SendResult platformStopChargingReplyMessage(JSONObject jsonObject) { |
| | | PlatformStopChargingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformStopChargingReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.PLATFORM_STOP_CHARGING_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.PLATFORM_STOP_CHARGING_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 交易记录 |
| | | */ |
| | | public SendResult transactionRecordMessage(JSONObject jsonObject) { |
| | | TransactionRecordMessage message = JSON.parseObject(jsonObject.toJSONString(),TransactionRecordMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.TRANSACTION_RECORD.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.TRANSACTION_RECORD.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 余额更新应答 |
| | | */ |
| | | public SendResult updateBalanceReplyMessage(JSONObject jsonObject) { |
| | | UpdateBalanceReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),UpdateBalanceReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.UPDATE_BALANCE_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.UPDATE_BALANCE_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 卡数据同步应答 |
| | | */ |
| | | public SendResult synchronizeOfflineCardReplyMessage(JSONObject jsonObject) { |
| | | SynchronizeOfflineCardReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),SynchronizeOfflineCardReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.SYNCHRONIZE_OFFLINE_CARD_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.SYNCHRONIZE_OFFLINE_CARD_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 离线卡数据清除应答 |
| | | */ |
| | | public SendResult clearOfflineCardReplyMessage(JSONObject jsonObject) { |
| | | ClearOfflineCardReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),ClearOfflineCardReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.CLEAR_OFFLINE_CARD_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.CLEAR_OFFLINE_CARD_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电桩工作参数设置应答 |
| | | */ |
| | | public SendResult workingParameterSettingReplyMessage(JSONObject jsonObject) { |
| | | WorkingParameterSettingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),WorkingParameterSettingReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.WORKING_PARAMETER_SETTING_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.WORKING_PARAMETER_SETTING_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 对时设置应答 |
| | | */ |
| | | public SendResult timingSettingReplyMessage(JSONObject jsonObject) { |
| | | TimingSettingReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),TimingSettingReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.TIMING_SETTING_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.TIMING_SETTING_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 计费模型应答 |
| | | */ |
| | | public SendResult setupBillingModelReplyMessage(JSONObject jsonObject) { |
| | | SetupBillingModelReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),SetupBillingModelReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.SETUP_BILLING_MODEL_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.SETUP_BILLING_MODEL_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 地锁数据上送(充电桩上送) |
| | | */ |
| | | public SendResult groundLockRealTimeDataMessage(JSONObject jsonObject) { |
| | | GroundLockRealTimeDataMessage message = JSON.parseObject(jsonObject.toJSONString(),GroundLockRealTimeDataMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.GROUND_LOCK_REAL_TIME_DATA.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.GROUND_LOCK_REAL_TIME_DATA.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 充电桩返回数据(上行) |
| | | */ |
| | | public SendResult chargingPileReturnsGroundLockDataMessage(JSONObject jsonObject) { |
| | | ChargingPileReturnsGroundLockDataMessage message = JSON.parseObject(jsonObject.toJSONString(),ChargingPileReturnsGroundLockDataMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 远程重启应答 |
| | | */ |
| | | public SendResult platformRestartReplyMessage(JSONObject jsonObject) { |
| | | PlatformRestartReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformRestartReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.PLATFORM_RESTART_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.PLATFORM_RESTART_REPLY.getValue(), message); |
| | | } |
| | | |
| | | /** |
| | | * 远程更新应答 |
| | | */ |
| | | public SendResult platformRemoteUpdateReplyMessage(JSONObject jsonObject) { |
| | | PlatformRemoteUpdateReplyMessage message = JSON.parseObject(jsonObject.toJSONString(),PlatformRemoteUpdateReplyMessage.class); |
| | | // 设置业务key |
| | | message.setKey(UUID.randomUUID().toString()); |
| | | // 设置消息来源,便于查询 |
| | | message.setSource(SendTagMenu.PLATFORM_REMOTE_UPDATE_REPLY.getValue()); |
| | | return rocketMQEnhanceTemplate.send(TOPIC, SendTagMenu.PLATFORM_REMOTE_UPDATE_REPLY.getValue(), message); |
| | | } |
| | | } |