feat: 环保部-水生生态调查-水生生态面板
This commit is contained in:
parent
0b673d4620
commit
2e6a1197f5
@ -44,4 +44,10 @@ public class WeFishController {
|
|||||||
public ResponseResult getQgcWeFishStatList(@RequestBody DataSourceRequest dataSourceRequest) {
|
public ResponseResult getQgcWeFishStatList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
return ResponseResult.successData(weFishService.getQgcWeFishStatList(dataSourceRequest));
|
return ResponseResult.successData(weFishService.getQgcWeFishStatList(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/we/fishList/stat/qgc/GetKendoListCust")
|
||||||
|
@Operation(summary = "环保部-水生生态调查-水生生态面板")
|
||||||
|
public ResponseResult getQgcFishListStat(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(weFishService.getQgcFishListStat(dataSourceRequest));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.yfd.platform.qgc_env.wte.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Schema(description = "环保部-水生生态调查-水生生态面板")
|
||||||
|
public class WeFishListStatQgcVo {
|
||||||
|
|
||||||
|
@Schema(description = "鱼类编码")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "河流编码")
|
||||||
|
private String rvcd;
|
||||||
|
|
||||||
|
@Schema(description = "河流名称")
|
||||||
|
private String rvcdName;
|
||||||
|
|
||||||
|
@Schema(description = "流域编码")
|
||||||
|
private String hbrvcd;
|
||||||
|
|
||||||
|
@Schema(description = "流域名称")
|
||||||
|
private String hbrvcdName;
|
||||||
|
|
||||||
|
@Schema(description = "电站编码")
|
||||||
|
private String rstcd;
|
||||||
|
|
||||||
|
@Schema(description = "电站名称")
|
||||||
|
private String ennm;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
private Date tm;
|
||||||
|
|
||||||
|
@Schema(description = "年份")
|
||||||
|
private Integer yr;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类数量")
|
||||||
|
private Long fcnt;
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ package com.yfd.platform.qgc_env.wte.service;
|
|||||||
|
|
||||||
import com.yfd.platform.common.DataSourceRequest;
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
import com.yfd.platform.common.DataSourceResult;
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishListStatQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishStatQgcVo;
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishStatQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo;
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo;
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo;
|
||||||
@ -18,4 +19,6 @@ public interface WeFishService {
|
|||||||
DataSourceResult<WeStaticsVo> getQgcWeFishStatics(DataSourceRequest dataSourceRequest);
|
DataSourceResult<WeStaticsVo> getQgcWeFishStatics(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<WeFishStatQgcVo> getQgcWeFishStatList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<WeFishStatQgcVo> getQgcWeFishStatList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult<WeFishListStatQgcVo> getQgcFishListStat(DataSourceRequest dataSourceRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.yfd.platform.common.DataSourceResult;
|
|||||||
import com.yfd.platform.common.GroupHelper;
|
import com.yfd.platform.common.GroupHelper;
|
||||||
import com.yfd.platform.common.GroupingInfo;
|
import com.yfd.platform.common.GroupingInfo;
|
||||||
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||||
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishListStatQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishStatQgcVo;
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishStatQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo;
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeRvcdYearVo;
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeRvcdYearVo;
|
||||||
@ -192,6 +193,43 @@ public class WeFishServiceImpl implements WeFishService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<WeFishListStatQgcVo> getQgcFishListStat(DataSourceRequest dataSourceRequest) {
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
String filterSql = buildWeFishListStatFilterCondition(
|
||||||
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||||
|
paramMap,
|
||||||
|
new int[]{0}
|
||||||
|
);
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT r.yr AS yr, r.id AS id, r.name AS name, r.hbrvcd AS hbrvcd, r.hbrvcdName AS hbrvcdName, ")
|
||||||
|
.append("SUM(NVL(r.fcnt, 0)) AS fcnt ")
|
||||||
|
.append("FROM (")
|
||||||
|
.append(buildWeFishListStatQgcDetailSql())
|
||||||
|
.append(") r WHERE 1 = 1 ");
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
sql.append("AND ").append(filterSql).append(" ");
|
||||||
|
}
|
||||||
|
sql.append("GROUP BY r.yr, r.id, r.name, r.hbrvcd, r.hbrvcdName ")
|
||||||
|
.append("ORDER BY r.yr ASC");
|
||||||
|
|
||||||
|
List<Map<String, Object>> rows = microservicDynamicSQLMapper.getAllList(sql.toString(), paramMap);
|
||||||
|
List<WeFishListStatQgcVo> list = new ArrayList<>();
|
||||||
|
for (Map<String, Object> row : rows) {
|
||||||
|
WeFishListStatQgcVo vo = buildWeFishListStatQgcVo(row);
|
||||||
|
if (vo != null) {
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataSourceResult<WeFishListStatQgcVo> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal((long) list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private String buildWeFishQgcGroupSql(String baseSql, GroupingInfo[] groupInfos) {
|
private String buildWeFishQgcGroupSql(String baseSql, GroupingInfo[] groupInfos) {
|
||||||
if (groupInfos == null || groupInfos.length == 0) {
|
if (groupInfos == null || groupInfos.length == 0) {
|
||||||
return baseSql;
|
return baseSql;
|
||||||
@ -407,6 +445,35 @@ public class WeFishServiceImpl implements WeFishService {
|
|||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildWeFishListStatQgcDetailSql() {
|
||||||
|
return "SELECT " +
|
||||||
|
"dict.FISH_ID AS id, " +
|
||||||
|
"dict.NAME AS name, " +
|
||||||
|
"dict.CODE AS code, " +
|
||||||
|
"eng.RVCD AS rvcd, " +
|
||||||
|
"eng.RVCD_NAME AS rvcdName, " +
|
||||||
|
"eng.HBRVCD AS hbrvcd, " +
|
||||||
|
"eng.HBRVCD_NAME AS hbrvcdName, " +
|
||||||
|
"section.RSTCD AS rstcd, " +
|
||||||
|
"eng.ENNM AS ennm, " +
|
||||||
|
"eng.BASE_ID AS baseId, " +
|
||||||
|
"eng.BASE_NAME AS baseName, " +
|
||||||
|
"we.TM AS tm, " +
|
||||||
|
"TO_CHAR(we.TM, 'yyyy') AS yr, " +
|
||||||
|
"fish.FCNT AS fcnt " +
|
||||||
|
"FROM SD_WE_R we " +
|
||||||
|
"INNER JOIN SD_WEFISH_R fish ON we.ID = fish.WER_ID " +
|
||||||
|
" AND NVL(fish.IS_DELETED, 0) = 0 " +
|
||||||
|
"INNER JOIN SD_WE_B_H section ON we.STCD = section.STCD " +
|
||||||
|
" AND NVL(section.USFL, 0) = 1 " +
|
||||||
|
"INNER JOIN SD_ENGINFO_B_H eng ON eng.STCD = section.RSTCD " +
|
||||||
|
" AND NVL(eng.IS_DELETED, 0) = 0 " +
|
||||||
|
"INNER JOIN V_SD_FISHDICTORY_B dict ON dict.FISH_ID = fish.FTP " +
|
||||||
|
" AND (eng.HBRVCD = dict.RVCD OR dict.RVCD = 'ZY') " +
|
||||||
|
"WHERE NVL(we.IS_DELETED, 0) = 0 " +
|
||||||
|
"AND NVL(we.STATUS, 1) = 1 ";
|
||||||
|
}
|
||||||
|
|
||||||
private String buildWeFishStaticsSql(String baseId,
|
private String buildWeFishStaticsSql(String baseId,
|
||||||
String hbrvcd,
|
String hbrvcd,
|
||||||
String yr,
|
String yr,
|
||||||
@ -746,6 +813,212 @@ public class WeFishServiceImpl implements WeFishService {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildWeFishListStatFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildWeFishListStatLeafCondition(filter, paramMap, indexHolder);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildWeFishListStatFilterCondition(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 buildWeFishListStatLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
String column = mapWeFishListStatColumn(filter.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||||
|
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 ("in".equals(operator) || "ni".equals(operator)) {
|
||||||
|
List<Object> values = normalizeWeFishQgcValues(filter.getValue());
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (Object value : values) {
|
||||||
|
Object normalizedValue = normalizeWeFishListStatValue(filter.getField(), value);
|
||||||
|
if (normalizedValue == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String key = "weFishListStatP" + indexHolder[0]++;
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
placeholders.add("#{map." + key + "}");
|
||||||
|
}
|
||||||
|
if (placeholders.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return column + ("ni".equals(operator) ? " NOT IN (" : " IN (") + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
Object normalizedValue = normalizeWeFishListStatValue(filter.getField(), filter.getValue());
|
||||||
|
if (normalizedValue == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String key = "weFishListStatP" + indexHolder[0]++;
|
||||||
|
return switch (operator) {
|
||||||
|
case "eq" -> {
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
yield column + " = #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "neq" -> {
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
yield column + " <> #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "gt" -> {
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
yield column + " > #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "gte" -> {
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
yield column + " >= #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "lt" -> {
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
yield column + " < #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "lte" -> {
|
||||||
|
paramMap.put(key, normalizedValue);
|
||||||
|
yield column + " <= #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "contains" -> {
|
||||||
|
paramMap.put(key, "%" + String.valueOf(normalizedValue).trim() + "%");
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "doesnotcontain" -> {
|
||||||
|
paramMap.put(key, "%" + String.valueOf(normalizedValue).trim() + "%");
|
||||||
|
yield column + " NOT LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "startswith" -> {
|
||||||
|
paramMap.put(key, String.valueOf(normalizedValue).trim() + "%");
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "endswith" -> {
|
||||||
|
paramMap.put(key, "%" + String.valueOf(normalizedValue).trim());
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapWeFishListStatColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "id" -> "r.id";
|
||||||
|
case "name" -> "r.name";
|
||||||
|
case "baseId" -> "r.baseId";
|
||||||
|
case "baseName" -> "r.baseName";
|
||||||
|
case "rvcd" -> "r.rvcd";
|
||||||
|
case "rvcdName" -> "r.rvcdName";
|
||||||
|
case "hbrvcd" -> "r.hbrvcd";
|
||||||
|
case "hbrvcdName" -> "r.hbrvcdName";
|
||||||
|
case "rstcd" -> "r.rstcd";
|
||||||
|
case "ennm" -> "r.ennm";
|
||||||
|
case "tm" -> "r.tm";
|
||||||
|
case "yr" -> "r.yr";
|
||||||
|
case "fcnt" -> "r.fcnt";
|
||||||
|
case "code" -> "r.code";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object normalizeWeFishListStatValue(String field, Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ("yr".equals(field)) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(String.valueOf(value).trim());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("fcnt".equals(field)) {
|
||||||
|
try {
|
||||||
|
return new java.math.BigDecimal(String.valueOf(value).trim());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("tm".equals(field)) {
|
||||||
|
return parseDateTimeSafely(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WeFishListStatQgcVo buildWeFishListStatQgcVo(Map<String, Object> row) {
|
||||||
|
if (row == null || row.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new WeFishListStatQgcVo()
|
||||||
|
.setId(safeWeFishString(firstPresentWeFishValue(row, "ID", "id")))
|
||||||
|
.setName(safeWeFishString(firstPresentWeFishValue(row, "NAME", "name")))
|
||||||
|
.setBaseId(safeWeFishString(firstPresentWeFishValue(row, "BASEID", "baseId")))
|
||||||
|
.setBaseName(safeWeFishString(firstPresentWeFishValue(row, "BASENAME", "baseName")))
|
||||||
|
.setRvcd(safeWeFishString(firstPresentWeFishValue(row, "RVCD", "rvcd")))
|
||||||
|
.setRvcdName(safeWeFishString(firstPresentWeFishValue(row, "RVCDNAME", "rvcdName")))
|
||||||
|
.setHbrvcd(safeWeFishString(firstPresentWeFishValue(row, "HBRVCD", "hbrvcd")))
|
||||||
|
.setHbrvcdName(safeWeFishString(firstPresentWeFishValue(row, "HBRVCDNAME", "hbrvcdName")))
|
||||||
|
.setRstcd(safeWeFishString(firstPresentWeFishValue(row, "RSTCD", "rstcd")))
|
||||||
|
.setEnnm(safeWeFishString(firstPresentWeFishValue(row, "ENNM", "ennm")))
|
||||||
|
.setTm(toDateValue(firstPresentWeFishValue(row, "TM", "tm")))
|
||||||
|
.setYr(toWeFishIntegerValue(firstPresentWeFishValue(row, "YR", "yr")))
|
||||||
|
.setFcnt(toWeFishLongValue(firstPresentWeFishValue(row, "FCNT", "fcnt")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date toDateValue(Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (value instanceof Date date) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
if (value instanceof Number number) {
|
||||||
|
return new Date(number.longValue());
|
||||||
|
}
|
||||||
|
String text = String.valueOf(value).trim();
|
||||||
|
if (StrUtil.isBlank(text)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return DateUtil.parse(text).toJdkDate();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void appendWeFishQgcValues(List<Object> values, Object value) {
|
private void appendWeFishQgcValues(List<Object> values, Object value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user