puzhibing
7 小时以前 e1c8c9d51f1c6e42c9868743f16fa8e52bb419cd
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/service/UdanEmsMessageProcessor.java
@@ -8,13 +8,7 @@
import com.ruoyi.other.emind.mapper.EmindStationMapper;
import com.ruoyi.other.emind.mapper.EmindStorageDashboardMapper;
import com.ruoyi.other.emind.service.EmindEnergyChainDetailService;
import com.ruoyi.other.udan.model.EmsState;
import com.ruoyi.other.udan.model.BatteryStackState;
import com.ruoyi.other.udan.model.ElectricMeterState;
import com.ruoyi.other.udan.model.PcsState;
import com.ruoyi.other.udan.model.PowerMeterState;
import com.ruoyi.other.udan.model.TmsState;
import com.ruoyi.other.udan.model.UdanEmsDeviceState;
import com.ruoyi.other.udan.model.*;
import com.ruoyi.other.udan.util.UdanEmsKafkaUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@@ -108,6 +102,9 @@
            else if (type == 2 && field == 8) state.setPowerMeterState(parsePowerMeter(in.readBytes().toByteArray()));
            else if (type == 2 && field == 14 && state.getTmsState() == null) {
                state.setTmsState(parseTms(in.readBytes().toByteArray()));
            }
            else if (type == 2 && field == 15 && state.getPeripheralDeviceState() == null) {
                state.setPeripheralDeviceState(parsePeripheral(in.readBytes().toByteArray()));
            }
            else skip(in, type);
        });
@@ -318,6 +315,19 @@
        return value;
    }
    private PeripheralDeviceState parsePeripheral(byte[] bytes) throws IOException {
        PeripheralDeviceState value = new PeripheralDeviceState();
        read(bytes, (field, type, input) -> {
            switch (field) {
                case 1: value.setDeviceId(str(input, type)); break;
                case 2: value.setDiState(u32(input, type)); break;
                default: skip(input, type);
            }
        });
        value.convert();
        return value;
    }
    private void read(byte[] bytes, Reader reader) throws IOException {
        CodedInputStream input = CodedInputStream.newInstance(bytes == null ? new byte[0] : bytes);
        while (!input.isAtEnd()) {
@@ -435,4 +445,5 @@
    private interface Reader {
        void read(int field, int type, CodedInputStream input) throws IOException;
    }
}