yanderong
2 天以前 686790777f722b0621bcc20e550d15965cda7b67
feat: 光伏储能bug修改
1个文件已添加
5个文件已修改
120 ■■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/emind/service/EmindEnergyChainDetailService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/energyreport/vo/StorageDailyReportRow.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TStationInfoServiceImpl.java 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/model/PeripheralDeviceState.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/model/UdanEmsDeviceState.java 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/service/UdanEmsMessageProcessor.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/emind/service/EmindEnergyChainDetailService.java
@@ -102,6 +102,16 @@
            detail.setStationType("BMS");
            detailList.add(detail);
        }
        if(Objects.nonNull(udanEmsDeviceState.getPeripheralDeviceState())) {
            EmindEnergyChainDetail detail = new EmindEnergyChainDetail();
            detail.setPlatformName("欧力特");
            detail.setDataSource(2);
            detail.setStationCode(udanEmsDeviceState.getEmsSystemId());
            detail.setDetail(JSON.toJSONString(udanEmsDeviceState.getPeripheralDeviceState()));
            detail.setStationId(udanEmsDeviceState.getTmsState().getDeviceId());
            detail.setStationType("外设");
            detailList.add(detail);
        }
        detailList.forEach(d -> {
            mapper.delete(new QueryWrapper<EmindEnergyChainDetail>().eq("station_code", d.getStationCode()).eq("station_type", d.getStationType()));
            add(d);
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/energyreport/vo/StorageDailyReportRow.java
@@ -12,8 +12,8 @@
    @ExcelProperty("电站ID") private String stationId;
    @ExcelProperty("电站名称") private String stationName;
    @ExcelProperty("日期") private LocalDate statDate;
    @ExcelProperty("当日电价") private BigDecimal price;
    @ExcelProperty("电价名称") private String priceName;
/*    @ExcelProperty("当日电价") private BigDecimal price;
    @ExcelProperty("电价名称") private String priceName;*/
    @ExcelProperty("总收益(元)") private BigDecimal income;
    @ExcelProperty("总充电量(kWh)") private BigDecimal chargedEnergy;
    @ExcelProperty("尖时段充电量(kWh)") private BigDecimal chargedEnergySharp;
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TStationInfoServiceImpl.java
@@ -457,6 +457,7 @@
            info.setLoanStatus(gridTime != null && gridTime.isBefore(LocalDateTime.now()) ? 3 : 1);
            info.setGridStatus(info.getLoanStatus() == 3 ? "1" : "0");
            info.setDataSource(2);
            info.setDeviceCount(1);
            info.setSyncTime(LocalDateTime.now());
            info.setCreateTime(LocalDateTime.now());
            info.setUpdateTime(LocalDateTime.now());
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/model/PeripheralDeviceState.java
New file
@@ -0,0 +1,79 @@
package com.ruoyi.other.udan.model;
import lombok.Data;
import java.io.Serializable;
import java.util.Objects;
/**
 * 外设
 *
 * @author Lux
 * @version 1.0.0
 * @since 2026/10/12 21:24
 */
@Data
public class PeripheralDeviceState implements Serializable {
    /**
     * 设备id
     */
    private String deviceId;
    /**
     * 原始di_state值
     */
    private Integer diState;
    /**
     * 急停状态 bit1
     */
    private Boolean emergencyStop;
    /**
     * 消防状态 bit2
     */
    private Boolean fireStatus;
    /**
     * 水浸状态 bit5
     */
    private Boolean waterLeak;
    /**
     * 消防喷洒 bit7
     */
    private Boolean fireSpray;
    /**
     * bit解析
     *
     * bit1 急停
     * bit2 消防
     * bit5 水浸
     * bit7 消防喷洒
     */
    public void convert() {
        if(Objects.nonNull(this.getDiState())) {
            this.setEmergencyStop(getBit(this.getDiState(),1));
            this.setFireStatus(getBit(this.getDiState(),2));
            this.setWaterLeak(getBit(this.getDiState(),5));
            this.setFireSpray(getBit(this.getDiState(),7));
        }
    }
    /**
     * 获取bit状态
     *
     * @param value 原始值
     * @param bit   bit编号,从1开始
     */
    public boolean getBit(int value, int bit) {
        return ((value >> (bit - 1)) & 1) == 1;
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/model/UdanEmsDeviceState.java
@@ -26,6 +26,7 @@
    private PcsState pcsState;
    private ElectricMeterState electricMeterState;
    private BatteryStackState batteryStackState;
    private PeripheralDeviceState peripheralDeviceState;
    public List<EmindIncomeHistoryDto> convert(Long stationId) {
        List<EmindIncomeHistoryDto> dailyList = new ArrayList<>();
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;
    }
}