opt:优化WQL分页查询改成selectcount(0);优化子卷包装关系页面及下载数限制
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package org.nl.config;
|
package org.nl.config;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.github.pagehelper.parser.CountSqlParser;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -12,7 +13,7 @@ import javax.sql.DataSource;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DataBaseConfig {
|
public class DataBaseConfig {
|
||||||
|
public static CountSqlParser countSqlParser = new CountSqlParser();
|
||||||
@Primary
|
@Primary
|
||||||
@Bean(name = "dataSource")
|
@Bean(name = "dataSource")
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ public class ResultBean implements Serializable, Cloneable {
|
|||||||
int nTotalSize = 0;
|
int nTotalSize = 0;
|
||||||
if (null != rows2 && rows2.size() > 0) {
|
if (null != rows2 && rows2.size() > 0) {
|
||||||
JSONObject jrow2 = this.row2jsonobject((BasicDynaBean) rows2.get(0));
|
JSONObject jrow2 = this.row2jsonobject((BasicDynaBean) rows2.get(0));
|
||||||
nTotalSize = jrow2.getInteger("page_totalrecordnum");
|
nTotalSize = jrow2.getInteger("count(0)");
|
||||||
}
|
}
|
||||||
jres.put("totalElements", nTotalSize);
|
jres.put("totalElements", nTotalSize);
|
||||||
return jres;
|
return jres;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.nl.modules.wql.core.engine.syntax;
|
package org.nl.modules.wql.core.engine.syntax;
|
||||||
|
|
||||||
|
import com.github.pagehelper.parser.CountSqlParser;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.config.DataBaseConfig;
|
||||||
import org.nl.modules.wql.WQLCore;
|
import org.nl.modules.wql.WQLCore;
|
||||||
import org.nl.modules.wql.core.DataType;
|
import org.nl.modules.wql.core.DataType;
|
||||||
import org.nl.modules.wql.core.bean.ErrorBean;
|
import org.nl.modules.wql.core.bean.ErrorBean;
|
||||||
@@ -410,7 +412,8 @@ public class wqlSELECT extends IWQL {
|
|||||||
//对sql进行特殊处理,找出和第一个select配对的from,并把中间全部换为1
|
//对sql进行特殊处理,找出和第一个select配对的from,并把中间全部换为1
|
||||||
// String page_sql = change_1(wo.wp.sSQL);
|
// String page_sql = change_1(wo.wp.sSQL);
|
||||||
String page_sql = wo.wp.sSQL;
|
String page_sql = wo.wp.sSQL;
|
||||||
wo.wp.sSQL = "select count(*) PAGE_TOTALRECORDNUM from ( " + page_sql + ") TOTALRECORDVIEW";
|
String countSql = DataBaseConfig.countSqlParser.getSmartCountSql(page_sql, "0");
|
||||||
|
wo.wp.sSQL = countSql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//2.3、加session并执行
|
//2.3、加session并执行
|
||||||
|
|||||||
@@ -25,10 +25,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.function.Supplier;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lyd
|
* @author lyd
|
||||||
@@ -99,9 +98,11 @@ public class SubpackagerelationServiceImpl implements SubpackagerelationService
|
|||||||
map.put("date_of_production", date_of_production);
|
map.put("date_of_production", date_of_production);
|
||||||
map.put("date_of_FG_inbound", date_of_FG_inbound);
|
map.put("date_of_FG_inbound", date_of_FG_inbound);
|
||||||
map.put("status", status);
|
map.put("status", status);
|
||||||
|
JSONObject json = WQL.getWO("PDM_BI_SUBPACKAGER01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page),"workorder_id desc");
|
||||||
|
JSONArray content = json.getJSONArray("content");
|
||||||
JSONObject json = WQL.getWO("PDM_BI_SUBPACKAGER01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time DESC");
|
String ids = content.stream().map(a -> ((JSONObject) a).getString("workorder_id")).collect(Collectors.joining("','"));
|
||||||
|
JSONArray subs = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("workorder_id in ('" + ids + "')").getResultJSONArray(0);
|
||||||
|
json.put("content",subs);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ public class SubpackagerelationServiceImpl implements SubpackagerelationService
|
|||||||
// 子卷号 是否计划外子卷 sap批次 制造完成日期 入库日期 状态
|
// 子卷号 是否计划外子卷 sap批次 制造完成日期 入库日期 状态
|
||||||
|
|
||||||
JSONObject map = new JSONObject();
|
JSONObject map = new JSONObject();
|
||||||
map.put("flag", "1");
|
map.put("flag", "4");
|
||||||
if (ObjectUtil.isNotEmpty(material_code)) {
|
if (ObjectUtil.isNotEmpty(material_code)) {
|
||||||
map.put("material_code", "%" + material_code + "%");
|
map.put("material_code", "%" + material_code + "%");
|
||||||
}
|
}
|
||||||
@@ -229,9 +230,8 @@ public class SubpackagerelationServiceImpl implements SubpackagerelationService
|
|||||||
map.put("date_of_production", date_of_production);
|
map.put("date_of_production", date_of_production);
|
||||||
map.put("date_of_FG_inbound", date_of_FG_inbound);
|
map.put("date_of_FG_inbound", date_of_FG_inbound);
|
||||||
map.put("status", status);
|
map.put("status", status);
|
||||||
|
map.put("limits", "10000");
|
||||||
JSONArray resultJSONArray = WQL.getWO("PDM_BI_SUBPACKAGER01").addParamMap(map).process().getResultJSONArray(0);
|
JSONArray resultJSONArray = WQL.getWO("PDM_BI_SUBPACKAGER01").addParamMap(map).process().getResultJSONArray(0);
|
||||||
|
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
for (int i = 0; i < resultJSONArray.size(); i++) {
|
for (int i = 0; i < resultJSONArray.size(); i++) {
|
||||||
JSONObject json = resultJSONArray.getJSONObject(i);
|
JSONObject json = resultJSONArray.getJSONObject(i);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
输入.customer_name TYPEAS s_string
|
输入.customer_name TYPEAS s_string
|
||||||
输入.customer_description TYPEAS s_string
|
输入.customer_description TYPEAS s_string
|
||||||
输入.package_box_sn TYPEAS s_string
|
输入.package_box_sn TYPEAS s_string
|
||||||
|
输入.limits TYPEAS s_string
|
||||||
输入.container_name TYPEAS s_string
|
输入.container_name TYPEAS s_string
|
||||||
输入.is_un_plan_production TYPEAS s_string
|
输入.is_un_plan_production TYPEAS s_string
|
||||||
输入.sap_pcsn TYPEAS s_string
|
输入.sap_pcsn TYPEAS s_string
|
||||||
@@ -52,7 +53,7 @@
|
|||||||
IF 输入.flag = "1"
|
IF 输入.flag = "1"
|
||||||
PAGEQUERY
|
PAGEQUERY
|
||||||
SELECT
|
SELECT
|
||||||
*
|
workorder_id
|
||||||
FROM
|
FROM
|
||||||
pdm_bi_subpackagerelation
|
pdm_bi_subpackagerelation
|
||||||
WHERE
|
WHERE
|
||||||
@@ -112,14 +113,13 @@
|
|||||||
|
|
||||||
IF 输入.flag = "2"
|
IF 输入.flag = "2"
|
||||||
PAGEQUERY
|
PAGEQUERY
|
||||||
SELECT DISTINCT
|
SELECT
|
||||||
sub.*
|
sub.workorder_id
|
||||||
FROM
|
FROM
|
||||||
pdm_bi_subpackagerelation sub
|
pdm_bi_subpackagerelation sub
|
||||||
INNER JOIN pdm_bi_subpackagerelationrecord record ON sub.container_name = record.container_name
|
INNER JOIN ( SELECT subre.container_name FROM pdm_bi_subpackagerelationrecord subre WHERE 1 = 1 GROUP BY subre.container_name ) c ON sub.container_name = c.container_name
|
||||||
WHERE
|
WHERE
|
||||||
1=1
|
1 =1
|
||||||
|
|
||||||
OPTION 输入.material_code <> ""
|
OPTION 输入.material_code <> ""
|
||||||
sub.product_name LIKE 输入.material_code
|
sub.product_name LIKE 输入.material_code
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
@@ -175,13 +175,12 @@
|
|||||||
IF 输入.flag = "3"
|
IF 输入.flag = "3"
|
||||||
PAGEQUERY
|
PAGEQUERY
|
||||||
SELECT
|
SELECT
|
||||||
sub.*
|
sub.workorder_id
|
||||||
FROM
|
FROM
|
||||||
pdm_bi_subpackagerelation sub
|
pdm_bi_subpackagerelation sub
|
||||||
LEFT JOIN pdm_bi_subpackagerelationrecord record ON sub.container_name = record.container_name
|
LEFT JOIN pdm_bi_subpackagerelationrecord record ON sub.container_name = record.container_name
|
||||||
WHERE
|
WHERE
|
||||||
IFNULL(record.bill_code,'') = ''
|
record.bill_code is null
|
||||||
|
|
||||||
OPTION 输入.material_code <> ""
|
OPTION 输入.material_code <> ""
|
||||||
sub.product_name LIKE 输入.material_code
|
sub.product_name LIKE 输入.material_code
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
@@ -233,3 +232,64 @@
|
|||||||
ENDSELECT
|
ENDSELECT
|
||||||
ENDPAGEQUERY
|
ENDPAGEQUERY
|
||||||
ENDIF
|
ENDIF
|
||||||
|
IF 输入.flag = "4"
|
||||||
|
QUERY
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
pdm_bi_subpackagerelation
|
||||||
|
WHERE
|
||||||
|
1=1
|
||||||
|
OPTION 输入.material_code <> ""
|
||||||
|
product_name LIKE 输入.material_code
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.package_box_sn <> ""
|
||||||
|
package_box_sn LIKE 输入.package_box_sn
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.material_name <> ""
|
||||||
|
product_description LIKE 输入.material_name
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.sale_order_name <> ""
|
||||||
|
sale_order_name LIKE 输入.sale_order_name
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.customer_name <> ""
|
||||||
|
customer_name LIKE 输入.customer_name
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.customer_description <> ""
|
||||||
|
customer_description LIKE 输入.customer_description
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.container_name <> ""
|
||||||
|
container_name LIKE 输入.container_name
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.sap_pcsn <> ""
|
||||||
|
sap_pcsn LIKE 输入.sap_pcsn
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.is_un_plan_production <> ""
|
||||||
|
is_un_plan_production = 输入.is_un_plan_production
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.date_of_production <> ""
|
||||||
|
date_of_production = 输入.date_of_production
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.date_of_FG_inbound <> ""
|
||||||
|
date_of_FG_inbound = 输入.date_of_FG_inbound
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.status <> ""
|
||||||
|
status = 输入.status
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.limits <> ""
|
||||||
|
1=1 order by workorder_id desc limit 0,输入.limits
|
||||||
|
ENDOPTION
|
||||||
|
ENDSELECT
|
||||||
|
ENDQUERY
|
||||||
|
ENDIF
|
||||||
|
|||||||
Reference in New Issue
Block a user