feat: 鱼类增殖站基础信息列表
This commit is contained in:
parent
23f3a73cf9
commit
1942b6c193
@ -0,0 +1,29 @@
|
|||||||
|
package com.yfd.platform.qgc_env.fb.controller;
|
||||||
|
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.qgc_env.fb.service.FbStationService;
|
||||||
|
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("/fb/msstbprpt")
|
||||||
|
@Tag(name = "鱼类增殖站基础信息")
|
||||||
|
@Validated
|
||||||
|
public class FbMsstbprptController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FbStationService fbStationService;
|
||||||
|
|
||||||
|
@PostMapping("/GetKendoList")
|
||||||
|
@Operation(summary = "鱼类增殖站基础信息列表")
|
||||||
|
public ResponseResult getKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(fbStationService.getMsstbprptList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,6 +14,7 @@ import com.yfd.platform.qgc_env.fb.entity.vo.YearRpStatisticsVo;
|
|||||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface FbStationService {
|
public interface FbStationService {
|
||||||
|
|
||||||
@ -21,6 +22,8 @@ public interface FbStationService {
|
|||||||
|
|
||||||
DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult<Map<String, Object>> getMsstbprptList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<FbFlDataVo> getFbFlDataKendoListCust(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbFlDataVo> getFbFlDataKendoListCust(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<FbMsfbrdmQgcVo> getQgcMsfbrdmKendoListCust(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbMsfbrdmQgcVo> getQgcMsfbrdmKendoListCust(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -83,6 +83,65 @@ public class FbStationServiceImpl implements FbStationService {
|
|||||||
return queryFbFlDataDetailList(dataSourceRequest, loadOptions);
|
return queryFbFlDataDetailList(dataSourceRequest, loadOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<Map<String, Object>> getMsstbprptList(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
String filterSql = buildFbMsstbprptFilterCondition(
|
||||||
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||||
|
paramMap,
|
||||||
|
new int[]{0}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(dataSourceRequest == null ? null : dataSourceRequest.getGroup())) {
|
||||||
|
StringBuilder groupedBaseSql = new StringBuilder("SELECT * FROM (")
|
||||||
|
.append(buildFbMsstbprptBaseSql())
|
||||||
|
.append(") t WHERE 1 = 1 ");
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
groupedBaseSql.append(" AND ").append(filterSql).append(" ");
|
||||||
|
}
|
||||||
|
String groupedSql = buildFbMsstbprptGroupSql(groupedBaseSql.toString(), dataSourceRequest.getGroup());
|
||||||
|
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(null, groupedSql, paramMap);
|
||||||
|
|
||||||
|
DataSourceResult<Map<String, Object>> result = new DataSourceResult<>();
|
||||||
|
GroupingInfo[] groupInfos = loadOptions == null ? null : loadOptions.getGroup();
|
||||||
|
if (Boolean.TRUE.equals(dataSourceRequest.getGroupResultFlat())) {
|
||||||
|
result.setData((List<Map<String, Object>>) (List<?>) new GroupHelper().faltGroup(
|
||||||
|
rows,
|
||||||
|
groupInfos == null ? Collections.emptyList() : Arrays.asList(groupInfos)
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
result.setData((List<Map<String, Object>>) (List<?>) new GroupHelper().group(
|
||||||
|
rows,
|
||||||
|
groupInfos == null ? Collections.emptyList() : Arrays.asList(groupInfos)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
result.setTotal(rows.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> selectedFields = resolveFbMsstbprptSelectFields(dataSourceRequest == null ? null : dataSourceRequest.getSelect());
|
||||||
|
StringBuilder sql = new StringBuilder("SELECT ")
|
||||||
|
.append(buildFbMsstbprptDetailSelectSql(selectedFields))
|
||||||
|
.append(" FROM (")
|
||||||
|
.append(buildFbMsstbprptBaseSql())
|
||||||
|
.append(") t WHERE 1 = 1 ");
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
sql.append(" AND ").append(filterSql).append(" ");
|
||||||
|
}
|
||||||
|
sql.append(buildFbMsstbprptOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||||
|
|
||||||
|
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(page, sql.toString(), paramMap);
|
||||||
|
|
||||||
|
DataSourceResult<Map<String, Object>> result = new DataSourceResult<>();
|
||||||
|
result.setData(normalizeFbMsstbprptRows(rows, selectedFields));
|
||||||
|
result.setTotal(page != null ? page.getTotal() : rows.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<FbMsfbrdmQgcVo> getQgcMsfbrdmKendoListCust(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<FbMsfbrdmQgcVo> getQgcMsfbrdmKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
@ -344,6 +403,405 @@ public class FbStationServiceImpl implements FbStationService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildFbMsstbprptBaseSql() {
|
||||||
|
return "SELECT " +
|
||||||
|
"fb.STCD AS stcd, " +
|
||||||
|
"fb.STCD AS id, " +
|
||||||
|
"fb.STNM AS stnm, " +
|
||||||
|
"fb.STTP AS sttp, " +
|
||||||
|
"fb.STTP AS sttpCode, " +
|
||||||
|
"sttp.STTP_NAME AS sttpName, " +
|
||||||
|
"sttp.FULL_PATH AS sttpFullPath, " +
|
||||||
|
"sttp.TREE_LEVEL AS sttpTreeLevel, " +
|
||||||
|
"fb.LGTD AS lgtd, " +
|
||||||
|
"fb.LTTD AS lttd, " +
|
||||||
|
"fb.ELEV AS dtmel, " +
|
||||||
|
"fb.STLC AS stlc, " +
|
||||||
|
"fb.USFL AS usfl, " +
|
||||||
|
"fb.RSTCD AS rstcd, " +
|
||||||
|
"eng.ENNM AS ennm, " +
|
||||||
|
"fb.BASE_ID AS baseId, " +
|
||||||
|
"hb.BASENAME AS baseName, " +
|
||||||
|
"fb.HBRVCD AS hbrvcd, " +
|
||||||
|
"hbrv.HBRVNM AS hbrvcdName, " +
|
||||||
|
"eng.RVCD AS rvcd, " +
|
||||||
|
"rv.RVNM AS rvcdName, " +
|
||||||
|
"eng.ADDVCD AS addvcd, " +
|
||||||
|
"addv.ADDVNM AS addvcdName, " +
|
||||||
|
"eng.COUNTRY AS country, " +
|
||||||
|
"country.COUNTRY_NAME AS countryName, " +
|
||||||
|
"eng.HYCD AS hycd, " +
|
||||||
|
"CAST(NULL AS VARCHAR2(200)) AS hynm, " +
|
||||||
|
"fb.STDSDT AS stdsdt, " +
|
||||||
|
"fb.PSTSTDT AS pststdt, " +
|
||||||
|
"fb.PESSTDT AS pesstdt, " +
|
||||||
|
"fb.SWDT AS ststdt, " +
|
||||||
|
"fb.JCDT AS jcdt, " +
|
||||||
|
"fb.WDDT AS stwddt, " +
|
||||||
|
"fb.INTRODUCE AS introduce, " +
|
||||||
|
"fb.INTRODUCE AS precis, " +
|
||||||
|
"fb.LOGO AS logo, " +
|
||||||
|
"fb.INFFILE AS inffile, " +
|
||||||
|
"fb.DTIN AS dtin, " +
|
||||||
|
"CASE NVL(fb.DTIN, 0) WHEN 1 THEN '是' WHEN 0 THEN '否' ELSE NULL END AS dtinName, " +
|
||||||
|
"fb.DTIN_TM AS dtinTm, " +
|
||||||
|
"fb.BLDSTT_CODE AS bldsttCode, " +
|
||||||
|
"CASE fb.BLDSTT_CODE WHEN 0 THEN '0' WHEN 1 THEN '1' WHEN 2 THEN '2' ELSE NULL END AS bldsttCcode, " +
|
||||||
|
"CASE fb.BLDSTT_CODE WHEN 0 THEN '未建/规划' WHEN 1 THEN '在建' WHEN 2 THEN '已建' ELSE NULL END AS bldsttCcodeName, " +
|
||||||
|
"fb.INV AS inv, " +
|
||||||
|
"fb.INVINMN AS invinmn, " +
|
||||||
|
"fb.ZZFLAR AS zzflar, " +
|
||||||
|
"fb.ZZFLGY AS zzflgy, " +
|
||||||
|
"fb.ZZFLYZMS AS zzflyzms, " +
|
||||||
|
"fb.ZZFLBJFS AS zzflbjfs, " +
|
||||||
|
"fb.ZZFLDX AS zzfldx, " +
|
||||||
|
"fb.ZZFLCNT AS zzflcnt, " +
|
||||||
|
"fb.ZZFLFLLC AS zzflfllc, " +
|
||||||
|
"fb.ZZFLTM AS zzfltm, " +
|
||||||
|
"fb.ZZFLRW AS zzflrw, " +
|
||||||
|
"fb.DSUN AS dsun, " +
|
||||||
|
"fb.JBTXCS AS jbtxcs, " +
|
||||||
|
"fb.DTFRQCY AS dtfrqcy, " +
|
||||||
|
"fb.REMARK AS remark, " +
|
||||||
|
"fb.VLSR AS vlsr, " +
|
||||||
|
"fb.VLSR_TM AS vlsrTm, " +
|
||||||
|
"fb.ORDER_INDEX AS orderIndex " +
|
||||||
|
"FROM SD_FBRD_B_H fb " +
|
||||||
|
"LEFT JOIN SD_STTP_B sttp ON sttp.STTP_CODE = fb.STTP AND NVL(sttp.ENABLE, 1) = 1 " +
|
||||||
|
"LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = fb.RSTCD AND NVL(eng.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = fb.BASE_ID AND NVL(hb.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN SD_HBRV_DIC hbrv ON hbrv.HBRVCD = fb.HBRVCD AND hbrv.BASEID = fb.BASE_ID " +
|
||||||
|
" AND NVL(hbrv.IS_DELETED, 0) = 0 AND NVL(hbrv.ENABLED, 1) = 1 " +
|
||||||
|
"LEFT JOIN SD_RVCD_DIC rv ON rv.RVCD = eng.RVCD " +
|
||||||
|
"LEFT JOIN SD_ADDVCD_DIC addv ON addv.ADDVCD = eng.ADDVCD " +
|
||||||
|
"LEFT JOIN SD_COUNTRY_B country ON country.COUNTRY_ID = eng.COUNTRY AND NVL(country.ENABLED, 1) = 1 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> resolveFbMsstbprptSelectFields(List<String> select) {
|
||||||
|
List<String> fields = CollUtil.isEmpty(select)
|
||||||
|
? new ArrayList<>(List.of(
|
||||||
|
"stcd", "stnm", "sttpCode", "sttpName", "lgtd", "lttd", "stlc", "rstcd", "ennm",
|
||||||
|
"baseId", "baseName", "hbrvcd", "hbrvcdName", "introduce", "logo", "precis",
|
||||||
|
"dtin", "dtinName", "dtinTm", "bldsttCcode", "bldsttCcodeName", "inv",
|
||||||
|
"zzflar", "zzflgy", "zzflyzms", "zzflbjfs", "zzfldx", "zzflcnt", "zzflfllc",
|
||||||
|
"zzfltm", "zzflrw", "dsun", "jbtxcs", "dtfrqcy", "remark", "vlsr", "vlsrTm"
|
||||||
|
))
|
||||||
|
: new ArrayList<>(select);
|
||||||
|
LinkedHashSet<String> uniqueFields = new LinkedHashSet<>();
|
||||||
|
for (String field : fields) {
|
||||||
|
if (StrUtil.isNotBlank(field)) {
|
||||||
|
uniqueFields.add(field.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uniqueFields.isEmpty()) {
|
||||||
|
uniqueFields.add("stcd");
|
||||||
|
}
|
||||||
|
return new ArrayList<>(uniqueFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbMsstbprptDetailSelectSql(List<String> selectFields) {
|
||||||
|
List<String> selectParts = new ArrayList<>();
|
||||||
|
for (String field : selectFields) {
|
||||||
|
String column = mapFbMsstbprptColumn(field);
|
||||||
|
if (StrUtil.isNotBlank(column)) {
|
||||||
|
selectParts.add(column + " AS \"" + field + "\"");
|
||||||
|
} else {
|
||||||
|
selectParts.add("NULL AS \"" + field + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selectParts.isEmpty()) {
|
||||||
|
selectParts.add("t.stcd AS \"stcd\"");
|
||||||
|
}
|
||||||
|
return String.join(", ", selectParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbMsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildFbMsstbprptLeafCondition(filter, paramMap, indexHolder);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildFbMsstbprptFilterCondition(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 buildFbMsstbprptLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
String column = mapFbMsstbprptColumn(filter.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||||
|
Object value = filter.getValue();
|
||||||
|
if ("isnull".equals(operator)) {
|
||||||
|
return column + " IS NULL";
|
||||||
|
}
|
||||||
|
if ("isnotnull".equals(operator)) {
|
||||||
|
return column + " IS NOT NULL";
|
||||||
|
}
|
||||||
|
if ("in".equals(operator)) {
|
||||||
|
List<Object> values = normalizeFbMsstbprptValues(value);
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (Object item : values) {
|
||||||
|
String key = "fbMsstbprptP" + indexHolder[0]++;
|
||||||
|
paramMap.put(key, item);
|
||||||
|
placeholders.add("#{map." + key + "}");
|
||||||
|
}
|
||||||
|
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = "fbMsstbprptP" + 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 buildFbMsstbprptOrderBySql(List<DataSourceRequest.SortDescriptor> sortDescriptors) {
|
||||||
|
if (CollUtil.isEmpty(sortDescriptors)) {
|
||||||
|
return " ORDER BY t.baseId ASC, t.orderIndex ASC, t.stcd ASC";
|
||||||
|
}
|
||||||
|
List<String> orderByParts = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.SortDescriptor descriptor : sortDescriptors) {
|
||||||
|
if (descriptor == null || StrUtil.isBlank(descriptor.getField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String column = mapFbMsstbprptColumn(descriptor.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String direction = "desc".equalsIgnoreCase(descriptor.getDir()) ? "DESC" : "ASC";
|
||||||
|
orderByParts.add(column + " " + direction);
|
||||||
|
}
|
||||||
|
if (orderByParts.isEmpty()) {
|
||||||
|
return " ORDER BY t.baseId ASC, t.orderIndex ASC, t.stcd ASC";
|
||||||
|
}
|
||||||
|
return " ORDER BY " + String.join(", ", orderByParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbMsstbprptGroupSql(String baseSql, List<DataSourceRequest.GroupDescriptor> groups) {
|
||||||
|
if (CollUtil.isEmpty(groups)) {
|
||||||
|
return baseSql;
|
||||||
|
}
|
||||||
|
List<DataSourceRequest.GroupDescriptor> validGroups = groups.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(group -> StrUtil.isNotBlank(group.getField()))
|
||||||
|
.filter(group -> StrUtil.isNotBlank(mapFbMsstbprptColumn(group.getField())))
|
||||||
|
.toList();
|
||||||
|
if (validGroups.isEmpty()) {
|
||||||
|
return baseSql;
|
||||||
|
}
|
||||||
|
List<String> selectParts = new ArrayList<>();
|
||||||
|
List<String> groupByParts = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.GroupDescriptor descriptor : validGroups) {
|
||||||
|
String column = mapFbMsstbprptColumn(descriptor.getField());
|
||||||
|
selectParts.add(column + " AS " + descriptor.getField().toUpperCase());
|
||||||
|
selectParts.add("COUNT(*) AS COUNT_" + descriptor.getField().toUpperCase());
|
||||||
|
groupByParts.add(column);
|
||||||
|
}
|
||||||
|
return "SELECT " + String.join(", ", selectParts) +
|
||||||
|
" FROM (" + baseSql + ") t GROUP BY " + String.join(", ", groupByParts) +
|
||||||
|
buildFbMsstbprptGroupOrderBySql(validGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFbMsstbprptGroupOrderBySql(List<DataSourceRequest.GroupDescriptor> groups) {
|
||||||
|
List<String> orderByParts = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.GroupDescriptor descriptor : groups) {
|
||||||
|
String column = mapFbMsstbprptColumn(descriptor.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String direction = "desc".equalsIgnoreCase(descriptor.getDir()) ? "DESC" : "ASC";
|
||||||
|
orderByParts.add(column + " " + direction);
|
||||||
|
}
|
||||||
|
if (orderByParts.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return " ORDER BY " + String.join(", ", orderByParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapFbMsstbprptColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "id" -> "t.id";
|
||||||
|
case "stcd" -> "t.stcd";
|
||||||
|
case "stnm" -> "t.stnm";
|
||||||
|
case "sttp" -> "t.sttp";
|
||||||
|
case "sttpCode" -> "t.sttpCode";
|
||||||
|
case "sttpName" -> "t.sttpName";
|
||||||
|
case "sttpFullPath" -> "t.sttpFullPath";
|
||||||
|
case "sttpTreeLevel" -> "t.sttpTreeLevel";
|
||||||
|
case "lgtd" -> "t.lgtd";
|
||||||
|
case "lttd" -> "t.lttd";
|
||||||
|
case "dtmel" -> "t.dtmel";
|
||||||
|
case "stlc" -> "t.stlc";
|
||||||
|
case "usfl" -> "t.usfl";
|
||||||
|
case "rstcd" -> "t.rstcd";
|
||||||
|
case "ennm" -> "t.ennm";
|
||||||
|
case "baseId" -> "t.baseId";
|
||||||
|
case "baseName" -> "t.baseName";
|
||||||
|
case "hbrvcd" -> "t.hbrvcd";
|
||||||
|
case "hbrvcdName" -> "t.hbrvcdName";
|
||||||
|
case "rvcd" -> "t.rvcd";
|
||||||
|
case "rvcdName" -> "t.rvcdName";
|
||||||
|
case "addvcd" -> "t.addvcd";
|
||||||
|
case "addvcdName" -> "t.addvcdName";
|
||||||
|
case "country" -> "t.country";
|
||||||
|
case "countryName" -> "t.countryName";
|
||||||
|
case "hycd" -> "t.hycd";
|
||||||
|
case "hynm" -> "t.hynm";
|
||||||
|
case "stdsdt" -> "t.stdsdt";
|
||||||
|
case "pststdt" -> "t.pststdt";
|
||||||
|
case "pesstdt" -> "t.pesstdt";
|
||||||
|
case "ststdt" -> "t.ststdt";
|
||||||
|
case "jcdt" -> "t.jcdt";
|
||||||
|
case "stwddt" -> "t.stwddt";
|
||||||
|
case "introduce" -> "t.introduce";
|
||||||
|
case "precis" -> "t.precis";
|
||||||
|
case "logo" -> "t.logo";
|
||||||
|
case "inffile" -> "t.inffile";
|
||||||
|
case "dtin" -> "t.dtin";
|
||||||
|
case "dtinName" -> "t.dtinName";
|
||||||
|
case "dtinTm" -> "t.dtinTm";
|
||||||
|
case "bldsttCode" -> "t.bldsttCode";
|
||||||
|
case "bldsttCcode" -> "t.bldsttCcode";
|
||||||
|
case "bldsttCcodeName" -> "t.bldsttCcodeName";
|
||||||
|
case "inv" -> "t.inv";
|
||||||
|
case "invinmn" -> "t.invinmn";
|
||||||
|
case "zzflar" -> "t.zzflar";
|
||||||
|
case "zzflgy" -> "t.zzflgy";
|
||||||
|
case "zzflyzms" -> "t.zzflyzms";
|
||||||
|
case "zzflbjfs" -> "t.zzflbjfs";
|
||||||
|
case "zzfldx" -> "t.zzfldx";
|
||||||
|
case "zzflcnt" -> "t.zzflcnt";
|
||||||
|
case "zzflfllc" -> "t.zzflfllc";
|
||||||
|
case "zzfltm" -> "t.zzfltm";
|
||||||
|
case "zzflrw" -> "t.zzflrw";
|
||||||
|
case "dsun" -> "t.dsun";
|
||||||
|
case "jbtxcs" -> "t.jbtxcs";
|
||||||
|
case "dtfrqcy" -> "t.dtfrqcy";
|
||||||
|
case "remark" -> "t.remark";
|
||||||
|
case "vlsr" -> "t.vlsr";
|
||||||
|
case "vlsrTm" -> "t.vlsrTm";
|
||||||
|
case "orderIndex" -> "t.orderIndex";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Object> normalizeFbMsstbprptValues(Object value) {
|
||||||
|
List<Object> values = new ArrayList<>();
|
||||||
|
if (value instanceof List<?> list) {
|
||||||
|
for (Object item : list) {
|
||||||
|
if (item != null) {
|
||||||
|
values.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
if (value instanceof Object[] array) {
|
||||||
|
for (Object item : array) {
|
||||||
|
if (item != null) {
|
||||||
|
values.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
if (value != null) {
|
||||||
|
values.add(value);
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> normalizeFbMsstbprptRows(List<Map<String, Object>> rows, List<String> fields) {
|
||||||
|
if (CollUtil.isEmpty(rows)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
|
for (Map<String, Object> row : rows) {
|
||||||
|
Map<String, Object> normalizedRow = new LinkedHashMap<>();
|
||||||
|
for (String field : fields) {
|
||||||
|
normalizedRow.put(field, getIgnoreCaseValue(row, field));
|
||||||
|
}
|
||||||
|
result.add(normalizedRow);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getIgnoreCaseValue(Map<String, Object> row, String field) {
|
||||||
|
if (row == null || StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (row.containsKey(field)) {
|
||||||
|
return row.get(field);
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Object> entry : row.entrySet()) {
|
||||||
|
if (entry.getKey() != null && entry.getKey().equalsIgnoreCase(field)) {
|
||||||
|
return entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private String buildOverviewStationListSql(String baseId,
|
private String buildOverviewStationListSql(String baseId,
|
||||||
List<String> stcdList,
|
List<String> stcdList,
|
||||||
Map<String, Object> paramMap) {
|
Map<String, Object> paramMap) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user