diff --git a/backend/src/main/java/com/yfd/platform/qgc_data/mapper/FishStatisticsMapper.java b/backend/src/main/java/com/yfd/platform/qgc_data/mapper/FishStatisticsMapper.java index f0df6603..8bb8fdd8 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_data/mapper/FishStatisticsMapper.java +++ b/backend/src/main/java/com/yfd/platform/qgc_data/mapper/FishStatisticsMapper.java @@ -9,9 +9,11 @@ public interface FishStatisticsMapper { List queryStatistics(@Param("basinCode") String basinCode, @Param("stationCode") String stationCode, + @Param("reportMonth") String reportMonth, @Param("startRow") int startRow, @Param("endRow") int endRow); int countStatistics(@Param("basinCode") String basinCode, - @Param("stationCode") String stationCode); -} \ No newline at end of file + @Param("stationCode") String stationCode, + @Param("reportMonth") String reportMonth); +} diff --git a/backend/src/main/java/com/yfd/platform/qgc_data/service/impl/FishStatisticsServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_data/service/impl/FishStatisticsServiceImpl.java index 87749f86..e9a688da 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_data/service/impl/FishStatisticsServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_data/service/impl/FishStatisticsServiceImpl.java @@ -12,6 +12,8 @@ import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -29,6 +31,10 @@ public class FishStatisticsServiceImpl implements IFishStatisticsService { String basinNamesStr = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "basinCode"); String stationNamesStr = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "stationCode"); + String reportMonth = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "reportMonth"); + if (StrUtil.isBlank(reportMonth)) { + reportMonth = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("yyyy-MM")); + } // List basinNames = parseFilterList(basinNamesStr); // List stationNames = parseFilterList(stationNamesStr); @@ -47,9 +53,9 @@ public class FishStatisticsServiceImpl implements IFishStatisticsService { int endRow = startRow + pageSize; List records = fishStatisticsMapper.queryStatistics( - basinNamesStr, stationNamesStr, startRow, endRow); + basinNamesStr, stationNamesStr, reportMonth, startRow, endRow); - int total = fishStatisticsMapper.countStatistics(basinNamesStr, basinNamesStr); + int total = fishStatisticsMapper.countStatistics(basinNamesStr, stationNamesStr, reportMonth); Page page = new Page<>(); page.setRecords(records); @@ -66,4 +72,4 @@ public class FishStatisticsServiceImpl implements IFishStatisticsService { } return Arrays.asList(filterValue.split(",")); } -} \ No newline at end of file +} diff --git a/backend/src/main/resources/mapper/data/FishStatisticsMapper.xml b/backend/src/main/resources/mapper/data/FishStatisticsMapper.xml index 64fd0a73..61f193c2 100644 --- a/backend/src/main/resources/mapper/data/FishStatisticsMapper.xml +++ b/backend/src/main/resources/mapper/data/FishStatisticsMapper.xml @@ -167,6 +167,9 @@ FROM FISH_DRAFT_DATA WHERE DELETED_FLAG = 0 AND STATUS IN ('PENDING','APPROVED') + + AND TO_CHAR(STRDT, 'YYYY-MM') = #{reportMonth} + GROUP BY CREATED_BY, TO_CHAR(STRDT, 'YYYY-MM') ), @@ -186,7 +189,7 @@ sa.MIN_STATION_CODE, ba.BASIN_NAMES, sa.STATION_NAMES, - fm.REPORT_MONTH, + NVL(fm.REPORT_MONTH, #{reportMonth}) AS REPORT_MONTH, fm.MIN_STRDT, fm.MAX_ENDDT, fm.TOTAL_FCNT,