dev:优化

This commit is contained in:
2023-12-05 15:43:59 +08:00
parent 8cab2ee440
commit f256124e79
15 changed files with 46 additions and 34 deletions

View File

@@ -1,6 +1,5 @@
package org.nl.modules.wql.core.engine.syntax;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.wql.WQLCore;
import org.nl.modules.wql.core.DataType;
@@ -160,7 +159,7 @@ public class wqlSELECT extends IWQL {
if ((wo.wp.PAGE_PAGESTART != -99 && wo.wp.PAGE_PAGERECORDNUM != -99) && (wo.wp.SORT_ORDERBYFIELD.length() > 0)) {
// String sqlTmp = "select * from("+wo.wp.sSQL+") TOTALRECORDVIEW order by " + wo.wp.SORT_ORDERBYFIELD + " limit "+wo.wp.PAGE_PAGESTART+","+wo.wp.PAGE_PAGERECORDNUM;
// String sqlTmp = wo.wp.sSQL+" order by " + wo.wp.SORT_ORDERBYFIELD + " limit "+wo.wp.PAGE_PAGESTART+","+wo.wp.PAGE_PAGERECORDNUM;
// String sqlTmp = "select top "+wo.wp.PAGE_PAGERECORDNUM+"* FROM () WHERE ID NOT IN(SELECT TOP 45000 ID FROM ARTICLE ORDER BY YEAR DESC, ID DESC) ORDER BY YEAR DESC,ID DESC
// String sqlTmp = "select top "+wo.wp.PAGE_PAGERECORDNUM+"* FROM () WHERE ID NOT IN(SELECT TOP 45000 ID FROM ARTICLE ORDER BY YEAR DESC, ID DESC) ORDER BY YEAR DESC,ID DESC
String sqlTmp = "select * from (select row_number() over( order by " + wo.wp.SORT_ORDERBYFIELD + ") rownumber,* from (" + wo.wp.sSQL + ") b ) a1 where rownumber between " + (wo.wp.PAGE_PAGESTART + 1) + " and " + (wo.wp.PAGE_PAGESTART + wo.wp.PAGE_PAGERECORDNUM);
@@ -371,15 +370,10 @@ public class wqlSELECT extends IWQL {
//2.2、对分页进行处理
Set keySettTempTable = WQLCore.tempTableMap.keySet();
if (this.isInQuery && this.isPageQuery) {
if ((wo.wp.PAGE_PAGESTART != -99 && wo.wp.PAGE_PAGERECORDNUM != -99) ) {
if ((wo.wp.PAGE_PAGESTART != -99 && wo.wp.PAGE_PAGERECORDNUM != -99) && (wo.wp.SORT_ORDERBYFIELD.length() > 0)) {
// String sqlTmp = "select * from("+wo.wp.sSQL+") TOTALRECORDVIEW order by " + wo.wp.SORT_ORDERBYFIELD + " limit "+wo.wp.PAGE_PAGESTART+","+wo.wp.PAGE_PAGERECORDNUM;
String sqlTmp = wo.wp.sSQL + " order by " + wo.wp.SORT_ORDERBYFIELD + " limit " + wo.wp.PAGE_PAGESTART + "," + wo.wp.PAGE_PAGERECORDNUM;
if (StrUtil.isEmpty(wo.wp.SORT_ORDERBYFIELD)){
sqlTmp = wo.wp.sSQL + " limit " + wo.wp.PAGE_PAGESTART + "," + wo.wp.PAGE_PAGERECORDNUM;
}
// String sqlTmp = "select * from (select PAGE_SRCRESULTSET_1.*, row_number() over(order by " + wo.wp.SORT_ORDERBYFIELD + ")"
// + " as SORT_INDEXFIELDALIAS from ( "
// + wo.wp.sSQL
@@ -412,7 +406,7 @@ public class wqlSELECT extends IWQL {
log.error("关闭st,rs出错" + e.toString());
}
}
if (this.isPageQuery) {
if (wo.wp.SORT_ORDERBYFIELD.length() > 0) {
//对sql进行特殊处理找出和第一个select配对的from并把中间全部换为1
// String page_sql = change_1(wo.wp.sSQL);
String page_sql = wo.wp.sSQL;