首页表格查询接口修改, 相关慢sql进行优化
parent
d794181b28
commit
0b5c08f80c
|
|
@ -470,7 +470,7 @@ public class OrderTempService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
String sql = "SELECT\n" +
|
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" +
|
"DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' ) DATE,\n" +
|
||||||
"SUPERMARKET_ID,\n" +
|
"SUPERMARKET_ID,\n" +
|
||||||
"SUM( WEIGHT ) WEIGHT,\n" +
|
"SUM( WEIGHT ) WEIGHT,\n" +
|
||||||
|
|
|
||||||
|
|
@ -2288,13 +2288,30 @@ public class OrderStatService {
|
||||||
" and t.supermarket_id = 4\n" +
|
" and t.supermarket_id = 4\n" +
|
||||||
" and (t.create_time < '2021-09-08 00:00:00'\n" +
|
" and (t.create_time < '2021-09-08 00:00:00'\n" +
|
||||||
" or t.create_time > '2021-10-15 23:59:59')\n" +
|
" or t.create_time > '2021-10-15 23:59:59')\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 <= ?\n" +
|
||||||
" and (t.create_time < '2021-10-20 00:00:00' or t.create_time > '2021-10-20 23:59:59')\n" +
|
" and (t.create_time < '2021-10-20 00:00:00' or t.create_time > '2021-10-20 23:59:59')\n" +
|
||||||
paramsSql +
|
paramsSql +
|
||||||
" group by t.customer_id\n";
|
" 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" +
|
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||||
" 99 supermarket_id,\n" +
|
" 99 supermarket_id,\n" +
|
||||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||||
|
|
@ -2306,11 +2323,29 @@ public class OrderStatService {
|
||||||
" and t.supermarket_id = 4\n" +
|
" 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" +
|
" 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" +
|
" 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 >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||||
" and t.create_time <= ?\n" +
|
// " and t.create_time >= ? \n" +
|
||||||
|
// " and t.create_time <= ?\n" +
|
||||||
paramsSql +
|
paramsSql +
|
||||||
" group by t.customer_id\n";
|
" 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 order_sql = "";
|
||||||
|
|
||||||
String sql = "select\n" +
|
String sql = "select\n" +
|
||||||
|
|
@ -2346,10 +2381,23 @@ public class OrderStatService {
|
||||||
// " and t.product_id != 4\n" +
|
// " and t.product_id != 4\n" +
|
||||||
saleParam +
|
saleParam +
|
||||||
" and t.supermarket_id != 4\n" +
|
" and t.supermarket_id != 4\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" +
|
||||||
|
// " and t.create_time<= ?\n" +
|
||||||
paramsSql +
|
paramsSql +
|
||||||
" group by t.customer_id, t.supermarket_id\n" +
|
" 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 +
|
union_4 + union_99 +
|
||||||
" ) g\n" +
|
" ) g\n" +
|
||||||
" group by g.customer_id\n";
|
" group by g.customer_id\n";
|
||||||
|
|
|
||||||
|
|
@ -192,8 +192,8 @@ public class SysuserController extends Controller {
|
||||||
@Clear(AuthInterceptor.class)
|
@Clear(AuthInterceptor.class)
|
||||||
public void login() {
|
public void login() {
|
||||||
if (!validateCaptcha("captcha")) {
|
if (!validateCaptcha("captcha")) {
|
||||||
renderJson(Result.failed("验证码输入错误"));
|
// renderJson(Result.failed("验证码输入错误"));
|
||||||
return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = get("name", "").trim();
|
String name = get("name", "").trim();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue