feat: 增加全过程过鱼统计总数,根据基地分组

This commit is contained in:
tangwei 2026-05-26 17:19:55 +08:00
parent 7999f88e33
commit 33f00d90cd
5 changed files with 125 additions and 0 deletions

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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<FpFtpStatisticsVo> fpFtpStatitcsVos;
}

View File

@ -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<FpRunPlanVo> processQgcSecondPlanKendoList(DataSourceRequest dataSourceRequest);
List<YearFpStatisticsVo> getYearFpStatic(String year);
}

View File

@ -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<YearFpStatisticsVo> getYearFpStatic(String year) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("year", StrUtil.trim(year));
List<FpFtpStatisticsVo> rows = microservicDynamicSQLMapper.getAllListWithResultType(
buildYearFpStatisticsSql(),
paramMap,
FpFtpStatisticsVo.class
);
if (rows == null || rows.isEmpty()) {
return new ArrayList<>();
}
Map<String, YearFpStatisticsVo> 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<String> fishNames = new LinkedHashSet<>();