Pu Zhibing
4 天以前 60688f1573eadd0c76dea6b94e684bf363bd99ab
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java
@@ -66,7 +66,7 @@
     */
    @PostMapping(value = "/message")
    public AjaxResult<String> message(@RequestBody JSONObject jsonObject) throws IOException {
        log.info("接收到消息中转:{}",jsonObject);
        log.info("接收到消息中转:{}",jsonObject.toJSONString());
        JSONObject body = jsonObject.getJSONObject("notify_data").getJSONObject("body");
        JSONObject content = null;
        try {
@@ -77,7 +77,7 @@
            if(!"}".equals(substring)){
                content1 = content1.substring(0, content1.length() - 1) + "}";
            }
            log.info("content1:"+content1);
//            log.info("content1:"+content1);
            content = JSON.parseObject(content1);
        }
        JSONObject header = jsonObject.getJSONObject("notify_data").getJSONObject("header");
@@ -85,7 +85,7 @@
        String nodeId = header.getString("node_id"); // 设备编号
        String productId = header.getString("product_id"); // 产品id
        String service_id = content.getString("service_id");
        log.info("服务id:{}",service_id);
//        log.info("服务id:{}",service_id);
        ChargingMessage chargingMessage = new ChargingMessage();
        chargingMessage.setServiceId(service_id);
        // 设备消息下发
@@ -103,7 +103,7 @@
                onlineReply.setCharging_pile_code(onlineMessage.getCharging_pile_code());
                onlineReply.setOnline_result(0);
                result = iotMessageProduce.sendMessage(onlineReply.getCharging_pile_code(), ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply));
                log.info("充电桩登录认证-返回结果:{}",result);
//                log.info("充电桩登录认证-返回结果:{}",result);
                // 响应硬件 对时设置应答
                TimingSettingReply timingSettingReplyOnline = new TimingSettingReply();
                timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code());
@@ -117,7 +117,7 @@
                
                PingMessage pingMessage = JSON.parseObject(content.toJSONString(),PingMessage.class);
                //存储缓存中,5分钟有效
                redisTemplate.opsForValue().set("ping:" + pingMessage.getCharging_pile_code() + pingMessage.getCharging_gun_code(), pingMessage, 5, TimeUnit.MINUTES);
//                redisTemplate.opsForValue().set("ping:" + pingMessage.getCharging_pile_code() + pingMessage.getCharging_gun_code(), pingMessage, 5, TimeUnit.MINUTES);
                
                // 响应硬件
                Pong pong = new Pong();
@@ -218,7 +218,6 @@
            case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA:
                long UPLOAD_REAL_TIME_MONITORING_DATA = System.currentTimeMillis();
                
                log.info("充电实时数据上传");
                UploadRealTimeMonitoringDataMessage uploadRealTimeMonitoringDataMessage = JSON.parseObject(content.toJSONString(),UploadRealTimeMonitoringDataMessage.class);
                chargingMessage.setUploadRealTimeMonitoringDataMessage(uploadRealTimeMonitoringDataMessage);
                chargingMessageUtil.handleMessage(chargingMessage);