feat: 根据条件查询水温基础站点列表
This commit is contained in:
parent
0715616e5f
commit
704a9c3ff2
@ -191,6 +191,12 @@ public class SdWTMonitorController {
|
|||||||
return ResponseResult.successData(sdWtMonitorService.getVmsstbprptList(dataSourceRequest));
|
return ResponseResult.successData(sdWtMonitorService.getVmsstbprptList(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/msstbprpt/GetKendoList")
|
||||||
|
@Operation(summary = "根据条件查询水温基础站点列表")
|
||||||
|
public ResponseResult getMsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(sdWtMonitorService.getMsstbprptList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/msstbprpt/getStcdInfo")
|
@GetMapping("/msstbprpt/getStcdInfo")
|
||||||
@Operation(summary = "根据站码查询单条水温基础数据")
|
@Operation(summary = "根据站码查询单条水温基础数据")
|
||||||
public ResponseResult getStcdInfo(@RequestParam String stcd) {
|
public ResponseResult getStcdInfo(@RequestParam String stcd) {
|
||||||
|
|||||||
@ -68,6 +68,9 @@ public class SdWtBaseInfoVO implements Serializable {
|
|||||||
@Schema(description = "站码")
|
@Schema(description = "站码")
|
||||||
private String stcd;
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "所属栖息地编码")
|
||||||
|
private String fhstcd;
|
||||||
|
|
||||||
@Schema(description = "所属电站编码")
|
@Schema(description = "所属电站编码")
|
||||||
private String rstcd;
|
private String rstcd;
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@ public interface SdWtMonitorService {
|
|||||||
|
|
||||||
DataSourceResult getVmsstbprptList(DataSourceRequest dataSourceRequest);
|
DataSourceResult getVmsstbprptList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult getMsstbprptList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
WtBaseInfoVo getStcdInfo(String stcd);
|
WtBaseInfoVo getStcdInfo(String stcd);
|
||||||
|
|
||||||
DataSourceResult getCxDetailList(DataSourceRequest dataSourceRequest);
|
DataSourceResult getCxDetailList(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -842,6 +842,37 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult getMsstbprptList(DataSourceRequest dataSourceRequest) {
|
||||||
|
List<String> selectFields = dataSourceRequest == null ? null : dataSourceRequest.getSelect();
|
||||||
|
String selectSql = buildWtMsstbprptSelectSql(selectFields);
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT ").append(selectSql).append(" ")
|
||||||
|
.append("FROM SD_WT_B_H wt ")
|
||||||
|
.append("LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = wt.RSTCD AND NVL(eng.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = eng.BASE_ID AND NVL(hb.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("LEFT JOIN SD_HBRV_DIC hbrv ON hbrv.HBRVCD = eng.HBRVCD AND hbrv.BASEID = eng.BASE_ID AND NVL(hbrv.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("LEFT JOIN SD_STTP_B sttp ON sttp.STTP_CODE = wt.STTP AND NVL(sttp.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("LEFT JOIN (SELECT DISTINCT STCD FROM SD_WTRV_R WHERE IS_DELETED = 0 AND TM >= SYSDATE - 1) rvRecent ON rvRecent.STCD = wt.STCD ")
|
||||||
|
.append("LEFT JOIN (SELECT DISTINCT STCD FROM SD_WTVT_R WHERE IS_DELETED = 0 AND TM >= SYSDATE - 1) vtRecent ON vtRecent.STCD = wt.STCD ")
|
||||||
|
.append("WHERE NVL(wt.IS_DELETED, 0) = 0 AND NVL(wt.DTIN_TYPE, 0) = 0 ");
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
appendWtMsstbprptFilters(sql, paramMap, dataSourceRequest == null ? null : dataSourceRequest.getFilter());
|
||||||
|
sql.append(buildVmsstbprptOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||||
|
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||||
|
Page<?> page = QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
List<SdWtBaseInfoVO> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, SdWtBaseInfoVO.class);
|
||||||
|
|
||||||
|
DataSourceResult<SdWtBaseInfoVO> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult getCxDetailList(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult getCxDetailList(DataSourceRequest dataSourceRequest) {
|
||||||
List<DataSourceRequest.FilterDescriptor> filters = new ArrayList<>();
|
List<DataSourceRequest.FilterDescriptor> filters = new ArrayList<>();
|
||||||
@ -1889,7 +1920,7 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
|||||||
} else if ("hbrvcd".equals(field)) {
|
} else if ("hbrvcd".equals(field)) {
|
||||||
orderColumns.add("NVL(hbrvcd, '~') " + dir);
|
orderColumns.add("NVL(hbrvcd, '~') " + dir);
|
||||||
} else if ("rstcdStepSort".equals(field)) {
|
} else if ("rstcdStepSort".equals(field)) {
|
||||||
orderColumns.add("NVL(rstcdStepSort, 999999) " + dir);
|
// orderColumns.add("NVL(rstcdStepSort, 999999) " + dir);
|
||||||
} else if ("siteStepSort".equals(field)) {
|
} else if ("siteStepSort".equals(field)) {
|
||||||
orderColumns.add("NVL(siteStepSort, 999999) " + dir);
|
orderColumns.add("NVL(siteStepSort, 999999) " + dir);
|
||||||
} else if ("stnm".equals(field)) {
|
} else if ("stnm".equals(field)) {
|
||||||
@ -1902,11 +1933,138 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (orderColumns.isEmpty()) {
|
if (orderColumns.isEmpty()) {
|
||||||
return " ORDER BY NVL(baseStepSort, 999999) ASC, NVL(rstcdStepSort, 999999) ASC";
|
return "";
|
||||||
|
// return " ORDER BY NVL(baseStepSort, 999999) ASC, NVL(rstcdStepSort, 999999) ASC";
|
||||||
}
|
}
|
||||||
return " ORDER BY " + String.join(", ", orderColumns);
|
return " ORDER BY " + String.join(", ", orderColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildWtMsstbprptSelectSql(List<String> selectFields) {
|
||||||
|
Map<String, String> columnMap = new LinkedHashMap<>();
|
||||||
|
columnMap.put("baseName", "hb.BASENAME AS baseName");
|
||||||
|
columnMap.put("baseId", "hb.BASEID AS baseId");
|
||||||
|
columnMap.put("baseStepSort", "hb.ORDER_INDEX AS baseStepSort");
|
||||||
|
columnMap.put("rvcdStepSort", "NVL(hbrv.ORDER_INDEX, 999999) AS rvcdStepSort");
|
||||||
|
columnMap.put("rstcdStepSort", "eng.ORDER_INDEX AS rstcdStepSort");
|
||||||
|
columnMap.put("siteStepSort", "wt.ORDER_INDEX AS siteStepSort");
|
||||||
|
columnMap.put("stnm", "wt.STNM AS stnm");
|
||||||
|
columnMap.put("ennm", "eng.ENNM AS ennm");
|
||||||
|
columnMap.put("jcdt", "wt.JCDT AS jcdt");
|
||||||
|
columnMap.put("stindx", "wt.STINDX AS stindx");
|
||||||
|
columnMap.put("coenvwState", "CASE WHEN wt.STTP = 'WTRV' AND rvRecent.STCD IS NOT NULL THEN 1 WHEN wt.STTP = 'WTVT' AND vtRecent.STCD IS NOT NULL THEN 1 ELSE 0 END AS coenvwState");
|
||||||
|
columnMap.put("sttpCode", "wt.STTP AS sttpCode");
|
||||||
|
columnMap.put("sttpName", "sttp.STTP_NAME AS sttpName");
|
||||||
|
columnMap.put("sttpFullPath", "sttp.FULL_PATH AS sttpFullPath");
|
||||||
|
columnMap.put("stcd", "wt.STCD AS stcd");
|
||||||
|
columnMap.put("fhstcd", "wt.FHSTCD AS fhstcd");
|
||||||
|
columnMap.put("rstcd", "wt.RSTCD AS rstcd");
|
||||||
|
columnMap.put("bldsttCcodeName", "CASE WHEN wt.BLDSTT_CODE IN ('1', '10', '11') THEN '已建' WHEN wt.BLDSTT_CODE IN ('2', '7', '8') THEN '在建' ELSE '未建/规划' END AS bldsttCcodeName");
|
||||||
|
columnMap.put("bldsttCcode", "wt.BLDSTT_CODE AS bldsttCcode");
|
||||||
|
columnMap.put("stCode", "NULL AS stCode");
|
||||||
|
columnMap.put("stName", "NULL AS stName");
|
||||||
|
columnMap.put("dvtp", "eng.DVTP AS dvtp");
|
||||||
|
columnMap.put("hbrvcd", "eng.HBRVCD AS hbrvcd");
|
||||||
|
|
||||||
|
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 void appendWtMsstbprptFilters(StringBuilder sql,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
DataSourceRequest.FilterDescriptor filter) {
|
||||||
|
List<DataSourceRequest.FilterDescriptor> filters = new ArrayList<>();
|
||||||
|
collectFilters(filter, filters);
|
||||||
|
for (DataSourceRequest.FilterDescriptor descriptor : filters) {
|
||||||
|
String field = descriptor.getField();
|
||||||
|
String operator = descriptor.getOperator();
|
||||||
|
Object value = descriptor.getValue();
|
||||||
|
if (StrUtil.isBlank(field) || StrUtil.isBlank(operator)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String paramKey = "wtMsst_" + field + "_" + paramMap.size();
|
||||||
|
if ("fhstcd".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.FHSTCD", operator, value);
|
||||||
|
} else if ("sttpCode".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.STTP", operator, value);
|
||||||
|
} else if ("stcd".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.STCD", operator, value);
|
||||||
|
} else if ("stnm".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.STNM", operator, value);
|
||||||
|
} else if ("rstcd".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.RSTCD", operator, value);
|
||||||
|
} else if ("baseId".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "eng.BASE_ID", operator, value);
|
||||||
|
} else if ("mway".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.MWAY", operator, value);
|
||||||
|
} else if ("dtin".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.DTIN", operator, value);
|
||||||
|
} else if ("bldsttCcode".equals(field)) {
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, "wt.BLDSTT_CODE", operator, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendWtMsstbprptLeaf(StringBuilder sql,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
String paramKey,
|
||||||
|
String column,
|
||||||
|
String operator,
|
||||||
|
Object value) {
|
||||||
|
switch (operator) {
|
||||||
|
case "eq":
|
||||||
|
sql.append("AND ").append(column).append(" = #{map.").append(paramKey).append("} ");
|
||||||
|
paramMap.put(paramKey, value);
|
||||||
|
break;
|
||||||
|
case "neq":
|
||||||
|
sql.append("AND ").append(column).append(" <> #{map.").append(paramKey).append("} ");
|
||||||
|
paramMap.put(paramKey, value);
|
||||||
|
break;
|
||||||
|
case "contains":
|
||||||
|
sql.append("AND ").append(column).append(" LIKE #{map.").append(paramKey).append("} ");
|
||||||
|
paramMap.put(paramKey, "%" + value + "%");
|
||||||
|
break;
|
||||||
|
case "startswith":
|
||||||
|
sql.append("AND ").append(column).append(" LIKE #{map.").append(paramKey).append("} ");
|
||||||
|
paramMap.put(paramKey, value + "%");
|
||||||
|
break;
|
||||||
|
case "endswith":
|
||||||
|
sql.append("AND ").append(column).append(" LIKE #{map.").append(paramKey).append("} ");
|
||||||
|
paramMap.put(paramKey, "%" + value);
|
||||||
|
break;
|
||||||
|
case "in":
|
||||||
|
if (value instanceof List && !((List<?>) value).isEmpty()) {
|
||||||
|
List<?> values = (List<?>) value;
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (int i = 0; i < values.size(); i++) {
|
||||||
|
String itemKey = paramKey + "_" + i;
|
||||||
|
placeholders.add("#{map." + itemKey + "}");
|
||||||
|
paramMap.put(itemKey, values.get(i));
|
||||||
|
}
|
||||||
|
sql.append("AND ").append(column).append(" IN (").append(String.join(", ", placeholders)).append(") ");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "isnull":
|
||||||
|
sql.append("AND ").append(column).append(" IS NULL ");
|
||||||
|
break;
|
||||||
|
case "isnotnull":
|
||||||
|
sql.append("AND ").append(column).append(" IS NOT NULL ");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void collectFilters(DataSourceRequest.FilterDescriptor filter, List<DataSourceRequest.FilterDescriptor> result) {
|
private void collectFilters(DataSourceRequest.FilterDescriptor filter, List<DataSourceRequest.FilterDescriptor> result) {
|
||||||
if (filter == null) {
|
if (filter == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user