feat: 全过程鱼类放流运行数据查询
This commit is contained in:
parent
bd6c366153
commit
d9f58678d8
@ -0,0 +1,29 @@
|
|||||||
|
package com.yfd.platform.qgc_env.fp.controller;
|
||||||
|
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.qgc_env.fp.service.FpRunService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/fp/fishrun")
|
||||||
|
@Tag(name = "鱼类运行数据")
|
||||||
|
@Validated
|
||||||
|
public class FishRunController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FpRunService fpRunService;
|
||||||
|
|
||||||
|
@PostMapping("/qgc/GetKendoListCust")
|
||||||
|
@Operation(summary = "全过程鱼类放流运行数据查询")
|
||||||
|
public ResponseResult getQgcKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(fpRunService.processFbFishRunQgcKendoList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.yfd.platform.qgc_env.fp.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "鱼类放流运行数据")
|
||||||
|
public class FbFishRunVo {
|
||||||
|
|
||||||
|
@Schema(description = "电站编码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "电站名称")
|
||||||
|
private String stnm;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类编码")
|
||||||
|
private String ftp;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类名称")
|
||||||
|
private String ftpName;
|
||||||
|
|
||||||
|
@Schema(description = "基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "年份")
|
||||||
|
private String flyr;
|
||||||
|
|
||||||
|
@Schema(description = "放鱼数")
|
||||||
|
private Long fcnt;
|
||||||
|
|
||||||
|
@Schema(description = "放鱼总数")
|
||||||
|
private Long totalFcnt;
|
||||||
|
|
||||||
|
@Schema(description = "文件ids")
|
||||||
|
private String fid;
|
||||||
|
|
||||||
|
@Schema(description = "放流来源")
|
||||||
|
private String release;
|
||||||
|
|
||||||
|
@Schema(description = "基地排序")
|
||||||
|
private Integer baseStepSort;
|
||||||
|
|
||||||
|
@Schema(description = "站点排序")
|
||||||
|
private Integer siteStepSort;
|
||||||
|
|
||||||
|
@Schema(description = "流域排序")
|
||||||
|
private Integer rvcdStepSort;
|
||||||
|
|
||||||
|
@Schema(description = "电站排序")
|
||||||
|
private Integer rstcdStepSort;
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ package com.yfd.platform.qgc_env.fp.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.fp.entity.vo.FbFishRunVo;
|
||||||
import com.yfd.platform.qgc_env.fp.entity.vo.FpFishSelectVo;
|
import com.yfd.platform.qgc_env.fp.entity.vo.FpFishSelectVo;
|
||||||
import com.yfd.platform.qgc_env.fp.entity.vo.FpFpssrlQueryVo;
|
import com.yfd.platform.qgc_env.fp.entity.vo.FpFpssrlQueryVo;
|
||||||
import com.yfd.platform.qgc_env.fp.entity.vo.FpRunAnalysisTableVo;
|
import com.yfd.platform.qgc_env.fp.entity.vo.FpRunAnalysisTableVo;
|
||||||
@ -18,6 +19,8 @@ public interface FpRunService {
|
|||||||
|
|
||||||
DataSourceResult<FpSdfpssrVo> processQgcSdfpssrKendoList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FpSdfpssrVo> processQgcSdfpssrKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult<FbFishRunVo> processFbFishRunQgcKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<FpFpssrlQueryVo> processQgcFpssrlQueryKendoList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FpFpssrlQueryVo> processQgcFpssrlQueryKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<FpTableVo> processQgcFpssTableKendoList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FpTableVo> processQgcFpssTableKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -13,6 +13,7 @@ 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.common.exception.BizException;
|
import com.yfd.platform.common.exception.BizException;
|
||||||
|
import com.yfd.platform.qgc_env.fp.entity.vo.FbFishRunVo;
|
||||||
import com.yfd.platform.qgc_env.fp.entity.vo.FpFishSelectVo;
|
import com.yfd.platform.qgc_env.fp.entity.vo.FpFishSelectVo;
|
||||||
import com.yfd.platform.qgc_env.fp.entity.vo.FpFpssrlQueryVo;
|
import com.yfd.platform.qgc_env.fp.entity.vo.FpFpssrlQueryVo;
|
||||||
import com.yfd.platform.qgc_env.fp.entity.vo.FpFtpStatisticsVo;
|
import com.yfd.platform.qgc_env.fp.entity.vo.FpFtpStatisticsVo;
|
||||||
@ -33,6 +34,7 @@ import java.math.RoundingMode;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@ -120,6 +122,95 @@ public class FpRunServiceImpl implements FpRunService {
|
|||||||
return queryQgcSdfpssrGroupList(dataSourceRequest, loadOptions);
|
return queryQgcSdfpssrGroupList(dataSourceRequest, loadOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<FbFishRunVo> processFbFishRunQgcKendoList(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
String flyr = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "flyr");
|
||||||
|
List<Integer> yearList = new ArrayList<>();
|
||||||
|
if (StrUtil.isNotBlank(flyr) && flyr.contains(",")) {
|
||||||
|
String[] split = flyr.split(",");
|
||||||
|
if (split.length == 2) {
|
||||||
|
String time1 = split[0].trim();
|
||||||
|
String time2 = split[1].trim();
|
||||||
|
String startTime = time1.compareTo(time2) > 0 ? time2 : time1;
|
||||||
|
String endTime = time1.compareTo(time2) > 0 ? time1 : time2;
|
||||||
|
try {
|
||||||
|
int startYear = Integer.parseInt(startTime.substring(0, 4));
|
||||||
|
int endYear = Integer.parseInt(endTime.substring(0, 4));
|
||||||
|
for (int i = startYear; i <= endYear; i++) {
|
||||||
|
yearList.add(i);
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Keep old behavior: ignore invalid year range and return actual query result.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT ")
|
||||||
|
.append(buildFbFishRunSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect()))
|
||||||
|
.append(" FROM (")
|
||||||
|
.append(buildFbFishRunCoreSql())
|
||||||
|
.append(") t WHERE 1 = 1 ");
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
String filterSql = buildFbFishRunFilterCondition(dataSourceRequest == null ? null : dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
sql.append(" AND ").append(filterSql).append(" ");
|
||||||
|
}
|
||||||
|
sql.append(buildFbFishRunOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||||
|
|
||||||
|
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
List<FbFishRunVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, FbFishRunVo.class);
|
||||||
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
|
for (FbFishRunVo fishRun : list) {
|
||||||
|
if (StrUtil.isNotBlank(fishRun.getFid())) {
|
||||||
|
LinkedHashSet<String> fidSet = Arrays.stream(fishRun.getFid().split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.collect(java.util.stream.Collectors.toCollection(LinkedHashSet::new));
|
||||||
|
fishRun.setFid(fidSet.isEmpty() ? null : String.join(",", fidSet));
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(fishRun.getRelease()) && fishRun.getRelease().contains(",")) {
|
||||||
|
LinkedHashSet<String> releaseSet = Arrays.stream(fishRun.getRelease().split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.collect(java.util.stream.Collectors.toCollection(LinkedHashSet::new));
|
||||||
|
fishRun.setRelease(releaseSet.isEmpty() ? null : String.join(",", releaseSet));
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(fishRun.getFlyr())) {
|
||||||
|
try {
|
||||||
|
Integer year = Integer.parseInt(fishRun.getFlyr());
|
||||||
|
yearList.remove(year);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Ignore invalid year text and keep current result row.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Integer year : yearList) {
|
||||||
|
FbFishRunVo fishRun = new FbFishRunVo();
|
||||||
|
fishRun.setFlyr(String.valueOf(year));
|
||||||
|
fishRun.setFcnt(0L);
|
||||||
|
fishRun.setTotalFcnt(0L);
|
||||||
|
if (page == null) {
|
||||||
|
list.add(fishRun);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (page == null && CollUtil.isNotEmpty(list)) {
|
||||||
|
list = list.stream()
|
||||||
|
.sorted(Comparator.comparing(FbFishRunVo::getFlyr, Comparator.nullsLast(String::compareTo)))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
DataSourceResult<FbFishRunVo> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<FpFpssrlQueryVo> processQgcFpssrlQueryKendoList(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<FpFpssrlQueryVo> processQgcFpssrlQueryKendoList(DataSourceRequest dataSourceRequest) {
|
||||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
@ -793,6 +884,307 @@ public class FpRunServiceImpl implements FpRunService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildFbFishRunCoreSql() {
|
||||||
|
return "SELECT " +
|
||||||
|
" fishAgg.STCD AS STCD, " +
|
||||||
|
" NVL(eng.ENNM, fishAgg.STCD) AS STNM, " +
|
||||||
|
" eng.BASE_ID AS BASEID, " +
|
||||||
|
" hb.BASENAME AS BASENAME, " +
|
||||||
|
" NVL(hb.ORDER_INDEX, 999999) AS BASESTEPSORT, " +
|
||||||
|
" NVL(eng.ORDER_INDEX, 999999) AS SITESTEPSORT, " +
|
||||||
|
" NVL(hbrv.ORDER_INDEX, 999999) AS RVCDSTEPSORT, " +
|
||||||
|
" NVL(eng.ORDER_INDEX, 999999) AS RSTCDSTEPSORT, " +
|
||||||
|
" fishAgg.FLYR AS FLYR, " +
|
||||||
|
" fishAgg.FLYR_DATE AS FLYR_DATE, " +
|
||||||
|
" fishAgg.FTP AS FTP, " +
|
||||||
|
" fishView.NAME AS FTPNAME, " +
|
||||||
|
" fishAgg.FCNT AS FCNT, " +
|
||||||
|
" totalAgg.TOTALFCNT AS TOTALFCNT, " +
|
||||||
|
" fishAgg.FID AS FID, " +
|
||||||
|
" fishAgg.RELEASE AS RELEASE " +
|
||||||
|
"FROM ( " +
|
||||||
|
" SELECT " +
|
||||||
|
" e.STCD AS STCD, " +
|
||||||
|
" TO_CHAR(e.TM, 'YYYY') AS FLYR, " +
|
||||||
|
" TRUNC(e.TM, 'YYYY') AS FLYR_DATE, " +
|
||||||
|
" f.FTP AS FTP, " +
|
||||||
|
" SUM(f.FCNT) AS FCNT, " +
|
||||||
|
" MAX(e.FPRFID) || ',' || MAX(e.FLRFID) || ',' || MAX(e.BRRFID) || ',' || MAX(e.BRFFID) AS FID, " +
|
||||||
|
" REGEXP_REPLACE(LISTAGG(COALESCE(releaseEng.ENNM, e.RSTCD), ',') WITHIN GROUP (ORDER BY NVL(releaseEng.ORDER_INDEX, 999999), e.RSTCD), '([^,]+)(,\\1)+', '\\1') AS RELEASE " +
|
||||||
|
" FROM SD_RPIMNFISH_R f " +
|
||||||
|
" LEFT JOIN SD_ENGFR_R e ON e.ID = f.RPIMN_ID " +
|
||||||
|
" LEFT JOIN SD_ENGINFO_B_H releaseEng ON releaseEng.STCD = e.RSTCD AND NVL(releaseEng.IS_DELETED, 0) = 0 " +
|
||||||
|
" WHERE f.FTP IS NOT NULL " +
|
||||||
|
" AND NVL(f.IS_DELETED, 0) = 0 " +
|
||||||
|
" AND NVL(e.IS_DELETED, 0) = 0 " +
|
||||||
|
" GROUP BY e.STCD, TO_CHAR(e.TM, 'YYYY'), TRUNC(e.TM, 'YYYY'), f.FTP " +
|
||||||
|
") fishAgg " +
|
||||||
|
"LEFT JOIN ( " +
|
||||||
|
" SELECT " +
|
||||||
|
" e.STCD AS STCD, " +
|
||||||
|
" TO_CHAR(e.TM, 'YYYY') AS FLYR, " +
|
||||||
|
" SUM(f.FCNT) AS TOTALFCNT " +
|
||||||
|
" FROM SD_RPIMNFISH_R f " +
|
||||||
|
" LEFT JOIN SD_ENGFR_R e ON e.ID = f.RPIMN_ID " +
|
||||||
|
" WHERE f.FTP IS NOT NULL " +
|
||||||
|
" AND NVL(f.IS_DELETED, 0) = 0 " +
|
||||||
|
" AND NVL(e.IS_DELETED, 0) = 0 " +
|
||||||
|
" GROUP BY e.STCD, TO_CHAR(e.TM, 'YYYY') " +
|
||||||
|
") totalAgg ON totalAgg.STCD = fishAgg.STCD AND totalAgg.FLYR = fishAgg.FLYR " +
|
||||||
|
"LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = fishAgg.STCD AND NVL(eng.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = eng.BASE_ID AND NVL(hb.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN SD_HBRV_DIC hbrv ON hbrv.BASEID = eng.BASE_ID AND hbrv.HBRVCD = eng.HBRVCD " +
|
||||||
|
" AND NVL(hbrv.IS_DELETED, 0) = 0 AND NVL(hbrv.ENABLED, 1) = 1 " +
|
||||||
|
"LEFT JOIN V_SD_FISHDICTORY_B fishView ON fishAgg.FTP = fishView.FISH_ID " +
|
||||||
|
" AND (fishView.RVCD = eng.HBRVCD OR fishView.RVCD = 'ZY') ";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbFishRunSelectSql(List<String> selectFields) {
|
||||||
|
Map<String, String> selectMap = new LinkedHashMap<>();
|
||||||
|
selectMap.put("stcd", "t.stcd AS stcd");
|
||||||
|
selectMap.put("stnm", "t.stnm AS stnm");
|
||||||
|
selectMap.put("ftp", "t.ftp AS ftp");
|
||||||
|
selectMap.put("ftpName", "t.ftpName AS ftpName");
|
||||||
|
selectMap.put("baseId", "t.baseId AS baseId");
|
||||||
|
selectMap.put("baseName", "t.baseName AS baseName");
|
||||||
|
selectMap.put("flyr", "t.flyr AS flyr");
|
||||||
|
selectMap.put("fcnt", "t.fcnt AS fcnt");
|
||||||
|
selectMap.put("totalFcnt", "t.totalFcnt AS totalFcnt");
|
||||||
|
selectMap.put("fid", "t.fid AS fid");
|
||||||
|
selectMap.put("release", "t.release AS release");
|
||||||
|
selectMap.put("baseStepSort", "t.baseStepSort AS baseStepSort");
|
||||||
|
selectMap.put("siteStepSort", "t.siteStepSort AS siteStepSort");
|
||||||
|
selectMap.put("rvcdStepSort", "t.rvcdStepSort AS rvcdStepSort");
|
||||||
|
selectMap.put("rstcdStepSort", "t.rstcdStepSort AS rstcdStepSort");
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(selectFields)) {
|
||||||
|
return String.join(", ", selectMap.values());
|
||||||
|
}
|
||||||
|
List<String> actualColumns = new ArrayList<>();
|
||||||
|
for (String field : selectFields) {
|
||||||
|
String column = selectMap.get(field);
|
||||||
|
if (StrUtil.isNotBlank(column)) {
|
||||||
|
actualColumns.add(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (actualColumns.isEmpty()) {
|
||||||
|
actualColumns.addAll(selectMap.values());
|
||||||
|
}
|
||||||
|
return String.join(", ", actualColumns);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbFishRunFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildFbFishRunLeafCondition(filter, paramMap, indexHolder);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildFbFishRunFilterCondition(child, paramMap, indexHolder);
|
||||||
|
if (StrUtil.isNotBlank(childSql)) {
|
||||||
|
conditions.add("(" + childSql + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conditions.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return String.join("or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ", conditions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbFishRunLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
String field = filter.getField();
|
||||||
|
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||||
|
Object value = filter.getValue();
|
||||||
|
|
||||||
|
if ("keyword".equalsIgnoreCase(field)) {
|
||||||
|
if (value == null || StrUtil.isBlank(String.valueOf(value))) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String key = "fbFishRunP" + indexHolder[0]++;
|
||||||
|
paramMap.put(key, "%" + String.valueOf(value).trim() + "%");
|
||||||
|
return "(t.STNM LIKE #{map." + key + "} OR t.BASENAME LIKE #{map." + key + "} OR t.FTPNAME LIKE #{map." + key + "} OR t.RELEASE LIKE #{map." + key + "})";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("flyr".equalsIgnoreCase(field)) {
|
||||||
|
return buildFbFishRunYearCondition(filter, paramMap, indexHolder);
|
||||||
|
}
|
||||||
|
if ("rstcd".equalsIgnoreCase(field)) {
|
||||||
|
field = "stcd";
|
||||||
|
}
|
||||||
|
|
||||||
|
String column = mapFbFishRunColumn(field);
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if ("isnull".equals(operator)) {
|
||||||
|
return column + " IS NULL";
|
||||||
|
}
|
||||||
|
if ("isnotnull".equals(operator)) {
|
||||||
|
return column + " IS NOT NULL";
|
||||||
|
}
|
||||||
|
if ("in".equals(operator)) {
|
||||||
|
List<Object> values = normalizeValues(value);
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (Object item : values) {
|
||||||
|
String key = "fbFishRunP" + indexHolder[0]++;
|
||||||
|
paramMap.put(key, item);
|
||||||
|
placeholders.add("#{map." + key + "}");
|
||||||
|
}
|
||||||
|
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = "fbFishRunP" + indexHolder[0]++;
|
||||||
|
return switch (operator) {
|
||||||
|
case "eq" -> {
|
||||||
|
paramMap.put(key, value);
|
||||||
|
yield column + " = #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "neq" -> {
|
||||||
|
paramMap.put(key, value);
|
||||||
|
yield column + " <> #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "contains" -> {
|
||||||
|
paramMap.put(key, "%" + value + "%");
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "startswith" -> {
|
||||||
|
paramMap.put(key, value + "%");
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "endswith" -> {
|
||||||
|
paramMap.put(key, "%" + value);
|
||||||
|
yield column + " LIKE #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "gt" -> {
|
||||||
|
paramMap.put(key, value);
|
||||||
|
yield column + " > #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "gte" -> {
|
||||||
|
paramMap.put(key, value);
|
||||||
|
yield column + " >= #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "lt" -> {
|
||||||
|
paramMap.put(key, value);
|
||||||
|
yield column + " < #{map." + key + "}";
|
||||||
|
}
|
||||||
|
case "lte" -> {
|
||||||
|
paramMap.put(key, value);
|
||||||
|
yield column + " <= #{map." + key + "}";
|
||||||
|
}
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbFishRunYearCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
Object value = filter.getValue();
|
||||||
|
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String text = String.valueOf(value).trim();
|
||||||
|
if (text.contains(",") && text.contains("-")) {
|
||||||
|
String[] split = text.split(",");
|
||||||
|
if (split.length == 2) {
|
||||||
|
String startKey = "fbFishRunP" + indexHolder[0]++;
|
||||||
|
String endKey = "fbFishRunP" + indexHolder[0]++;
|
||||||
|
paramMap.put(startKey, split[0].trim());
|
||||||
|
paramMap.put(endKey, split[1].trim());
|
||||||
|
return "t.FLYR_DATE >= " + buildValueExpr(startKey, true, split[0].trim()) +
|
||||||
|
" AND t.FLYR_DATE <= " + buildValueExpr(endKey, true, split[1].trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("in".equals(operator)) {
|
||||||
|
List<Object> values = normalizeValues(value);
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (Object item : values) {
|
||||||
|
String key = "fbFishRunP" + indexHolder[0]++;
|
||||||
|
paramMap.put(key, item);
|
||||||
|
placeholders.add("#{map." + key + "}");
|
||||||
|
}
|
||||||
|
return "t.FLYR IN (" + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
String key = "fbFishRunP" + indexHolder[0]++;
|
||||||
|
paramMap.put(key, text);
|
||||||
|
return switch (operator) {
|
||||||
|
case "eq" -> "t.FLYR = TO_CHAR(TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY')";
|
||||||
|
case "neq" -> "t.FLYR <> TO_CHAR(TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY')";
|
||||||
|
case "gt" -> "t.FLYR > TO_CHAR(TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY')";
|
||||||
|
case "gte" -> "t.FLYR >= TO_CHAR(TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY')";
|
||||||
|
case "lt" -> "t.FLYR < TO_CHAR(TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY')";
|
||||||
|
case "lte" -> "t.FLYR <= TO_CHAR(TO_DATE(#{map." + key + "}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY')";
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapFbFishRunColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "stcd" -> "t.STCD";
|
||||||
|
case "stnm" -> "t.STNM";
|
||||||
|
case "ftp" -> "t.FTP";
|
||||||
|
case "ftpName" -> "t.FTPNAME";
|
||||||
|
case "baseId" -> "t.BASEID";
|
||||||
|
case "baseName" -> "t.BASENAME";
|
||||||
|
case "fcnt" -> "t.FCNT";
|
||||||
|
case "totalFcnt" -> "t.TOTALFCNT";
|
||||||
|
case "fid" -> "t.FID";
|
||||||
|
case "release" -> "t.RELEASE";
|
||||||
|
case "baseStepSort" -> "t.BASESTEPSORT";
|
||||||
|
case "siteStepSort" -> "t.SITESTEPSORT";
|
||||||
|
case "rvcdStepSort" -> "t.RVCDSTEPSORT";
|
||||||
|
case "rstcdStepSort" -> "t.RSTCDSTEPSORT";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbFishRunOrderBySql(List<DataSourceRequest.SortDescriptor> sortList) {
|
||||||
|
if (CollUtil.isEmpty(sortList)) {
|
||||||
|
return " ORDER BY t.FLYR ASC, t.STCD ASC, t.FTP ASC";
|
||||||
|
}
|
||||||
|
List<String> orderColumns = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.SortDescriptor sortDescriptor : sortList) {
|
||||||
|
if (sortDescriptor == null || StrUtil.isBlank(sortDescriptor.getField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String field = sortDescriptor.getField();
|
||||||
|
if ("rstcd".equalsIgnoreCase(field)) {
|
||||||
|
field = "stcd";
|
||||||
|
}
|
||||||
|
String column = "flyr".equalsIgnoreCase(field) ? "t.FLYR" : mapFbFishRunColumn(field);
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String dir = "desc".equalsIgnoreCase(sortDescriptor.getDir()) || "des".equalsIgnoreCase(sortDescriptor.getDir()) ? "DESC" : "ASC";
|
||||||
|
orderColumns.add(column + " " + dir + " NULLS LAST");
|
||||||
|
}
|
||||||
|
if (orderColumns.isEmpty()) {
|
||||||
|
return " ORDER BY t.FLYR ASC, t.STCD ASC, t.FTP ASC";
|
||||||
|
}
|
||||||
|
return " ORDER BY " + String.join(", ", orderColumns);
|
||||||
|
}
|
||||||
|
|
||||||
private DataSourceResult<FpFpssrlQueryVo> queryQgcFpssrlDetailList(DataSourceRequest dataSourceRequest,
|
private DataSourceResult<FpFpssrlQueryVo> queryQgcFpssrlDetailList(DataSourceRequest dataSourceRequest,
|
||||||
DataSourceLoadOptionsBase loadOptions) {
|
DataSourceLoadOptionsBase loadOptions) {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user