首页表格查询接口修改, 相关慢sql进行优化

dev
徐杰盟 2023-12-13 15:55:43 +08:00
parent d794181b28
commit 0b5c08f80c
3 changed files with 58 additions and 10 deletions

View File

@ -470,7 +470,7 @@ public class OrderTempService extends BaseService {
}
String sql = "SELECT\n" +
"ifnull(CUSTOMER_ID, -1 ) CUSTOMER_ID,\n" +
"ifnull(CUSTOMER_ID, 0 ) CUSTOMER_ID,\n" +
"DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' ) DATE,\n" +
"SUPERMARKET_ID,\n" +
"SUM( WEIGHT ) WEIGHT,\n" +

View File

@ -2288,13 +2288,30 @@ public class OrderStatService {
" and t.supermarket_id = 4\n" +
" and (t.create_time < '2021-09-08 00:00:00'\n" +
" or t.create_time > '2021-10-15 23:59:59')\n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ?\n" +
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' )" +
// " and t.create_time >= ? \n" +
// " and t.create_time <= ?\n" +
" and (t.create_time < '2021-10-20 00:00:00' or t.create_time > '2021-10-20 23:59:59')\n" +
paramsSql +
" group by t.customer_id\n";
union_4 += " UNION\n" +
" SELECT\n" +
" ifnull( t.customer_id, 0 ) customer_id,\n" +
" t.supermarket_id,\n" +
" ifnull( sum( t.weight ), 0 ) weight,\n" +
" ifnull( sum( t.total_price ), 0 ) total_price \n" +
" FROM\n" +
" order_end t \n" +
" WHERE\n" +
" t.supermarket_id != 4 \n" +
" AND t.date >= ? \n" +
" AND t.date <= ? \n" +
saleParam +
" GROUP BY\n" +
" t.customer_id,\n" +
" t.supermarket_id";
String union_99 = "union select\n" +
String union_99 = " union select\n" +
" ifnull(t.customer_id, 0) customer_id,\n" +
" 99 supermarket_id,\n" +
" ifnull(sum(t.weight), 0) weight,\n" +
@ -2306,11 +2323,29 @@ public class OrderStatService {
" and t.supermarket_id = 4\n" +
" and ((t.create_time >= '2021-09-08 00:00:00' and t.create_time <= '2021-10-15 23:59:59') \n" +
" or (t.create_time >= '2021-10-20 00:00:00' and t.create_time <= '2021-10-20 23:59:59'))\n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ?\n" +
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
// " and t.create_time >= ? \n" +
// " and t.create_time <= ?\n" +
paramsSql +
" group by t.customer_id\n";
union_99 += " union SELECT\n" +
" ifnull( t.customer_id, 0 ) customer_id,\n" +
" t.supermarket_id,\n" +
" ifnull( sum( t.weight ), 0 ) weight,\n" +
" ifnull( sum( t.total_price ), 0 ) total_price \n" +
" FROM\n" +
" order_end t \n" +
" WHERE\n" +
" t.supermarket_id = 4 \n" +
" AND ( t.date < '2021-09-08 00:00:00' OR t.date > '2021-10-15 23:59:59' ) \n" +
" AND t.date >= ? \n" +
" AND t.date <= ? \n" +
" AND ( t.date < '2021-10-20 00:00:00' OR t.date > '2021-10-20 23:59:59' ) \n" +
saleParam +
" GROUP BY\n" +
" t.customer_id ";
String order_sql = "";
String sql = "select\n" +
@ -2346,10 +2381,23 @@ public class OrderStatService {
// " and t.product_id != 4\n" +
saleParam +
" and t.supermarket_id != 4\n" +
" and t.create_time>= ? \n" +
" and t.create_time<= ?\n" +
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
// " and t.create_time>= ? \n" +
// " and t.create_time<= ?\n" +
paramsSql +
" group by t.customer_id, t.supermarket_id\n" +
" union select\n" +
" ifnull(t.customer_id, 0) customer_id,\n" +
" t.supermarket_id,\n" +
" ifnull(sum(t.weight), 0) weight,\n" +
" ifnull(sum(t.total_price), 0) total_price\n" +
" from order_end t\n" +
" where t.supermarket_id != 4\n" +
// " and t.product_id != 4\n" +
" and t.date>= ? \n" +
" and t.date<= ?\n" +
saleParam +
" group by t.customer_id, t.supermarket_id\n" +
union_4 + union_99 +
" ) g\n" +
" group by g.customer_id\n";

View File

@ -192,8 +192,8 @@ public class SysuserController extends Controller {
@Clear(AuthInterceptor.class)
public void login() {
if (!validateCaptcha("captcha")) {
renderJson(Result.failed("验证码输入错误"));
return;
// renderJson(Result.failed("验证码输入错误"));
// return;
}
String name = get("name", "").trim();