feat: 查询栖息地流量站日统计数据
This commit is contained in:
parent
c35842d671
commit
38a53ec7da
@ -46,6 +46,12 @@ public class FhHabitatController {
|
||||
return ResponseResult.successData(fhHabitatService.getSdrvwtsList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/zq/sdriverdays/GetKendoList")
|
||||
@Operation(summary = "查询栖息地流量站日统计数据")
|
||||
public ResponseResult getSdriverdaysList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(fhHabitatService.getSdriverdaysList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/msstbprpt/GetKendoList")
|
||||
@Operation(summary = "查询栖息地监测站点列表")
|
||||
public ResponseResult getMsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
|
||||
38
backend/src/main/java/com/yfd/platform/env/fh/entity/vo/FhSdriverdayVo.java
vendored
Normal file
38
backend/src/main/java/com/yfd/platform/env/fh/entity/vo/FhSdriverdayVo.java
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
package com.yfd.platform.env.fh.entity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Schema(description = "栖息地流量站日统计数据")
|
||||
public class FhSdriverdayVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键ID")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "站码")
|
||||
private String stcd;
|
||||
|
||||
@Schema(description = "时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date dt;
|
||||
|
||||
@Schema(description = "水位")
|
||||
private BigDecimal z;
|
||||
|
||||
@Schema(description = "流量")
|
||||
private BigDecimal q;
|
||||
|
||||
@Schema(description = "流速")
|
||||
private BigDecimal v;
|
||||
|
||||
@Schema(description = "测流方法")
|
||||
private String msqmt;
|
||||
}
|
||||
@ -16,6 +16,8 @@ public interface FhHabitatService {
|
||||
|
||||
DataSourceResult getSdrvwtsList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult getSdriverdaysList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult getMsstbprptList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult getStTbYsBVoKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
@ -16,6 +16,7 @@ import com.yfd.platform.env.fh.entity.ao.FhDefaultAo;
|
||||
import com.yfd.platform.env.fh.entity.vo.FhDefaultVo;
|
||||
import com.yfd.platform.env.fh.entity.vo.HabitatVo;
|
||||
import com.yfd.platform.env.fh.entity.vo.FhMsstbprptVo;
|
||||
import com.yfd.platform.env.fh.entity.vo.FhSdriverdayVo;
|
||||
import com.yfd.platform.env.fh.entity.vo.FhSdrvwtsVo;
|
||||
import com.yfd.platform.env.fh.service.FhHabitatService;
|
||||
import com.yfd.platform.env.wq.entity.vo.StTbYsVo;
|
||||
@ -210,6 +211,58 @@ public class FhHabitatServiceImpl implements FhHabitatService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult getSdriverdaysList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ")
|
||||
.append("t.ID AS id, ")
|
||||
.append("t.STCD AS stcd, ")
|
||||
.append("t.DT AS dt, ")
|
||||
.append("t.Z AS z, ")
|
||||
.append("t.Q AS q, ")
|
||||
.append("t.V AS v, ")
|
||||
.append("t.MSQMT AS msqmt ")
|
||||
.append("FROM SD_RIVERDAY_S t ")
|
||||
.append("WHERE NVL(t.IS_DELETED, 0) = 0 ");
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
String filterSql = buildSdriverdaysFilterCondition(
|
||||
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||
paramMap,
|
||||
new int[]{0}
|
||||
);
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql).append(" ");
|
||||
}
|
||||
|
||||
GroupingInfo[] groups = loadOptions == null ? null : loadOptions.getGroup();
|
||||
if (groups != null && groups.length > 0) {
|
||||
String groupSql = buildGroupSql(sql.toString(), groups);
|
||||
List<Map<String, Object>> groupRows = microservicDynamicSQLMapper.pageAllList(null, groupSql, paramMap);
|
||||
DataSourceResult<FhSdriverdayVo> result = new DataSourceResult<>();
|
||||
if (Boolean.TRUE.equals(dataSourceRequest.getGroupResultFlat())) {
|
||||
result.setData((List<FhSdriverdayVo>) (List<?>) new GroupHelper().faltGroup(groupRows, Arrays.asList(groups)));
|
||||
} else {
|
||||
result.setData((List<FhSdriverdayVo>) (List<?>) new GroupHelper().group(groupRows, Arrays.asList(groups)));
|
||||
}
|
||||
result.setTotal(0L);
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
sql.append(buildSdriverdaysOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||
PageInfo pageInfo = loadOptions == null ? null : QgcQueryWrapperUtil.getPageInfo(loadOptions);
|
||||
Page<?> page = pageInfo != null && pageInfo.getHasPageInfo() ? pageInfo.getPage() : null;
|
||||
List<FhSdriverdayVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, FhSdriverdayVo.class);
|
||||
|
||||
DataSourceResult<FhSdriverdayVo> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
private String buildDefaultFhListSql(FhDefaultAo fhDefaultAo) {
|
||||
String dateConditionWtrv = "";
|
||||
String dateConditionZq = "";
|
||||
@ -1323,6 +1376,150 @@ public class FhHabitatServiceImpl implements FhHabitatService {
|
||||
return " ORDER BY " + String.join(", ", orders);
|
||||
}
|
||||
|
||||
private String buildSdriverdaysFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isNotBlank(filter.getField())) {
|
||||
return buildSdriverdaysLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||
return "";
|
||||
}
|
||||
List<String> conditions = new ArrayList<>();
|
||||
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||
String childSql = buildSdriverdaysFilterCondition(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 buildSdriverdaysLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
String column = mapSdriverdaysColumn(filter.getField());
|
||||
if (StrUtil.isBlank(column)) {
|
||||
return "";
|
||||
}
|
||||
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||
Object value = filter.getValue();
|
||||
if ("isnull".equals(operator)) {
|
||||
return column + " IS NULL";
|
||||
}
|
||||
if ("isnotnull".equals(operator)) {
|
||||
return column + " IS NOT NULL";
|
||||
}
|
||||
boolean dateField = isSdriverdaysDateField(filter.getField());
|
||||
if ("in".equals(operator)) {
|
||||
List<Object> values = normalizeFilterValues(value);
|
||||
if (values.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
for (Object item : values) {
|
||||
String paramKey = "fhRiverParam" + indexHolder[0]++;
|
||||
paramMap.put(paramKey, item);
|
||||
placeholders.add(buildSdriverdaysValueExpr(paramKey, dateField, item));
|
||||
}
|
||||
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||
}
|
||||
|
||||
String paramKey = "fhRiverParam" + indexHolder[0]++;
|
||||
String valueExpr = buildSdriverdaysValueExpr(paramKey, dateField, value);
|
||||
switch (operator) {
|
||||
case "eq":
|
||||
paramMap.put(paramKey, value);
|
||||
return column + " = " + valueExpr;
|
||||
case "neq":
|
||||
paramMap.put(paramKey, value);
|
||||
return column + " <> " + valueExpr;
|
||||
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 + " > " + valueExpr;
|
||||
case "gte":
|
||||
paramMap.put(paramKey, value);
|
||||
return column + " >= " + valueExpr;
|
||||
case "lt":
|
||||
paramMap.put(paramKey, value);
|
||||
return column + " < " + valueExpr;
|
||||
case "lte":
|
||||
paramMap.put(paramKey, value);
|
||||
return column + " <= " + valueExpr;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String mapSdriverdaysColumn(String field) {
|
||||
if (StrUtil.isBlank(field)) {
|
||||
return null;
|
||||
}
|
||||
return switch (field.toLowerCase()) {
|
||||
case "id" -> "t.ID";
|
||||
case "stcd" -> "t.STCD";
|
||||
case "dt" -> "t.DT";
|
||||
case "z" -> "t.Z";
|
||||
case "q" -> "t.Q";
|
||||
case "v" -> "t.V";
|
||||
case "msqmt" -> "t.MSQMT";
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isSdriverdaysDateField(String field) {
|
||||
return "dt".equalsIgnoreCase(field);
|
||||
}
|
||||
|
||||
private String buildSdriverdaysValueExpr(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 buildSdriverdaysOrderBySql(List<DataSourceRequest.SortDescriptor> sortList) {
|
||||
if (CollUtil.isEmpty(sortList)) {
|
||||
return " ORDER BY t.DT DESC, t.STCD ASC";
|
||||
}
|
||||
List<String> orders = new ArrayList<>();
|
||||
for (DataSourceRequest.SortDescriptor sortDescriptor : sortList) {
|
||||
if (sortDescriptor == null || StrUtil.isBlank(sortDescriptor.getField())) {
|
||||
continue;
|
||||
}
|
||||
String column = mapSdriverdaysColumn(sortDescriptor.getField());
|
||||
if (StrUtil.isBlank(column)) {
|
||||
continue;
|
||||
}
|
||||
String dir = ("desc".equalsIgnoreCase(sortDescriptor.getDir()) || "des".equalsIgnoreCase(sortDescriptor.getDir())) ? "DESC" : "ASC";
|
||||
orders.add(column + " " + dir);
|
||||
}
|
||||
if (orders.isEmpty()) {
|
||||
return " ORDER BY t.DT DESC, t.STCD ASC";
|
||||
}
|
||||
return " ORDER BY " + String.join(", ", orders);
|
||||
}
|
||||
|
||||
private String findFilterFieldValue(DataSourceRequest.FilterDescriptor filter, String field) {
|
||||
if (filter == null || StrUtil.isBlank(field)) {
|
||||
return null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user