feat: 野生动物监测默认数据
This commit is contained in:
parent
b566d7bacf
commit
4480109fb0
@ -63,6 +63,12 @@ public class WeFishController {
|
|||||||
return ResponseResult.successData(weFishService.getWvaList(dataSourceRequest));
|
return ResponseResult.successData(weFishService.getWvaList(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/wva/default/GetKendoListCust")
|
||||||
|
@Operation(summary = "野生动物监测默认数据")
|
||||||
|
public ResponseResult getWvaDefaultList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(weFishService.getWvaDefaultList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/we/fisht/year/qgc/GetKendoListCust")
|
@PostMapping("/we/fisht/year/qgc/GetKendoListCust")
|
||||||
@Operation(summary = "全过程沿程鱼类变化情况有数据的流域和年份")
|
@Operation(summary = "全过程沿程鱼类变化情况有数据的流域和年份")
|
||||||
public ResponseResult getQgcFishStaticsYearList(@RequestBody DataSourceRequest dataSourceRequest) {
|
public ResponseResult getQgcFishStaticsYearList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
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 WeWvaDefaultVo {
|
||||||
|
|
||||||
|
@Schema(description = "站点编码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "站点名称")
|
||||||
|
private String stnm;
|
||||||
|
|
||||||
|
@Schema(description = "站类编码")
|
||||||
|
private String sttpCode;
|
||||||
|
|
||||||
|
@Schema(description = "站类名称")
|
||||||
|
private String sttpName;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "最新时间")
|
||||||
|
private Date tm;
|
||||||
|
}
|
||||||
@ -13,6 +13,7 @@ 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.WeStaticsVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeTeSpecialAnimalVo;
|
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.WeVmsstbprptVo;
|
||||||
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaDefaultVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaQgcVo;
|
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.entity.vo.WeWvaYearQgcVo;
|
||||||
|
|
||||||
@ -33,6 +34,8 @@ public interface WeFishService {
|
|||||||
|
|
||||||
DataSourceResult<WeWvaQgcVo> getWvaList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<WeWvaQgcVo> getWvaList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult<WeWvaDefaultVo> getWvaDefaultList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<WeWvaYearQgcVo> getWvaDefaultYearList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<WeWvaYearQgcVo> getWvaDefaultYearList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -22,6 +22,7 @@ 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.WeStaticsVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeTeSpecialAnimalVo;
|
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.WeVmsstbprptVo;
|
||||||
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaDefaultVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaQgcVo;
|
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.entity.vo.WeWvaYearQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.service.WeFishService;
|
import com.yfd.platform.qgc_env.wte.service.WeFishService;
|
||||||
@ -320,6 +321,64 @@ public class WeFishServiceImpl implements WeFishService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<WeWvaDefaultVo> getWvaDefaultList(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
Map<String, Object> innerParamMap = new HashMap<>();
|
||||||
|
Map<String, Object> outerParamMap = new HashMap<>();
|
||||||
|
|
||||||
|
String innerFilterSql = buildWeWvaDefaultInnerFilterCondition(
|
||||||
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||||
|
innerParamMap,
|
||||||
|
new int[]{0}
|
||||||
|
);
|
||||||
|
String outerFilterSql = buildWeWvaDefaultOuterFilterCondition(
|
||||||
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||||
|
outerParamMap,
|
||||||
|
new int[]{0}
|
||||||
|
);
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT t.stcd AS stcd, t.stnm AS stnm, t.tm AS tm, t.sttpCode AS sttpCode, t.sttpName AS sttpName ")
|
||||||
|
.append("FROM (")
|
||||||
|
.append("SELECT latest.stcd AS stcd, ai.STNM AS stnm, latest.tm AS tm, ai.STTP AS sttpCode, sttp.STTP_NAME AS sttpName, ")
|
||||||
|
.append("ai.RSTCD AS rstcd, ai.BASE_ID AS baseId, ai.HBRVCD AS hbrvcd ")
|
||||||
|
.append("FROM (SELECT src.STCD AS stcd, MAX(src.TM) AS tm FROM SD_WVA_R src WHERE NVL(src.IS_DELETED, 0) = 0 ");
|
||||||
|
if (StrUtil.isNotBlank(innerFilterSql)) {
|
||||||
|
sql.append("AND ").append(innerFilterSql).append(" ");
|
||||||
|
}
|
||||||
|
sql.append("GROUP BY src.STCD) latest ")
|
||||||
|
.append("INNER JOIN SD_AIMONITOR_B_H ai ON latest.stcd = ai.STCD ")
|
||||||
|
.append("AND NVL(ai.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("AND ai.STTP = 'WVA' ")
|
||||||
|
.append("LEFT JOIN SD_STTP_B sttp ON ai.STTP = sttp.STTP_CODE ")
|
||||||
|
.append("AND NVL(sttp.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(") t WHERE 1 = 1 ");
|
||||||
|
if (StrUtil.isNotBlank(outerFilterSql)) {
|
||||||
|
sql.append("AND ").append(outerFilterSql).append(" ");
|
||||||
|
}
|
||||||
|
sql.append(buildWeWvaDefaultOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
paramMap.putAll(innerParamMap);
|
||||||
|
paramMap.putAll(outerParamMap);
|
||||||
|
|
||||||
|
Page<?> page = loadOptions == null ? null
|
||||||
|
: QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
List<WeWvaDefaultVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
|
page,
|
||||||
|
sql.toString(),
|
||||||
|
paramMap,
|
||||||
|
WeWvaDefaultVo.class
|
||||||
|
);
|
||||||
|
|
||||||
|
DataSourceResult<WeWvaDefaultVo> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal(page != null ? page.getTotal() : (long) list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<WeWvaQgcVo> getWvaList(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<WeWvaQgcVo> getWvaList(DataSourceRequest dataSourceRequest) {
|
||||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
@ -1748,6 +1807,207 @@ public class WeFishServiceImpl implements WeFishService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildWeWvaDefaultInnerFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildWeWvaDefaultLeafCondition(filter, paramMap, indexHolder, true);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildWeWvaDefaultInnerFilterCondition(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 buildWeWvaDefaultOuterFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildWeWvaDefaultLeafCondition(filter, paramMap, indexHolder, false);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildWeWvaDefaultOuterFilterCondition(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 buildWeWvaDefaultLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder,
|
||||||
|
boolean inner) {
|
||||||
|
String column = inner ? mapWeWvaDefaultInnerColumn(filter.getField()) : mapWeWvaDefaultOuterColumn(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<Object> values = normalizeWeWvaValues(filter.getValue());
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (Object value : values) {
|
||||||
|
Object normalizedValue = normalizeWeWvaDefaultValue(filter.getField(), value);
|
||||||
|
if (normalizedValue == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String key = (inner ? "weWvaDefaultInnerP" : "weWvaDefaultOuterP") + indexHolder[0]++;
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
placeholders.add(buildWeWvaDefaultValueExpr(key, "tm".equals(filter.getField()), normalizedValue));
|
||||||
|
}
|
||||||
|
if (placeholders.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return column + ("ni".equals(operator) ? " NOT IN (" : " IN (") + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
Object normalizedValue = normalizeWeWvaDefaultValue(filter.getField(), filter.getValue());
|
||||||
|
if (normalizedValue == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String key = (inner ? "weWvaDefaultInnerP" : "weWvaDefaultOuterP") + indexHolder[0]++;
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
String valueExpr = buildWeWvaDefaultValueExpr(key, "tm".equals(filter.getField()), normalizedValue);
|
||||||
|
return switch (operator) {
|
||||||
|
case "eq" -> column + " = " + valueExpr;
|
||||||
|
case "neq" -> column + " <> " + valueExpr;
|
||||||
|
case "gt" -> column + " > " + valueExpr;
|
||||||
|
case "gte" -> column + " >= " + valueExpr;
|
||||||
|
case "lt" -> column + " < " + valueExpr;
|
||||||
|
case "lte" -> column + " <= " + valueExpr;
|
||||||
|
case "contains" -> {
|
||||||
|
paramMap.put(key, "%" + String.valueOf(normalizedValue).trim() + "%");
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "doesnotcontain" -> {
|
||||||
|
paramMap.put(key, "%" + String.valueOf(normalizedValue).trim() + "%");
|
||||||
|
yield column + " NOT LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "startswith" -> {
|
||||||
|
paramMap.put(key, String.valueOf(normalizedValue).trim() + "%");
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "endswith" -> {
|
||||||
|
paramMap.put(key, "%" + String.valueOf(normalizedValue).trim());
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapWeWvaDefaultInnerColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "stcd" -> "src.STCD";
|
||||||
|
case "tm" -> "src.TM";
|
||||||
|
case "fid" -> "src.FID";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapWeWvaDefaultOuterColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "stcd" -> "t.stcd";
|
||||||
|
case "stnm" -> "t.stnm";
|
||||||
|
case "tm" -> "t.tm";
|
||||||
|
case "sttpCode" -> "t.sttpCode";
|
||||||
|
case "sttpName" -> "t.sttpName";
|
||||||
|
case "rstcd" -> "t.rstcd";
|
||||||
|
case "baseId" -> "t.baseId";
|
||||||
|
case "hbrvcd" -> "t.hbrvcd";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object normalizeWeWvaDefaultValue(String field, Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ("tm".equals(field)) {
|
||||||
|
String text = String.valueOf(value).trim();
|
||||||
|
return StrUtil.isBlank(text) ? null : text;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildWeWvaDefaultValueExpr(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 buildWeWvaDefaultOrderBySql(List<DataSourceRequest.SortDescriptor> sorts) {
|
||||||
|
if (CollUtil.isEmpty(sorts)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> orderByParts = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.SortDescriptor sort : sorts) {
|
||||||
|
if (sort == null || StrUtil.isBlank(sort.getField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String column = mapWeWvaDefaultOuterColumn(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 "";
|
||||||
|
}
|
||||||
|
return " ORDER BY " + String.join(", ", orderByParts);
|
||||||
|
}
|
||||||
|
|
||||||
private String buildWeMsstbprptViewSql() {
|
private String buildWeMsstbprptViewSql() {
|
||||||
return "SELECT " +
|
return "SELECT " +
|
||||||
"ai.STCD AS id, " +
|
"ai.STCD AS id, " +
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user