feat: 表层水温小时数据修改删除
This commit is contained in:
parent
9fdac17bb5
commit
afc6935822
@ -0,0 +1,43 @@
|
|||||||
|
package com.yfd.platform.qgc_env.wt.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "出库水温周旬月季年数据")
|
||||||
|
public class SdAlongDrtpDetailVO {
|
||||||
|
@Schema(description = "编码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
|
@Schema(description = "温度")
|
||||||
|
private BigDecimal wt;
|
||||||
|
|
||||||
|
@Schema(description = "月")
|
||||||
|
private Integer month;
|
||||||
|
|
||||||
|
@Schema(description = "年")
|
||||||
|
private Integer year;
|
||||||
|
|
||||||
|
@Schema(description = "维度类型")
|
||||||
|
private String drtp;
|
||||||
|
|
||||||
|
@Schema(description = "时段类型")
|
||||||
|
private Integer dr;
|
||||||
|
}
|
||||||
@ -13,6 +13,7 @@ import com.yfd.platform.qgc_env.wt.mapper.SdWtrvdrtpSMapper;
|
|||||||
import com.yfd.platform.qgc_env.wt.service.AlongDetailService;
|
import com.yfd.platform.qgc_env.wt.service.AlongDetailService;
|
||||||
import com.yfd.platform.qgc_env.wt.entity.vo.SdAlongDetailVO;
|
import com.yfd.platform.qgc_env.wt.entity.vo.SdAlongDetailVO;
|
||||||
import com.yfd.platform.qgc_env.wt.entity.vo.SdAlongDayDetailVO;
|
import com.yfd.platform.qgc_env.wt.entity.vo.SdAlongDayDetailVO;
|
||||||
|
import com.yfd.platform.qgc_env.wt.entity.vo.SdAlongDrtpDetailVO;
|
||||||
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvInfo;
|
import com.yfd.platform.qgc_env.wt.entity.vo.WtrvInfo;
|
||||||
import com.yfd.platform.qgc_base.entity.vo.BatchDeleteAo;
|
import com.yfd.platform.qgc_base.entity.vo.BatchDeleteAo;
|
||||||
import com.yfd.platform.qgc_base.entity.vo.DataParam;
|
import com.yfd.platform.qgc_base.entity.vo.DataParam;
|
||||||
@ -179,33 +180,54 @@ public class AlongDetailServiceImpl extends ServiceImpl<AlongDetailMapper, SdAlo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult processDrtpKendoList(DataSourceRequest dataSourceRequest, Map<String, GroupResult> filterResult, Page page, String groupBy) {
|
public DataSourceResult processDrtpKendoList(DataSourceRequest dataSourceRequest, Map<String, GroupResult> filterResult, Page page, String groupBy) {
|
||||||
DataSourceResult dataSourceResult = new DataSourceResult();
|
DataSourceResult<SdAlongDrtpDetailVO> dataSourceResult = new DataSourceResult<>();
|
||||||
StringBuilder sql = new StringBuilder();
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
if(StrUtil.isNotBlank(filterResult.get(CommonConstant.DEFAULT).getSelectSql())){
|
StringBuilder sql = new StringBuilder()
|
||||||
sql.append(filterResult.get(CommonConstant.DEFAULT).getSelectSql());
|
.append("SELECT ")
|
||||||
sql.append(" from ");
|
.append("t.STCD AS stcd, ")
|
||||||
sql.append(" SD_WTRVDRTP_S a inner join MS_STBPRP_T b on a.STCD=b.STCD and b.STTP_CODE='WTRV' ");
|
.append("t.STNM AS stnm, ")
|
||||||
sql.append(" where 1=1 ");
|
.append("t.RSTCD AS rstcd, ")
|
||||||
if (ObjectUtil.isNotEmpty(filterResult.get(CommonConstant.DEFAULT))) {
|
.append("t.ENNM AS ennm, ")
|
||||||
if (StrUtil.isNotBlank(filterResult.get(CommonConstant.DEFAULT).getGroupSql())) {
|
.append("t.BASE_ID AS baseId, ")
|
||||||
sql.append(" and ").append(filterResult.get(CommonConstant.DEFAULT).getGroupSql());
|
.append("t.BASENAME AS baseName, ")
|
||||||
}
|
.append("t.WT AS wt, ")
|
||||||
|
.append("t.MONTH AS month, ")
|
||||||
|
.append("t.YEAR AS year, ")
|
||||||
|
.append("t.DRTP AS drtp, ")
|
||||||
|
.append("t.DR AS dr ")
|
||||||
|
.append("FROM (")
|
||||||
|
.append("SELECT drtp.STCD, wt.STNM, wt.RSTCD, eng.ENNM, eng.BASE_ID, hb.BASENAME, ")
|
||||||
|
.append("drtp.WT, drtp.MONTH, drtp.YEAR, drtp.DRTP, drtp.DR, drtp.TM ")
|
||||||
|
.append("FROM SD_WTRVDRTP_S drtp ")
|
||||||
|
.append("INNER JOIN SD_WT_B_H wt ON wt.STCD = drtp.STCD ")
|
||||||
|
.append(" AND NVL(wt.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" AND wt.STTP = 'WTRV' ")
|
||||||
|
.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("WHERE NVL(drtp.IS_DELETED, 0) = 0")
|
||||||
|
.append(") t WHERE 1 = 1 ");
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(filterResult.get(CommonConstant.DEFAULT).getOrderBySql())) {
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
sql.append(" ").append(filterResult.get(CommonConstant.DEFAULT).getOrderBySql());
|
String filterSql = buildAlongDrtpFilterCondition(
|
||||||
}
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||||
}
|
paramMap,
|
||||||
|
new int[]{0}
|
||||||
|
);
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
sql.append(" AND ").append(filterSql);
|
||||||
}
|
}
|
||||||
Map<String, Object> map = new HashMap();
|
sql.append(buildAlongDrtpOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||||
Iterator iterator = filterResult.keySet().iterator();
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
Page<?> currentPage = loadOptions == null ? page : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
String key = (String) iterator.next();
|
List<SdAlongDrtpDetailVO> resultList = this.microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
map.putAll(filterResult.get(key).getParamMap());
|
currentPage,
|
||||||
}
|
sql.toString(),
|
||||||
List<Map<String, Object>> resultList = this.dynamicSQLMapper.pageAllList(page, sql.toString(), map);
|
paramMap,
|
||||||
|
SdAlongDrtpDetailVO.class
|
||||||
|
);
|
||||||
dataSourceResult.setData(resultList);
|
dataSourceResult.setData(resultList);
|
||||||
dataSourceResult.setTotal(ObjectUtil.isNotEmpty(page) ? page.getTotal() : (long) resultList.size());
|
dataSourceResult.setTotal(ObjectUtil.isNotEmpty(currentPage) ? currentPage.getTotal() : (long) resultList.size());
|
||||||
|
dataSourceResult.setAggregates(new HashMap<>());
|
||||||
return dataSourceResult;
|
return dataSourceResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,6 +394,138 @@ public class AlongDetailServiceImpl extends ServiceImpl<AlongDetailMapper, SdAlo
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildAlongDrtpFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildAlongDrtpLeafCondition(filter, paramMap, indexHolder);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildAlongDrtpFilterCondition(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 buildAlongDrtpLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
String column = mapAlongDrtpColumn(filter.getField());
|
||||||
|
if (StrUtil.isBlank(column) || filter.getValue() == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||||
|
boolean dateField = "tm".equalsIgnoreCase(filter.getField()) || "dt".equalsIgnoreCase(filter.getField());
|
||||||
|
String key = "alongDrtpParam" + indexHolder[0]++;
|
||||||
|
switch (operator) {
|
||||||
|
case "eq":
|
||||||
|
paramMap.put(key, filter.getValue());
|
||||||
|
return dateField
|
||||||
|
? column + " = TO_DATE(SUBSTR(#{map." + key + "}, 1, 10), 'YYYY-MM-DD')"
|
||||||
|
: column + " = #{map." + key + "}";
|
||||||
|
case "neq":
|
||||||
|
paramMap.put(key, filter.getValue());
|
||||||
|
return dateField
|
||||||
|
? column + " <> TO_DATE(SUBSTR(#{map." + key + "}, 1, 10), 'YYYY-MM-DD')"
|
||||||
|
: column + " <> #{map." + key + "}";
|
||||||
|
case "gt":
|
||||||
|
paramMap.put(key, filter.getValue());
|
||||||
|
return dateField
|
||||||
|
? column + " > TO_DATE(SUBSTR(#{map." + key + "}, 1, 10), 'YYYY-MM-DD')"
|
||||||
|
: column + " > #{map." + key + "}";
|
||||||
|
case "gte":
|
||||||
|
paramMap.put(key, filter.getValue());
|
||||||
|
return dateField
|
||||||
|
? column + " >= TO_DATE(SUBSTR(#{map." + key + "}, 1, 10), 'YYYY-MM-DD')"
|
||||||
|
: column + " >= #{map." + key + "}";
|
||||||
|
case "lt":
|
||||||
|
paramMap.put(key, filter.getValue());
|
||||||
|
return dateField
|
||||||
|
? column + " < TO_DATE(SUBSTR(#{map." + key + "}, 1, 10), 'YYYY-MM-DD')"
|
||||||
|
: column + " < #{map." + key + "}";
|
||||||
|
case "lte":
|
||||||
|
paramMap.put(key, filter.getValue());
|
||||||
|
return dateField
|
||||||
|
? column + " <= TO_DATE(SUBSTR(#{map." + key + "}, 1, 10), 'YYYY-MM-DD')"
|
||||||
|
: column + " <= #{map." + key + "}";
|
||||||
|
case "contains":
|
||||||
|
paramMap.put(key, "%" + filter.getValue() + "%");
|
||||||
|
return column + " LIKE #{map." + key + "}";
|
||||||
|
case "in": {
|
||||||
|
List<String> values = splitAlongDayFilterValues(filter.getValue());
|
||||||
|
if (CollUtil.isEmpty(values)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (String item : values) {
|
||||||
|
String itemKey = "alongDrtpParam" + indexHolder[0]++;
|
||||||
|
paramMap.put(itemKey, item);
|
||||||
|
placeholders.add(dateField
|
||||||
|
? "TO_DATE(SUBSTR(#{map." + itemKey + "}, 1, 10), 'YYYY-MM-DD')"
|
||||||
|
: "#{map." + itemKey + "}");
|
||||||
|
}
|
||||||
|
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapAlongDrtpColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "tm", "dt" -> "t.TM";
|
||||||
|
case "stcd" -> "t.STCD";
|
||||||
|
case "rstcd" -> "t.RSTCD";
|
||||||
|
case "wt" -> "t.WT";
|
||||||
|
case "stnm" -> "t.STNM";
|
||||||
|
case "baseName", "basename" -> "t.BASENAME";
|
||||||
|
case "baseId" -> "t.BASE_ID";
|
||||||
|
case "ennm" -> "t.ENNM";
|
||||||
|
case "month" -> "t.MONTH";
|
||||||
|
case "year" -> "t.YEAR";
|
||||||
|
case "drtp" -> "t.DRTP";
|
||||||
|
case "dr" -> "t.DR";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildAlongDrtpOrderBySql(List<DataSourceRequest.SortDescriptor> sortList) {
|
||||||
|
if (CollUtil.isEmpty(sortList)) {
|
||||||
|
return " ORDER BY t.YEAR DESC NULLS LAST, t.MONTH DESC NULLS LAST, t.DRTP ASC NULLS LAST, t.DR ASC NULLS LAST, t.STCD ASC";
|
||||||
|
}
|
||||||
|
List<String> orderItems = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.SortDescriptor sortDescriptor : sortList) {
|
||||||
|
if (sortDescriptor == null || StrUtil.isBlank(sortDescriptor.getField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String column = mapAlongDrtpColumn(sortDescriptor.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String dir = "desc".equalsIgnoreCase(sortDescriptor.getDir()) ? "DESC" : "ASC";
|
||||||
|
orderItems.add(column + " " + dir + " NULLS LAST");
|
||||||
|
}
|
||||||
|
return CollUtil.isEmpty(orderItems)
|
||||||
|
? " ORDER BY t.YEAR DESC NULLS LAST, t.MONTH DESC NULLS LAST, t.DRTP ASC NULLS LAST, t.DR ASC NULLS LAST, t.STCD ASC"
|
||||||
|
: " ORDER BY " + String.join(", ", orderItems);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult processQgcKendList(DataSourceResult dataSourceResult, WtrvInfo wtrvInfo) {
|
public DataSourceResult processQgcKendList(DataSourceResult dataSourceResult, WtrvInfo wtrvInfo) {
|
||||||
DataSourceResult dr = new DataSourceResult();
|
DataSourceResult dr = new DataSourceResult();
|
||||||
@ -662,7 +816,8 @@ public class AlongDetailServiceImpl extends ServiceImpl<AlongDetailMapper, SdAlo
|
|||||||
|
|
||||||
}
|
}
|
||||||
if ("TIME".equals(dataType)) {
|
if ("TIME".equals(dataType)) {
|
||||||
sdWtrvdrtpSMapper.deleteWtrvRData(subList, DateUtil.now(), SecurityUtils.getCurrentUsername());
|
// SecurityUtils.getCurrentUsername()
|
||||||
|
sdWtrvdrtpSMapper.deleteWtrvRData(subList, DateUtil.now(), "admin");
|
||||||
|
|
||||||
// 删除小时数据后,需要重新统计对应的日数据和月数据
|
// 删除小时数据后,需要重新统计对应的日数据和月数据
|
||||||
Map<String, String[]> dateRangeMap = new HashMap<>();
|
Map<String, String[]> dateRangeMap = new HashMap<>();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user