longz
2026-08-03 50827659c0c6d9bfd797d9dc381c34fe52039608
修复光伏历史发电量同步
1个文件已添加
1个文件已修改
32 ■■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TStationInfoServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/test/java/com/ruoyi/other/service/impl/TStationInfoServiceImplTest.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TStationInfoServiceImpl.java
@@ -81,16 +81,8 @@
        log.info("-------2结束同步科士达-逆变器列表----");
        log.info("-------3开始同步科士达-电站的电量和收益统计查询----");
        LocalDate startDate = stationEarnService.getMaxSaveTime();
        String startDateStr = "";
        String endDateStr = "";
        if(Objects.nonNull(startDate)) {
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
            // String dateStr = startDate.plusDays(1).format(formatter);
            String dateStr = startDate.format(formatter);
            startDateStr = dateStr + " 00:00:00";
            endDateStr = LocalDateTime.now().format(formatter);
        }
        String startDateStr = buildSyncStartDate(LocalDate.now());
        String endDateStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        JSONArray stationEarnList = KsolarUtils.getStationElecList(startDateStr, endDateStr, token);
        stationEarnService.saveStationEarnList(stationEarnList);
        log.info("-------3结束同步科士达-电站的电量和收益统计查询----");
@@ -248,6 +240,10 @@
        return baseMap;
    }
    static String buildSyncStartDate(LocalDate date) {
        return date.withDayOfYear(1).format(DateTimeFormatter.ISO_LOCAL_DATE) + " 00:00:00";
    }
    private Long parseStationId(String stationId) {
        try {
            return Long.valueOf(stationId);
ruoyi-service/ruoyi-other/src/test/java/com/ruoyi/other/service/impl/TStationInfoServiceImplTest.java
New file
@@ -0,0 +1,16 @@
package com.ruoyi.other.service.impl;
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import static org.junit.jupiter.api.Assertions.assertEquals;
class TStationInfoServiceImplTest {
    @Test
    void syncsFromTheFirstDayOfTheCurrentYear() {
        assertEquals("2026-01-01 00:00:00",
                TStationInfoServiceImpl.buildSyncStartDate(LocalDate.of(2026, 8, 3)));
    }
}