feat: 条件过滤数据列表
This commit is contained in:
parent
1b7f52783d
commit
25aeb62e95
@ -2,6 +2,7 @@ package com.yfd.platform.qgc_base.controller;
|
||||
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.config.ResponseResult;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngRsvrcscdBVo;
|
||||
import com.yfd.platform.qgc_base.service.ISdEngInfoBHService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -50,4 +51,10 @@ public class SdEngMonitorController {
|
||||
public ResponseResult getEngPointKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(engInfoBHService.getEngPointKendoListCust(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/rsvrcscdb/GetKendoList")
|
||||
@Operation(summary = "条件过滤数据列表")
|
||||
public ResponseResult getRsvrcscdBKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(engInfoBHService.getRsvrcscdBKendoList(dataSourceRequest));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
package com.yfd.platform.qgc_base.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class EngRsvrcscdBVo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String rvcd;
|
||||
|
||||
private String rvcdName;
|
||||
|
||||
private String stcd;
|
||||
|
||||
private String ennm;
|
||||
|
||||
private Double srcdis;
|
||||
|
||||
private Double dmhg;
|
||||
|
||||
private Double normz;
|
||||
|
||||
private String recordUser;
|
||||
|
||||
private Date recordTime;
|
||||
|
||||
private String modifyUser;
|
||||
|
||||
private Date modifyTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
private Double lgtd;
|
||||
|
||||
private Double lttd;
|
||||
|
||||
private String stlc;
|
||||
}
|
||||
@ -9,6 +9,7 @@ import com.yfd.platform.qgc_base.domain.SdEngInfoBHRequest;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngBaseInfoVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngEiaapprovalVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngOperatVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngRsvrcscdBVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngPointVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngStInfoResultVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngVmsstbprptVo;
|
||||
@ -89,4 +90,6 @@ public interface ISdEngInfoBHService extends IService<SdEngInfoBH> {
|
||||
DataSourceResult getStbprpDataKendoListCust(DataSourceRequest dataSourceRequest, String tbCode, Boolean ignorePageLimit);
|
||||
|
||||
DataSourceResult<EngPointVo> getEngPointKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<EngRsvrcscdBVo> getRsvrcscdBKendoList(DataSourceRequest dataSourceRequest);
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import com.yfd.platform.qgc_base.domain.SdEngInfoBHRequest;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngBaseInfoVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngEiaapprovalVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngOperatVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngRsvrcscdBVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngPointVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngStbprpDataVo;
|
||||
import com.yfd.platform.qgc_base.domain.vo.EngStBaseInfoVo;
|
||||
@ -2928,4 +2929,198 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
|
||||
}
|
||||
return " ORDER BY " + String.join(", ", orderItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<EngRsvrcscdBVo> getRsvrcscdBKendoList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceResult<EngRsvrcscdBVo> result = new DataSourceResult<>();
|
||||
result.setAggregates(new HashMap<>());
|
||||
|
||||
if (dataSourceRequest == null) {
|
||||
result.setData(new ArrayList<>());
|
||||
result.setTotal(0L);
|
||||
return result;
|
||||
}
|
||||
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
|
||||
sql.append("SELECT ")
|
||||
.append("r.ID AS id, ")
|
||||
.append("r.RVCD AS rvcd, ")
|
||||
.append("rv.RVNM AS rvcdName, ")
|
||||
.append("r.STCD AS stcd, ")
|
||||
.append("r.ENNM AS ennm, ")
|
||||
.append("r.SRCDIS AS srcdis, ")
|
||||
.append("r.DMHG AS dmhg, ")
|
||||
.append("r.NORMZ AS normz, ")
|
||||
.append("r.RECORD_USER AS recordUser, ")
|
||||
.append("r.RECORD_TIME AS recordTime, ")
|
||||
.append("r.MODIFY_USER AS modifyUser, ")
|
||||
.append("r.MODIFY_TIME AS modifyTime, ")
|
||||
.append("r.IS_DELETED AS isDeleted, ")
|
||||
.append("eng.LGTD AS lgtd, ")
|
||||
.append("eng.LTTD AS lttd, ")
|
||||
.append("eng.STLC AS stlc ")
|
||||
.append("FROM SD_RSVRCSCD_B r ")
|
||||
.append("LEFT JOIN SD_RVCD_DIC rv ON rv.RVCD = r.RVCD ")
|
||||
.append("LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = r.STCD AND NVL(eng.IS_DELETED, 0) = 0 ")
|
||||
.append("WHERE NVL(r.IS_DELETED, 0) = 0 ");
|
||||
|
||||
String filterSql = buildRsvrcscdBFilterCondition(dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
||||
if (StringUtils.hasText(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql);
|
||||
}
|
||||
|
||||
sql.append(buildRsvrcscdBOrderBySql(dataSourceRequest.getSort()));
|
||||
|
||||
List<EngRsvrcscdBVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page, sql.toString(), paramMap, EngRsvrcscdBVo.class);
|
||||
result.setData(list);
|
||||
result.setTotal(page == null ? list.size() : page.getTotal());
|
||||
return result;
|
||||
}
|
||||
|
||||
private String buildRsvrcscdBFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (StringUtils.hasText(filter.getField())) {
|
||||
return buildRsvrcscdBLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
if (filter.getFilters() == null || filter.getFilters().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
List<String> childConditions = new ArrayList<>();
|
||||
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||
String childSql = buildRsvrcscdBFilterCondition(child, paramMap, indexHolder);
|
||||
if (StringUtils.hasText(childSql)) {
|
||||
childConditions.add("(" + childSql + ")");
|
||||
}
|
||||
}
|
||||
if (childConditions.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
String logic = "or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ";
|
||||
return String.join(logic, childConditions);
|
||||
}
|
||||
|
||||
private String buildRsvrcscdBLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
String column = mapRsvrcscdBColumn(filter.getField());
|
||||
if (!StringUtils.hasText(column)) {
|
||||
return "";
|
||||
}
|
||||
String operator = filter.getOperator() == null ? "eq" : filter.getOperator().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 = normalizeFilterValues(value);
|
||||
if (values.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
for (Object item : values) {
|
||||
String key = "rsvrParam" + indexHolder[0]++;
|
||||
paramMap.put(key, item);
|
||||
placeholders.add("#{map." + key + "}");
|
||||
}
|
||||
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||
}
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
String key = "rsvrParam" + 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 mapRsvrcscdBColumn(String field) {
|
||||
if (!StringUtils.hasText(field)) {
|
||||
return null;
|
||||
}
|
||||
return switch (field) {
|
||||
case "id" -> "r.ID";
|
||||
case "rvcd" -> "r.RVCD";
|
||||
case "rvcdName" -> "rv.RVNM";
|
||||
case "stcd" -> "r.STCD";
|
||||
case "ennm" -> "r.ENNM";
|
||||
case "srcdis" -> "r.SRCDIS";
|
||||
case "dmhg" -> "r.DMHG";
|
||||
case "normz" -> "r.NORMZ";
|
||||
case "lgtd" -> "eng.LGTD";
|
||||
case "lttd" -> "eng.LTTD";
|
||||
case "stlc" -> "eng.STLC";
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private String buildRsvrcscdBOrderBySql(List<DataSourceRequest.SortDescriptor> sortList) {
|
||||
if (sortList == null || sortList.isEmpty()) {
|
||||
return " ORDER BY r.RVCD ASC, r.STCD ASC";
|
||||
}
|
||||
List<String> orderItems = new ArrayList<>();
|
||||
for (DataSourceRequest.SortDescriptor sortDescriptor : sortList) {
|
||||
if (sortDescriptor == null || !StringUtils.hasText(sortDescriptor.getField())) {
|
||||
continue;
|
||||
}
|
||||
String column = mapRsvrcscdBColumn(sortDescriptor.getField());
|
||||
if (!StringUtils.hasText(column)) {
|
||||
continue;
|
||||
}
|
||||
String dir = "desc".equalsIgnoreCase(sortDescriptor.getDir()) || "des".equalsIgnoreCase(sortDescriptor.getDir()) ? "DESC" : "ASC";
|
||||
orderItems.add(column + " " + dir + " NULLS LAST");
|
||||
}
|
||||
if (orderItems.isEmpty()) {
|
||||
return " ORDER BY r.RVCD ASC, r.STCD ASC";
|
||||
}
|
||||
return " ORDER BY " + String.join(", ", orderItems);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public interface MsMapmoduleBMapper extends BaseMapper<MsMapmoduleB> {
|
||||
+ "<when test=\"templateId != null and templateId != ''\"> AND BMM.TEMPLATE_ID = #{templateId}</when>"
|
||||
+ "<otherwise> AND (BMM.TEMPLATE_ID IS NULL OR BMM.TEMPLATE_ID = '00000000-0000-0000-0000-000000000000')</otherwise>"
|
||||
+ "</choose>"
|
||||
+ "WHERE BML.ENABLE = 1 AND (BML.TYPE NOT IN ('YXDT','DXDT','SLDT') OR BML.TYPE IS NULL) "
|
||||
+ "WHERE BML.ENABLE = 1 AND BML.IS_DELETED =0 AND (BML.TYPE NOT IN ('YXDT','DXDT','SLDT') OR BML.TYPE IS NULL) "
|
||||
+ "ORDER BY BML.ORDER_INDEX"
|
||||
+ "</script>")
|
||||
List<MapLayerVo> getMapLayerTree(@Param("moduleId") String moduleId, @Param("sid") String sid,
|
||||
|
||||
@ -68,8 +68,10 @@ public class MapmoduleBController {
|
||||
// 3. 执行分页查询
|
||||
Page<MsMapmoduleB> resultPage;
|
||||
if (page != null) {
|
||||
wrapper.eq("IS_DELETED", 0);
|
||||
resultPage = mapmoduleBService.page(page, wrapper);
|
||||
} else {
|
||||
wrapper.eq("IS_DELETED", 0);
|
||||
List<MsMapmoduleB> list = mapmoduleBService.list(wrapper);
|
||||
resultPage = new Page<>();
|
||||
resultPage.setRecords(list);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user