无关风月
2024-12-11 4d7a208f388e42e7dd83dab0e38eadfa0847de1c
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java
@@ -23,6 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
@@ -44,7 +45,7 @@
    private MessageUtil messageUtil;
    @Autowired
    private IotMessageProduce iotMessageProduce;
    @Autowired
    @Resource
    private AccountingStrategyDetailClient accountingStrategyDetailClient;
    /**
     * 设备消息监听
@@ -81,13 +82,13 @@
                OnlineReply onlineReply = new OnlineReply();
                onlineReply.setCharging_pile_code(onlineMessage.getCharging_pile_code());
                onlineReply.setOnline_result(0);
                result = iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply));
                result = iotMessageProduce.sendMessage(onlineReply.getCharging_pile_code(), ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply));
                log.info("充电桩登录认证-返回结果:{}",result);
                // 响应硬件 对时设置应答
                TimingSettingReply timingSettingReplyOnline = new TimingSettingReply();
                timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code());
                timingSettingReplyOnline.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date()));
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline));
                iotMessageProduce.sendMessage(timingSettingReplyOnline.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.PING:
@@ -98,7 +99,7 @@
                pong.setCharging_pile_code(pingMessage.getCharging_pile_code());
                pong.setCharging_gun_code(pingMessage.getCharging_gun_code());
                pong.setCharging_gun_status(0);
                result = iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong));
                result = iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong));
                log.info("充电桩心跳包-返回结果:{}",result);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
@@ -139,7 +140,7 @@
                        billingModeVerifyReply.setBilling_model_result(1);
                    }
                }
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply));
                iotMessageProduce.sendMessage(billingModeVerifyReply.getCharging_pile_code(), ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.ACQUISITION_BILLING_MODE:
@@ -157,7 +158,7 @@
                acquisitionBillingModeReply.setBilling_model_code(accountingStrategyDetail.getId().toString());
                acquisitionBillingModeReply.setCharging_pile_code(acquisitionBillingModeMessage.getCharging_pile_code());
                acquisitionBillingModeReply.setLoss_ratio(BigDecimal.ZERO);
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply));
                iotMessageProduce.sendMessage(acquisitionBillingModeReply.getCharging_pile_code(), ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA:
@@ -212,7 +213,7 @@
                platformConfirmationCharging.setAccount_balance(BigDecimal.ZERO);
                platformConfirmationCharging.setAuthentication(1);
                // TODO 若是失败,给出失败原因
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging));
                iotMessageProduce.sendMessage(platformConfirmationCharging.getCharging_pile_code(), ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.PLATFORM_START_CHARGING_REPLY:
@@ -234,7 +235,7 @@
                ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord();
                confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number());
                confirmTransactionRecord.setConfirm_result(0);
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord));
                iotMessageProduce.sendMessage(confirmTransactionRecord.getTransaction_serial_number(), ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.UPDATE_BALANCE_REPLY:
@@ -268,7 +269,7 @@
                TimingSettingReply timingSettingReply = new TimingSettingReply();
                timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code());
                timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date()));
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply));
                iotMessageProduce.sendMessage(timingSettingReply.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.SETUP_BILLING_MODEL_REPLY: