feat: 水温日数据统计修正结果数据
This commit is contained in:
parent
c0499f93dc
commit
8e3fa72fd1
@ -308,7 +308,7 @@ public class SdFpssBH implements Serializable {
|
||||
/**
|
||||
* 设计过鱼规模,单位:尾
|
||||
*/
|
||||
private Long sjgycnt;
|
||||
private String sjgycnt;
|
||||
|
||||
/**
|
||||
* 主要过鱼对象{[code:鱼编码1,name:鱼名称1,数量],[code:鱼编码2,name:鱼名称2]...}
|
||||
|
||||
@ -199,8 +199,11 @@ public class FpVmsstbprptVo implements Serializable {
|
||||
@Schema(description = "升鱼机集鱼槽水深")
|
||||
private String syjwdp;
|
||||
|
||||
// @Schema(description = "设计过鱼规模")
|
||||
// private Integer sjgycnt;
|
||||
|
||||
@Schema(description = "设计过鱼规模")
|
||||
private Integer sjgycnt;
|
||||
private String sjgycnt;
|
||||
|
||||
@Schema(description = "主要过鱼对象描述")
|
||||
private String zygydxms;
|
||||
|
||||
@ -203,6 +203,12 @@ public class SdWTMonitorController {
|
||||
return ResponseResult.successData(sdWtMonitorService.getMsstbprptEngList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/wtrvAmend/dayAmend/GetKendoListCust")
|
||||
@Operation(summary = "水温日数据统计修正结果数据")
|
||||
public ResponseResult getWtrvAmendDayList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(sdWtMonitorService.getWtrvAmendDayList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@GetMapping("/msstbprpt/getStcdInfo")
|
||||
@Operation(summary = "根据站码查询单条水温基础数据")
|
||||
public ResponseResult getStcdInfo(@RequestParam String stcd) {
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package com.yfd.platform.qgc_env.wt.entity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Schema(description = "水温日数据统计修正结果数据")
|
||||
public class WtrvAmendResultVo {
|
||||
|
||||
@Schema(description = "站点编码")
|
||||
private String stcd;
|
||||
|
||||
@Schema(description = "日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date dt;
|
||||
|
||||
@Schema(description = "温度")
|
||||
private BigDecimal wt;
|
||||
|
||||
@Schema(description = "站点名称")
|
||||
private String stnm;
|
||||
|
||||
@Schema(description = "电站编码")
|
||||
private String rstcd;
|
||||
|
||||
@Schema(description = "电站名称")
|
||||
private String ennm;
|
||||
|
||||
@Schema(description = "基地编码")
|
||||
private String baseId;
|
||||
|
||||
@Schema(description = "基地名称")
|
||||
private String baseName;
|
||||
}
|
||||
@ -11,6 +11,7 @@ import com.yfd.platform.qgc_env.wt.entity.vo.SttpInfoVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WbsbVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtBaseInfoVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendResultVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -24,6 +25,8 @@ public interface SdWtMonitorService {
|
||||
|
||||
DataSourceResult getMsstbprptEngList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<WtrvAmendResultVo> getWtrvAmendDayList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
WtBaseInfoVo getStcdInfo(String stcd);
|
||||
|
||||
DataSourceResult getCxDetailList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
@ -16,6 +16,7 @@ import com.yfd.platform.qgc_env.wt.entity.vo.WbsbVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtBaseInfoVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtFishVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtTreeStcdVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendResultVo;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvVo;
|
||||
import com.yfd.platform.qgc_env.wt.mapper.SdWtMonitorMapper;
|
||||
import com.yfd.platform.qgc_env.wt.service.SdWtMonitorService;
|
||||
@ -897,6 +898,37 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<WtrvAmendResultVo> getWtrvAmendDayList(DataSourceRequest dataSourceRequest) {
|
||||
List<String> selectFields = dataSourceRequest == null ? null : dataSourceRequest.getSelect();
|
||||
String selectSql = buildWtrvAmendSelectSql(selectFields);
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ").append(selectSql).append(" FROM (")
|
||||
.append(buildWtrvAmendMergedSql())
|
||||
.append(") t WHERE 1 = 1 ");
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
String filterSql = buildWtrvAmendFilterCondition(dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||
paramMap, new int[]{0});
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql);
|
||||
}
|
||||
sql.append(buildWtrvAmendOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
Page<?> page = loadOptions == null ? null
|
||||
: QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<WtrvAmendResultVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page,
|
||||
sql.toString(), paramMap, WtrvAmendResultVo.class);
|
||||
|
||||
DataSourceResult<WtrvAmendResultVo> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult getCxDetailList(DataSourceRequest dataSourceRequest) {
|
||||
List<DataSourceRequest.FilterDescriptor> filters = new ArrayList<>();
|
||||
@ -1819,6 +1851,244 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
||||
return " ORDER BY " + String.join(", ", orderColumns);
|
||||
}
|
||||
|
||||
private String buildWtrvAmendMergedSql() {
|
||||
return "SELECT " +
|
||||
"dayData.STCD AS stcd, " +
|
||||
"dayData.DT AS dt, " +
|
||||
"NVL(amendData.WT, dayData.WT) AS wt, " +
|
||||
"wt.STNM AS stnm, " +
|
||||
"wt.RSTCD AS rstcd, " +
|
||||
"eng.ENNM AS ennm, " +
|
||||
"eng.BASE_ID AS baseId, " +
|
||||
"hb.BASENAME AS baseName " +
|
||||
"FROM SD_WTRVDAY_S dayData " +
|
||||
"INNER JOIN SD_WT_B_H wt ON dayData.STCD = wt.STCD " +
|
||||
" AND wt.STTP = 'WTRV' " +
|
||||
" AND NVL(wt.IS_DELETED, 0) = 0 " +
|
||||
"LEFT JOIN SD_WTRVAMEND_S amendData ON amendData.STCD = dayData.STCD " +
|
||||
" AND amendData.DT = dayData.DT " +
|
||||
" AND NVL(amendData.IS_DELETED, 0) = 0 " +
|
||||
"LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = wt.RSTCD " +
|
||||
" AND NVL(eng.IS_DELETED, 0) = 0 " +
|
||||
"LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = eng.BASE_ID " +
|
||||
" AND NVL(hb.IS_DELETED, 0) = 0 " +
|
||||
"WHERE NVL(dayData.IS_DELETED, 0) = 0 " +
|
||||
"UNION ALL " +
|
||||
"SELECT " +
|
||||
"amendData.STCD AS stcd, " +
|
||||
"amendData.DT AS dt, " +
|
||||
"amendData.WT AS wt, " +
|
||||
"wt.STNM AS stnm, " +
|
||||
"wt.RSTCD AS rstcd, " +
|
||||
"eng.ENNM AS ennm, " +
|
||||
"eng.BASE_ID AS baseId, " +
|
||||
"hb.BASENAME AS baseName " +
|
||||
"FROM SD_WTRVAMEND_S amendData " +
|
||||
"INNER JOIN SD_WT_B_H wt ON amendData.STCD = wt.STCD " +
|
||||
" AND wt.STTP = 'WTRV' " +
|
||||
" AND NVL(wt.IS_DELETED, 0) = 0 " +
|
||||
"LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = wt.RSTCD " +
|
||||
" AND NVL(eng.IS_DELETED, 0) = 0 " +
|
||||
"LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = eng.BASE_ID " +
|
||||
" AND NVL(hb.IS_DELETED, 0) = 0 " +
|
||||
"WHERE NVL(amendData.IS_DELETED, 0) = 0 " +
|
||||
"AND NOT EXISTS ( " +
|
||||
" SELECT 1 FROM SD_WTRVDAY_S dayData " +
|
||||
" WHERE dayData.STCD = amendData.STCD " +
|
||||
" AND dayData.DT = amendData.DT " +
|
||||
" AND NVL(dayData.IS_DELETED, 0) = 0 " +
|
||||
")";
|
||||
}
|
||||
|
||||
private String buildWtrvAmendSelectSql(List<String> selectFields) {
|
||||
Map<String, String> columnMap = buildWtrvAmendColumnMap();
|
||||
List<String> actualColumns = new ArrayList<>();
|
||||
if (selectFields != null && !selectFields.isEmpty()) {
|
||||
for (String field : selectFields) {
|
||||
String column = columnMap.get(field);
|
||||
if (StrUtil.isNotBlank(column)) {
|
||||
actualColumns.add(column);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (actualColumns.isEmpty()) {
|
||||
actualColumns.addAll(columnMap.values());
|
||||
}
|
||||
return String.join(", ", actualColumns);
|
||||
}
|
||||
|
||||
private Map<String, String> buildWtrvAmendColumnMap() {
|
||||
Map<String, String> columnMap = new LinkedHashMap<>();
|
||||
columnMap.put("stcd", "t.stcd AS stcd");
|
||||
columnMap.put("dt", "t.dt AS dt");
|
||||
columnMap.put("wt", "t.wt AS wt");
|
||||
columnMap.put("stnm", "t.stnm AS stnm");
|
||||
columnMap.put("rstcd", "t.rstcd AS rstcd");
|
||||
columnMap.put("ennm", "t.ennm AS ennm");
|
||||
columnMap.put("baseId", "t.baseId AS baseId");
|
||||
columnMap.put("baseName", "t.baseName AS baseName");
|
||||
return columnMap;
|
||||
}
|
||||
|
||||
private String buildWtrvAmendFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (filter.getFilters() != null && !filter.getFilters().isEmpty()) {
|
||||
List<String> conditions = new ArrayList<>();
|
||||
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||
String condition = buildWtrvAmendFilterCondition(child, paramMap, indexHolder);
|
||||
if (StrUtil.isNotBlank(condition)) {
|
||||
conditions.add("(" + condition + ")");
|
||||
}
|
||||
}
|
||||
if (conditions.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
String logic = "or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ";
|
||||
return String.join(logic, conditions);
|
||||
}
|
||||
return buildWtrvAmendLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
|
||||
private String buildWtrvAmendLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
String column = mapWtrvAmendColumn(filter == null ? null : filter.getField());
|
||||
if (StrUtil.isBlank(column) || StrUtil.isBlank(filter.getOperator())) {
|
||||
return "";
|
||||
}
|
||||
String operator = filter.getOperator().toLowerCase();
|
||||
Object rawValue = filter.getValue();
|
||||
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 (rawValue == null) {
|
||||
return "";
|
||||
}
|
||||
String paramKey = "wtrvAmendP" + indexHolder[0]++;
|
||||
boolean dateField = isWtrvAmendDateField(filter);
|
||||
if ("in".equals(operator) || "ni".equals(operator)) {
|
||||
List<?> values = normalizeToList(rawValue);
|
||||
if (values.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
int itemIndex = 0;
|
||||
for (Object value : values) {
|
||||
String itemKey = paramKey + "_" + itemIndex++;
|
||||
paramMap.put(itemKey, String.valueOf(value).trim());
|
||||
placeholders.add(buildWtrvAmendValueExpr(itemKey, dateField, value));
|
||||
}
|
||||
return column + ("ni".equals(operator) ? " NOT IN (" : " IN (") + String.join(", ", placeholders) + ")";
|
||||
}
|
||||
String text = String.valueOf(rawValue).trim();
|
||||
paramMap.put(paramKey, text);
|
||||
String valueExpr = buildWtrvAmendValueExpr(paramKey, dateField, rawValue);
|
||||
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(paramKey, "%" + text + "%");
|
||||
yield column + " LIKE #{map." + paramKey + "}";
|
||||
}
|
||||
case "doesnotcontain" -> {
|
||||
paramMap.put(paramKey, "%" + text + "%");
|
||||
yield column + " NOT LIKE #{map." + paramKey + "}";
|
||||
}
|
||||
case "startswith" -> {
|
||||
paramMap.put(paramKey, text + "%");
|
||||
yield column + " LIKE #{map." + paramKey + "}";
|
||||
}
|
||||
case "endswith" -> {
|
||||
paramMap.put(paramKey, "%" + text);
|
||||
yield column + " LIKE #{map." + paramKey + "}";
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
private String mapWtrvAmendColumn(String field) {
|
||||
if (StrUtil.isBlank(field)) {
|
||||
return null;
|
||||
}
|
||||
return switch (field) {
|
||||
case "stcd" -> "t.stcd";
|
||||
case "dt" -> "t.dt";
|
||||
case "wt" -> "t.wt";
|
||||
case "stnm" -> "t.stnm";
|
||||
case "rstcd" -> "t.rstcd";
|
||||
case "ennm" -> "t.ennm";
|
||||
case "baseId" -> "t.baseId";
|
||||
case "baseName" -> "t.baseName";
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private String buildWtrvAmendOrderBySql(List<DataSourceRequest.SortDescriptor> sortList) {
|
||||
List<String> orderColumns = new ArrayList<>();
|
||||
if (sortList != null) {
|
||||
for (DataSourceRequest.SortDescriptor sortDescriptor : sortList) {
|
||||
String column = mapWtrvAmendColumn(sortDescriptor.getField());
|
||||
if (StrUtil.isBlank(column)) {
|
||||
continue;
|
||||
}
|
||||
String dir = "desc".equalsIgnoreCase(sortDescriptor.getDir()) || "des".equalsIgnoreCase(sortDescriptor.getDir()) ? "DESC" : "ASC";
|
||||
orderColumns.add(column + " " + dir + ("t.dt".equals(column) || "t.wt".equals(column) ? " NULLS LAST" : ""));
|
||||
}
|
||||
}
|
||||
if (orderColumns.isEmpty()) {
|
||||
return " ORDER BY t.dt DESC, t.stcd ASC";
|
||||
}
|
||||
return " ORDER BY " + String.join(", ", orderColumns);
|
||||
}
|
||||
|
||||
private boolean isWtrvAmendDateField(DataSourceRequest.FilterDescriptor filter) {
|
||||
if (filter == null || StrUtil.isBlank(filter.getField())) {
|
||||
return false;
|
||||
}
|
||||
if ("dt".equalsIgnoreCase(filter.getField())) {
|
||||
return true;
|
||||
}
|
||||
return "date".equalsIgnoreCase(filter.getDataType());
|
||||
}
|
||||
|
||||
private String buildWtrvAmendValueExpr(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 List<?> normalizeToList(Object value) {
|
||||
if (value == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (value instanceof List<?> list) {
|
||||
return list.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
return Collections.singletonList(value);
|
||||
}
|
||||
|
||||
private String buildSttpInfoFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user