yanderong
2026-09-26 a8aa680ab800afc04e710ee55f7297e06889f3f2
feat: 储能数据同步
6个文件已修改
33 ■■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/emind/mapper/EmindStorageDashboardMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/emind/service/EmindStationManagementService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/service/UdanEmsMessageProcessor.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/EmindStationMapper.xml 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/EmindStorageDashboardMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/sql/t_screen_content_alter.sql 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/emind/mapper/EmindStorageDashboardMapper.java
@@ -9,6 +9,7 @@
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface EmindStorageDashboardMapper {
    int upsertSnapshot(@Param("station") EmindStation station, @Param("data") EmindMainTotalDto data,
@@ -27,4 +28,6 @@
                                               @Param("endDate") LocalDate endDate);
    List<Map<String, Object>> selectCurveRows(@Param("stationId") Long stationId, @Param("platformNames") List<String> platformNames);
    List<Map<String, Object>> selectEnergyBlockRows(@Param("stationId") Long stationId, @Param("platformNames") List<String> platformNames);
    void deleteByStationIdDay(@Param("stationId") Long stationId, @Param("dateSet") Set<LocalDate> dateSet);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/emind/service/EmindStationManagementService.java
@@ -38,7 +38,7 @@
    public EmindStation add(EmindStation input) {
        LocalDateTime now = LocalDateTime.now(clock);
        EmindStation station = new EmindStation();
        station.setStationId(input.getStationId() == null ? -System.currentTimeMillis() : input.getStationId());
        station.setStationId(input.getStationId() == null ? System.currentTimeMillis() : input.getStationId());
        station.setName(input.getName());
        station.setAddress(input.getAddress());
        station.setProvince(input.getProvince());
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/udan/service/UdanEmsMessageProcessor.java
@@ -12,15 +12,19 @@
import com.ruoyi.other.udan.model.UdanEmsDeviceState;
import com.ruoyi.other.udan.util.UdanEmsKafkaUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/** 将 IEmsAllDeviceState 中模型已有的 EMS 和能耗计字段转换为业务对象。 */
@Slf4j
@@ -52,9 +56,16 @@
                EmindStation station = stations.stream().filter(s -> udanEmsDeviceState.getEmsDeviceId().equals(s.getStationCode())).findFirst().orElse(null);
                if(Objects.nonNull(station)) {
                    List<EmindIncomeHistoryDto> daily = udanEmsDeviceState.convert(station.getStationId());
                    Set<LocalDate> dateSet = daily.stream().map(EmindIncomeHistoryDto::getDate).collect(Collectors.toSet());
                    // 删除电站下该天已存在的旧数据
                    if(CollectionUtils.isNotEmpty(dateSet)) {
                        dashboardMapper.deleteByStationIdDay(station.getStationId(), dateSet);
                    }
                    if(CollectionUtils.isNotEmpty(daily)) {
                    dashboardMapper.upsertDaily(station.getStationId(), daily, now);
                    }
                }else{
                    log.info("UDAN EMS数据同步错误-电站信息不存在!");
                    log.error("UDAN EMS数据同步错误-电站信息不存在!");
                }
            }
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/EmindStationMapper.xml
@@ -79,9 +79,9 @@
    <select id="selectRemoteActiveStations" resultMap="stationResultMap">
        SELECT id, station_id, name, address, province, city, longitude, latitude,
               max_power, capacity, commissioning_time, platform_name, source_type,
               management_deleted, del_flag, synced_at, create_time, update_time
               management_deleted, del_flag, synced_at, create_time, update_time, station_code
        FROM t_emind_station
        WHERE source_type = 1 AND del_flag = 0 AND management_deleted = 0
        WHERE del_flag = 0 AND management_deleted = 0
        ORDER BY id
    </select>
</mapper>
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/EmindStorageDashboardMapper.xml
@@ -79,4 +79,9 @@
        <if test="stationId != null">AND block.station_id=#{stationId}</if>
        <if test="platformNames != null and platformNames.size() > 0">AND snapshot.platform_name IN <foreach collection="platformNames" item="name" open="(" separator="," close=")">#{name}</foreach></if>
    </select>
    <select id="deleteByStationIdDay">
        delete from t_emind_dashboard_daily
               where station_id=#{stationId}
                and stat_date in <foreach collection="dateSet" item="dateValue" open="(" separator="," close=")">#{dateValue}</foreach>
    </select>
</mapper>
ruoyi-service/ruoyi-other/src/main/resources/sql/t_screen_content_alter.sql
@@ -1,8 +1,10 @@
-- ----------------------------
-- 1、增加大屏名称配置字段
alter table t_screen_content add column screen_name varchar(255)   default 'NULL'  null comment '大屏名称';
alter table t_screen_content add column screen_name varchar(255)   default ''  null comment '大屏名称';
-- 2、增加储能电站表设备编号
alter table t_emind_station add column station_code varchar(255)   default 'NULL'  null comment '设备编号';
alter table t_emind_station add column station_code varchar(255)   default ''  null comment '设备编号';
ALTER TABLE t_emind_dashboard_daily MODIFY COLUMN id BIGINT NOT NULL AUTO_INCREMENT comment '主键ID';