feat: 水生生态站点基础统计查询
This commit is contained in:
parent
8ee9952d0e
commit
7f967f4cba
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wte")
|
||||
@Tag(name = "水生生态模块")
|
||||
@Tag(name = "生态调查模块")
|
||||
@Validated
|
||||
public class WeFishController {
|
||||
|
||||
@ -39,6 +39,12 @@ public class WeFishController {
|
||||
return ResponseResult.successData(weFishService.getMsstbprptList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/vmsstbprpt/GetKendoList")
|
||||
@Operation(summary = "水生生态站点基础统计查询")
|
||||
public ResponseResult getVmsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(weFishService.getVmsstbprptList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/wva/year/GetKendoListCust")
|
||||
@Operation(summary = "野生动物监测默认有数据的年份和月份")
|
||||
public ResponseResult getWvaDefaultYearList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package com.yfd.platform.qgc_env.wte.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Schema(description = "水生生态站点基础统计查询")
|
||||
public class WeVmsstbprptVo {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "站类编码")
|
||||
private String sttpCode;
|
||||
|
||||
@Schema(description = "站点编码")
|
||||
private String stcd;
|
||||
|
||||
@Schema(description = "站点名称")
|
||||
private String stnm;
|
||||
|
||||
@Schema(description = "所属电站编码")
|
||||
private String rstcd;
|
||||
|
||||
@Schema(description = "所属电站名称")
|
||||
private String ennm;
|
||||
|
||||
@Schema(description = "基地编码")
|
||||
private String baseId;
|
||||
|
||||
@Schema(description = "流域编码")
|
||||
private String hbrvcd;
|
||||
|
||||
@Schema(description = "河流编码")
|
||||
private String rvcd;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer orderIndex;
|
||||
|
||||
@Schema(description = "经度")
|
||||
private BigDecimal lgtd;
|
||||
|
||||
@Schema(description = "纬度")
|
||||
private BigDecimal lttd;
|
||||
}
|
||||
@ -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.WeVmsstbprptVo;
|
||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaYearQgcVo;
|
||||
|
||||
import java.util.List;
|
||||
@ -22,6 +23,8 @@ public interface WeFishService {
|
||||
|
||||
DataSourceResult<WeMsstbprptVo> getMsstbprptList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<WeVmsstbprptVo> getVmsstbprptList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<WeWvaYearQgcVo> getWvaDefaultYearList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
@ -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.WeVmsstbprptVo;
|
||||
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;
|
||||
@ -186,6 +187,44 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<WeVmsstbprptVo> getVmsstbprptList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ")
|
||||
.append(buildWeVmsstbprptSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect()))
|
||||
.append(" FROM (")
|
||||
.append(buildWeVmsstbprptViewSql())
|
||||
.append(") t WHERE 1 = 1 ");
|
||||
|
||||
String filterSql = buildWeVmsstbprptFilterCondition(
|
||||
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||
paramMap,
|
||||
new int[]{0}
|
||||
);
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append("AND ").append(filterSql).append(" ");
|
||||
}
|
||||
sql.append(buildWeVmsstbprptOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||
|
||||
Page<?> page = loadOptions == null ? null
|
||||
: QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<WeVmsstbprptVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page,
|
||||
sql.toString(),
|
||||
paramMap,
|
||||
WeVmsstbprptVo.class
|
||||
);
|
||||
|
||||
DataSourceResult<WeVmsstbprptVo> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<WeWvaYearQgcVo> getWvaDefaultYearList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
@ -863,6 +902,25 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
"WHERE NVL(ai.IS_DELETED, 0) = 0";
|
||||
}
|
||||
|
||||
private String buildWeVmsstbprptViewSql() {
|
||||
return "SELECT " +
|
||||
"ai.STCD AS id, " +
|
||||
"ai.STTP AS sttpCode, " +
|
||||
"ai.STCD AS stcd, " +
|
||||
"ai.STNM AS stnm, " +
|
||||
"ai.RSTCD AS rstcd, " +
|
||||
"eng.ENNM AS ennm, " +
|
||||
"ai.BASE_ID AS baseId, " +
|
||||
"ai.HBRVCD AS hbrvcd, " +
|
||||
"ai.RVCD AS rvcd, " +
|
||||
"ai.ORDER_INDEX AS orderIndex, " +
|
||||
"ai.LGTD AS lgtd, " +
|
||||
"ai.LTTD AS lttd " +
|
||||
"FROM SD_AIMONITOR_B_H ai " +
|
||||
"LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = ai.RSTCD AND NVL(eng.IS_DELETED, 0) = 0 " +
|
||||
"WHERE NVL(ai.IS_DELETED, 0) = 0";
|
||||
}
|
||||
|
||||
private String buildWeMsstbprptSelectSql(List<String> selectFields) {
|
||||
Map<String, String> columns = weMsstbprptFieldColumns();
|
||||
List<String> selected = new ArrayList<>();
|
||||
@ -882,6 +940,29 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return String.join(", ", selected);
|
||||
}
|
||||
|
||||
private String buildWeVmsstbprptSelectSql(List<String> selectFields) {
|
||||
Map<String, String> columns = weVmsstbprptFieldColumns();
|
||||
List<String> selected = new ArrayList<>();
|
||||
if (CollUtil.isEmpty(selectFields)) {
|
||||
selected.add("t.sttpCode AS sttpCode");
|
||||
selected.add("t.stnm AS stnm");
|
||||
selected.add("t.stcd AS stcd");
|
||||
} else {
|
||||
for (String field : selectFields) {
|
||||
String column = columns.get(field);
|
||||
if (StrUtil.isNotBlank(column)) {
|
||||
selected.add(column);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selected.isEmpty()) {
|
||||
selected.add("t.sttpCode AS sttpCode");
|
||||
selected.add("t.stnm AS stnm");
|
||||
selected.add("t.stcd AS stcd");
|
||||
}
|
||||
return String.join(", ", selected);
|
||||
}
|
||||
|
||||
private Map<String, String> weMsstbprptFieldColumns() {
|
||||
Map<String, String> columns = new LinkedHashMap<>();
|
||||
columns.put("id", "t.id AS id");
|
||||
@ -896,6 +977,23 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return columns;
|
||||
}
|
||||
|
||||
private Map<String, String> weVmsstbprptFieldColumns() {
|
||||
Map<String, String> columns = new LinkedHashMap<>();
|
||||
columns.put("id", "t.id AS id");
|
||||
columns.put("sttpCode", "t.sttpCode AS sttpCode");
|
||||
columns.put("stcd", "t.stcd AS stcd");
|
||||
columns.put("stnm", "t.stnm AS stnm");
|
||||
columns.put("rstcd", "t.rstcd AS rstcd");
|
||||
columns.put("ennm", "t.ennm AS ennm");
|
||||
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");
|
||||
columns.put("lgtd", "t.lgtd AS lgtd");
|
||||
columns.put("lttd", "t.lttd AS lttd");
|
||||
return columns;
|
||||
}
|
||||
|
||||
private String buildWeMsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
@ -970,6 +1068,98 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
};
|
||||
}
|
||||
|
||||
private String buildWeVmsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isNotBlank(filter.getField())) {
|
||||
return buildWeVmsstbprptLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||
return "";
|
||||
}
|
||||
List<String> conditions = new ArrayList<>();
|
||||
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||
String childSql = buildWeVmsstbprptFilterCondition(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 buildWeVmsstbprptLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
String column = mapWeVmsstbprptColumn(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 = "weVmsstbprptP" + 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 = "weVmsstbprptP" + indexHolder[0]++;
|
||||
String text = String.valueOf(rawValue).trim();
|
||||
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 + "}";
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
private String mapWeMsstbprptColumn(String field) {
|
||||
if (StrUtil.isBlank(field)) {
|
||||
return null;
|
||||
@ -988,6 +1178,27 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
};
|
||||
}
|
||||
|
||||
private String mapWeVmsstbprptColumn(String field) {
|
||||
if (StrUtil.isBlank(field)) {
|
||||
return null;
|
||||
}
|
||||
return switch (field) {
|
||||
case "id" -> "t.id";
|
||||
case "sttpCode" -> "t.sttpCode";
|
||||
case "stcd" -> "t.stcd";
|
||||
case "stnm" -> "t.stnm";
|
||||
case "rstcd" -> "t.rstcd";
|
||||
case "ennm" -> "t.ennm";
|
||||
case "baseId" -> "t.baseId";
|
||||
case "hbrvcd" -> "t.hbrvcd";
|
||||
case "rvcd" -> "t.rvcd";
|
||||
case "orderIndex" -> "t.orderIndex";
|
||||
case "lgtd" -> "t.lgtd";
|
||||
case "lttd" -> "t.lttd";
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private String buildWeMsstbprptOrderBySql(List<DataSourceRequest.SortDescriptor> sorts) {
|
||||
if (CollUtil.isEmpty(sorts)) {
|
||||
return "";
|
||||
@ -1010,6 +1221,28 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return " ORDER BY " + String.join(", ", orderByParts);
|
||||
}
|
||||
|
||||
private String buildWeVmsstbprptOrderBySql(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 = mapWeVmsstbprptColumn(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 buildWeFishListQgcGroupSql(String baseSql, GroupingInfo[] groupInfos) {
|
||||
if (groupInfos == null || groupInfos.length == 0) {
|
||||
return baseSql;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user