feat: 野生动物监测情况
This commit is contained in:
parent
7f967f4cba
commit
dd9ca6df75
@ -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) {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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<WeVmsstbprptVo> getVmsstbprptList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<WeWvaQgcVo> getWvaList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<WeWvaYearQgcVo> getWvaDefaultYearList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
@ -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<WeWvaQgcVo> getWvaList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
Map<String, Object> 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<WeWvaQgcVo> 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<WeWvaQgcVo> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest) {
|
||||
Map<String, Object> 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<String> selectFields) {
|
||||
Map<String, String> columns = weMsstbprptFieldColumns();
|
||||
List<String> selected = new ArrayList<>();
|
||||
@ -963,6 +1055,39 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return String.join(", ", selected);
|
||||
}
|
||||
|
||||
private String buildWeWvaSelectSql(List<String> selectFields) {
|
||||
Map<String, String> columns = weWvaFieldColumns();
|
||||
List<String> 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<String, String> weMsstbprptFieldColumns() {
|
||||
Map<String, String> columns = new LinkedHashMap<>();
|
||||
columns.put("id", "t.id AS id");
|
||||
@ -994,6 +1119,26 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return columns;
|
||||
}
|
||||
|
||||
private Map<String, String> weWvaFieldColumns() {
|
||||
Map<String, String> 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<String, Object> 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<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isNotBlank(filter.getField())) {
|
||||
return buildWeWvaLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||
return "";
|
||||
}
|
||||
List<String> 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<String, Object> 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<Object> values = normalizeWeFishQgcValues(filter.getValue());
|
||||
if (values.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
List<String> 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<DataSourceRequest.SortDescriptor> 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<DataSourceRequest.SortDescriptor> sorts) {
|
||||
if (CollUtil.isEmpty(sorts)) {
|
||||
return " ORDER BY t.tm DESC NULLS LAST";
|
||||
}
|
||||
List<String> 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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user