feat: 栖息地增加监测表数据接口
This commit is contained in:
parent
389f49bb1d
commit
f757060292
@ -39,4 +39,10 @@ public class FhHabitatController {
|
|||||||
public ResponseResult getDefaultFhList(@RequestBody FhDefaultAo fhDefaultAo) {
|
public ResponseResult getDefaultFhList(@RequestBody FhDefaultAo fhDefaultAo) {
|
||||||
return ResponseResult.successData(fhHabitatService.getDefaultFhList(fhDefaultAo));
|
return ResponseResult.successData(fhHabitatService.getDefaultFhList(fhDefaultAo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/stTbYs/GetStTbYsBVoKendoListCust")
|
||||||
|
@Operation(summary = "水质监测信息查询")
|
||||||
|
public ResponseResult getStTbYsBVoKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(fhHabitatService.getStTbYsBVoKendoListCust(dataSourceRequest));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,6 @@ public interface FhHabitatService {
|
|||||||
DataSourceResult<HabitatVo> getKendoListCustom(DataSourceRequest dataSourceRequest);
|
DataSourceResult<HabitatVo> getKendoListCustom(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
FhDefaultVo getDefaultFhList(FhDefaultAo fhDefaultAo);
|
FhDefaultVo getDefaultFhList(FhDefaultAo fhDefaultAo);
|
||||||
|
|
||||||
|
DataSourceResult getStTbYsBVoKendoListCust(DataSourceRequest dataSourceRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import com.yfd.platform.env.fh.entity.ao.FhDefaultAo;
|
|||||||
import com.yfd.platform.env.fh.entity.vo.FhDefaultVo;
|
import com.yfd.platform.env.fh.entity.vo.FhDefaultVo;
|
||||||
import com.yfd.platform.env.fh.entity.vo.HabitatVo;
|
import com.yfd.platform.env.fh.entity.vo.HabitatVo;
|
||||||
import com.yfd.platform.env.fh.service.FhHabitatService;
|
import com.yfd.platform.env.fh.service.FhHabitatService;
|
||||||
|
import com.yfd.platform.env.wq.entity.vo.StTbYsVo;
|
||||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -869,6 +870,185 @@ public class FhHabitatServiceImpl implements FhHabitatService {
|
|||||||
return " ORDER BY " + String.join(", ", orderItems);
|
return " ORDER BY " + String.join(", ", orderItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult getStTbYsBVoKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT ")
|
||||||
|
.append("y.ID AS id, ")
|
||||||
|
.append("y.TB_ID AS tbId, ")
|
||||||
|
.append("t.TB_NAME AS tbName, ")
|
||||||
|
.append("t.TB_CODE AS tbCode, ")
|
||||||
|
.append("y.DESCRIPTION AS description, ")
|
||||||
|
.append("y.YS AS ys, ")
|
||||||
|
.append("y.YS_SHOW_NAME AS ysShowName, ")
|
||||||
|
.append("y.SHOW_CONTROL AS showControl, ")
|
||||||
|
.append("TO_CHAR(y.ENABLE) AS enable, ")
|
||||||
|
.append("y.ORDER_INDEX AS orderIndex ")
|
||||||
|
.append("FROM ST_TB_YS_B y ")
|
||||||
|
.append("INNER JOIN ST_TB_B t ON t.ID = y.TB_ID AND NVL(t.IS_DELETED, 0) = 0 ")
|
||||||
|
.append("WHERE NVL(y.IS_DELETED, 0) = 0 ");
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
String filterSql = buildStTbYsFilterCondition(
|
||||||
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||||
|
paramMap,
|
||||||
|
new int[]{0}
|
||||||
|
);
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
sql.append(" AND ").append(filterSql).append(" ");
|
||||||
|
}
|
||||||
|
sql.append(buildStTbYsOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||||
|
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
PageInfo pageInfo = loadOptions == null ? null : QgcQueryWrapperUtil.getPageInfo(loadOptions);
|
||||||
|
Page<?> page = pageInfo != null && pageInfo.getHasPageInfo() ? pageInfo.getPage() : null;
|
||||||
|
List<StTbYsVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, StTbYsVo.class);
|
||||||
|
|
||||||
|
DataSourceResult<StTbYsVo> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildStTbYsFilterCondition(DataSourceRequest.FilterDescriptor root,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] paramIndex) {
|
||||||
|
if (root == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(root.getField())) {
|
||||||
|
return buildStTbYsLeafCondition(root, paramMap, paramIndex);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(root.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> parts = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : root.getFilters()) {
|
||||||
|
String sql = buildStTbYsFilterCondition(child, paramMap, paramIndex);
|
||||||
|
if (StrUtil.isNotBlank(sql)) {
|
||||||
|
parts.add("(" + sql + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parts.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String logic = "or".equalsIgnoreCase(root.getLogic()) ? " OR " : " AND ";
|
||||||
|
return String.join(logic, parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildStTbYsLeafCondition(DataSourceRequest.FilterDescriptor descriptor,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] paramIndex) {
|
||||||
|
String column = mapStTbYsColumn(descriptor.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String operator = StrUtil.blankToDefault(descriptor.getOperator(), "eq").toLowerCase();
|
||||||
|
Object value = descriptor.getValue();
|
||||||
|
if ("isnull".equals(operator)) {
|
||||||
|
return column + " IS NULL";
|
||||||
|
}
|
||||||
|
if ("isnotnull".equals(operator)) {
|
||||||
|
return column + " IS NOT NULL";
|
||||||
|
}
|
||||||
|
String paramName = "stTbYsParam" + paramIndex[0]++;
|
||||||
|
switch (operator) {
|
||||||
|
case "eq":
|
||||||
|
paramMap.put(paramName, value);
|
||||||
|
return column + " = #{map." + paramName + "}";
|
||||||
|
case "neq":
|
||||||
|
paramMap.put(paramName, value);
|
||||||
|
return column + " <> #{map." + paramName + "}";
|
||||||
|
case "contains":
|
||||||
|
paramMap.put(paramName, "%" + value + "%");
|
||||||
|
return column + " LIKE #{map." + paramName + "}";
|
||||||
|
case "startswith":
|
||||||
|
paramMap.put(paramName, value + "%");
|
||||||
|
return column + " LIKE #{map." + paramName + "}";
|
||||||
|
case "endswith":
|
||||||
|
paramMap.put(paramName, "%" + value);
|
||||||
|
return column + " LIKE #{map." + paramName + "}";
|
||||||
|
case "gt":
|
||||||
|
paramMap.put(paramName, value);
|
||||||
|
return column + " > #{map." + paramName + "}";
|
||||||
|
case "gte":
|
||||||
|
paramMap.put(paramName, value);
|
||||||
|
return column + " >= #{map." + paramName + "}";
|
||||||
|
case "lt":
|
||||||
|
paramMap.put(paramName, value);
|
||||||
|
return column + " < #{map." + paramName + "}";
|
||||||
|
case "lte":
|
||||||
|
paramMap.put(paramName, value);
|
||||||
|
return column + " <= #{map." + paramName + "}";
|
||||||
|
case "in":
|
||||||
|
if (!(value instanceof List) || CollUtil.isEmpty((List<?>) value)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
int idx = 0;
|
||||||
|
for (Object item : (List<?>) value) {
|
||||||
|
String inParam = paramName + "_" + idx++;
|
||||||
|
paramMap.put(inParam, item);
|
||||||
|
placeholders.add("#{map." + inParam + "}");
|
||||||
|
}
|
||||||
|
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String buildStTbYsOrderBySql(List<DataSourceRequest.SortDescriptor> sortList) {
|
||||||
|
if (CollUtil.isEmpty(sortList)) {
|
||||||
|
return " ORDER BY LOWER(t.TB_NAME) ASC, NVL(y.ORDER_INDEX, 999999) ASC, y.YS ASC";
|
||||||
|
}
|
||||||
|
List<String> orders = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.SortDescriptor sortDescriptor : sortList) {
|
||||||
|
String column = mapStTbYsColumn(sortDescriptor.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
orders.add(column + " " + ("desc".equalsIgnoreCase(sortDescriptor.getDir()) ? "DESC" : "ASC"));
|
||||||
|
}
|
||||||
|
if (orders.isEmpty()) {
|
||||||
|
return " ORDER BY LOWER(t.TB_NAME) ASC, NVL(y.ORDER_INDEX, 999999) ASC, y.YS ASC";
|
||||||
|
}
|
||||||
|
return " ORDER BY " + String.join(", ", orders);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapStTbYsColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
switch (field) {
|
||||||
|
case "id":
|
||||||
|
return "y.ID";
|
||||||
|
case "tbId":
|
||||||
|
return "y.TB_ID";
|
||||||
|
case "tbName":
|
||||||
|
return "t.TB_NAME";
|
||||||
|
case "tbCode":
|
||||||
|
return "t.TB_CODE";
|
||||||
|
case "description":
|
||||||
|
return "y.DESCRIPTION";
|
||||||
|
case "ys":
|
||||||
|
return "y.YS";
|
||||||
|
case "ysShowName":
|
||||||
|
return "y.YS_SHOW_NAME";
|
||||||
|
case "showControl":
|
||||||
|
return "y.SHOW_CONTROL";
|
||||||
|
case "enable":
|
||||||
|
return "y.ENABLE";
|
||||||
|
case "orderIndex":
|
||||||
|
return "y.ORDER_INDEX";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private String buildGroupSql(String baseSql, GroupingInfo[] groups) {
|
private String buildGroupSql(String baseSql, GroupingInfo[] groups) {
|
||||||
List<String> fields = Arrays.stream(groups)
|
List<String> fields = Arrays.stream(groups)
|
||||||
.map(GroupingInfo::getSelector)
|
.map(GroupingInfo::getSelector)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user