feat: 查询站类信息列表(支持模糊搜索和STTP_CODE过滤)
This commit is contained in:
parent
36892c222d
commit
757efd4d62
@ -2959,7 +2959,7 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService {
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Cacheable(cacheNames = "wtCache#3600", keyGenerator = "cacheKeyByUserGenerator")
|
||||
@Cacheable(cacheNames = "wtCache#3600", keyGenerator = "cacheKeyByUserGenerator")
|
||||
public DataSourceResult<WaterTempMapVO> getEngTempPointListKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceResult<WaterTempMapVO> dataSourceResult = new DataSourceResult<>();
|
||||
dataSourceResult.setAggregates(new HashMap<>());
|
||||
|
||||
@ -11,6 +11,7 @@ import com.yfd.platform.qgc_base.service.ISdHbrvDicService;
|
||||
import com.yfd.platform.qgc_env.wt.service.SdWtMonitorService;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.MsAlongB;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.PowerDto;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.SttpDto;
|
||||
import com.yfd.platform.qgc_lygk.along.service.IMsAlongBService;
|
||||
import com.yfd.platform.qgc_sys.mapcfg.service.IMapmoduleBService;
|
||||
import com.yfd.platform.utils.DataSourceRequestUtil;
|
||||
@ -99,4 +100,11 @@ public class MsAlongBController {
|
||||
DataSourceResult<PowerDto> result = msAlongBService.getKendoPage(dataSourceRequest);
|
||||
return ResponseResult.successData(result);
|
||||
}
|
||||
|
||||
@PostMapping("/sttp/GetKendoList")
|
||||
@Operation(summary = "查询站类信息列表(支持模糊搜索和STTP_CODE过滤)")
|
||||
public ResponseResult getSttpList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
DataSourceResult<SttpDto> result = msAlongBService.getSttpList(dataSourceRequest);
|
||||
return ResponseResult.successData(result);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.yfd.platform.qgc_lygk.along.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 站类信息查询结果 DTO
|
||||
*/
|
||||
@Data
|
||||
public class SttpDto {
|
||||
|
||||
private String id;
|
||||
private String sttpCode;
|
||||
private String sttpName;
|
||||
private String sttpSname;
|
||||
private String description;
|
||||
private Integer enabled;
|
||||
private String parentId;
|
||||
private String fullPath;
|
||||
private Integer treeLevel;
|
||||
private Integer hasChildren;
|
||||
private String introduce;
|
||||
private String logo;
|
||||
private String inffile;
|
||||
private Integer internal;
|
||||
private Integer orderIndex;
|
||||
private String recordUser;
|
||||
private Date recordTime;
|
||||
private String modifyUser;
|
||||
private Date modifyTime;
|
||||
}
|
||||
@ -5,6 +5,7 @@ import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.MsAlongB;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.PowerDto;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.SttpDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -28,6 +29,14 @@ public interface IMsAlongBService extends IService<MsAlongB> {
|
||||
|
||||
DataSourceResult<PowerDto> getKendoPage(DataSourceRequest dataSourceRequest);
|
||||
|
||||
/**
|
||||
* 查询站类信息列表(支持模糊搜索和STTP_CODE过滤)
|
||||
*
|
||||
* @param dataSourceRequest 数据源请求
|
||||
* @return 数据源结果
|
||||
*/
|
||||
DataSourceResult<SttpDto> getSttpList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
// /**
|
||||
// * 保存或更新沿程配置
|
||||
// *
|
||||
|
||||
@ -13,6 +13,7 @@ import com.yfd.platform.qgc_base.domain.SdRvcdDic;
|
||||
import com.yfd.platform.qgc_base.mapper.SdRvcdDicMapper;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.MsAlongB;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.PowerDto;
|
||||
import com.yfd.platform.qgc_lygk.along.domain.SttpDto;
|
||||
import com.yfd.platform.qgc_lygk.along.mapper.MsAlongBMapper;
|
||||
import com.yfd.platform.qgc_lygk.along.service.IMsAlongBService;
|
||||
import com.yfd.platform.utils.CodeToNameMetadataBo;
|
||||
@ -154,6 +155,127 @@ public class MsAlongBServiceImpl extends ServiceImpl<MsAlongBMapper, MsAlongB> i
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<SttpDto> getSttpList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM SD_STTP_B WHERE NVL(IS_DELETED, 0) = 0");
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
|
||||
// 解析过滤条件
|
||||
if (dataSourceRequest != null && dataSourceRequest.getFilter() != null) {
|
||||
String filterSql = parseSttpFilter(dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql);
|
||||
}
|
||||
}
|
||||
|
||||
// 解析排序
|
||||
if (dataSourceRequest != null && CollUtil.isNotEmpty(dataSourceRequest.getSort())) {
|
||||
List<String> orderList = new ArrayList<>();
|
||||
for (SortDescriptor sort : dataSourceRequest.getSort()) {
|
||||
String field = sort.getField();
|
||||
if (StrUtil.isBlank(field) || !isSafeSttpField(field)) continue;
|
||||
String direction = "asc".equalsIgnoreCase(sort.getDir()) ? "ASC" : "DESC";
|
||||
orderList.add(field + " " + direction);
|
||||
}
|
||||
if (!orderList.isEmpty()) {
|
||||
sql.append(" ORDER BY ").append(String.join(", ", orderList));
|
||||
}
|
||||
} else {
|
||||
sql.append(" ORDER BY ORDER_INDEX ASC, STTP_CODE ASC");
|
||||
}
|
||||
|
||||
// 执行分页查询
|
||||
Page<?> page = loadOptions == null ? null :
|
||||
QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<SttpDto> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page, sql.toString(), paramMap, SttpDto.class
|
||||
);
|
||||
|
||||
DataSourceResult<SttpDto> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归解析站类过滤条件
|
||||
*/
|
||||
private String parseSttpFilter(FilterDescriptor filter, Map<String, Object> paramMap, int[] paramIndex) {
|
||||
if (filter == null) return "";
|
||||
|
||||
List<FilterDescriptor> childFilters = filter.getFilters();
|
||||
if (CollUtil.isNotEmpty(childFilters)) {
|
||||
List<String> childConditions = new ArrayList<>();
|
||||
for (FilterDescriptor child : childFilters) {
|
||||
String childSql = parseSttpFilter(child, paramMap, paramIndex);
|
||||
if (StrUtil.isNotBlank(childSql)) {
|
||||
childConditions.add(childSql);
|
||||
}
|
||||
}
|
||||
if (childConditions.isEmpty()) return "";
|
||||
String logic = StrUtil.isNotBlank(filter.getLogic()) ? filter.getLogic() : "and";
|
||||
String connector = "and".equalsIgnoreCase(logic) ? " AND " : " OR ";
|
||||
return "(" + String.join(connector, childConditions) + ")";
|
||||
}
|
||||
|
||||
String field = filter.getField();
|
||||
Object value = filter.getValue();
|
||||
String operator = filter.getOperator();
|
||||
|
||||
if (StrUtil.isBlank(field)) return "";
|
||||
if (!isSafeSttpField(field)) return "";
|
||||
|
||||
String paramKey = "stp" + paramIndex[0]++;
|
||||
paramMap.put(paramKey, value);
|
||||
|
||||
if ("contains".equalsIgnoreCase(operator)) {
|
||||
return field + " LIKE '%' || #{map." + paramKey + "} || '%'";
|
||||
} else if ("startswith".equalsIgnoreCase(operator)) {
|
||||
return field + " LIKE #{map." + paramKey + "} || '%'";
|
||||
} else if ("endswith".equalsIgnoreCase(operator)) {
|
||||
return field + " LIKE '%' || #{map." + paramKey + "}";
|
||||
} else if ("neq".equalsIgnoreCase(operator)) {
|
||||
return field + " != #{map." + paramKey + "}";
|
||||
} else if ("gt".equalsIgnoreCase(operator)) {
|
||||
return field + " > #{map." + paramKey + "}";
|
||||
} else if ("gte".equalsIgnoreCase(operator)) {
|
||||
return field + " >= #{map." + paramKey + "}";
|
||||
} else if ("lt".equalsIgnoreCase(operator)) {
|
||||
return field + " < #{map." + paramKey + "}";
|
||||
} else if ("lte".equalsIgnoreCase(operator)) {
|
||||
return field + " <= #{map." + paramKey + "}";
|
||||
} else if ("isnull".equalsIgnoreCase(operator)) {
|
||||
paramMap.remove(paramKey);
|
||||
return field + " IS NULL";
|
||||
} else if ("isnotnull".equalsIgnoreCase(operator)) {
|
||||
paramMap.remove(paramKey);
|
||||
return field + " IS NOT NULL";
|
||||
} else if (value == null) {
|
||||
paramMap.remove(paramKey);
|
||||
return "";
|
||||
} else {
|
||||
// 默认 eq
|
||||
return field + " = #{map." + paramKey + "}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 站类表安全字段白名单
|
||||
*/
|
||||
private boolean isSafeSttpField(String field) {
|
||||
if (StrUtil.isBlank(field)) return false;
|
||||
Set<String> validFields = new HashSet<>(Arrays.asList(
|
||||
"ID", "STTP_CODE", "STTP_NAME", "STTP_SNAME", "DESCRIPTION",
|
||||
"ENABLED", "PARENT_ID", "FULL_PATH", "TREE_LEVEL", "HAS_CHILDREN",
|
||||
"INTRODUCE", "LOGO", "INFFILE", "INTERNAL", "ORDER_INDEX",
|
||||
"IS_DELETED"
|
||||
));
|
||||
return validFields.contains(field.toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归解析 FilterDescriptor(完美适配你的内部类结构)
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user