feat: 野生动物监测默认有数据的年份和月份
This commit is contained in:
parent
adee795bed
commit
8ee9952d0e
@ -39,6 +39,12 @@ public class WeFishController {
|
|||||||
return ResponseResult.successData(weFishService.getMsstbprptList(dataSourceRequest));
|
return ResponseResult.successData(weFishService.getMsstbprptList(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/wva/year/GetKendoListCust")
|
||||||
|
@Operation(summary = "野生动物监测默认有数据的年份和月份")
|
||||||
|
public ResponseResult getWvaDefaultYearList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(weFishService.getWvaDefaultYearList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/we/fisht/year/qgc/GetKendoListCust")
|
@PostMapping("/we/fisht/year/qgc/GetKendoListCust")
|
||||||
@Operation(summary = "全过程沿程鱼类变化情况有数据的流域和年份")
|
@Operation(summary = "全过程沿程鱼类变化情况有数据的流域和年份")
|
||||||
public ResponseResult getQgcFishStaticsYearList(@RequestBody DataSourceRequest dataSourceRequest) {
|
public ResponseResult getQgcFishStaticsYearList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.yfd.platform.qgc_env.wte.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "野生动物监测默认有数据的年月")
|
||||||
|
public class WeWvaYearQgcVo {
|
||||||
|
|
||||||
|
@Schema(description = "年月,格式yyyy-MM")
|
||||||
|
private String ym;
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@ import com.yfd.platform.qgc_env.wte.entity.vo.WeFishPointQgcVo;
|
|||||||
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;
|
||||||
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaYearQgcVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -21,6 +22,8 @@ public interface WeFishService {
|
|||||||
|
|
||||||
DataSourceResult<WeMsstbprptVo> getMsstbprptList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<WeMsstbprptVo> getMsstbprptList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult<WeWvaYearQgcVo> getWvaDefaultYearList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<WeStaticsVo> getQgcWeFishStatics(DataSourceRequest dataSourceRequest);
|
DataSourceResult<WeStaticsVo> getQgcWeFishStatics(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -18,6 +18,7 @@ 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;
|
||||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo;
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo;
|
||||||
|
import com.yfd.platform.qgc_env.wte.entity.vo.WeWvaYearQgcVo;
|
||||||
import com.yfd.platform.qgc_env.wte.service.WeFishService;
|
import com.yfd.platform.qgc_env.wte.service.WeFishService;
|
||||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -185,6 +186,46 @@ public class WeFishServiceImpl implements WeFishService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<WeWvaYearQgcVo> getWvaDefaultYearList(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
|
||||||
|
String filterSql = buildWeWvaYearFilterCondition(
|
||||||
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||||
|
paramMap,
|
||||||
|
new int[]{0}
|
||||||
|
);
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT TO_CHAR(a.TM, 'yyyy') || '-' || TO_CHAR(a.TM, 'MM') AS ym ")
|
||||||
|
.append("FROM SD_WVA_R a ")
|
||||||
|
.append("INNER JOIN SD_AIMONITOR_B_H b ON a.STCD = b.STCD ")
|
||||||
|
.append("WHERE NVL(a.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("AND NVL(b.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("AND b.STTP = 'WVA' ");
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
sql.append("AND ").append(filterSql).append(" ");
|
||||||
|
}
|
||||||
|
sql.append("GROUP BY TO_CHAR(a.TM, 'yyyy'), TO_CHAR(a.TM, 'MM') ")
|
||||||
|
.append("ORDER BY TO_CHAR(a.TM, 'yyyy') DESC, TO_CHAR(a.TM, 'MM') DESC");
|
||||||
|
|
||||||
|
Page<?> page = loadOptions == null ? null
|
||||||
|
: QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
List<WeWvaYearQgcVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
|
page,
|
||||||
|
sql.toString(),
|
||||||
|
paramMap,
|
||||||
|
WeWvaYearQgcVo.class
|
||||||
|
);
|
||||||
|
|
||||||
|
DataSourceResult<WeWvaYearQgcVo> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal((long) list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest) {
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
@ -695,6 +736,117 @@ public class WeFishServiceImpl implements WeFishService {
|
|||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildWeWvaYearFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildWeWvaYearLeafCondition(filter, paramMap, indexHolder);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildWeWvaYearFilterCondition(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 buildWeWvaYearLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
String column = mapWeWvaYearColumn(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) {
|
||||||
|
if (value == null || StrUtil.isBlank(String.valueOf(value).trim())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String key = "weWvaYearP" + indexHolder[0]++;
|
||||||
|
paramMap.put(key, String.valueOf(value).trim());
|
||||||
|
placeholders.add("#{map." + key + "}");
|
||||||
|
}
|
||||||
|
if (placeholders.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return column + ("ni".equals(operator) ? " NOT IN (" : " IN (") + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
Object rawValue = filter.getValue();
|
||||||
|
if (rawValue == null || StrUtil.isBlank(String.valueOf(rawValue).trim())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String text = String.valueOf(rawValue).trim();
|
||||||
|
String key = "weWvaYearP" + indexHolder[0]++;
|
||||||
|
return switch (operator) {
|
||||||
|
case "eq" -> {
|
||||||
|
paramMap.put(key, text);
|
||||||
|
yield column + " = #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "neq" -> {
|
||||||
|
paramMap.put(key, text);
|
||||||
|
yield column + " <> #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "contains" -> {
|
||||||
|
paramMap.put(key, "%" + text + "%");
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "doesnotcontain" -> {
|
||||||
|
paramMap.put(key, "%" + text + "%");
|
||||||
|
yield column + " NOT LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapWeWvaYearColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "stcd" -> "a.STCD";
|
||||||
|
case "tm" -> "a.TM";
|
||||||
|
case "fid" -> "a.FID";
|
||||||
|
case "stnm" -> "b.STNM";
|
||||||
|
case "sttpCode" -> "b.STTP";
|
||||||
|
case "rstcd" -> "b.RSTCD";
|
||||||
|
case "baseId" -> "b.BASE_ID";
|
||||||
|
case "hbrvcd" -> "b.HBRVCD";
|
||||||
|
case "ym" -> "TO_CHAR(a.TM, 'yyyy') || '-' || TO_CHAR(a.TM, 'MM')";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private String buildWeMsstbprptViewSql() {
|
private String buildWeMsstbprptViewSql() {
|
||||||
return "SELECT " +
|
return "SELECT " +
|
||||||
"ai.STCD AS id, " +
|
"ai.STCD AS id, " +
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user