diff --git a/backend/src/main/java/com/yfd/platform/env/fp/controller/FishPassageController.java b/backend/src/main/java/com/yfd/platform/env/fp/controller/FishPassageController.java index e562d6f..4b4f1ba 100644 --- a/backend/src/main/java/com/yfd/platform/env/fp/controller/FishPassageController.java +++ b/backend/src/main/java/com/yfd/platform/env/fp/controller/FishPassageController.java @@ -8,8 +8,10 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -37,4 +39,10 @@ public class FishPassageController { public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) { return ResponseResult.successData(fpBuildService.processKendoList(dataSourceRequest)); } + + @GetMapping("/run/qgc/year/GetYearFpStatistics") + @Operation(summary = "全过程过鱼统计总数,根据基地分组") + public ResponseResult getYearFpStatic(@RequestParam("year") String year) { + return ResponseResult.successData(fpRunService.getYearFpStatic(year)); + } } diff --git a/backend/src/main/java/com/yfd/platform/env/fp/entity/vo/FpFtpStatisticsVo.java b/backend/src/main/java/com/yfd/platform/env/fp/entity/vo/FpFtpStatisticsVo.java new file mode 100644 index 0000000..8073de0 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/env/fp/entity/vo/FpFtpStatisticsVo.java @@ -0,0 +1,24 @@ +package com.yfd.platform.env.fp.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "按鱼种统计的过鱼数量") +public class FpFtpStatisticsVo { + + @Schema(description = "基地编码") + private String baseId; + + @Schema(description = "基地名称") + private String baseName; + + @Schema(description = "鱼种编码") + private String ftp; + + @Schema(description = "鱼种名称") + private String fishName; + + @Schema(description = "过鱼数量") + private Integer fcnt; +} diff --git a/backend/src/main/java/com/yfd/platform/env/fp/entity/vo/YearFpStatisticsVo.java b/backend/src/main/java/com/yfd/platform/env/fp/entity/vo/YearFpStatisticsVo.java new file mode 100644 index 0000000..ccbc42c --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/env/fp/entity/vo/YearFpStatisticsVo.java @@ -0,0 +1,23 @@ +package com.yfd.platform.env.fp.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "按基地分组的年度过鱼统计") +public class YearFpStatisticsVo { + + @Schema(description = "过鱼总数") + private Integer fpCount; + + @Schema(description = "基地编码") + private String baseId; + + @Schema(description = "基地名称") + private String baseName; + + @Schema(description = "按鱼种统计列表") + private List fpFtpStatitcsVos; +} diff --git a/backend/src/main/java/com/yfd/platform/env/fp/service/FpRunService.java b/backend/src/main/java/com/yfd/platform/env/fp/service/FpRunService.java index b531a5c..da68571 100644 --- a/backend/src/main/java/com/yfd/platform/env/fp/service/FpRunService.java +++ b/backend/src/main/java/com/yfd/platform/env/fp/service/FpRunService.java @@ -2,9 +2,14 @@ package com.yfd.platform.env.fp.service; import com.yfd.platform.common.DataSourceRequest; import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.env.fp.entity.vo.YearFpStatisticsVo; import com.yfd.platform.env.fp.entity.vo.FpRunPlanVo; +import java.util.List; + public interface FpRunService { DataSourceResult processQgcSecondPlanKendoList(DataSourceRequest dataSourceRequest); + + List getYearFpStatic(String year); } diff --git a/backend/src/main/java/com/yfd/platform/env/fp/service/impl/FpRunServiceImpl.java b/backend/src/main/java/com/yfd/platform/env/fp/service/impl/FpRunServiceImpl.java index e06ec8e..d2d0e9a 100644 --- a/backend/src/main/java/com/yfd/platform/env/fp/service/impl/FpRunServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/env/fp/service/impl/FpRunServiceImpl.java @@ -9,7 +9,9 @@ import com.yfd.platform.common.DataSourceRequest; import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.common.MicroservicDynamicSQLMapper; import com.yfd.platform.common.exception.BizException; +import com.yfd.platform.env.fp.entity.vo.FpFtpStatisticsVo; import com.yfd.platform.env.fp.entity.vo.FpRunPlanVo; +import com.yfd.platform.env.fp.entity.vo.YearFpStatisticsVo; import com.yfd.platform.env.fp.service.FpRunService; import com.yfd.platform.utils.QgcQueryWrapperUtil; import jakarta.annotation.Resource; @@ -17,9 +19,12 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; @@ -94,6 +99,36 @@ public class FpRunServiceImpl implements FpRunService { return result; } + @Override + public List getYearFpStatic(String year) { + Map paramMap = new HashMap<>(); + paramMap.put("year", StrUtil.trim(year)); + List rows = microservicDynamicSQLMapper.getAllListWithResultType( + buildYearFpStatisticsSql(), + paramMap, + FpFtpStatisticsVo.class + ); + if (rows == null || rows.isEmpty()) { + return new ArrayList<>(); + } + + Map grouped = new LinkedHashMap<>(); + for (FpFtpStatisticsVo row : rows) { + String key = StrUtil.nullToDefault(row.getBaseId(), ""); + YearFpStatisticsVo yearVo = grouped.computeIfAbsent(key, k -> { + YearFpStatisticsVo item = new YearFpStatisticsVo(); + item.setBaseId(row.getBaseId()); + item.setBaseName(row.getBaseName()); + item.setFpCount(0); + item.setFpFtpStatitcsVos(new ArrayList<>()); + return item; + }); + yearVo.setFpCount(yearVo.getFpCount() + (row.getFcnt() == null ? 0 : row.getFcnt())); + yearVo.getFpFtpStatitcsVos().add(row); + } + return new ArrayList<>(grouped.values()); + } + private String buildQgcSecondPlanSql() { return "SELECT t.STCD AS stcd, " + " t2.stm AS designStartDate, " + @@ -161,6 +196,36 @@ public class FpRunServiceImpl implements FpRunService { "WHERE t.STCD = #{map.stcd}"; } + private String buildYearFpStatisticsSql() { + return "SELECT eng.BASE_ID AS baseId, " + + " hb.BASENAME AS baseName, " + + " a.FTP AS ftp, " + + " COALESCE(fishRv.NAME, relRv.FISH_NAME, fishZy.NAME, relZy.FISH_NAME, a.FTP) AS fishName, " + + " SUM(a.FCNT) AS fcnt " + + "FROM SD_FPSS_R a " + + "INNER JOIN ( " + + " SELECT STCD, MAX(RSTCD) AS RSTCD " + + " FROM SD_FPSS_B_H " + + " GROUP BY STCD " + + ") fpss ON fpss.STCD = a.STCD " + + "LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = fpss.RSTCD " + + "LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = eng.BASE_ID " + + "LEFT JOIN SD_FISHDICTORY_RLTN_B relRv ON relRv.FISH_ID = a.FTP " + + " AND relRv.RVCD = eng.HBRVCD " + + " AND relRv.IS_DELETED = 0 " + + "LEFT JOIN SD_FISHDICTORY_B fishRv ON fishRv.ID = NVL(relRv.ZY_FISH_ID, relRv.FISH_ID) " + + " AND fishRv.IS_DELETED = 0 " + + "LEFT JOIN SD_FISHDICTORY_RLTN_B relZy ON relZy.FISH_ID = a.FTP " + + " AND relZy.RVCD = 'ZY' " + + " AND relZy.IS_DELETED = 0 " + + "LEFT JOIN SD_FISHDICTORY_B fishZy ON fishZy.ID = NVL(relZy.ZY_FISH_ID, relZy.FISH_ID) " + + " AND fishZy.IS_DELETED = 0 " + + "WHERE NVL(a.IS_DELETED, 0) = 0 " + + " AND (#{map.year} IS NULL OR #{map.year} = '' OR TO_CHAR(a.STRDT, 'YYYY') = #{map.year}) " + + "GROUP BY eng.BASE_ID, hb.BASENAME, a.FTP, COALESCE(fishRv.NAME, relRv.FISH_NAME, fishZy.NAME, relZy.FISH_NAME, a.FTP) " + + "ORDER BY eng.BASE_ID, a.FTP"; + } + private String resolveFallbackFishText(String fallbackFishJson, String fallbackFishText) { if (StrUtil.isNotBlank(fallbackFishJson)) { Set fishNames = new LinkedHashSet<>();