xuhy
2024-09-02 2c7a721e947d86d4f8988a9b2b11b87ad7e923bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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();
    }
 
}