feat: 鱼类字典列表

This commit is contained in:
tangwei 2026-06-16 11:30:40 +08:00
parent 1c7ad58b5b
commit 16f60e6b18
5 changed files with 541 additions and 2 deletions

View File

@ -130,7 +130,7 @@ public class SwaggerConfig {
@Bean @Bean
public GroupedOpenApi groupEnvFbApi() { public GroupedOpenApi groupEnvFbApi() {
return GroupedOpenApi.builder() return GroupedOpenApi.builder()
.group("3.7 全过程-生态环保数据服务-鱼类调查") .group("3.7 全过程-生态环保数据服务-增殖放流")
.packagesToScan("com.yfd.platform.qgc_env.fb.controller") .packagesToScan("com.yfd.platform.qgc_env.fb.controller")
.build(); .build();
} }

View File

@ -70,6 +70,12 @@ public class FishPassageController {
return ResponseResult.successData(fpBuildService.processKendoList(dataSourceRequest)); return ResponseResult.successData(fpBuildService.processKendoList(dataSourceRequest));
} }
@PostMapping("/fishDic/GetKendoListCust")
@Operation(summary = "鱼类字典列表")
public ResponseResult getFishDicList(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(fpBuildService.getFishDicList(dataSourceRequest));
}
@PostMapping("/vmsstbprpt/GetKendoList") @PostMapping("/vmsstbprpt/GetKendoList")
@Operation(summary = "根据条件查询过鱼设施基础列表") @Operation(summary = "根据条件查询过鱼设施基础列表")
public ResponseResult getVmsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) { public ResponseResult getVmsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {

View File

@ -0,0 +1,73 @@
package com.yfd.platform.qgc_env.fp.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
@Data
@Schema(description = "过鱼设施模块鱼类字典信息")
public class FpFishDicVo {
private String id;
private String code;
private String name;
private String nameEn;
private String alias;
private String logo;
private String introduce;
private String inffile;
private String orders;
private String family;
private String genus;
private String species;
private Integer type;
private String typeName;
private String fsz;
private Integer rare;
private String rareName;
private Integer specOrigin;
private String specOriginName;
private Integer ptype;
private String ptypeName;
private String rvcd;
private String rvcdName;
private String habitMigrat;
private String feedingHabit;
private String spawnCharact;
private String food;
private String timeFeed;
private String orignDate;
private String pretemp;
private String flowRate;
private String depth;
private String botmMater;
private String wqtq;
private String wqtqName;
private Integer habitat;
private String habitatName;
private Integer situation;
private String situationName;
private Integer resourceType;
private String resourceTypeName;
private String shapedesc;
private String protectlvl;
private String habitation;
private String fid;
private String description;
private Integer enable;
private String enableName;
private Integer internal;
private String internalName;
private Integer orderIndex;
private String recordUser;
private Date recordTime;
private String modifyUser;
private Date modifyTime;
private Integer isDeleted;
private String deleteUser;
private Date deleteTime;
private String spawnMonth;
private String vlsr;
private Date vlsrTm;
}

View File

@ -3,6 +3,7 @@ package com.yfd.platform.qgc_env.fp.service;
import com.yfd.platform.common.DataSourceRequest; import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.qgc_env.fp.entity.vo.FpConstructionSituationVo; import com.yfd.platform.qgc_env.fp.entity.vo.FpConstructionSituationVo;
import com.yfd.platform.qgc_env.fp.entity.vo.FpFishDicVo;
import com.yfd.platform.qgc_env.fp.entity.vo.FpVmsstbprptVo; import com.yfd.platform.qgc_env.fp.entity.vo.FpVmsstbprptVo;
public interface FpBuildService { public interface FpBuildService {
@ -11,6 +12,8 @@ public interface FpBuildService {
DataSourceResult<FpVmsstbprptVo> getVmsstbprptList(DataSourceRequest dataSourceRequest); DataSourceResult<FpVmsstbprptVo> getVmsstbprptList(DataSourceRequest dataSourceRequest);
DataSourceResult<FpFishDicVo> getFishDicList(DataSourceRequest dataSourceRequest);
DataSourceResult<FpVmsstbprptVo> getFpqMsstbprptList(DataSourceRequest dataSourceRequest); DataSourceResult<FpVmsstbprptVo> getFpqMsstbprptList(DataSourceRequest dataSourceRequest);
FpVmsstbprptVo getStInfoByStcd(String stcd); FpVmsstbprptVo getStInfoByStcd(String stcd);

View File

@ -1,21 +1,28 @@
package com.yfd.platform.qgc_env.fp.service.impl; package com.yfd.platform.qgc_env.fp.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfd.platform.common.DataSourceLoadOptionsBase; import com.yfd.platform.common.DataSourceLoadOptionsBase;
import com.yfd.platform.common.DataSourceRequest; import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.common.GroupHelper;
import com.yfd.platform.common.GroupingInfo;
import com.yfd.platform.common.MicroservicDynamicSQLMapper; import com.yfd.platform.common.MicroservicDynamicSQLMapper;
import com.yfd.platform.common.PageInfo; import com.yfd.platform.common.PageInfo;
import com.yfd.platform.qgc_env.fp.entity.vo.FpConstructionSituationVo; import com.yfd.platform.qgc_env.fp.entity.vo.FpConstructionSituationVo;
import com.yfd.platform.qgc_env.fp.entity.vo.FpFishDicVo;
import com.yfd.platform.qgc_env.fp.entity.vo.FpVmsstbprptVo; import com.yfd.platform.qgc_env.fp.entity.vo.FpVmsstbprptVo;
import com.yfd.platform.qgc_env.fp.service.FpBuildService; import com.yfd.platform.qgc_env.fp.service.FpBuildService;
import com.yfd.platform.utils.QgcQueryWrapperUtil; import com.yfd.platform.utils.QgcQueryWrapperUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.util.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -61,6 +68,60 @@ public class FpBuildServiceImpl implements FpBuildService {
return queryVmsstbprptList(dataSourceRequest, null); return queryVmsstbprptList(dataSourceRequest, null);
} }
@Override
public DataSourceResult<FpFishDicVo> getFishDicList(DataSourceRequest dataSourceRequest) {
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
Map<String, Object> paramMap = new HashMap<>();
String filterSql = buildFishDicFilterCondition(
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
paramMap,
new int[]{0}
);
if (CollUtil.isNotEmpty(dataSourceRequest == null ? null : dataSourceRequest.getGroup())) {
StringBuilder groupedBaseSql = new StringBuilder("SELECT * FROM (")
.append(buildFishDicBaseSql())
.append(") t WHERE 1 = 1 ");
if (StrUtil.isNotBlank(filterSql)) {
groupedBaseSql.append(" AND ").append(filterSql).append(" ");
}
GroupingInfo[] groupInfos = loadOptions == null ? null : loadOptions.getGroup();
String groupedSql = buildFishDicGroupSql(groupedBaseSql.toString(), groupInfos);
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(null, groupedSql, paramMap);
DataSourceResult result = new DataSourceResult();
if (Boolean.TRUE.equals(dataSourceRequest.getGroupResultFlat())) {
result.setData(new GroupHelper().faltGroup(rows, Arrays.asList(groupInfos)));
} else {
result.setData(new GroupHelper().group(rows, Arrays.asList(groupInfos)));
}
result.setTotal((long) rows.size());
result.setAggregates(new HashMap<>());
return result;
}
StringBuilder sql = new StringBuilder("SELECT ")
.append(buildFishDicDetailSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect()))
.append(" FROM (")
.append(buildFishDicBaseSql())
.append(") t WHERE 1 = 1 ");
if (StrUtil.isNotBlank(filterSql)) {
sql.append(" AND ").append(filterSql).append(" ");
}
sql.append(buildFishDicOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
List<FpFishDicVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
page, sql.toString(), paramMap, FpFishDicVo.class
);
DataSourceResult<FpFishDicVo> result = new DataSourceResult<>();
result.setData(list);
result.setTotal(page != null ? page.getTotal() : list.size());
result.setAggregates(new HashMap<>());
return result;
}
@Override @Override
public DataSourceResult<FpVmsstbprptVo> getFpqMsstbprptList(DataSourceRequest dataSourceRequest) { public DataSourceResult<FpVmsstbprptVo> getFpqMsstbprptList(DataSourceRequest dataSourceRequest) {
return queryVmsstbprptList(dataSourceRequest, "FPQ"); return queryVmsstbprptList(dataSourceRequest, "FPQ");
@ -113,6 +174,77 @@ public class FpBuildServiceImpl implements FpBuildService {
return list.getFirst(); return list.getFirst();
} }
private String buildFishDicBaseSql() {
return "SELECT " +
"src.ID AS id, " +
"src.CODE AS code, " +
"src.NAME AS name, " +
"src.NAME_EN AS nameEn, " +
"src.ALIAS AS alias, " +
"src.LOGO AS logo, " +
"src.INTRODUCE AS introduce, " +
"src.INFFILE AS inffile, " +
"src.ORDERS AS orders, " +
"src.FAMILY AS family, " +
"src.GENUS AS genus, " +
"src.SPECIES AS species, " +
"src.TYPE AS type, " +
"CASE WHEN src.TYPE = 1 THEN '淡水' WHEN src.TYPE = 2 THEN '海水' ELSE NULL END AS typeName, " +
"src.FSZ AS fsz, " +
"src.RARE AS rare, " +
"CASE WHEN src.RARE = 1 THEN '是' WHEN src.RARE = 0 THEN '否' ELSE NULL END AS rareName, " +
"src.SPEC_ORIGIN AS specOrigin, " +
"CASE WHEN src.SPEC_ORIGIN = 1 THEN '本土物种' WHEN src.SPEC_ORIGIN = 2 THEN '外来物种' ELSE NULL END AS specOriginName, " +
"src.PTYPE AS ptype, " +
"CASE src.PTYPE " +
"WHEN 1 THEN '濒危' WHEN 2 THEN '极危' WHEN 3 THEN '近危' WHEN 4 THEN '易危' " +
"WHEN 5 THEN '重点保护' WHEN 6 THEN '无危' WHEN 7 THEN '国家二级' WHEN 8 THEN '市二级保护' ELSE NULL END AS ptypeName, " +
"src.RVCD AS rvcd, " +
"rv.RVNM AS rvcdName, " +
"src.HABIT_MIGRAT AS habitMigrat, " +
"src.FEEDING_HABIT AS feedingHabit, " +
"src.SPAWN_CHARACT AS spawnCharact, " +
"src.FOOD AS food, " +
"src.TIME_FEED AS timeFeed, " +
"src.ORIGN_DATE AS orignDate, " +
"src.PRETEMP AS pretemp, " +
"src.FLOW_RATE AS flowRate, " +
"src.DEPTH AS depth, " +
"src.BOTM_MATER AS botmMater, " +
"src.WQTQ AS wqtq, " +
"CASE src.WQTQ " +
"WHEN '1' THEN 'Ⅰ类' WHEN '2' THEN 'Ⅱ类' WHEN '3' THEN 'Ⅲ类' WHEN '4' THEN 'Ⅳ类' WHEN '5' THEN 'Ⅴ类' WHEN '6' THEN '劣V类' ELSE NULL END AS wqtqName, " +
"src.HABITAT AS habitat, " +
"CASE src.HABITAT WHEN 1 THEN '流水生境' WHEN 2 THEN '静缓流生境' WHEN 3 THEN '洞穴生境' ELSE NULL END AS habitatName, " +
"src.SITUATION AS situation, " +
"CASE src.SITUATION WHEN 1 THEN '优势种' WHEN 2 THEN '常见种' WHEN 3 THEN '少见种' WHEN 4 THEN '记录种' ELSE NULL END AS situationName, " +
"src.RESOURCE_TYPE AS resourceType, " +
"CASE src.RESOURCE_TYPE WHEN 1 THEN '保护鱼类' WHEN 2 THEN '特有鱼类' WHEN 3 THEN '重要经济鱼类' WHEN 4 THEN '濒危状况' ELSE NULL END AS resourceTypeName, " +
"src.SHAPEDESC AS shapedesc, " +
"src.PROTECTLVL AS protectlvl, " +
"src.HABITATION AS habitation, " +
"src.FID AS fid, " +
"src.DESCRIPTION AS description, " +
"src.ENABLE AS enable, " +
"CASE WHEN src.ENABLE = 1 THEN '启用' WHEN src.ENABLE = 0 THEN '禁用' ELSE NULL END AS enableName, " +
"src.INTERNAL AS internal, " +
"CASE WHEN src.INTERNAL = 1 THEN '是' WHEN src.INTERNAL = 0 THEN '否' ELSE NULL END AS internalName, " +
"src.ORDER_INDEX AS orderIndex, " +
"src.RECORD_USER AS recordUser, " +
"src.RECORD_TIME AS recordTime, " +
"src.MODIFY_USER AS modifyUser, " +
"src.MODIFY_TIME AS modifyTime, " +
"src.IS_DELETED AS isDeleted, " +
"src.DELETE_USER AS deleteUser, " +
"src.DELETE_TIME AS deleteTime, " +
"src.SPAWN_MONTH AS spawnMonth, " +
"src.VLSR AS vlsr, " +
"src.VLSR_TM AS vlsrTm " +
"FROM SD_FISHDICTORY_B src " +
"LEFT JOIN SD_RVCD_DIC rv ON rv.RVCD = src.RVCD " +
"WHERE NVL(src.IS_DELETED, 0) = 0 ";
}
private String buildVmsstbprptBaseSql() { private String buildVmsstbprptBaseSql() {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.append("SELECT ") sql.append("SELECT ")
@ -319,6 +451,87 @@ public class FpBuildServiceImpl implements FpBuildService {
return selectMap; return selectMap;
} }
private String buildFishDicDetailSelectSql(List<String> selectFields) {
LinkedHashMap<String, String> columnMap = buildFishDicSelectColumnMap();
if (CollUtil.isEmpty(selectFields)) {
return String.join(", ", columnMap.values());
}
List<String> selectColumns = new ArrayList<>();
for (String field : selectFields) {
String column = columnMap.get(field);
if (StrUtil.isNotBlank(column)) {
selectColumns.add(column);
}
}
return selectColumns.isEmpty() ? String.join(", ", columnMap.values()) : String.join(", ", selectColumns);
}
private LinkedHashMap<String, String> buildFishDicSelectColumnMap() {
LinkedHashMap<String, String> columnMap = new LinkedHashMap<>();
columnMap.put("id", "t.id AS id");
columnMap.put("code", "t.code AS code");
columnMap.put("name", "t.name AS name");
columnMap.put("nameEn", "t.nameEn AS nameEn");
columnMap.put("alias", "t.alias AS alias");
columnMap.put("logo", "t.logo AS logo");
columnMap.put("introduce", "t.introduce AS introduce");
columnMap.put("inffile", "t.inffile AS inffile");
columnMap.put("orders", "t.orders AS orders");
columnMap.put("family", "t.family AS family");
columnMap.put("genus", "t.genus AS genus");
columnMap.put("species", "t.species AS species");
columnMap.put("type", "t.type AS type");
columnMap.put("typeName", "t.typeName AS typeName");
columnMap.put("fsz", "t.fsz AS fsz");
columnMap.put("rare", "t.rare AS rare");
columnMap.put("rareName", "t.rareName AS rareName");
columnMap.put("specOrigin", "t.specOrigin AS specOrigin");
columnMap.put("specOriginName", "t.specOriginName AS specOriginName");
columnMap.put("ptype", "t.ptype AS ptype");
columnMap.put("ptypeName", "t.ptypeName AS ptypeName");
columnMap.put("rvcd", "t.rvcd AS rvcd");
columnMap.put("rvcdName", "t.rvcdName AS rvcdName");
columnMap.put("habitMigrat", "t.habitMigrat AS habitMigrat");
columnMap.put("feedingHabit", "t.feedingHabit AS feedingHabit");
columnMap.put("spawnCharact", "t.spawnCharact AS spawnCharact");
columnMap.put("food", "t.food AS food");
columnMap.put("timeFeed", "t.timeFeed AS timeFeed");
columnMap.put("orignDate", "t.orignDate AS orignDate");
columnMap.put("pretemp", "t.pretemp AS pretemp");
columnMap.put("flowRate", "t.flowRate AS flowRate");
columnMap.put("depth", "t.depth AS depth");
columnMap.put("botmMater", "t.botmMater AS botmMater");
columnMap.put("wqtq", "t.wqtq AS wqtq");
columnMap.put("wqtqName", "t.wqtqName AS wqtqName");
columnMap.put("habitat", "t.habitat AS habitat");
columnMap.put("habitatName", "t.habitatName AS habitatName");
columnMap.put("situation", "t.situation AS situation");
columnMap.put("situationName", "t.situationName AS situationName");
columnMap.put("resourceType", "t.resourceType AS resourceType");
columnMap.put("resourceTypeName", "t.resourceTypeName AS resourceTypeName");
columnMap.put("shapedesc", "t.shapedesc AS shapedesc");
columnMap.put("protectlvl", "t.protectlvl AS protectlvl");
columnMap.put("habitation", "t.habitation AS habitation");
columnMap.put("fid", "t.fid AS fid");
columnMap.put("description", "t.description AS description");
columnMap.put("enable", "t.enable AS enable");
columnMap.put("enableName", "t.enableName AS enableName");
columnMap.put("internal", "t.internal AS internal");
columnMap.put("internalName", "t.internalName AS internalName");
columnMap.put("orderIndex", "t.orderIndex AS orderIndex");
columnMap.put("recordUser", "t.recordUser AS recordUser");
columnMap.put("recordTime", "t.recordTime AS recordTime");
columnMap.put("modifyUser", "t.modifyUser AS modifyUser");
columnMap.put("modifyTime", "t.modifyTime AS modifyTime");
columnMap.put("isDeleted", "t.isDeleted AS isDeleted");
columnMap.put("deleteUser", "t.deleteUser AS deleteUser");
columnMap.put("deleteTime", "t.deleteTime AS deleteTime");
columnMap.put("spawnMonth", "t.spawnMonth AS spawnMonth");
columnMap.put("vlsr", "t.vlsr AS vlsr");
columnMap.put("vlsrTm", "t.vlsrTm AS vlsrTm");
return columnMap;
}
private String buildVmsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter, private String buildVmsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap, Map<String, Object> paramMap,
int[] indexHolder) { int[] indexHolder) {
@ -345,6 +558,32 @@ public class FpBuildServiceImpl implements FpBuildService {
return String.join(logic, conditions); return String.join(logic, conditions);
} }
private String buildFishDicFilterCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap,
int[] indexHolder) {
if (filter == null) {
return "";
}
if (filter.getField() != null && !filter.getField().isBlank()) {
return buildFishDicLeafCondition(filter, paramMap, indexHolder);
}
if (CollectionUtils.isEmpty(filter.getFilters())) {
return "";
}
List<String> conditions = new ArrayList<>();
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
String childSql = buildFishDicFilterCondition(child, paramMap, indexHolder);
if (!childSql.isBlank()) {
conditions.add("(" + childSql + ")");
}
}
if (conditions.isEmpty()) {
return "";
}
String logic = "or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ";
return String.join(logic, conditions);
}
private String buildVmsstbprptLeafCondition(DataSourceRequest.FilterDescriptor filter, private String buildVmsstbprptLeafCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap, Map<String, Object> paramMap,
int[] indexHolder) { int[] indexHolder) {
@ -410,6 +649,96 @@ public class FpBuildServiceImpl implements FpBuildService {
} }
} }
private String buildFishDicLeafCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap,
int[] indexHolder) {
String column = mapFishDicColumn(filter.getField());
if (column == null || column.isBlank()) {
return "";
}
String operator = filter.getOperator() == null ? "eq" : filter.getOperator().toLowerCase();
Object value = filter.getValue();
if (isFishDicDateField(filter.getField())) {
return buildDateCondition(column, operator, value, paramMap, indexHolder, "fpFishDicP");
}
if ("isnull".equals(operator)) {
return column + " IS NULL";
}
if ("isnotnull".equals(operator)) {
return column + " IS NOT NULL";
}
if ("in".equals(operator)) {
List<Object> values = normalizeValues(value);
if (values.isEmpty()) {
return "";
}
List<String> placeholders = new ArrayList<>();
for (Object item : values) {
String paramKey = "fpFishDicP" + indexHolder[0]++;
paramMap.put(paramKey, item);
placeholders.add("#{map." + paramKey + "}");
}
return column + " IN (" + String.join(", ", placeholders) + ")";
}
if (value == null) {
return "";
}
String paramKey = "fpFishDicP" + indexHolder[0]++;
switch (operator) {
case "eq":
paramMap.put(paramKey, value);
return column + " = #{map." + paramKey + "}";
case "neq":
paramMap.put(paramKey, value);
return column + " <> #{map." + paramKey + "}";
case "contains":
paramMap.put(paramKey, "%" + value + "%");
return column + " LIKE #{map." + paramKey + "}";
case "startswith":
paramMap.put(paramKey, value + "%");
return column + " LIKE #{map." + paramKey + "}";
case "endswith":
paramMap.put(paramKey, "%" + value);
return column + " LIKE #{map." + paramKey + "}";
case "gt":
paramMap.put(paramKey, value);
return column + " > #{map." + paramKey + "}";
case "gte":
paramMap.put(paramKey, value);
return column + " >= #{map." + paramKey + "}";
case "lt":
paramMap.put(paramKey, value);
return column + " < #{map." + paramKey + "}";
case "lte":
paramMap.put(paramKey, value);
return column + " <= #{map." + paramKey + "}";
default:
return "";
}
}
private String buildDateCondition(String column,
String operator,
Object value,
Map<String, Object> paramMap,
int[] indexHolder,
String prefix) {
if (value == null) {
return "";
}
String paramKey = prefix + indexHolder[0]++;
paramMap.put(paramKey, value);
return switch (operator) {
case "eq" -> "TRUNC(" + column + ") = TRUNC(#{map." + paramKey + "})";
case "neq" -> "TRUNC(" + column + ") <> TRUNC(#{map." + paramKey + "})";
case "gt" -> column + " > #{map." + paramKey + "}";
case "gte" -> column + " >= #{map." + paramKey + "}";
case "lt" -> column + " < #{map." + paramKey + "}";
case "lte" -> column + " <= #{map." + paramKey + "}";
default -> "";
};
}
private List<Object> normalizeValues(Object value) { private List<Object> normalizeValues(Object value) {
List<Object> values = new ArrayList<>(); List<Object> values = new ArrayList<>();
if (value instanceof List<?> list) { if (value instanceof List<?> list) {
@ -531,6 +860,76 @@ public class FpBuildServiceImpl implements FpBuildService {
return columnMap.get(field); return columnMap.get(field);
} }
private String mapFishDicColumn(String field) {
if (StrUtil.isBlank(field)) {
return null;
}
return switch (field) {
case "id" -> "t.id";
case "code" -> "t.code";
case "name" -> "t.name";
case "nameEn" -> "t.nameEn";
case "alias" -> "t.alias";
case "logo" -> "t.logo";
case "introduce" -> "t.introduce";
case "inffile" -> "t.inffile";
case "orders" -> "t.orders";
case "family" -> "t.family";
case "genus" -> "t.genus";
case "species" -> "t.species";
case "type" -> "t.type";
case "typeName" -> "t.typeName";
case "fsz" -> "t.fsz";
case "rare" -> "t.rare";
case "rareName" -> "t.rareName";
case "specOrigin" -> "t.specOrigin";
case "specOriginName" -> "t.specOriginName";
case "ptype" -> "t.ptype";
case "ptypeName" -> "t.ptypeName";
case "rvcd" -> "t.rvcd";
case "rvcdName" -> "t.rvcdName";
case "habitMigrat" -> "t.habitMigrat";
case "feedingHabit" -> "t.feedingHabit";
case "spawnCharact" -> "t.spawnCharact";
case "food" -> "t.food";
case "timeFeed" -> "t.timeFeed";
case "orignDate" -> "t.orignDate";
case "pretemp" -> "t.pretemp";
case "flowRate" -> "t.flowRate";
case "depth" -> "t.depth";
case "botmMater" -> "t.botmMater";
case "wqtq" -> "t.wqtq";
case "wqtqName" -> "t.wqtqName";
case "habitat" -> "t.habitat";
case "habitatName" -> "t.habitatName";
case "situation" -> "t.situation";
case "situationName" -> "t.situationName";
case "resourceType" -> "t.resourceType";
case "resourceTypeName" -> "t.resourceTypeName";
case "shapedesc" -> "t.shapedesc";
case "protectlvl" -> "t.protectlvl";
case "habitation" -> "t.habitation";
case "fid" -> "t.fid";
case "description" -> "t.description";
case "enable" -> "t.enable";
case "enableName" -> "t.enableName";
case "internal" -> "t.internal";
case "internalName" -> "t.internalName";
case "orderIndex" -> "t.orderIndex";
case "recordUser" -> "t.recordUser";
case "recordTime" -> "t.recordTime";
case "modifyUser" -> "t.modifyUser";
case "modifyTime" -> "t.modifyTime";
case "isDeleted" -> "t.isDeleted";
case "deleteUser" -> "t.deleteUser";
case "deleteTime" -> "t.deleteTime";
case "spawnMonth" -> "t.spawnMonth";
case "vlsr" -> "t.vlsr";
case "vlsrTm" -> "t.vlsrTm";
default -> null;
};
}
private String buildVmsstbprptOrderBySql(List<DataSourceRequest.SortDescriptor> sorts) { private String buildVmsstbprptOrderBySql(List<DataSourceRequest.SortDescriptor> sorts) {
if (sorts == null || sorts.isEmpty()) { if (sorts == null || sorts.isEmpty()) {
return " ORDER BY t.baseStepSort ASC NULLS LAST, t.rvcdStepSort ASC NULLS LAST, " + return " ORDER BY t.baseStepSort ASC NULLS LAST, t.rvcdStepSort ASC NULLS LAST, " +
@ -555,6 +954,64 @@ public class FpBuildServiceImpl implements FpBuildService {
return " ORDER BY " + String.join(", ", orderItems); return " ORDER BY " + String.join(", ", orderItems);
} }
private String buildFishDicOrderBySql(List<DataSourceRequest.SortDescriptor> sorts) {
List<String> orderItems = new ArrayList<>();
if (CollUtil.isNotEmpty(sorts)) {
for (DataSourceRequest.SortDescriptor sort : sorts) {
if (sort == null || sort.getField() == null || sort.getField().isBlank()) {
continue;
}
String column = mapFishDicColumn(sort.getField());
if (StrUtil.isBlank(column)) {
continue;
}
String direction = "desc".equalsIgnoreCase(sort.getDir()) || "des".equalsIgnoreCase(sort.getDir())
? "DESC" : "ASC";
orderItems.add(column + " " + direction + " NULLS LAST");
}
}
if (orderItems.isEmpty()) {
return " ORDER BY t.orderIndex ASC NULLS LAST, t.name ASC";
}
return " ORDER BY " + String.join(", ", orderItems);
}
private String buildFishDicGroupSql(String detailSql, GroupingInfo[] groupInfos) {
if (groupInfos == null || groupInfos.length == 0) {
return detailSql;
}
List<String> groupFields = new ArrayList<>();
List<String> selectItems = new ArrayList<>();
List<String> orderItems = new ArrayList<>();
for (GroupingInfo item : groupInfos) {
if (item == null || StrUtil.isBlank(item.getSelector())) {
continue;
}
String selector = item.getSelector();
String column = mapFishDicColumn(selector);
if (StrUtil.isBlank(column)) {
continue;
}
groupFields.add(column);
selectItems.add(column + " AS " + selector);
selectItems.add("COUNT(*) AS count_" + selector);
orderItems.add(column + (item.getDesc() ? " DESC" : " ASC"));
}
if (groupFields.isEmpty()) {
return "SELECT * FROM (" + detailSql + ") t WHERE 1 = 0";
}
return "SELECT " + String.join(", ", selectItems) +
" FROM (" + detailSql + ") t GROUP BY " + String.join(", ", groupFields) +
" ORDER BY " + String.join(", ", orderItems);
}
private boolean isFishDicDateField(String field) {
return "recordTime".equals(field)
|| "modifyTime".equals(field)
|| "deleteTime".equals(field)
|| "vlsrTm".equals(field);
}
private String mapVmsstbprptOuterColumn(String field) { private String mapVmsstbprptOuterColumn(String field) {
if (field == null || field.isBlank()) { if (field == null || field.isBlank()) {
return null; return null;