Pu Zhibing
22 小时以前 4fcd1f89d42fef05fb6592d30f168f3bfc6728d6
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java
@@ -92,6 +92,8 @@
        String result;
        switch (service_id){
            case SendTagConstant.ONLINE:
                long ONLINE = System.currentTimeMillis();
                OnlineMessage onlineMessage = JSON.parseObject(content.toJSONString(),OnlineMessage.class);
                chargingMessage.setOnlineMessage(onlineMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
@@ -107,8 +109,12 @@
                timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code());
                timingSettingReplyOnline.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date()));
                iotMessageProduce.sendMessage(timingSettingReplyOnline.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline));
                log.warn("ONLINE消息处理:{} 毫秒", System.currentTimeMillis() - ONLINE);
                break;
            case SendTagConstant.PING:
                long PING = System.currentTimeMillis();
                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);
@@ -119,24 +125,45 @@
                pong.setCharging_gun_code(pingMessage.getCharging_gun_code());
                pong.setCharging_gun_status(0);
                iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong));
                Long time = (Long) redisTemplate.opsForHash().get("charging_gun_online", (pingMessage.getCharging_pile_code() + pingMessage.getCharging_gun_code()));
                //小于1分钟才处理数据,防止频繁查询数据
                if(null != time && (System.currentTimeMillis() - time) < 60000){
                    log.warn("PING消息处理:{} 毫秒", System.currentTimeMillis() - PING);
                    break;
                }
                //检查修改设备状态
                UpdateChargingPileStatusVo vo1 = new UpdateChargingPileStatusVo();
                vo1.setGun_code(pingMessage.getCharging_gun_code());
                vo1.setPile_code(pingMessage.getCharging_pile_code());
                vo1.setStatus(pingMessage.getCharging_gun_status());
                chargingPileClient.updateChargingPileStatus(vo1);
                log.warn("PING消息处理:{} 毫秒", System.currentTimeMillis() - PING);
                break;
            case SendTagConstant.END_CHARGE:
                long END_CHARGE = System.currentTimeMillis();
                EndChargeMessage endChargeMessage = JSON.parseObject(content.toJSONString(),EndChargeMessage.class);
                chargingMessage.setEndChargeMessage(endChargeMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("END_CHARGE消息处理:{} 毫秒", System.currentTimeMillis() - END_CHARGE);
                break;
            case SendTagConstant.ERROR_MESSAGE:
                long ERROR_MESSAGE = System.currentTimeMillis();
                ErrorMessageMessage errorMessageMessage = JSON.parseObject(content.toJSONString(),ErrorMessageMessage.class);
                chargingMessage.setErrorMessageMessage(errorMessageMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("ERROR_MESSAGE消息处理:{} 毫秒", System.currentTimeMillis() - ERROR_MESSAGE);
                break;
            case SendTagConstant.BILLING_MODE_VERIFY:
                long BILLING_MODE_VERIFY = System.currentTimeMillis();
                BillingModeVerifyMessage billingModeVerifyMessage = JSON.parseObject(content.toJSONString(),BillingModeVerifyMessage.class);
                chargingMessage.setBillingModeVerifyMessage(billingModeVerifyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
@@ -163,8 +190,12 @@
                    }
                }
                iotMessageProduce.sendMessage(billingModeVerifyReply.getCharging_pile_code(), ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply));
                log.warn("ERROR_MESSAGE消息处理:{} 毫秒", System.currentTimeMillis() - BILLING_MODE_VERIFY);
                break;
            case SendTagConstant.ACQUISITION_BILLING_MODE:
                long ACQUISITION_BILLING_MODE = System.currentTimeMillis();
                AcquisitionBillingModeMessage acquisitionBillingModeMessage = JSON.parseObject(content.toJSONString(),AcquisitionBillingModeMessage.class);
                chargingMessage.setAcquisitionBillingModeMessage(acquisitionBillingModeMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
@@ -181,44 +212,76 @@
                acquisitionBillingModeReply.setCharging_pile_code(acquisitionBillingModeMessage.getCharging_pile_code());
                acquisitionBillingModeReply.setLoss_ratio(BigDecimal.ZERO);
                iotMessageProduce.sendMessage(acquisitionBillingModeReply.getCharging_pile_code(), ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply));
                log.warn("ACQUISITION_BILLING_MODE消息处理:{} 毫秒", System.currentTimeMillis() - ACQUISITION_BILLING_MODE);
                break;
            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);
                log.warn("UPLOAD_REAL_TIME_MONITORING_DATA消息处理:{} 毫秒", System.currentTimeMillis() - UPLOAD_REAL_TIME_MONITORING_DATA);
                break;
            case SendTagConstant.CHARGING_HANDSHAKE:
                long CHARGING_HANDSHAKE = System.currentTimeMillis();
                ChargingHandshakeMessage chargingHandshakeMessage = JSON.parseObject(content.toJSONString(),ChargingHandshakeMessage.class);
                chargingMessage.setChargingHandshakeMessage(chargingHandshakeMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("CHARGING_HANDSHAKE消息处理:{} 毫秒", System.currentTimeMillis() - CHARGING_HANDSHAKE);
                break;
            case SendTagConstant.PARAMETER_SETTING:
                long PARAMETER_SETTING = System.currentTimeMillis();
                ParameterSettingMessage parameterSettingMessage = JSON.parseObject(content.toJSONString(),ParameterSettingMessage.class);
                chargingMessage.setParameterSettingMessage(parameterSettingMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("PARAMETER_SETTING消息处理:{} 毫秒", System.currentTimeMillis() - PARAMETER_SETTING);
                break;
            case SendTagConstant.BMS_ABORT:
                long BMS_ABORT = System.currentTimeMillis();
                BmsAbortMessage bmsAbortMessage = JSON.parseObject(content.toJSONString(),BmsAbortMessage.class);
                chargingMessage.setBmsAbortMessage(bmsAbortMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("BMS_ABORT消息处理:{} 毫秒", System.currentTimeMillis() - BMS_ABORT);
                break;
            case SendTagConstant.MOTOR_ABORT:
                long MOTOR_ABORT = System.currentTimeMillis();
                MotorAbortMessage motorAbortMessage = JSON.parseObject(content.toJSONString(),MotorAbortMessage.class);
                chargingMessage.setMotorAbortMessage(motorAbortMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("MOTOR_ABORT消息处理:{} 毫秒", System.currentTimeMillis() - MOTOR_ABORT);
                break;
            case SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION:
                long BMS_DEMAND_AND_CHARGER_EXPORTATION = System.currentTimeMillis();
                BmsDemandAndChargerExportationMessage bmsDemandAndChargerExportationMessage = JSON.parseObject(content.toJSONString(),BmsDemandAndChargerExportationMessage.class);
                chargingMessage.setBmsDemandAndChargerExportationMessage(bmsDemandAndChargerExportationMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("BMS_DEMAND_AND_CHARGER_EXPORTATION消息处理:{} 毫秒", System.currentTimeMillis() - BMS_DEMAND_AND_CHARGER_EXPORTATION);
                break;
            case SendTagConstant.BMS_INFORMATION:
                long BMS_INFORMATION = System.currentTimeMillis();
                BmsInformationMessage bmsInformationMessage = JSON.parseObject(content.toJSONString(),BmsInformationMessage.class);
                chargingMessage.setBmsInformationMessage(bmsInformationMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("BMS_INFORMATION消息处理:{} 毫秒", System.currentTimeMillis() - BMS_INFORMATION);
                break;
            case SendTagConstant.CHARGING_PILE_STARTS_CHARGING:
                long CHARGING_PILE_STARTS_CHARGING = System.currentTimeMillis();
                ChargingPileStartsChargingMessage chargingPileStartsChargingMessage = JSON.parseObject(content.toJSONString(),ChargingPileStartsChargingMessage.class);
                chargingMessage.setChargingPileStartsChargingMessage(chargingPileStartsChargingMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
@@ -231,18 +294,30 @@
                platformConfirmationCharging.setAuthentication(1);
                // TODO 若是失败,给出失败原因
                iotMessageProduce.sendMessage(platformConfirmationCharging.getCharging_pile_code(), ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging));
                log.warn("CHARGING_PILE_STARTS_CHARGING消息处理:{} 毫秒", System.currentTimeMillis() - CHARGING_PILE_STARTS_CHARGING);
                break;
            case SendTagConstant.PLATFORM_START_CHARGING_REPLY:
                long PLATFORM_START_CHARGING_REPLY = System.currentTimeMillis();
                PlatformStartChargingReplyMessage platformStartChargingReplyMessage = JSON.parseObject(content.toJSONString(),PlatformStartChargingReplyMessage.class);
                chargingMessage.setPlatformStartChargingReplyMessage(platformStartChargingReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("PLATFORM_START_CHARGING_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - PLATFORM_START_CHARGING_REPLY);
                break;
            case SendTagConstant.PLATFORM_STOP_CHARGING_REPLY:
                long PLATFORM_STOP_CHARGING_REPLY = System.currentTimeMillis();
                PlatformStopChargingReplyMessage platformStopChargingReplyMessage = JSON.parseObject(content.toJSONString(),PlatformStopChargingReplyMessage.class);
                chargingMessage.setPlatformStopChargingReplyMessage(platformStopChargingReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("PLATFORM_STOP_CHARGING_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - PLATFORM_STOP_CHARGING_REPLY);
                break;
            case SendTagConstant.TRANSACTION_RECORD:
                long TRANSACTION_RECORD = System.currentTimeMillis();
                TransactionRecordMessage transactionRecordMessage = JSON.parseObject(content.toJSONString(),TransactionRecordMessage.class);
                transactionRecordMessage.setResult(content.toJSONString());
                chargingMessage.setTransactionRecordMessage(transactionRecordMessage);
@@ -252,28 +327,48 @@
                confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number());
                confirmTransactionRecord.setConfirm_result(0);
                iotMessageProduce.sendMessage(transactionRecordMessage.getCharging_pile_code(), ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord));
                log.warn("TRANSACTION_RECORD消息处理:{} 毫秒", System.currentTimeMillis() - TRANSACTION_RECORD);
                break;
            case SendTagConstant.UPDATE_BALANCE_REPLY:
                long UPDATE_BALANCE_REPLY = System.currentTimeMillis();
                UpdateBalanceReplyMessage updateBalanceReplyMessage = JSON.parseObject(content.toJSONString(),UpdateBalanceReplyMessage.class);
                chargingMessage.setUpdateBalanceReplyMessage(updateBalanceReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("UPDATE_BALANCE_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - UPDATE_BALANCE_REPLY);
                break;
            case SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY:
                long SYNCHRONIZE_OFFLINE_CARD_REPLY = System.currentTimeMillis();
                SynchronizeOfflineCardReplyMessage synchronizeOfflineCardReplyMessage = JSON.parseObject(content.toJSONString(),SynchronizeOfflineCardReplyMessage.class);
                chargingMessage.setSynchronizeOfflineCardReplyMessage(synchronizeOfflineCardReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("SYNCHRONIZE_OFFLINE_CARD_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - SYNCHRONIZE_OFFLINE_CARD_REPLY);
                break;
            case SendTagConstant.CLEAR_OFFLINE_CARD_REPLY:
                long CLEAR_OFFLINE_CARD_REPLY = System.currentTimeMillis();
                ClearOfflineCardReplyMessage clearOfflineCardReplyMessage = JSON.parseObject(content.toJSONString(),ClearOfflineCardReplyMessage.class);
                chargingMessage.setClearOfflineCardReplyMessage(clearOfflineCardReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("CLEAR_OFFLINE_CARD_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - CLEAR_OFFLINE_CARD_REPLY);
                break;
            case SendTagConstant.WORKING_PARAMETER_SETTING_REPLY:
                long WORKING_PARAMETER_SETTING_REPLY = System.currentTimeMillis();
                WorkingParameterSettingReplyMessage workingParameterSettingReplyMessage = JSON.parseObject(content.toJSONString(),WorkingParameterSettingReplyMessage.class);
                chargingMessage.setWorkingParameterSettingReplyMessage(workingParameterSettingReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("WORKING_PARAMETER_SETTING_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - WORKING_PARAMETER_SETTING_REPLY);
                break;
            case SendTagConstant.TIMING_SETTING:
                long TIMING_SETTING = System.currentTimeMillis();
                TimingSettingMessage timingSettingMessage = JSON.parseObject(content.toJSONString(),TimingSettingMessage.class);
                chargingMessage.setTimingSettingMessage(timingSettingMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
@@ -282,41 +377,71 @@
                timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code());
                timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date()));
                iotMessageProduce.sendMessage(timingSettingReply.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply));
                log.warn("TIMING_SETTING消息处理:{} 毫秒", System.currentTimeMillis() - TIMING_SETTING);
                break;
            case SendTagConstant.SETUP_BILLING_MODEL_REPLY:
                long SETUP_BILLING_MODEL_REPLY = System.currentTimeMillis();
                SetupBillingModelReplyMessage setupBillingModelReplyMessage = JSON.parseObject(content.toJSONString(),SetupBillingModelReplyMessage.class);
                chargingMessage.setSetupBillingModelReplyMessage(setupBillingModelReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("SETUP_BILLING_MODEL_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - SETUP_BILLING_MODEL_REPLY);
                break;
            case SendTagConstant.GROUND_LOCK_REAL_TIME_DATA:
                long GROUND_LOCK_REAL_TIME_DATA = System.currentTimeMillis();
                GroundLockRealTimeDataMessage groundLockRealTimeDataMessage = JSON.parseObject(content.toJSONString(),GroundLockRealTimeDataMessage.class);
                chargingMessage.setGroundLockRealTimeDataMessage(groundLockRealTimeDataMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("GROUND_LOCK_REAL_TIME_DATA消息处理:{} 毫秒", System.currentTimeMillis() - GROUND_LOCK_REAL_TIME_DATA);
                break;
            case SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA:
                long CHARGING_PILE_RETURNS_GROUND_LOCK_DATA = System.currentTimeMillis();
                ChargingPileReturnsGroundLockDataMessage chargingPileReturnsGroundLockDataMessage = JSON.parseObject(content.toJSONString(),ChargingPileReturnsGroundLockDataMessage.class);
                chargingMessage.setChargingPileReturnsGroundLockDataMessage(chargingPileReturnsGroundLockDataMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("CHARGING_PILE_RETURNS_GROUND_LOCK_DATA消息处理:{} 毫秒", System.currentTimeMillis() - CHARGING_PILE_RETURNS_GROUND_LOCK_DATA);
                break;
            case SendTagConstant.PLATFORM_RESTART_REPLY:
                long PLATFORM_RESTART_REPLY = System.currentTimeMillis();
                PlatformRestartReplyMessage platformRestartReplyMessage = JSON.parseObject(content.toJSONString(),PlatformRestartReplyMessage.class);
                chargingMessage.setPlatformRestartReplyMessage(platformRestartReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("PLATFORM_RESTART_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - PLATFORM_RESTART_REPLY);
                break;
            case SendTagConstant.QR_CODE_DELIVERY_REPLY:
                long QR_CODE_DELIVERY_REPLY = System.currentTimeMillis();
                QrCodeDeliveryReplyMessage qrCodeDeliveryReplyMessage = JSON.parseObject(content.toJSONString(),QrCodeDeliveryReplyMessage.class);
                chargingMessage.setQrCodeDeliveryReplyMessage(qrCodeDeliveryReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("QR_CODE_DELIVERY_REPLY消息处理:{} 毫秒", System.currentTimeMillis() - QR_CODE_DELIVERY_REPLY);
                break;
            case SendTagConstant.SECURITY_DETECTION:
                long SECURITY_DETECTION = System.currentTimeMillis();
                SecurityDetectionMessage securityDetectionMessage = JSON.parseObject(content.toJSONString(),SecurityDetectionMessage.class);
                chargingMessage.setSecurityDetectionMessage(securityDetectionMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("SECURITY_DETECTION消息处理:{} 毫秒", System.currentTimeMillis() - SECURITY_DETECTION);
                break;
            default:
                long other = System.currentTimeMillis();
                PlatformRemoteUpdateReplyMessage platformRemoteUpdateReplyMessage = JSON.parseObject(content.toJSONString(),PlatformRemoteUpdateReplyMessage.class);
                chargingMessage.setPlatformRemoteUpdateReplyMessage(platformRemoteUpdateReplyMessage);
                chargingMessageUtil.handleMessage(chargingMessage);
                log.warn("other消息处理:{} 毫秒", System.currentTimeMillis() - other);
                break;
        }
        return AjaxResult.success();