From dd9ca6df75bfa1fa6a8a75668f1760a56fe570aa Mon Sep 17 00:00:00 2001 From: tangwei Date: Fri, 26 Jun 2026 10:49:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8E=E7=94=9F=E5=8A=A8=E7=89=A9?= =?UTF-8?q?=E7=9B=91=E6=B5=8B=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wte/controller/WeFishController.java | 6 + .../qgc_env/wte/entity/vo/WeWvaQgcVo.java | 58 +++ .../qgc_env/wte/service/WeFishService.java | 3 + .../wte/service/impl/WeFishServiceImpl.java | 338 ++++++++++++++++++ 4 files changed, 405 insertions(+) create mode 100644 backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeWvaQgcVo.java diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wte/controller/WeFishController.java b/backend/src/main/java/com/yfd/platform/qgc_env/wte/controller/WeFishController.java index af9a014c..adebfe77 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wte/controller/WeFishController.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wte/controller/WeFishController.java @@ -51,6 +51,12 @@ public class WeFishController { return ResponseResult.successData(weFishService.getWvaDefaultYearList(dataSourceRequest)); } + @PostMapping("/wva/GetKendoListCust") + @Operation(summary = "野生动物监测情况") + public ResponseResult getWvaList(@RequestBody DataSourceRequest dataSourceRequest) { + return ResponseResult.successData(weFishService.getWvaList(dataSourceRequest)); + } + @PostMapping("/we/fisht/year/qgc/GetKendoListCust") @Operation(summary = "全过程沿程鱼类变化情况有数据的流域和年份") public ResponseResult getQgcFishStaticsYearList(@RequestBody DataSourceRequest dataSourceRequest) { diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeWvaQgcVo.java b/backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeWvaQgcVo.java new file mode 100644 index 00000000..b0911f8d --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeWvaQgcVo.java @@ -0,0 +1,58 @@ +package com.yfd.platform.qgc_env.wte.entity.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +@Data +@Schema(description = "野生动物监测情况") +public class WeWvaQgcVo { + + @Schema(description = "主键") + private String id; + + @Schema(description = "野生动物监测站编码") + private String stcd; + + @Schema(description = "野生动物监测站名称") + private String stnm; + + @Schema(description = "站类编码") + private String sttpCode; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Schema(description = "时间") + private Date tm; + + @Schema(description = "显示名称") + private String flnm; + + @Schema(description = "图片路径") + private String imgPath; + + @Schema(description = "视频路径") + private String flpth; + + @Schema(description = "附件ID") + private String fid; + + @Schema(description = "备注") + private String description; + + @Schema(description = "所属电站编码") + private String rstcd; + + @Schema(description = "基地编码") + private String baseId; + + @Schema(description = "流域编码") + private String hbrvcd; + + @Schema(description = "河流编码") + private String rvcd; + + @Schema(description = "排序") + private Integer orderIndex; +} diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/WeFishService.java b/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/WeFishService.java index af594668..4412fbbb 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/WeFishService.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/WeFishService.java @@ -10,6 +10,7 @@ import com.yfd.platform.qgc_env.wte.entity.vo.WeFishStatQgcVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeVmsstbprptVo; +import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaQgcVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaYearQgcVo; import java.util.List; @@ -25,6 +26,8 @@ public interface WeFishService { DataSourceResult getVmsstbprptList(DataSourceRequest dataSourceRequest); + DataSourceResult getWvaList(DataSourceRequest dataSourceRequest); + DataSourceResult getWvaDefaultYearList(DataSourceRequest dataSourceRequest); DataSourceResult>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest); diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java index 16d87af7..5d086cec 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java @@ -19,6 +19,7 @@ import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeRvcdYearVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeVmsstbprptVo; +import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaQgcVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaYearQgcVo; import com.yfd.platform.qgc_env.wte.service.WeFishService; import com.yfd.platform.utils.QgcQueryWrapperUtil; @@ -265,6 +266,50 @@ public class WeFishServiceImpl implements WeFishService { return result; } + @Override + public DataSourceResult getWvaList(DataSourceRequest dataSourceRequest) { + DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest(); + Map paramMap = new HashMap<>(); + + StringBuilder sql = new StringBuilder(); + sql.append("SELECT ") + .append(buildWeWvaSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect())) + .append(" FROM (") + .append(buildWeWvaViewSql()) + .append(") t WHERE 1 = 1 "); + + String filterSql = buildWeWvaFilterCondition( + dataSourceRequest == null ? null : dataSourceRequest.getFilter(), + paramMap, + new int[]{0} + ); + if (StrUtil.isNotBlank(filterSql)) { + sql.append("AND ").append(filterSql).append(" "); + } + sql.append(buildWeWvaOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort())); + + Page page = loadOptions == null ? null + : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake()); + List list = microservicDynamicSQLMapper.pageAllListWithResultType( + page, + sql.toString(), + paramMap, + WeWvaQgcVo.class + ); + for (WeWvaQgcVo vo : list) { + if (vo == null || vo.getTm() == null || StrUtil.isBlank(vo.getStnm())) { + continue; + } + vo.setFlnm(vo.getStnm() + " " + DateUtil.format(vo.getTm(), "yyyy-MM-dd HH")); + } + + DataSourceResult result = new DataSourceResult<>(); + result.setData(list); + result.setTotal(page != null ? page.getTotal() : list.size()); + result.setAggregates(new HashMap<>()); + return result; + } + @Override public DataSourceResult>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest) { Map paramMap = new HashMap<>(); @@ -856,6 +901,22 @@ public class WeFishServiceImpl implements WeFishService { paramMap.put(key, text); yield column + " <> #{map." + key + "}"; } + case "gt" -> { + paramMap.put(key, text); + yield column + " > #{map." + key + "}"; + } + case "gte" -> { + paramMap.put(key, text); + yield column + " >= #{map." + key + "}"; + } + case "lt" -> { + paramMap.put(key, text); + yield column + " < #{map." + key + "}"; + } + case "lte" -> { + paramMap.put(key, text); + yield column + " <= #{map." + key + "}"; + } case "contains" -> { paramMap.put(key, "%" + text + "%"); yield column + " LIKE #{map." + key + "}"; @@ -864,6 +925,14 @@ public class WeFishServiceImpl implements WeFishService { paramMap.put(key, "%" + text + "%"); yield column + " NOT LIKE #{map." + key + "}"; } + case "startswith" -> { + paramMap.put(key, text + "%"); + yield column + " LIKE #{map." + key + "}"; + } + case "endswith" -> { + paramMap.put(key, "%" + text); + yield column + " LIKE #{map." + key + "}"; + } default -> ""; }; } @@ -921,6 +990,29 @@ public class WeFishServiceImpl implements WeFishService { "WHERE NVL(ai.IS_DELETED, 0) = 0"; } + private String buildWeWvaViewSql() { + return "SELECT " + + "a.ID AS id, " + + "a.STCD AS stcd, " + + "b.STNM AS stnm, " + + "b.STTP AS sttpCode, " + + "a.TM AS tm, " + + "a.FLNM AS flnm, " + + "a.IMG_PATH AS imgPath, " + + "a.FLPTH AS flpth, " + + "a.FID AS fid, " + + "a.DESCRIPTION AS description, " + + "b.RSTCD AS rstcd, " + + "b.BASE_ID AS baseId, " + + "b.HBRVCD AS hbrvcd, " + + "b.RVCD AS rvcd, " + + "b.ORDER_INDEX AS orderIndex " + + "FROM SD_WVA_R a " + + "INNER JOIN SD_AIMONITOR_B_H b ON a.STCD = b.STCD " + + "WHERE NVL(a.IS_DELETED, 0) = 0 " + + "AND NVL(b.IS_DELETED, 0) = 0"; + } + private String buildWeMsstbprptSelectSql(List selectFields) { Map columns = weMsstbprptFieldColumns(); List selected = new ArrayList<>(); @@ -963,6 +1055,39 @@ public class WeFishServiceImpl implements WeFishService { return String.join(", ", selected); } + private String buildWeWvaSelectSql(List selectFields) { + Map columns = weWvaFieldColumns(); + List selected = new ArrayList<>(); + if (CollUtil.isEmpty(selectFields)) { + selected.add("t.id AS id"); + selected.add("t.stcd AS stcd"); + selected.add("t.stnm AS stnm"); + selected.add("t.tm AS tm"); + selected.add("t.flnm AS flnm"); + selected.add("t.imgPath AS imgPath"); + selected.add("t.flpth AS flpth"); + selected.add("t.fid AS fid"); + selected.add("t.description AS description"); + } else { + for (String field : selectFields) { + String column = columns.get(field); + if (StrUtil.isNotBlank(column)) { + selected.add(column); + } + } + } + if (!selected.stream().anyMatch(item -> item.contains(" AS stnm"))) { + selected.add("t.stnm AS stnm"); + } + if (!selected.stream().anyMatch(item -> item.contains(" AS tm"))) { + selected.add("t.tm AS tm"); + } + if (!selected.stream().anyMatch(item -> item.contains(" AS flnm"))) { + selected.add("t.flnm AS flnm"); + } + return String.join(", ", selected); + } + private Map weMsstbprptFieldColumns() { Map columns = new LinkedHashMap<>(); columns.put("id", "t.id AS id"); @@ -994,6 +1119,26 @@ public class WeFishServiceImpl implements WeFishService { return columns; } + private Map weWvaFieldColumns() { + Map columns = new LinkedHashMap<>(); + columns.put("id", "t.id AS id"); + columns.put("stcd", "t.stcd AS stcd"); + columns.put("stnm", "t.stnm AS stnm"); + columns.put("sttpCode", "t.sttpCode AS sttpCode"); + columns.put("tm", "t.tm AS tm"); + columns.put("flnm", "t.flnm AS flnm"); + columns.put("imgPath", "t.imgPath AS imgPath"); + columns.put("flpth", "t.flpth AS flpth"); + columns.put("fid", "t.fid AS fid"); + columns.put("description", "t.description AS description"); + columns.put("rstcd", "t.rstcd AS rstcd"); + columns.put("baseId", "t.baseId AS baseId"); + columns.put("hbrvcd", "t.hbrvcd AS hbrvcd"); + columns.put("rvcd", "t.rvcd AS rvcd"); + columns.put("orderIndex", "t.orderIndex AS orderIndex"); + return columns; + } + private String buildWeMsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter, Map paramMap, int[] indexHolder) { @@ -1148,6 +1293,22 @@ public class WeFishServiceImpl implements WeFishService { paramMap.put(key, text); yield column + " <> #{map." + key + "}"; } + case "gt" -> { + paramMap.put(key, text); + yield column + " > #{map." + key + "}"; + } + case "gte" -> { + paramMap.put(key, text); + yield column + " >= #{map." + key + "}"; + } + case "lt" -> { + paramMap.put(key, text); + yield column + " < #{map." + key + "}"; + } + case "lte" -> { + paramMap.put(key, text); + yield column + " <= #{map." + key + "}"; + } case "contains" -> { paramMap.put(key, "%" + text + "%"); yield column + " LIKE #{map." + key + "}"; @@ -1160,6 +1321,137 @@ public class WeFishServiceImpl implements WeFishService { }; } + private String buildWeWvaFilterCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + if (filter == null) { + return ""; + } + if (StrUtil.isNotBlank(filter.getField())) { + return buildWeWvaLeafCondition(filter, paramMap, indexHolder); + } + if (CollUtil.isEmpty(filter.getFilters())) { + return ""; + } + List conditions = new ArrayList<>(); + for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) { + String childSql = buildWeWvaFilterCondition(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 buildWeWvaLeafCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + String column = mapWeWvaColumn(filter.getField()); + if (StrUtil.isBlank(column)) { + return ""; + } + String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase(); + if ("isnull".equals(operator)) { + return column + " IS NULL"; + } + if ("isnotnull".equals(operator)) { + return column + " IS NOT NULL"; + } + if ("isempty".equals(operator)) { + return "(" + column + " IS NULL OR " + column + " = '')"; + } + if ("isnotempty".equals(operator)) { + return "(" + column + " IS NOT NULL AND " + column + " <> '')"; + } + if ("in".equals(operator) || "ni".equals(operator)) { + List values = normalizeWeFishQgcValues(filter.getValue()); + if (values.isEmpty()) { + return ""; + } + List placeholders = new ArrayList<>(); + for (Object value : values) { + if (value == null || StrUtil.isBlank(String.valueOf(value).trim())) { + continue; + } + String key = "weWvaP" + indexHolder[0]++; + paramMap.put(key, String.valueOf(value).trim()); + placeholders.add("#{map." + key + "}"); + } + if (placeholders.isEmpty()) { + return ""; + } + return column + ("ni".equals(operator) ? " NOT IN (" : " IN (") + String.join(", ", placeholders) + ")"; + } + Object rawValue = filter.getValue(); + if (rawValue == null || StrUtil.isBlank(String.valueOf(rawValue).trim())) { + return ""; + } + String key = "weWvaP" + indexHolder[0]++; + String text = String.valueOf(rawValue).trim(); + boolean dateField = isWeWvaDateField(filter); + String valueExpr = buildWeWvaValueExpr(key, dateField, rawValue); + return switch (operator) { + case "eq" -> { + paramMap.put(key, text); + yield column + " = " + valueExpr; + } + case "neq" -> { + paramMap.put(key, text); + yield column + " <> " + valueExpr; + } + case "gt" -> { + paramMap.put(key, text); + yield column + " > " + valueExpr; + } + case "gte" -> { + paramMap.put(key, text); + yield column + " >= " + valueExpr; + } + case "lt" -> { + paramMap.put(key, text); + yield column + " < " + valueExpr; + } + case "lte" -> { + paramMap.put(key, text); + yield column + " <= " + valueExpr; + } + case "contains" -> { + paramMap.put(key, "%" + text + "%"); + yield column + " LIKE #{map." + key + "}"; + } + case "doesnotcontain" -> { + paramMap.put(key, "%" + text + "%"); + yield column + " NOT LIKE #{map." + key + "}"; + } + default -> ""; + }; + } + + private boolean isWeWvaDateField(DataSourceRequest.FilterDescriptor filter) { + if (filter == null || StrUtil.isBlank(filter.getField())) { + return false; + } + if ("tm".equalsIgnoreCase(filter.getField())) { + return true; + } + return "date".equalsIgnoreCase(filter.getDataType()); + } + + private String buildWeWvaValueExpr(String paramKey, boolean dateField, Object value) { + if (!dateField || value == null) { + return "#{map." + paramKey + "}"; + } + String text = String.valueOf(value).trim(); + if (text.length() <= 10) { + return "TO_DATE(#{map." + paramKey + "}, 'YYYY-MM-DD')"; + } + return "TO_DATE(#{map." + paramKey + "}, 'YYYY-MM-DD HH24:MI:SS')"; + } + private String mapWeMsstbprptColumn(String field) { if (StrUtil.isBlank(field)) { return null; @@ -1199,6 +1491,30 @@ public class WeFishServiceImpl implements WeFishService { }; } + private String mapWeWvaColumn(String field) { + if (StrUtil.isBlank(field)) { + return null; + } + return switch (field) { + case "id" -> "t.id"; + case "stcd" -> "t.stcd"; + case "stnm" -> "t.stnm"; + case "sttpCode" -> "t.sttpCode"; + case "tm" -> "t.tm"; + case "flnm" -> "t.flnm"; + case "imgPath" -> "t.imgPath"; + case "flpth" -> "t.flpth"; + case "fid" -> "t.fid"; + case "description" -> "t.description"; + case "rstcd" -> "t.rstcd"; + case "baseId" -> "t.baseId"; + case "hbrvcd" -> "t.hbrvcd"; + case "rvcd" -> "t.rvcd"; + case "orderIndex" -> "t.orderIndex"; + default -> null; + }; + } + private String buildWeMsstbprptOrderBySql(List sorts) { if (CollUtil.isEmpty(sorts)) { return ""; @@ -1243,6 +1559,28 @@ public class WeFishServiceImpl implements WeFishService { return " ORDER BY " + String.join(", ", orderByParts); } + private String buildWeWvaOrderBySql(List sorts) { + if (CollUtil.isEmpty(sorts)) { + return " ORDER BY t.tm DESC NULLS LAST"; + } + List orderByParts = new ArrayList<>(); + for (DataSourceRequest.SortDescriptor sort : sorts) { + if (sort == null || StrUtil.isBlank(sort.getField())) { + continue; + } + String column = mapWeWvaColumn(sort.getField()); + if (StrUtil.isBlank(column)) { + continue; + } + String direction = "desc".equalsIgnoreCase(sort.getDir()) ? "DESC" : "ASC"; + orderByParts.add(column + " " + direction + " NULLS LAST"); + } + if (orderByParts.isEmpty()) { + return " ORDER BY t.tm DESC NULLS LAST"; + } + return " ORDER BY " + String.join(", ", orderByParts); + } + private String buildWeFishListQgcGroupSql(String baseSql, GroupingInfo[] groupInfos) { if (groupInfos == null || groupInfos.length == 0) { return baseSql;