fix: 优化逻辑
This commit is contained in:
parent
9cace820e8
commit
15e81b746e
@ -200,6 +200,12 @@ public class SdWTMonitorController {
|
|||||||
return ResponseResult.successData(sdWtMonitorService.getVmsstbprptList(dataSourceRequest));
|
return ResponseResult.successData(sdWtMonitorService.getVmsstbprptList(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/base/vmsstbprpt/GetKendoList")
|
||||||
|
@Operation(summary = "根据条件查询基础站点列表(关联水温电站关系表)")
|
||||||
|
public ResponseResult getBaseVmsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(sdWtMonitorService.getBaseVmsstbprptList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/msstbprpt/GetKendoList")
|
@PostMapping("/msstbprpt/GetKendoList")
|
||||||
@Operation(summary = "根据条件查询水温基础站点列表")
|
@Operation(summary = "根据条件查询水温基础站点列表")
|
||||||
public ResponseResult getMsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {
|
public ResponseResult getMsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
|||||||
@ -0,0 +1,140 @@
|
|||||||
|
package com.yfd.platform.qgc_env.wt.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电站出入库水温站码基础信息(电站 SD_ENGINFO_B_H 为主表,关联水温站与水温电站关系表)
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "电站出入库水温站码基础信息")
|
||||||
|
public class WtEngRelBaseInfoVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "电站编码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "电站名称")
|
||||||
|
private String ennm;
|
||||||
|
|
||||||
|
@Schema(description = "电站名称")
|
||||||
|
private String stnm;
|
||||||
|
|
||||||
|
@Schema(description = "站类编码")
|
||||||
|
private String sttpCode;
|
||||||
|
|
||||||
|
@Schema(description = "所属基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "所属基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "所属基地河段编码")
|
||||||
|
private String hbrvcd;
|
||||||
|
|
||||||
|
@Schema(description = "所属基地河段名称")
|
||||||
|
private String hbrvcdName;
|
||||||
|
|
||||||
|
@Schema(description = "所属流域代码")
|
||||||
|
private String rvcd;
|
||||||
|
|
||||||
|
@Schema(description = "所属流域名称")
|
||||||
|
private String rvcdName;
|
||||||
|
|
||||||
|
@Schema(description = "所属行政区编码")
|
||||||
|
private String addvcd;
|
||||||
|
|
||||||
|
@Schema(description = "所属行政区名称")
|
||||||
|
private String addvnm;
|
||||||
|
|
||||||
|
@Schema(description = "所属公司编码")
|
||||||
|
private String hycd;
|
||||||
|
|
||||||
|
@Schema(description = "所属公司名称")
|
||||||
|
private String hynm;
|
||||||
|
|
||||||
|
@Schema(description = "所属集团编码")
|
||||||
|
private String topHycd;
|
||||||
|
|
||||||
|
@Schema(description = "所属集团名称")
|
||||||
|
private String topHynm;
|
||||||
|
|
||||||
|
@Schema(description = "位置经度")
|
||||||
|
private BigDecimal lgtd;
|
||||||
|
|
||||||
|
@Schema(description = "位置纬度")
|
||||||
|
private BigDecimal lttd;
|
||||||
|
|
||||||
|
@Schema(description = "高程")
|
||||||
|
private BigDecimal elev;
|
||||||
|
|
||||||
|
@Schema(description = "站址")
|
||||||
|
private String stlc;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用")
|
||||||
|
private Integer usfl;
|
||||||
|
|
||||||
|
@Schema(description = "水能利用数据是否接入")
|
||||||
|
private Integer dtin;
|
||||||
|
|
||||||
|
@Schema(description = "数据接入时间")
|
||||||
|
private Date dtinTm;
|
||||||
|
|
||||||
|
@Schema(description = "建设状态分类")
|
||||||
|
private Integer bldsttCcode;
|
||||||
|
|
||||||
|
@Schema(description = "建设状态分类")
|
||||||
|
private Integer bldsttCode;
|
||||||
|
|
||||||
|
@Schema(description = "建设状态名称")
|
||||||
|
private String bldsttCcodeName;
|
||||||
|
|
||||||
|
@Schema(description = "规划设计日期")
|
||||||
|
private Date stdsdt;
|
||||||
|
|
||||||
|
@Schema(description = "计划开工日期")
|
||||||
|
private Date pststdt;
|
||||||
|
|
||||||
|
@Schema(description = "计划完工日期")
|
||||||
|
private Date pesstdt;
|
||||||
|
|
||||||
|
@Schema(description = "开工日期")
|
||||||
|
private Date swdt;
|
||||||
|
|
||||||
|
@Schema(description = "建成日期")
|
||||||
|
private Date jcdt;
|
||||||
|
|
||||||
|
@Schema(description = "退役/拆除日期")
|
||||||
|
private Date wddt;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer orderIndex;
|
||||||
|
|
||||||
|
@Schema(description = "电站简介")
|
||||||
|
private String introduce;
|
||||||
|
|
||||||
|
@Schema(description = "电站LOGO")
|
||||||
|
private String logo;
|
||||||
|
|
||||||
|
@Schema(description = "介绍弹窗图片")
|
||||||
|
private String inffile;
|
||||||
|
|
||||||
|
@Schema(description = "入库水温站码")
|
||||||
|
private String engIwtCode;
|
||||||
|
|
||||||
|
@Schema(description = "入库水温名称")
|
||||||
|
private String engIwtName;
|
||||||
|
|
||||||
|
@Schema(description = "下泄水温站码")
|
||||||
|
private String engDwtCode;
|
||||||
|
|
||||||
|
@Schema(description = "下泄水温名称")
|
||||||
|
private String engDwtName;
|
||||||
|
}
|
||||||
@ -14,6 +14,7 @@ import com.yfd.platform.qgc_env.wt.entity.vo.WtBaseInfoVo;
|
|||||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendSaveVo;
|
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendSaveVo;
|
||||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvVo;
|
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvVo;
|
||||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendResultVo;
|
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendResultVo;
|
||||||
|
import com.yfd.platform.qgc_env.wt.entity.vo.WtEngRelBaseInfoVo;
|
||||||
import com.yfd.platform.qgc_env.wt.entity.vo.DwSlowFacilityMapVO;
|
import com.yfd.platform.qgc_env.wt.entity.vo.DwSlowFacilityMapVO;
|
||||||
import com.yfd.platform.qgc_env.wt.entity.vo.WaterTempMapVO;
|
import com.yfd.platform.qgc_env.wt.entity.vo.WaterTempMapVO;
|
||||||
|
|
||||||
@ -73,4 +74,9 @@ public interface SdWtMonitorService {
|
|||||||
* 获取监测点水温变化数据(当前时段 + 去年同期对比)
|
* 获取监测点水温变化数据(当前时段 + 去年同期对比)
|
||||||
*/
|
*/
|
||||||
DataSourceResult getWtRV(DataSourceRequest dataSourceRequest);
|
DataSourceResult getWtRV(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询基础站点列表(关联水温电站关系表)
|
||||||
|
*/
|
||||||
|
DataSourceResult<WtEngRelBaseInfoVo> getBaseVmsstbprptList(DataSourceRequest dataSourceRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -922,6 +922,42 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<WtEngRelBaseInfoVo> getBaseVmsstbprptList(DataSourceRequest dataSourceRequest) {
|
||||||
|
// 电站表 SD_ENGINFO_B_H 作为主表,其它表均为 LEFT JOIN:
|
||||||
|
// SD_ENGINFO_B_H eng
|
||||||
|
// LEFT JOIN SD_WT_B_H wt ON wt.RSTCD = eng.STCD
|
||||||
|
// LEFT JOIN SD_WTENGRLTN_B rel ON rel.STCD = wt.STCD
|
||||||
|
// 同一电站(rstcd 相同)的多条水温站记录会展开成多行,故按 eng.STCD 分组,
|
||||||
|
// 把该电站的 engIwtCode/engDwtCode 用 MAX 聚合合并为一行(该电站的出入库水温站码);
|
||||||
|
// 本接口不关联温度实时表、不查询温度数据。filter.stcd 语义为电站编码。
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||||
|
|
||||||
|
String selectSql = buildVmsstbprptRelSelectSql(dataSourceRequest.getSelect());
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT ").append(selectSql).append(" ")
|
||||||
|
.append(buildVmsstbprptRelFromSql());
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
appendVmsstbprptRelFilters(sql, paramMap, dataSourceRequest.getFilter());
|
||||||
|
|
||||||
|
String orderSql = buildVmsstbprptOrderBySql(dataSourceRequest.getSort());
|
||||||
|
if (StrUtil.isBlank(orderSql)) {
|
||||||
|
orderSql = " ORDER BY MAX(eng.ORDER_INDEX) NULLS LAST, MAX(eng.STCD) NULLS LAST ";
|
||||||
|
}
|
||||||
|
sql.append("GROUP BY eng.STCD ").append(orderSql);
|
||||||
|
|
||||||
|
Page<?> page = QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
List<WtEngRelBaseInfoVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, WtEngRelBaseInfoVo.class);
|
||||||
|
|
||||||
|
DataSourceResult<WtEngRelBaseInfoVo> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<WtrvAmendResultVo> getWtrvAmendDayList(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<WtrvAmendResultVo> getWtrvAmendDayList(DataSourceRequest dataSourceRequest) {
|
||||||
List<String> selectFields = dataSourceRequest == null ? null : dataSourceRequest.getSelect();
|
List<String> selectFields = dataSourceRequest == null ? null : dataSourceRequest.getSelect();
|
||||||
@ -2523,6 +2559,152 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildVmsstbprptRelSelectSql(List<String> selectFields) {
|
||||||
|
Map<String, String> columnMap = buildVmsstbprptRelColumnMap();
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
// 外层已按 eng.STCD 分组,每个 select 项统一包成 MAX(...) AS 别名
|
||||||
|
return actualColumns.stream().map(this::aggregateVmsstbprptColumn).collect(Collectors.joining(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String aggregateVmsstbprptColumn(String expressionWithAlias) {
|
||||||
|
int idx = expressionWithAlias.lastIndexOf(" AS ");
|
||||||
|
if (idx <= 0) {
|
||||||
|
return expressionWithAlias;
|
||||||
|
}
|
||||||
|
return "MAX(" + expressionWithAlias.substring(0, idx) + ") AS " + expressionWithAlias.substring(idx + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildVmsstbprptRelFromSql() {
|
||||||
|
return "FROM SD_ENGINFO_B_H eng " +
|
||||||
|
"LEFT JOIN SD_WT_B_H wt ON wt.RSTCD = eng.STCD AND NVL(wt.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN SD_WTENGRLTN_B rel ON rel.STCD = wt.STCD AND NVL(rel.IS_DELETED, 0) = 0 " +
|
||||||
|
"WHERE NVL(eng.IS_DELETED, 0) = 0 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> buildVmsstbprptRelColumnMap() {
|
||||||
|
Map<String, String> columnMap = new LinkedHashMap<>();
|
||||||
|
// SD_ENGINFO_B_H 电站基础字段(电站为主表)
|
||||||
|
columnMap.put("stcd", "eng.STCD AS stcd");
|
||||||
|
columnMap.put("ennm", "eng.ENNM AS ennm");
|
||||||
|
columnMap.put("stnm", "eng.ENNM AS stnm");
|
||||||
|
columnMap.put("sttpCode", "'ENG' AS sttpCode");
|
||||||
|
columnMap.put("baseId", "eng.BASE_ID AS baseId");
|
||||||
|
columnMap.put("baseName", "eng.BASE_NAME AS baseName");
|
||||||
|
columnMap.put("hbrvcd", "eng.HBRVCD AS hbrvcd");
|
||||||
|
columnMap.put("hbrvcdName", "eng.HBRVCD_NAME AS hbrvcdName");
|
||||||
|
columnMap.put("rvcd", "eng.RVCD AS rvcd");
|
||||||
|
columnMap.put("rvcdName", "eng.RVCD_NAME AS rvcdName");
|
||||||
|
columnMap.put("addvcd", "eng.ADDVCD AS addvcd");
|
||||||
|
columnMap.put("addvnm", "eng.ADDVCD_NAME AS addvnm");
|
||||||
|
columnMap.put("hycd", "eng.HYCD AS hycd");
|
||||||
|
columnMap.put("hynm", "eng.HYNM AS hynm");
|
||||||
|
columnMap.put("topHycd", "eng.TOP_HYCD AS topHycd");
|
||||||
|
columnMap.put("topHynm", "eng.TOP_HYNM AS topHynm");
|
||||||
|
columnMap.put("lgtd", "eng.LGTD AS lgtd");
|
||||||
|
columnMap.put("lttd", "eng.LTTD AS lttd");
|
||||||
|
columnMap.put("elev", "eng.ELEV AS elev");
|
||||||
|
columnMap.put("stlc", "eng.STLC AS stlc");
|
||||||
|
columnMap.put("usfl", "eng.USFL AS usfl");
|
||||||
|
columnMap.put("dtin", "eng.DTIN AS dtin");
|
||||||
|
columnMap.put("dtinTm", "eng.DTIN_TM AS dtinTm");
|
||||||
|
columnMap.put("bldsttCcode", "eng.BLDSTT_CODE AS bldsttCcode");
|
||||||
|
columnMap.put("bldsttCode", "eng.BLDSTT_CODE AS bldsttCode");
|
||||||
|
columnMap.put("bldsttCcodeName",
|
||||||
|
"CASE WHEN eng.BLDSTT_CODE = 0 THEN '未建/规划' " +
|
||||||
|
"WHEN eng.BLDSTT_CODE = 1 THEN '在建' " +
|
||||||
|
"WHEN eng.BLDSTT_CODE = 2 THEN '已建' " +
|
||||||
|
"ELSE '未知' END AS bldsttCcodeName");
|
||||||
|
columnMap.put("stdsdt", "eng.STDSDT AS stdsdt");
|
||||||
|
columnMap.put("pststdt", "eng.PSTSTDT AS pststdt");
|
||||||
|
columnMap.put("pesstdt", "eng.PESSTDT AS pesstdt");
|
||||||
|
columnMap.put("swdt", "eng.SWDT AS swdt");
|
||||||
|
columnMap.put("jcdt", "eng.JCDT AS jcdt");
|
||||||
|
columnMap.put("wddt", "eng.WDDT AS wddt");
|
||||||
|
columnMap.put("orderIndex", "eng.ORDER_INDEX AS orderIndex");
|
||||||
|
columnMap.put("introduce", "eng.INTRODUCE AS introduce");
|
||||||
|
columnMap.put("logo", "eng.LOGO AS logo");
|
||||||
|
columnMap.put("inffile", "eng.INFFILE AS inffile");
|
||||||
|
// SD_WTENGRLTN_B 出入库水温站码/名称:同 rstcd 多行按电站合并
|
||||||
|
columnMap.put("engIwtCode", "rel.ENG_IWT_CODE AS engIwtCode");
|
||||||
|
columnMap.put("engIwtName", "rel.ENG_IWT_NAME AS engIwtName");
|
||||||
|
columnMap.put("engDwtCode", "rel.ENG_DWT_CODE AS engDwtCode");
|
||||||
|
columnMap.put("engDwtName", "rel.ENG_DWT_NAME AS engDwtName");
|
||||||
|
return columnMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendVmsstbprptRelFilters(StringBuilder sql,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
DataSourceRequest.FilterDescriptor filter) {
|
||||||
|
Map<String, String> filterColumnMap = buildVmsstbprptRelFilterColumnMap();
|
||||||
|
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 column = filterColumnMap.get(field);
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String paramKey = "vmsstbprptRel_" + field + "_" + paramMap.size();
|
||||||
|
appendWtMsstbprptLeaf(sql, paramMap, paramKey, column, operator, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> buildVmsstbprptRelFilterColumnMap() {
|
||||||
|
Map<String, String> columnMap = new LinkedHashMap<>();
|
||||||
|
// 电站(SD_ENGINFO_B_H)为主表,主表自身字段的过滤条件直接作用到 eng 上
|
||||||
|
columnMap.put("stcd", "eng.STCD");
|
||||||
|
columnMap.put("rstcd", "eng.STCD");
|
||||||
|
columnMap.put("stnm", "eng.ENNM");
|
||||||
|
columnMap.put("ennm", "eng.ENNM");
|
||||||
|
columnMap.put("baseId", "eng.BASE_ID");
|
||||||
|
columnMap.put("baseName", "eng.BASE_NAME");
|
||||||
|
columnMap.put("hbrvcd", "eng.HBRVCD");
|
||||||
|
columnMap.put("usfl", "eng.USFL");
|
||||||
|
columnMap.put("dtin", "eng.DTIN");
|
||||||
|
columnMap.put("bldsttCode", "eng.BLDSTT_CODE");
|
||||||
|
columnMap.put("bldsttCcode", "eng.BLDSTT_CODE");
|
||||||
|
// 关联的水温站/关系表字段仍可按需过滤子表行
|
||||||
|
columnMap.put("sttp", "wt.STTP");
|
||||||
|
columnMap.put("sttpCode", "wt.STTP");
|
||||||
|
columnMap.put("fhstcd", "wt.FHSTCD");
|
||||||
|
columnMap.put("dmstcd", "wt.DMSTCD");
|
||||||
|
columnMap.put("dtinType", "wt.DTIN_TYPE");
|
||||||
|
columnMap.put("mway", "wt.MWAY");
|
||||||
|
columnMap.put("wtDeviceType", "wt.WT_DEVICE_TYPE");
|
||||||
|
columnMap.put("engIwtCode", "rel.ENG_IWT_CODE");
|
||||||
|
columnMap.put("engIwtName", "rel.ENG_IWT_NAME");
|
||||||
|
columnMap.put("engMwtCode", "rel.ENG_MWT_CODE");
|
||||||
|
columnMap.put("engMwtName", "rel.ENG_MWT_NAME");
|
||||||
|
columnMap.put("engRwtCode", "rel.ENG_RWT_CODE");
|
||||||
|
columnMap.put("engRwtName", "rel.ENG_RWT_NAME");
|
||||||
|
columnMap.put("engDwtCode", "rel.ENG_DWT_CODE");
|
||||||
|
columnMap.put("engDwtName", "rel.ENG_DWT_NAME");
|
||||||
|
columnMap.put("engLctn1Code", "rel.ENG_LCTN1_CODE");
|
||||||
|
columnMap.put("engLctn1Name", "rel.ENG_LCTN1_NAME");
|
||||||
|
columnMap.put("engLctn2Code", "rel.ENG_LCTN2_CODE");
|
||||||
|
columnMap.put("engLctn2Name", "rel.ENG_LCTN2_NAME");
|
||||||
|
columnMap.put("engLctn3Code", "rel.ENG_LCTN3_CODE");
|
||||||
|
columnMap.put("engLctn3Name", "rel.ENG_LCTN3_NAME");
|
||||||
|
return columnMap;
|
||||||
|
}
|
||||||
|
|
||||||
private void appendWtMsstbprptLeaf(StringBuilder sql,
|
private void appendWtMsstbprptLeaf(StringBuilder sql,
|
||||||
Map<String, Object> paramMap,
|
Map<String, Object> paramMap,
|
||||||
String paramKey,
|
String paramKey,
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.yfd.platform.common.utils.UserNameFillHelper;
|
|||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.SdChgWarningR;
|
import com.yfd.platform.qgc_lygk.along.domain.SdChgWarningR;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.vo.DeviceCompositionVo;
|
import com.yfd.platform.qgc_lygk.along.domain.vo.DeviceCompositionVo;
|
||||||
|
import com.yfd.platform.qgc_lygk.along.domain.vo.EnvProfinfVo;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.vo.MeasureImplementVo;
|
import com.yfd.platform.qgc_lygk.along.domain.vo.MeasureImplementVo;
|
||||||
import com.yfd.platform.qgc_lygk.along.service.ISdChgWarningRService;
|
import com.yfd.platform.qgc_lygk.along.service.ISdChgWarningRService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -53,4 +54,11 @@ public class SdChgWarningRController {
|
|||||||
DataSourceResult<DeviceCompositionVo> result = sdChgWarningRService.getDeviceCompositionInfo(dataSourceRequest);
|
DataSourceResult<DeviceCompositionVo> result = sdChgWarningRService.getDeviceCompositionInfo(dataSourceRequest);
|
||||||
return ResponseResult.successData(result);
|
return ResponseResult.successData(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/hbssyx/GetKendoListCust")
|
||||||
|
@Operation(summary = "环保设施运行预警")
|
||||||
|
public ResponseResult getHbssyxKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult<EnvProfinfVo> result = sdChgWarningRService.getEnvProfinfInfo(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package com.yfd.platform.qgc_lygk.along.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环保设施运行预警实体
|
||||||
|
*
|
||||||
|
* @author migration
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "环保设施运行预警实体")
|
||||||
|
public class EnvProfinfVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 设施编号 */
|
||||||
|
@Schema(description = "设施编号")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
/** 电站编号 */
|
||||||
|
@Schema(description = "电站编号")
|
||||||
|
private String rstcd;
|
||||||
|
|
||||||
|
/** 电站名称 */
|
||||||
|
@Schema(description = "电站名称")
|
||||||
|
private String ennm;
|
||||||
|
|
||||||
|
/** 设施名称 */
|
||||||
|
@Schema(description = "设施名称")
|
||||||
|
private String stnm;
|
||||||
|
|
||||||
|
/** 设施类型 */
|
||||||
|
@Schema(description = "设施类型")
|
||||||
|
private String sttp;
|
||||||
|
|
||||||
|
/** 电站所属行政区编码 */
|
||||||
|
@Schema(description = "电站所属行政区编码")
|
||||||
|
private String addvcd;
|
||||||
|
|
||||||
|
/** 电站所属行政区名称 */
|
||||||
|
@Schema(description = "电站所属行政区名称")
|
||||||
|
private String addvnm;
|
||||||
|
|
||||||
|
/** 预警状态 */
|
||||||
|
@Schema(description = "预警状态")
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ import com.yfd.platform.common.DataSourceRequest;
|
|||||||
import com.yfd.platform.common.DataSourceResult;
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.SdChgWarningR;
|
import com.yfd.platform.qgc_lygk.along.domain.SdChgWarningR;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.vo.DeviceCompositionVo;
|
import com.yfd.platform.qgc_lygk.along.domain.vo.DeviceCompositionVo;
|
||||||
|
import com.yfd.platform.qgc_lygk.along.domain.vo.EnvProfinfVo;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.vo.MeasureImplementVo;
|
import com.yfd.platform.qgc_lygk.along.domain.vo.MeasureImplementVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,4 +29,9 @@ public interface ISdChgWarningRService extends IService<SdChgWarningR> {
|
|||||||
* 环保设施建设预警
|
* 环保设施建设预警
|
||||||
*/
|
*/
|
||||||
DataSourceResult<DeviceCompositionVo> getDeviceCompositionInfo(DataSourceRequest dataSourceRequest);
|
DataSourceResult<DeviceCompositionVo> getDeviceCompositionInfo(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环保设施运行预警
|
||||||
|
*/
|
||||||
|
DataSourceResult<EnvProfinfVo> getEnvProfinfInfo(DataSourceRequest dataSourceRequest);
|
||||||
}
|
}
|
||||||
@ -11,14 +11,18 @@ import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
|||||||
import com.yfd.platform.common.exception.BizException;
|
import com.yfd.platform.common.exception.BizException;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.SdChgWarningR;
|
import com.yfd.platform.qgc_lygk.along.domain.SdChgWarningR;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.vo.DeviceCompositionVo;
|
import com.yfd.platform.qgc_lygk.along.domain.vo.DeviceCompositionVo;
|
||||||
|
import com.yfd.platform.qgc_lygk.along.domain.vo.EnvProfinfVo;
|
||||||
import com.yfd.platform.qgc_lygk.along.domain.vo.MeasureImplementVo;
|
import com.yfd.platform.qgc_lygk.along.domain.vo.MeasureImplementVo;
|
||||||
import com.yfd.platform.qgc_lygk.along.mapper.SdChgWarningRMapper;
|
import com.yfd.platform.qgc_lygk.along.mapper.SdChgWarningRMapper;
|
||||||
import com.yfd.platform.qgc_lygk.along.service.ISdChgWarningRService;
|
import com.yfd.platform.qgc_lygk.along.service.ISdChgWarningRService;
|
||||||
|
import com.yfd.platform.utils.CodeToNameMetadataBo;
|
||||||
import com.yfd.platform.utils.DataSourceRequestUtil;
|
import com.yfd.platform.utils.DataSourceRequestUtil;
|
||||||
|
import com.yfd.platform.utils.DictCodeToNameConverter;
|
||||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -34,6 +38,16 @@ public class SdChgWarningRServiceImpl extends ServiceImpl<SdChgWarningRMapper, S
|
|||||||
@Resource
|
@Resource
|
||||||
private MicroservicDynamicSQLMapper microservicDynamicSQLMapper;
|
private MicroservicDynamicSQLMapper microservicDynamicSQLMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DictCodeToNameConverter dictCodeToNameConverter;
|
||||||
|
|
||||||
|
private static final List<CodeToNameMetadataBo> CODE_TO_NAME_META_LIST = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
CODE_TO_NAME_META_LIST.add(CodeToNameMetadataBo.builder().codeProperty("prenvftp").modifyProperty("ennm").dictType("STATIC").dictSource("PRENVFTP").build());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<SdChgWarningR> getKendoList(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<SdChgWarningR> getKendoList(DataSourceRequest dataSourceRequest) {
|
||||||
// 1. 构建查询条件
|
// 1. 构建查询条件
|
||||||
@ -149,7 +163,7 @@ public class SdChgWarningRServiceImpl extends ServiceImpl<SdChgWarningRMapper, S
|
|||||||
// 4. 执行查询
|
// 4. 执行查询
|
||||||
List<DeviceCompositionVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
List<DeviceCompositionVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
page, sql.toString(), paramMap, DeviceCompositionVo.class);
|
page, sql.toString(), paramMap, DeviceCompositionVo.class);
|
||||||
|
dictCodeToNameConverter.convertCodeToName(list, CODE_TO_NAME_META_LIST);
|
||||||
// 5. 构建结果
|
// 5. 构建结果
|
||||||
DataSourceResult<DeviceCompositionVo> dataSourceResult = new DataSourceResult<>();
|
DataSourceResult<DeviceCompositionVo> dataSourceResult = new DataSourceResult<>();
|
||||||
dataSourceResult.setData(list);
|
dataSourceResult.setData(list);
|
||||||
@ -157,4 +171,48 @@ public class SdChgWarningRServiceImpl extends ServiceImpl<SdChgWarningRMapper, S
|
|||||||
dataSourceResult.setAggregates(new HashMap<>());
|
dataSourceResult.setAggregates(new HashMap<>());
|
||||||
return dataSourceResult;
|
return dataSourceResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<EnvProfinfVo> getEnvProfinfInfo(DataSourceRequest dataSourceRequest) {
|
||||||
|
// 1. 解析过滤条件中的 stcd
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
String stcd = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "stcd");
|
||||||
|
if (StrUtil.isBlank(stcd)) {
|
||||||
|
throw new BizException("设施编码(stcd)不能为空.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 构建 SQL(按新库表结构:基础站点视图 + 对象节点关系表 + WBS 节点视图 + 对象状态统计表取运行状态)
|
||||||
|
StringBuilder sql = new StringBuilder("select distinct t4.STCD rstcd, t1.STCD, t4.ENNM, t4.ADDVCD, t4.ADDVNM addvnm, t1.STNM, t1.STTP_CODE sttp,\n" +
|
||||||
|
" case when st.RUN_STATE is null then 0 else st.RUN_STATE end status\n" +
|
||||||
|
" from V_MS_STBPRP_T t1\n" +
|
||||||
|
" inner join SD_STRLTN_B t2 on t1.STCD = t2.STCD and NVL(t2.IS_DELETED, 0) = 0\n" +
|
||||||
|
" inner join V_WBS_B t3 on t3.ID = t2.WBS_ID\n" +
|
||||||
|
" inner join V_MS_STBPRP_T t4 on t4.STCD = t3.WBS_CODE\n" +
|
||||||
|
" left join (select sts.STCD, sts.RUN_STATE\n" +
|
||||||
|
" from (select STCD, RUN_STATE,\n" +
|
||||||
|
" row_number() over (partition by STCD order by NVL(TM, TO_DATE('1970-01-01','YYYY-MM-DD')) desc) rn\n" +
|
||||||
|
" from MS_STSTATE_T\n" +
|
||||||
|
" where NVL(IS_DELETED, 0) = 0) sts\n" +
|
||||||
|
" where sts.rn = 1) st on st.STCD = t1.STCD\n" +
|
||||||
|
" where t1.STTP_FULL_PATH like 'ENV,ENVP,%'\n" +
|
||||||
|
" and t1.STTP_CODE != 'FH'\n" +
|
||||||
|
" and t4.STCD = #{map.stcd} ");
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
paramMap.put("stcd", stcd);
|
||||||
|
|
||||||
|
// 3. 分页处理
|
||||||
|
Page<?> page = loadOptions == null ? null
|
||||||
|
: QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
|
||||||
|
// 4. 执行查询
|
||||||
|
List<EnvProfinfVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
|
page, sql.toString(), paramMap, EnvProfinfVo.class);
|
||||||
|
|
||||||
|
// 5. 构建结果
|
||||||
|
DataSourceResult<EnvProfinfVo> dataSourceResult = new DataSourceResult<>();
|
||||||
|
dataSourceResult.setData(list);
|
||||||
|
dataSourceResult.setTotal(page != null ? page.getTotal() : (long) list.size());
|
||||||
|
dataSourceResult.setAggregates(new HashMap<>());
|
||||||
|
return dataSourceResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user