From 4ab11f3b94562488d48c9f132d93c44ebd3dce9a Mon Sep 17 00:00:00 2001 From: tangwei Date: Fri, 26 Jun 2026 14:22:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E7=82=B9=E9=99=86=E7=94=9F?= =?UTF-8?q?=E5=8A=A8=E7=89=A9=E4=BA=8C=E7=BA=A7=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wte/controller/WeFishController.java | 6 + .../wte/entity/vo/WeTeSpecialAnimalVo.java | 32 +++ .../qgc_env/wte/service/WeFishService.java | 3 + .../wte/service/impl/WeFishServiceImpl.java | 222 ++++++++++++++++++ 4 files changed, 263 insertions(+) create mode 100644 backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeTeSpecialAnimalVo.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 adebfe77..d9456491 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 @@ -86,4 +86,10 @@ public class WeFishController { public ResponseResult getQgcWeFishPoint(@RequestBody DataSourceRequest dataSourceRequest) { return ResponseResult.successData(weFishService.getQgcWeFishPoint(dataSourceRequest)); } + + @PostMapping("/te/tet/spec/GetKendoListCust") + @Operation(summary = "重点陆生动物二级页面") + public ResponseResult getTeSpecialAnimalList(@RequestBody DataSourceRequest dataSourceRequest) { + return ResponseResult.successData(weFishService.getTeSpecialAnimalList(dataSourceRequest)); + } } diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeTeSpecialAnimalVo.java b/backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeTeSpecialAnimalVo.java new file mode 100644 index 00000000..7622d501 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wte/entity/vo/WeTeSpecialAnimalVo.java @@ -0,0 +1,32 @@ +package com.yfd.platform.qgc_env.wte.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +@Schema(description = "重点陆生动物二级页面") +public class WeTeSpecialAnimalVo { + + @Schema(description = "动物主键") + private String id; + + @Schema(description = "动物名称") + private String name; + + @Schema(description = "动物英文名称") + private String nameEn; + + @Schema(description = "保护级别编码") + private String protectlvl; + + @Schema(description = "保护级别名称") + private String protectlvlName; + + @Schema(description = "LOGO") + private String logo; + + @Schema(description = "介绍") + private String introduce; +} 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 4412fbbb..9cf1c024 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 @@ -9,6 +9,7 @@ import com.yfd.platform.qgc_env.wte.entity.vo.WeFishPointQgcVo; 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.WeTeSpecialAnimalVo; 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; @@ -39,4 +40,6 @@ public interface WeFishService { DataSourceResult getQgcFishListStat(DataSourceRequest dataSourceRequest); DataSourceResult getQgcWeFishPoint(DataSourceRequest dataSourceRequest); + + DataSourceResult getTeSpecialAnimalList(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 5d086cec..fbaaf40c 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 @@ -18,6 +18,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.WeRvcdYearVo; import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo; +import com.yfd.platform.qgc_env.wte.entity.vo.WeTeSpecialAnimalVo; 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; @@ -486,6 +487,44 @@ public class WeFishServiceImpl implements WeFishService { return result; } + @Override + public DataSourceResult getTeSpecialAnimalList(DataSourceRequest dataSourceRequest) { + DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest(); + Map paramMap = new HashMap<>(); + + StringBuilder sql = new StringBuilder(); + sql.append("SELECT ") + .append(buildTeSpecialAnimalSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect())) + .append(" FROM (") + .append(buildTeSpecialAnimalDetailSql()) + .append(") t WHERE 1 = 1 "); + + String filterSql = buildTeSpecialAnimalFilterCondition( + dataSourceRequest == null ? null : dataSourceRequest.getFilter(), + paramMap, + new int[]{0} + ); + if (StrUtil.isNotBlank(filterSql)) { + sql.append("AND ").append(filterSql).append(" "); + } + sql.append(buildTeSpecialAnimalOrderBySql(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, + WeTeSpecialAnimalVo.class + ); + + DataSourceResult result = new DataSourceResult<>(); + result.setData(list); + result.setTotal(page != null ? page.getTotal() : list.size()); + result.setAggregates(new HashMap<>()); + return result; + } + private String buildWeFishQgcGroupSql(String baseSql, GroupingInfo[] groupInfos) { if (groupInfos == null || groupInfos.length == 0) { return baseSql; @@ -820,6 +859,189 @@ public class WeFishServiceImpl implements WeFishService { return sql.toString(); } + private String buildTeSpecialAnimalDetailSql() { + return "SELECT DISTINCT " + + "b.ID AS id, " + + "b.NAME AS name, " + + "b.NAME_EN AS nameEn, " + + "b.PROTECTLVL AS protectlvl, " + + "b.PROTECTLVL AS protectlvlName, " + + "b.LOGO AS logo, " + + "b.INTRODUCE AS introduce " + + "FROM MS_SPECANIMALS_B a " + + "INNER JOIN SD_VABASIC_B b ON a.ANIMAL_ID = b.ID " + + "WHERE NVL(a.IS_DELETED, 0) = 0 " + + "AND NVL(b.IS_DELETED, 0) = 0 " + + "AND NVL(b.ENABLE, 1) = 1 "; + } + + private String buildTeSpecialAnimalSelectSql(List selectFields) { + Map columnMap = buildTeSpecialAnimalColumnMap(); + List columns = new ArrayList<>(); + if (CollUtil.isNotEmpty(selectFields)) { + for (String field : selectFields) { + String column = columnMap.get(field); + if (StrUtil.isNotBlank(column)) { + columns.add(column); + } + } + } + if (columns.isEmpty()) { + columns.addAll(columnMap.values()); + } + return String.join(", ", columns); + } + + private Map buildTeSpecialAnimalColumnMap() { + Map columnMap = new LinkedHashMap<>(); + columnMap.put("id", "t.id AS id"); + columnMap.put("name", "t.name AS name"); + columnMap.put("nameEn", "t.nameEn AS nameEn"); + columnMap.put("protectlvl", "t.protectlvl AS protectlvl"); + columnMap.put("protectlvlName", "t.protectlvlName AS protectlvlName"); + columnMap.put("logo", "t.logo AS logo"); + columnMap.put("introduce", "t.introduce AS introduce"); + return columnMap; + } + + private String buildTeSpecialAnimalFilterCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + if (filter == null) { + return ""; + } + if (StrUtil.isNotBlank(filter.getField())) { + return buildTeSpecialAnimalLeafCondition(filter, paramMap, indexHolder); + } + if (CollUtil.isEmpty(filter.getFilters())) { + return ""; + } + List conditions = new ArrayList<>(); + for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) { + String childSql = buildTeSpecialAnimalFilterCondition(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 buildTeSpecialAnimalLeafCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + String column = mapTeSpecialAnimalColumn(filter == null ? null : 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) { + String text = safeWeFishString(value); + if (StrUtil.isBlank(text)) { + continue; + } + String key = "teSpecP" + indexHolder[0]++; + paramMap.put(key, text); + placeholders.add("#{map." + key + "}"); + } + if (placeholders.isEmpty()) { + return ""; + } + return column + ("ni".equals(operator) ? " NOT IN (" : " IN (") + String.join(", ", placeholders) + ")"; + } + String text = safeWeFishString(filter.getValue()); + if (StrUtil.isBlank(text)) { + return ""; + } + String key = "teSpecP" + indexHolder[0]++; + return switch (operator) { + case "eq" -> { + paramMap.put(key, text); + yield column + " = #{map." + key + "}"; + } + case "neq" -> { + paramMap.put(key, text); + yield column + " <> #{map." + key + "}"; + } + case "contains" -> { + paramMap.put(key, "%" + text + "%"); + yield column + " LIKE #{map." + key + "}"; + } + case "doesnotcontain" -> { + 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 -> ""; + }; + } + + private String mapTeSpecialAnimalColumn(String field) { + if (StrUtil.isBlank(field)) { + return null; + } + return switch (field) { + case "id" -> "t.id"; + case "name" -> "t.name"; + case "nameEn" -> "t.nameEn"; + case "protectlvl" -> "t.protectlvl"; + case "protectlvlName" -> "t.protectlvlName"; + case "logo" -> "t.logo"; + case "introduce" -> "t.introduce"; + default -> null; + }; + } + + private String buildTeSpecialAnimalOrderBySql(List sorts) { + if (CollUtil.isEmpty(sorts)) { + return " ORDER BY t.name ASC NULLS LAST, t.id ASC"; + } + List orderByParts = new ArrayList<>(); + for (DataSourceRequest.SortDescriptor sort : sorts) { + if (sort == null || StrUtil.isBlank(sort.getField())) { + continue; + } + String column = mapTeSpecialAnimalColumn(sort.getField()); + if (StrUtil.isBlank(column)) { + continue; + } + String direction = "desc".equalsIgnoreCase(sort.getDir()) || "des".equalsIgnoreCase(sort.getDir()) ? "DESC" : "ASC"; + orderByParts.add(column + " " + direction + " NULLS LAST"); + } + if (orderByParts.isEmpty()) { + return " ORDER BY t.name ASC NULLS LAST, t.id ASC"; + } + return " ORDER BY " + String.join(", ", orderByParts); + } + private String buildWeWvaYearFilterCondition(DataSourceRequest.FilterDescriptor filter, Map paramMap, int[] indexHolder) {