package com.ruoyi.integration.iotda.utils.listener;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.integration.iotda.constant.SendTagConstant;
|
import com.ruoyi.integration.rocket.produce.EnhanceProduce;
|
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.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.io.IOException;
|
|
/**
|
* iotda消息监听
|
*/
|
@Slf4j
|
@RestController
|
public class IotMessageListener {
|
|
@Autowired
|
private EnhanceProduce enhanceProduce;
|
|
/**
|
* 设备消息监听
|
* @param jsonObject
|
* @return
|
* @throws IOException
|
*/
|
@PostMapping(value = "/message")
|
public AjaxResult<String> message(@RequestBody JSONObject jsonObject) throws IOException {
|
log.info("接收到消息中转:{}",jsonObject);
|
JSONObject content = jsonObject.getJSONObject("content");
|
String service_id = content.getString("service_id");
|
log.info("服务id:{}",service_id);
|
SendResult sendResult;
|
// 设备消息下发
|
switch (service_id){
|
case SendTagConstant.ONLINE:
|
sendResult = enhanceProduce.onlineMessage(content);
|
break;
|
case SendTagConstant.PING:
|
sendResult = enhanceProduce.pingMessage(content);
|
break;
|
case SendTagConstant.BILLING_MODE_VERIFY:
|
sendResult = enhanceProduce.billingModeVerifyMessage(content);
|
break;
|
case SendTagConstant.ACQUISITION_BILLING_MODE:
|
sendResult = enhanceProduce.acquisitionBillingModeMessage(content);
|
break;
|
case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA:
|
sendResult = enhanceProduce.uploadRealTimeMonitoringDataMessage(content);
|
break;
|
case SendTagConstant.CHARGING_HANDSHAKE:
|
sendResult = enhanceProduce.chargingHandshakeMessage(content);
|
break;
|
case SendTagConstant.BMS_ABORT:
|
sendResult = enhanceProduce.bmsAbortMessage(content);
|
break;
|
case SendTagConstant.MOTOR_ABORT:
|
sendResult = enhanceProduce.motorAbortMessage(content);
|
break;
|
case SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION:
|
sendResult = enhanceProduce.bmsDemandAndChargerExportationMessage(content);
|
break;
|
case SendTagConstant.BMS_INFORMATION:
|
sendResult = enhanceProduce.bmsInformationMessage(content);
|
break;
|
case SendTagConstant.CHARGING_PILE_STARTS_CHARGING:
|
sendResult = enhanceProduce.chargingPileStartsChargingMessage(content);
|
break;
|
case SendTagConstant.PLATFORM_START_CHARGING_REPLY:
|
sendResult = enhanceProduce.platformStartChargingReplyMessage(content);
|
break;
|
case SendTagConstant.PLATFORM_STOP_CHARGING_REPLY:
|
sendResult = enhanceProduce.platformStopChargingReplyMessage(content);
|
break;
|
case SendTagConstant.TRANSACTION_RECORD:
|
sendResult = enhanceProduce.transactionRecordMessage(content);
|
break;
|
case SendTagConstant.UPDATE_BALANCE_REPLY:
|
sendResult = enhanceProduce.updateBalanceReplyMessage(content);
|
break;
|
case SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY:
|
sendResult = enhanceProduce.synchronizeOfflineCardReplyMessage(content);
|
break;
|
case SendTagConstant.CLEAR_OFFLINE_CARD_REPLY:
|
sendResult = enhanceProduce.clearOfflineCardReplyMessage(content);
|
break;
|
case SendTagConstant.WORKING_PARAMETER_SETTING_REPLY:
|
sendResult = enhanceProduce.workingParameterSettingReplyMessage(content);
|
break;
|
case SendTagConstant.TIMING_SETTING_REPLY:
|
sendResult = enhanceProduce.timingSettingReplyMessage(content);
|
break;
|
case SendTagConstant.SETUP_BILLING_MODEL_REPLY:
|
sendResult = enhanceProduce.setupBillingModelReplyMessage(content);
|
break;
|
case SendTagConstant.GROUND_LOCK_REAL_TIME_DATA:
|
sendResult = enhanceProduce.groundLockRealTimeDataMessage(content);
|
break;
|
case SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA:
|
sendResult = enhanceProduce.chargingPileReturnsGroundLockDataMessage(content);
|
break;
|
case SendTagConstant.PLATFORM_RESTART_REPLY:
|
sendResult = enhanceProduce.platformRestartReplyMessage(content);
|
break;
|
default:
|
sendResult = enhanceProduce.platformRemoteUpdateReplyMessage(content);
|
break;
|
}
|
log.info("rocketmq消息下发结果:{}",sendResult);
|
return AjaxResult.success();
|
}
|
|
}
|