From d964cf6d2017eb99e1a92691bfdfbc0f13c5f4cf Mon Sep 17 00:00:00 2001 From: tangwei Date: Wed, 1 Jul 2026 13:37:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20(=E5=85=A8=E8=BF=87=E7=A8=8B)=E5=A2=9E?= =?UTF-8?q?=E6=AE=96=E7=AB=99=E4=BA=8C=E7=BA=A7=E9=A1=B5=E9=9D=A2:=20?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E5=9B=BE-=E9=B1=BC=E8=8B=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fb/controller/FbStationController.java | 6 + .../qgc_env/fb/entity/vo/FishbreedRVo.java | 15 ++ .../qgc_env/fb/service/FbStationService.java | 2 + .../fb/service/impl/FbStationServiceImpl.java | 236 ++++++++++++++++++ 4 files changed, 259 insertions(+) create mode 100644 backend/src/main/java/com/yfd/platform/qgc_env/fb/entity/vo/FishbreedRVo.java diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/fb/controller/FbStationController.java b/backend/src/main/java/com/yfd/platform/qgc_env/fb/controller/FbStationController.java index f0d90c09..7fa6c42f 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/fb/controller/FbStationController.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/fb/controller/FbStationController.java @@ -140,4 +140,10 @@ public class FbStationController { @RequestBody DataSourceRequest dataSourceRequest) { return ResponseResult.successData(fbStationService.getFishhatchrecrFishKendoListCust(type, dataSourceRequest)); } + + @PostMapping("/fishbreedr/fish/GetKendoListCust") + @Operation(summary = "(全过程)增殖站二级页面: 过程图-鱼苗") + public ResponseResult getFishbreedrFishKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) { + return ResponseResult.successData(fbStationService.getFishbreedrFishKendoListCust(dataSourceRequest)); + } } diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/fb/entity/vo/FishbreedRVo.java b/backend/src/main/java/com/yfd/platform/qgc_env/fb/entity/vo/FishbreedRVo.java new file mode 100644 index 00000000..1d184777 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_env/fb/entity/vo/FishbreedRVo.java @@ -0,0 +1,15 @@ +package com.yfd.platform.qgc_env.fb.entity.vo; + +import lombok.Data; + +@Data +public class FishbreedRVo { + + private String tm; + + private String ftp; + + private String ftpName; + + private String counts; +} \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/FbStationService.java b/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/FbStationService.java index b9fde95c..77cd39aa 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/FbStationService.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/FbStationService.java @@ -60,4 +60,6 @@ public interface FbStationService { DataSourceResult getQgcOverviewSecond(DataSourceRequest dataSourceRequest); DataSourceResult getFishhatchrecrFishKendoListCust(Integer type, DataSourceRequest dataSourceRequest); + + DataSourceResult getFishbreedrFishKendoListCust(DataSourceRequest dataSourceRequest); } diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/impl/FbStationServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/impl/FbStationServiceImpl.java index dff8e149..e1fa5911 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/impl/FbStationServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/fb/service/impl/FbStationServiceImpl.java @@ -30,6 +30,7 @@ import com.yfd.platform.qgc_env.fb.entity.vo.FbStInfoResultVo; import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo; import com.yfd.platform.qgc_env.fb.entity.vo.FbStationStaticsDataVo; import com.yfd.platform.qgc_env.fb.entity.vo.FbStationStaticsRawVo; +import com.yfd.platform.qgc_env.fb.entity.vo.FishbreedRVo; import com.yfd.platform.qgc_env.fb.entity.vo.FishhatchrecRVo; import com.yfd.platform.qgc_env.fb.entity.vo.HeadColunmsVo; import com.yfd.platform.qgc_env.fb.entity.vo.TableVo; @@ -4336,4 +4337,239 @@ public class FbStationServiceImpl implements FbStationService { tableVo.setTotal(total); return tableVo; } + + @Override + public DataSourceResult getFishbreedrFishKendoListCust(DataSourceRequest dataSourceRequest) { + DataSourceResult dataSourceResult = new DataSourceResult<>(); + + Map paramMap = new HashMap<>(); + StringBuilder sql = new StringBuilder(); + sql.append("SELECT tm,\n") + .append("LISTAGG(TO_CHAR(ftp), ',') WITHIN GROUP (ORDER BY ftp) AS ftp,\n") + .append("LISTAGG(TO_CHAR(NAME), ',') WITHIN GROUP (ORDER BY ftp) AS ftpName,\n") + .append("LISTAGG(counts, ',') WITHIN GROUP (ORDER BY ftp) AS counts\n") + .append("FROM (\n") + .append("SELECT \n") + .append("to_CHAR(tm,'YYYY-MM') AS tm, ftp, CASE WHEN NAME IS NULL THEN TO_NCHAR(ftp) ELSE NAME END AS NAME, CASE WHEN SUM(counts) IS NULL THEN '-' ELSE TO_CHAR(SUM(counts)) END AS counts\n") + .append("FROM (\n") + .append("SELECT\n") + .append("\ttm,\n") + .append("\tCASE WHEN ZY_FISH_ID IS NULL THEN ftp ELSE ZY_FISH_ID END AS ftp,\n") + .append("\tCASE WHEN NAME IS NULL THEN TO_NCHAR(ftp) ELSE NAME END AS NAME,\n") + .append("\tcounts\n") + .append("FROM\n") + .append("\t(\n") + .append("\tSELECT\n") + .append("\t\tstcd,\n") + .append("\t\tftp AS ftp,\n") + .append("\t\tcounts AS counts,\n") + .append("\t\ttm AS tm\n") + .append("\tFROM\n") + .append("\t\tSD_FBFISHBREED_R\n") + .append("\tWHERE\n") + .append("\t\tNVL(is_deleted, 0) = 0 "); + + appendFishbreedrFishFilterConditions(sql, dataSourceRequest, paramMap); + + sql.append(") t\n") + .append("LEFT JOIN SD_FBRD_B_H s ON\n") + .append("\tt.stcd = s.STCD\n") + .append("LEFT JOIN V_SD_FISHDICTORY_B f ON\n") + .append("\tt.FTP = f.FISH_ID\n") + .append("\tAND (s.HBRVCD = f.RVCD\n") + .append("\t\tOR f.RVCD = 'ZY')\n") + .append(") GROUP BY to_CHAR(tm,'YYYY-MM'), ftp, NAME\n") + .append(") GROUP BY tm\n") + .append("ORDER BY TM DESC"); + + DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest(); + Page page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake()); + List list = microservicDynamicSQLMapper.pageAllListWithResultType( + page, sql.toString(), paramMap, FishbreedRVo.class + ); + + long total = page != null ? page.getTotal() : list.size(); + TableVo tableVo = buildFishbreedrFishTableVo(list, total); + dataSourceResult.setData(Collections.singletonList(tableVo)); + dataSourceResult.setTotal(total); + dataSourceResult.setAggregates(new HashMap<>()); + return dataSourceResult; + } + + private void appendFishbreedrFishFilterConditions(StringBuilder sql, + DataSourceRequest dataSourceRequest, + Map paramMap) { + if (dataSourceRequest == null || dataSourceRequest.getFilter() == null) { + return; + } + String filterSql = buildFishbreedrFishFilterCondition(dataSourceRequest.getFilter(), paramMap, new int[]{0}); + if (StrUtil.isNotBlank(filterSql)) { + sql.append(" AND ").append(filterSql).append(" "); + } + } + + private String buildFishbreedrFishFilterCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + if (filter == null) { + return ""; + } + if (StrUtil.isNotBlank(filter.getField())) { + return buildFishbreedrFishLeafCondition(filter, paramMap, indexHolder); + } + if (CollUtil.isEmpty(filter.getFilters())) { + return ""; + } + List conditions = new ArrayList<>(); + for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) { + String childSql = buildFishbreedrFishFilterCondition(child, paramMap, indexHolder); + if (StrUtil.isNotBlank(childSql)) { + conditions.add("(" + childSql + ")"); + } + } + if (conditions.isEmpty()) { + return ""; + } + String logic = "or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND "; + return String.join(logic, conditions); + } + + private String buildFishbreedrFishLeafCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + String field = filter.getField(); + String column = mapFishbreedrFishColumn(field); + if (StrUtil.isBlank(column)) { + return ""; + } + String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase(); + Object value = filter.getValue(); + if ("isnull".equals(operator)) { + return column + " IS NULL"; + } + if ("isnotnull".equals(operator)) { + return column + " IS NOT NULL"; + } + if ("in".equals(operator)) { + List values = normalizeQgcBsmfRValues(value); + if (values.isEmpty()) { + return ""; + } + List placeholders = new ArrayList<>(); + for (Object item : values) { + String key = "breedFishP" + indexHolder[0]++; + paramMap.put(key, item); + placeholders.add("#{map." + key + "}"); + } + return column + " IN (" + String.join(", ", placeholders) + ")"; + } + if (value == null) { + return ""; + } + String key = "breedFishP" + indexHolder[0]++; + Object normalizedValue = normalizeFishbreedrFishValue(field, value); + return switch (operator) { + case "eq" -> { + paramMap.put(key, normalizedValue); + yield column + " = #{map." + key + "}"; + } + case "neq" -> { + paramMap.put(key, normalizedValue); + yield column + " <> #{map." + key + "}"; + } + case "contains" -> { + paramMap.put(key, "%" + normalizedValue + "%"); + yield column + " LIKE #{map." + key + "}"; + } + case "startswith" -> { + paramMap.put(key, normalizedValue + "%"); + yield column + " LIKE #{map." + key + "}"; + } + case "endswith" -> { + paramMap.put(key, "%" + normalizedValue); + yield column + " LIKE #{map." + key + "}"; + } + case "gt" -> { + paramMap.put(key, normalizedValue); + yield column + " > #{map." + key + "}"; + } + case "gte" -> { + paramMap.put(key, normalizedValue); + yield column + " >= #{map." + key + "}"; + } + case "lt" -> { + paramMap.put(key, normalizedValue); + yield column + " < #{map." + key + "}"; + } + case "lte" -> { + paramMap.put(key, normalizedValue); + yield column + " <= #{map." + key + "}"; + } + default -> ""; + }; + } + + private String mapFishbreedrFishColumn(String field) { + return switch (field) { + case "stcd" -> "t.STCD"; + case "ftp" -> "t.FTP"; + case "counts" -> "t.COUNTS"; + case "tm" -> "t.TM"; + case "rstcd" -> "s.RSTCD"; + case "baseId" -> "s.BASE_ID"; + case "hbrvcd" -> "s.HBRVCD"; + default -> ""; + }; + } + + private Object normalizeFishbreedrFishValue(String field, Object value) { + if (value == null) { + return null; + } + if ("tm".equalsIgnoreCase(field) && value instanceof String text) { + return parseDateTimeSafely(text); + } + return value; + } + + private TableVo buildFishbreedrFishTableVo(List list, long total) { + TableVo tableVo = new TableVo(); + List> resultData = new ArrayList<>(); + List columns = new ArrayList<>(); + Map fishMap = new LinkedHashMap<>(); + + if (CollUtil.isNotEmpty(list)) { + for (FishbreedRVo vo : list) { + Map rowMap = new LinkedHashMap<>(); + rowMap.put("tm", vo.getTm()); + + List ftpList = splitCsv(vo.getFtp()); + List ftpNameList = splitCsv(vo.getFtpName()); + List countsList = splitCsv(vo.getCounts()); + + int size = Math.min(ftpList.size(), Math.min(ftpNameList.size(), countsList.size())); + + for (int i = 0; i < size; i++) { + String ftp = ftpList.get(i); + String ftpName = ftpNameList.get(i); + String countStr = countsList.get(i); + rowMap.put(ftp, "-".equals(countStr) ? null : countStr); + fishMap.putIfAbsent(ftp, ftpName); + } + resultData.add(rowMap); + } + } + + columns.add(new HeadColunmsVo("tm", "时间", true, "tm", false, new ArrayList<>()) + .setDataType("date") + .setDataFormat("yyyy-MM")); + for (Map.Entry entry : fishMap.entrySet()) { + columns.add(new HeadColunmsVo(entry.getKey(), entry.getValue() + "(尾)", true, entry.getKey(), false, new ArrayList<>())); + } + + tableVo.setColumns(columns); + tableVo.setDataSource(resultData); + tableVo.setTotal(total); + return tableVo; + } }