From 8240bf65c04de31035e873f4a590661b0ed45d41 Mon Sep 17 00:00:00 2001 From: tangwei Date: Fri, 12 Jun 2026 16:33:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9F=A5=E8=AF=A2=E6=B0=B4=E8=B4=A8?= =?UTF-8?q?=E5=91=A8=E6=97=AC=E6=9C=88=E5=AD=A3=E5=B9=B4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wq/controller/EnvWqDataController.java | 6 + .../qgc_env/wq/entity/vo/EnvWqDrtpDataVo.java | 78 ++++ .../qgc_env/wq/service/EnvWqDataService.java | 2 + .../wq/service/impl/EnvWqDataServiceImpl.java | 337 ++++++++++++++++++ 4 files changed, 423 insertions(+) create mode 100644 backend/src/main/java/com/yfd/platform/qgc_env/wq/entity/vo/EnvWqDrtpDataVo.java diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wq/controller/EnvWqDataController.java b/backend/src/main/java/com/yfd/platform/qgc_env/wq/controller/EnvWqDataController.java index ba23d28a..682a1104 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wq/controller/EnvWqDataController.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wq/controller/EnvWqDataController.java @@ -48,6 +48,12 @@ public class EnvWqDataController { return ResponseResult.successData(envWqDataService.getDayKendoListCust(dataSourceRequest)); } + @PostMapping("/data/drtp/GetKendoListCust") + @Operation(summary = "查询水质周旬月季年数据") + public ResponseResult getDrtpKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) { + return ResponseResult.successData(envWqDataService.getDrtpKendoListCust(dataSourceRequest)); + } + @PostMapping("/GetStbprpYsByStcd") @Operation(summary = "水质监测数据查询") public ResponseResult GetStbprpYsByStcd(@RequestBody DataSourceRequest dataSourceRequest) { diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wq/entity/vo/EnvWqDrtpDataVo.java b/backend/src/main/java/com/yfd/platform/qgc_env/wq/entity/vo/EnvWqDrtpDataVo.java new file mode 100644 index 00000000..5da93652 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wq/entity/vo/EnvWqDrtpDataVo.java @@ -0,0 +1,78 @@ +package com.yfd.platform.qgc_env.wq.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@Schema(description = "水质周旬月季年数据") +public class EnvWqDrtpDataVo { + private String stcd; + private String stnm; + private String rstcd; + private String ennm; + private String stCode; + private String stName; + private Integer month; + private Integer year; + private String drtp; + private Integer dr; + private BigDecimal wtmp; + private BigDecimal ph; + private BigDecimal dox; + private BigDecimal codmn; + private BigDecimal codcr; + private BigDecimal bod5; + private BigDecimal nh3n; + private BigDecimal tp; + private BigDecimal tn; + private BigDecimal cu; + private BigDecimal zn; + private BigDecimal f; + private BigDecimal se; + private BigDecimal ars; + private BigDecimal hg; + private BigDecimal cd; + private BigDecimal cr6; + private BigDecimal pb; + private BigDecimal cn; + private BigDecimal vlph; + private BigDecimal oil; + private BigDecimal las; + private BigDecimal s2; + private BigDecimal fcg; + private BigDecimal cl; + private BigDecimal so4; + private BigDecimal no3; + private BigDecimal thrd; + private BigDecimal cond; + private BigDecimal fe; + private BigDecimal mn; + private BigDecimal al; + private BigDecimal ss; + private BigDecimal no2; + private BigDecimal chla; + private BigDecimal clarity; + private BigDecimal tu; + private BigDecimal tod; + private BigDecimal cyano; + private String wqgrd; + private String wqgrdName; + private String wwqtg; + private String wwqtgName; + private Integer sfdb; + private String sfdbName; + private String wqSfdbhnYs; + private String baseId; + private String baseName; + private String rvcdName; + private String addvcdName; + private String dtinType; + private Date tm; + private Integer baseStepSort; + private Integer rvcdStepSort; + private Integer rstcdStepSort; + private Integer siteStepSort; +} diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/EnvWqDataService.java b/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/EnvWqDataService.java index 6b473403..fba7baa5 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/EnvWqDataService.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/EnvWqDataService.java @@ -14,6 +14,8 @@ public interface EnvWqDataService { DataSourceResult getDayKendoListCust(DataSourceRequest dataSourceRequest); + DataSourceResult getDrtpKendoListCust(DataSourceRequest dataSourceRequest); + DataSourceResult getStbprpYsByStcd(DataSourceRequest dataSourceRequest); DataSourceResult getAlongWqKendoListCust(DataSourceRequest dataSourceRequest); diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/impl/EnvWqDataServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/impl/EnvWqDataServiceImpl.java index a2487669..942d42a6 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/impl/EnvWqDataServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wq/service/impl/EnvWqDataServiceImpl.java @@ -191,6 +191,53 @@ public class EnvWqDataServiceImpl implements EnvWqDataService { return result; } + @Override + public DataSourceResult getDrtpKendoListCust(DataSourceRequest dataSourceRequest) { + StringBuilder sql = new StringBuilder(buildEnvWqDrtpBaseSql()); + Map paramMap = new HashMap<>(); + String filterSql = buildEnvWqDrtpFilterCondition( + dataSourceRequest == null ? null : dataSourceRequest.getFilter(), + paramMap, + new int[]{0} + ); + if (StrUtil.isNotBlank(filterSql)) { + sql.append(" AND ").append(filterSql).append(" "); + } + + DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest(); + String groupBy = KendoUtil.getGroupBy(dataSourceRequest); + GroupingInfo[] groupInfos = loadOptions.getGroup(); + if (StrUtil.isNotBlank(groupBy) && groupInfos != null && groupInfos.length > 0) { + String groupedSql = buildEnvWqDayGroupSql(sql.toString(), groupBy, groupInfos); + List> list = microservicDynamicSQLMapper.pageAllList(null, groupedSql, paramMap); + DataSourceResult result = new DataSourceResult(); + if (Boolean.TRUE.equals(dataSourceRequest.getGroupResultFlat())) { + result.setData(new GroupHelper().faltGroup(list, Arrays.asList(groupInfos))); + } else { + result.setData(new GroupHelper().group(list, Arrays.asList(groupInfos))); + } + result.setTotal(0L); + result.setAggregates(new HashMap<>()); + return result; + } + + sql.append(buildEnvWqDrtpOrderBySql(dataSourceRequest.getSort())); + Page page = QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake()); + List list = microservicDynamicSQLMapper.pageAllListWithResultType( + page, + sql.toString(), + paramMap, + EnvWqDrtpDataVo.class + ); + fillEnvWqDrtpDerivedFields(list); + + DataSourceResult result = new DataSourceResult<>(); + result.setData(list); + result.setTotal(page != null ? page.getTotal() : list.size()); + result.setAggregates(new HashMap<>()); + return result; + } + @Override public DataSourceResult getStbprpYsByStcd(DataSourceRequest dataSourceRequest) { DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest(); @@ -1058,8 +1105,90 @@ public class EnvWqDataServiceImpl implements EnvWqDataService { .toString(); } + private String buildEnvWqDrtpBaseSql() { + return new StringBuilder() + .append("SELECT ") + .append("T.STCD AS stcd, ") + .append("T.STNM AS stnm, ") + .append("T.RSTCD AS rstcd, ") + .append("T.ENNM AS ennm, ") + .append("T.ST_CODE AS stCode, ") + .append("T.ST_NAME AS stName, ") + .append("T.MONTH AS month, ") + .append("T.YEAR AS year, ") + .append("T.DRTP AS drtp, ") + .append("T.DR AS dr, ") + .append("T.WTMP AS wtmp, ") + .append("T.PH AS ph, ") + .append("T.DOX AS dox, ") + .append("T.CODMN AS codmn, ") + .append("T.CODCR AS codcr, ") + .append("T.BOD5 AS bod5, ") + .append("T.NH3N AS nh3n, ") + .append("T.TP AS tp, ") + .append("T.TN AS tn, ") + .append("T.CU AS cu, ") + .append("T.ZN AS zn, ") + .append("T.F AS f, ") + .append("T.SE AS se, ") + .append("T.ARS AS ars, ") + .append("T.HG AS hg, ") + .append("T.CD AS cd, ") + .append("T.CR6 AS cr6, ") + .append("T.PB AS pb, ") + .append("T.CN AS cn, ") + .append("T.VLPH AS vlph, ") + .append("T.OIL AS oil, ") + .append("T.LAS AS las, ") + .append("T.S2 AS s2, ") + .append("T.FCG AS fcg, ") + .append("T.CL AS cl, ") + .append("T.SO4 AS so4, ") + .append("T.NO3 AS no3, ") + .append("T.THRD AS thrd, ") + .append("T.COND AS cond, ") + .append("T.FE AS fe, ") + .append("T.MN AS mn, ") + .append("T.AL AS al, ") + .append("T.SS AS ss, ") + .append("T.NO2 AS no2, ") + .append("T.CHLA AS chla, ") + .append("T.CLARITY AS clarity, ") + .append("T.TU AS tu, ") + .append("CAST(NULL AS NUMBER(15,2)) AS tod, ") + .append("T.CYANO AS cyano, ") + .append("T.WQGRD AS wqgrd, ") + .append("T.WWQTG AS wwqtg, ") + .append("T.SFDB AS sfdb, ") + .append("CAST(NULL AS VARCHAR2(512)) AS wqSfdbhnYs, ") + .append("T.BASE_ID AS baseId, ") + .append("T.BASE_NAME AS baseName, ") + .append("T.RVCD_NAME AS rvcdName, ") + .append("T.ADDVCD_NAME AS addvcdName, ") + .append("T.DTIN_TYPE AS dtinType, ") + .append("T.TM AS tm, ") + .append("T.BASESTEPSORT AS baseStepSort, ") + .append("T.RVCDSTEPSORT AS rvcdStepSort, ") + .append("T.RSTCDSTEPSORT AS rstcdStepSort, ") + .append("T.SITESTEPSORT AS siteStepSort ") + .append("FROM (SELECT ") + .append("drtp.STCD,station.MWAY, station.STNM, station.RSTCD, station.ENNM, station.ST_CODE, station.ST_NAME, ") + .append("drtp.MONTH, drtp.YEAR, drtp.DRTP, drtp.DR, drtp.WTMP, drtp.PH, drtp.DOX, drtp.CODMN, drtp.CODCR, ") + .append("drtp.BOD5, drtp.NH3N, drtp.TP, drtp.TN, drtp.CU, drtp.ZN, drtp.F, drtp.SE, drtp.ARS, drtp.HG, ") + .append("drtp.CD, drtp.CR6, drtp.PB, drtp.CN, drtp.VLPH, drtp.OIL, drtp.LAS, drtp.S2, drtp.FCG, drtp.CL, ") + .append("drtp.SO4, drtp.NO3, drtp.THRD, drtp.COND, drtp.FE, drtp.MN, drtp.AL, drtp.SS, drtp.NO2, ") + .append("drtp.CHLA, drtp.CLARITY, drtp.TU, drtp.CYANO, drtp.WQGRD, station.WWQTG, drtp.SFDB, ") + .append("station.BASE_ID, station.BASE_NAME, station.RVCD_NAME, station.ADDVCD_NAME, station.DTIN_TYPE, ") + .append("drtp.TM, station.BASESTEPSORT, station.RVCDSTEPSORT, station.RSTCDSTEPSORT, station.SITESTEPSORT ") + .append("FROM SD_WQDRTP_S drtp ") + .append("INNER JOIN (").append(buildEnvWqDayStationBaseSql()).append(") station ON station.STCD = drtp.STCD ") + .append("WHERE NVL(drtp.IS_DELETED, 0) = 0) T WHERE 1 = 1 ") + .toString(); + } + private String buildEnvWqDayStationBaseSql() { return "SELECT " + + "wq.MWAY, " + "wq.STCD, " + "wq.STNM, " + "wq.RSTCD, " + @@ -1157,6 +1286,24 @@ public class EnvWqDataServiceImpl implements EnvWqDataService { case "contains": paramMap.put(key, "%" + filter.getValue() + "%"); return column + " LIKE #{map." + key + "}"; + case "in": { + List list = null; + if (filter.getValue() instanceof List l) { + list = l; + } else if (filter.getValue() instanceof Object[] arr) { + list = Arrays.asList(arr); + } + if (list != null && !list.isEmpty()) { + List placeholders = new ArrayList<>(); + for (Object item : list) { + String itemKey = "envWqDrtpParam" + indexHolder[0]++; + paramMap.put(itemKey, item); + placeholders.add("#{map." + itemKey + "}"); + } + return column + " IN (" + String.join(", ", placeholders) + ")"; + } + return ""; + } default: return ""; } @@ -1232,6 +1379,160 @@ public class EnvWqDataServiceImpl implements EnvWqDataService { }; } + private String buildEnvWqDrtpFilterCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + if (filter == null) { + return ""; + } + if (StrUtil.isNotBlank(filter.getField())) { + return buildEnvWqDrtpLeafCondition(filter, paramMap, indexHolder); + } + if (CollUtil.isEmpty(filter.getFilters())) { + return ""; + } + List conditions = new ArrayList<>(); + for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) { + String childSql = buildEnvWqDrtpFilterCondition(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 buildEnvWqDrtpLeafCondition(DataSourceRequest.FilterDescriptor filter, + Map paramMap, + int[] indexHolder) { + String column = mapEnvWqDrtpColumn(filter.getField()); + if (StrUtil.isBlank(column) || filter.getValue() == null) { + return ""; + } + String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase(); + String key = "envWqDrtpParam" + indexHolder[0]++; + boolean dateField = "tm".equals(filter.getField()); + switch (operator) { + case "eq": + paramMap.put(key, filter.getValue()); + return dateField ? column + " = TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS')" : column + " = #{map." + key + "}"; + case "neq": + paramMap.put(key, filter.getValue()); + return dateField ? column + " <> TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS')" : column + " <> #{map." + key + "}"; + case "gt": + paramMap.put(key, filter.getValue()); + return dateField ? column + " > TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS')" : column + " > #{map." + key + "}"; + case "gte": + paramMap.put(key, filter.getValue()); + return dateField ? column + " >= TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS')" : column + " >= #{map." + key + "}"; + case "lt": + paramMap.put(key, filter.getValue()); + return dateField ? column + " < TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS')" : column + " < #{map." + key + "}"; + case "lte": + paramMap.put(key, filter.getValue()); + return dateField ? column + " <= TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS')" : column + " <= #{map." + key + "}"; + case "contains": + paramMap.put(key, "%" + filter.getValue() + "%"); + return column + " LIKE #{map." + key + "}"; + case "in": { + List list = null; + if (filter.getValue() instanceof List l) { + list = l; + } else if (filter.getValue() instanceof Object[] arr) { + list = Arrays.asList(arr); + } + if (list != null && !list.isEmpty()) { + List placeholders = new ArrayList<>(); + for (Object item : list) { + String itemKey = "envWqDrtpParam" + indexHolder[0]++; + paramMap.put(itemKey, item); + placeholders.add("#{map." + itemKey + "}"); + } + return column + " IN (" + String.join(", ", placeholders) + ")"; + } + return ""; + } + default: + return ""; + } + } + + private String mapEnvWqDrtpColumn(String field) { + if (StrUtil.isBlank(field)) { + return null; + } + return switch (field) { + case "stcd" -> "T.STCD"; + case "mway" -> "T.MWAY"; + case "stnm" -> "T.STNM"; + case "rstcd" -> "T.RSTCD"; + case "ennm" -> "T.ENNM"; + case "stCode" -> "T.ST_CODE"; + case "stName" -> "T.ST_NAME"; + case "month" -> "T.MONTH"; + case "year" -> "T.YEAR"; + case "drtp" -> "T.DRTP"; + case "dr" -> "T.DR"; + case "wtmp" -> "T.WTMP"; + case "ph" -> "T.PH"; + case "dox" -> "T.DOX"; + case "codmn" -> "T.CODMN"; + case "codcr" -> "T.CODCR"; + case "bod5" -> "T.BOD5"; + case "nh3n" -> "T.NH3N"; + case "tp" -> "T.TP"; + case "tn" -> "T.TN"; + case "cu" -> "T.CU"; + case "zn" -> "T.ZN"; + case "f" -> "T.F"; + case "se" -> "T.SE"; + case "ars" -> "T.ARS"; + case "hg" -> "T.HG"; + case "cd" -> "T.CD"; + case "cr6" -> "T.CR6"; + case "pb" -> "T.PB"; + case "cn" -> "T.CN"; + case "vlph" -> "T.VLPH"; + case "oil" -> "T.OIL"; + case "las" -> "T.LAS"; + case "s2" -> "T.S2"; + case "fcg" -> "T.FCG"; + case "cl" -> "T.CL"; + case "so4" -> "T.SO4"; + case "no3" -> "T.NO3"; + case "thrd" -> "T.THRD"; + case "cond" -> "T.COND"; + case "fe" -> "T.FE"; + case "mn" -> "T.MN"; + case "al" -> "T.AL"; + case "ss" -> "T.SS"; + case "no2" -> "T.NO2"; + case "chla" -> "T.CHLA"; + case "clarity" -> "T.CLARITY"; + case "tu" -> "T.TU"; + case "tod" -> "T.TOD"; + case "cyano" -> "T.CYANO"; + case "wqgrd" -> "T.WQGRD"; + case "wwqtg" -> "T.WWQTG"; + case "sfdb" -> "T.SFDB"; + case "wqSfdbhnYs" -> "T.WQ_SFDBHN_YS"; + case "baseId" -> "T.BASE_ID"; + case "baseName" -> "T.BASE_NAME"; + case "rvcdName" -> "T.RVCD_NAME"; + case "addvcdName" -> "T.ADDVCD_NAME"; + case "dtinType" -> "T.DTIN_TYPE"; + case "tm" -> "T.TM"; + case "siteStepSort" -> "T.SITESTEPSORT"; + case "baseStepSort" -> "T.BASESTEPSORT"; + case "rvcdStepSort" -> "T.RVCDSTEPSORT"; + case "rstcdStepSort" -> "T.RSTCDSTEPSORT"; + default -> null; + }; + } + private String buildEnvWqDayGroupSql(String baseSql, String groupBy, GroupingInfo[] groupInfos) { StringBuilder sql = new StringBuilder("SELECT "); List groupFields = new ArrayList<>(); @@ -1273,6 +1574,31 @@ public class EnvWqDataServiceImpl implements EnvWqDataService { return appended ? sql.toString() : " ORDER BY T.DT DESC NULLS LAST, T.BASESTEPSORT ASC NULLS LAST, T.RVCDSTEPSORT ASC NULLS LAST, T.RSTCDSTEPSORT ASC NULLS LAST, T.SITESTEPSORT ASC NULLS LAST, T.STCD ASC"; } + private String buildEnvWqDrtpOrderBySql(List sortList) { + if (sortList == null || sortList.isEmpty()) { + return " ORDER BY T.TM DESC NULLS LAST, T.BASESTEPSORT ASC NULLS LAST, T.RVCDSTEPSORT ASC NULLS LAST, T.RSTCDSTEPSORT ASC NULLS LAST, T.SITESTEPSORT ASC NULLS LAST, T.STCD ASC"; + } + StringBuilder sql = new StringBuilder(" ORDER BY "); + boolean appended = false; + for (DataSourceRequest.SortDescriptor sortDescriptor : sortList) { + if (sortDescriptor == null || StrUtil.isBlank(sortDescriptor.getField())) { + continue; + } + String column = mapEnvWqDrtpColumn(sortDescriptor.getField()); + if (column == null) { + continue; + } + if (appended) { + sql.append(", "); + } + sql.append(column).append(" ") + .append("desc".equalsIgnoreCase(sortDescriptor.getDir()) ? "DESC" : "ASC") + .append(" NULLS LAST"); + appended = true; + } + return appended ? sql.toString() : " ORDER BY T.TM DESC NULLS LAST, T.BASESTEPSORT ASC NULLS LAST, T.RVCDSTEPSORT ASC NULLS LAST, T.RSTCDSTEPSORT ASC NULLS LAST, T.SITESTEPSORT ASC NULLS LAST, T.STCD ASC"; + } + private void fillEnvWqDayDerivedFields(List list) { if (CollUtil.isEmpty(list)) { return; @@ -1285,6 +1611,17 @@ public class EnvWqDataServiceImpl implements EnvWqDataService { } } + private void fillEnvWqDrtpDerivedFields(List list) { + if (CollUtil.isEmpty(list)) { + return; + } + for (EnvWqDrtpDataVo item : list) { + item.setWqgrdName(getWqLevelName(item.getWqgrd())); + item.setWwqtgName(getWqLevelName(item.getWwqtg())); + item.setSfdbName(getSfdbName(item.getSfdb())); + } + } + private void fillEnvWqDayLimit(List list) { if (CollUtil.isEmpty(list)) { return;