Commit 07ecddbba5de62949f0aebc17d0271ae723f42c3

Authored by 王彬
1 parent c2d37ac2

test sql

src/main/java/com/taover/repository/UtilsSql.java
@@ -27,12 +27,12 @@ public class UtilsSql { @@ -27,12 +27,12 @@ public class UtilsSql {
27 if("SELECT".equals(currSubStr)) { 27 if("SELECT".equals(currSubStr)) {
28 ++selectSubSqlNum; 28 ++selectSubSqlNum;
29 currWindowIndex += 6; 29 currWindowIndex += 6;
30 - }else if(currSubStr.startsWith("FROM")) { 30 + }else if(currSubStr.startsWith(" FROM")) {
31 if(selectSubSqlNum == 1) { 31 if(selectSubSqlNum == 1) {
32 return currWindowIndex; 32 return currWindowIndex;
33 } 33 }
34 --selectSubSqlNum; 34 --selectSubSqlNum;
35 - currWindowIndex += 4; 35 + currWindowIndex += 5;
36 } 36 }
37 ++currWindowIndex; 37 ++currWindowIndex;
38 } 38 }
@@ -144,10 +144,19 @@ public class UtilsSql { @@ -144,10 +144,19 @@ public class UtilsSql {
144 } 144 }
145 145
146 public static void main(String[] args) { 146 public static void main(String[] args) {
  147 + String[] testSql = new String[] {
  148 + "select actionFrom t,(select * as 'fromCActio', dd as 'seelctsele\'ctd' from t) from www where 223",
  149 + "SELECT wxorder_order.refund_way refundWay,wxorder_order.refund_delivery_sn refundDeliverySn, (SELECT sum(wxorder_compensate.`ware_refund_money`) from `wxorder_compensate` where wxorder_compensate.`order_id` = wxorder_order.id) as wareRefundMoney,(SELECT sum(wxorder_compensate.`refund_money`) from `wxorder_compensate` where wxorder_compensate.`order_id` = wxorder_order.id) as refundMoney, wxorder_order.operate_refund_time applyCompensateTime,wxorder_order.refund_instructions refundInstructions, wxorder_order.channel_id channelId, wxorder_channel.name channelName, wxorder_channel.platform_code platformCode, wxorder_order.pre_control_status as refundPreStatus, wxorder_order.ware_id wareId, wxorder_ware.name wareName, wxorder_order.id, wxorder_order.order_sn orderSn, wxorder_order.upload_sn uploadSn, wxorder_order.money_paid moneyPaid, wxorder_order.consignee, wxorder_order.mobile, wxorder_order.province_name provinceName, wxorder_order.city_name cityName, wxorder_order.district_name districtName, wxorder_order.address, wxorder_order.channel_remark channelRemark, wxorder_order.customer_remark customerRemark, wxorder_order.platform_customer_remark platformCustomerRemark, wxorder_order.sender_name senderName, wxorder_order.sender_mobile senderMobile, date_format(wxorder_order.create_time, '%Y-%m-%d %H:%i:%s') createTime, date_format(wxorder_order.real_delivery_time, '%Y-%m-%d %H:%i:%s') realDeliveryTime, wxorder_order.progress_distribute progressDistribute, wxorder_order.progress_delivery progressDelivery, wxorder_order.control_status controlStatus, wxorder_order.express_name expressName, wxorder_order.express_number expressNumber,wxorder_order.shipping_price shippingPrice, wxorder_order.customer_network_name ,(select count(*) from wxorder_compensate WHERE wxorder_compensate.order_id = wxorder_order.id) as compensateCountAll,(select count(*) from wxorder_compensate WHERE wxorder_compensate.order_id = wxorder_order.id and wxorder_compensate.progress_status = 1) as compensateCountDealed ,(select count(*) from wxorder_channel_refund_payment where wxorder_channel_refund_payment.order_id = wxorder_order.id) as channelRefundPaymentStatus,(select count(*) from wxorder_ware_refund_payment where wxorder_ware_refund_payment.order_id = wxorder_order.id) as wareRefundPaymentStatus FROM wxorder_order wxorder_order INNER JOIN wxorder_channel wxorder_channel ON wxorder_order.channel_id=wxorder_channel.id and wxorder_channel.tenant_id=54 INNER JOIN wxorder_ware wxorder_ware ON wxorder_order.ware_id=wxorder_ware.id and wxorder_ware.tenant_id=54 INNER JOIN wxorder_order_goods wxorder_order_goods ON wxorder_order.id=wxorder_order_goods.order_id and wxorder_order_goods.tenant_id=54 WHERE 1=1 AND wxorder_order.tenant_id='54' AND wxorder_order.control_status='4' GROUP BY wxorder_order.id",
  150 + "select wdd, fromType from www where 223",
  151 + };
147 try { 152 try {
148 - String[] data = splitCoreSql("select t,(select * as 'fromCActio', dd as 'seelctsele\'ctd' from t) from www where 223");  
149 - System.out.println(data[0]);  
150 - System.out.println(data[1]); 153 + for(int i=0; i<testSql.length; ++i) {
  154 + String item = testSql[i];
  155 + System.out.println("================testSql["+i+"]===============");
  156 + String[] data = splitCoreSql(item);
  157 + System.out.println(data[0]);
  158 + System.out.println(data[1]);
  159 + }
151 } catch (Exception e) { 160 } catch (Exception e) {
152 e.printStackTrace(); 161 e.printStackTrace();
153 } 162 }