From 71afdbce940507e4383dfac047c8e4927c550eb4 Mon Sep 17 00:00:00 2001 From: dimengzhe Date: Sat, 11 May 2024 08:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E9=94=80=E5=94=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0isDelete=E7=9A=84=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/databases/统计报表更新.sql | 87 +++++++++++++++++++++------- 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/doc/databases/统计报表更新.sql b/doc/databases/统计报表更新.sql index cd7e782991..fb5bbd78f3 100644 --- a/doc/databases/统计报表更新.sql +++ b/doc/databases/统计报表更新.sql @@ -348,7 +348,7 @@ BEGIN left join anrui_base.base_vehicle_state bs on bs.busSid = bov.sid WHERE bo.nodeState = '已办结' AND (bs.busState = '602' or bs.busState = '501' or bs.busState = '502' or - bs.busState = '503' or bs.busState = '601' or bs.busState = '602') + bs.busState = '503' or bs.busState = '601') and bo.useOrgSid = a.useOrgSid and bm.modelSid = a.modelSid and bm.modelConfigSid = a.modelConfigSid @@ -367,19 +367,60 @@ BEGIN and bs.busSid is null and bo.contractNo = a.contractNo) as ssscount FROM ( - SELECT count(bov.id) AS scount, - bo.useOrgSid, - bm.modelSid, - bm.modelConfigSid, - bo.contractNo - FROM anrui_buscenter.bus_sales_order_vehicle bov - LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bov.salesOrderSid - LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid - WHERE bo.nodeState = '已办结' - GROUP BY bo.useOrgSid, - bm.modelSid, - bm.modelConfigSid, - bo.contractNo + select sum(scount) as scount, + d.useOrgSid, + d.modelSid, + d.modelConfigSid, + d.contractNo + from (SELECT count(bov.id) AS scount, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo + FROM anrui_buscenter.bus_sales_order_vehicle bov + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bov.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + WHERE bo.nodeState = '已办结' + and bo.type = 1 + and length(bov.linkSid) > 0 + GROUP BY bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo + union all + SELECT bp.quantity as scount, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo + from anrui_buscenter.bus_sales_order bo + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_price bp on bp.salesOrderSid = bo.sid + WHERE bo.nodeState = '已办结' + and bo.type = 2 + GROUP BY bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo + union all + SELECT bp.quantity as scount, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo + from anrui_buscenter.bus_sales_order bo + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_price bp on bp.salesOrderSid = bo.sid + WHERE bo.nodeState = '已办结' + and bo.type = 3 + GROUP BY bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo) d + group by d.useOrgSid, + d.modelSid, + d.modelConfigSid, + d.contractNo ) a) b) c group by c.useOrgSid, c.modelSid, c.modelConfigSid ) AS s ON r.useOrgSid = s.useOrgSid @@ -396,7 +437,7 @@ BEGIN left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid where bv.salesDate like concat('%', CURDATE(), '%') - and bvoa.saleTypeKey = '001' + and bvoa.saleTypeKey = '001' and bvo.isDelete = 0 and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or length(bvo.materialTypeValue) = 0) group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss @@ -414,7 +455,7 @@ BEGIN left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid where bv.salesDate like concat('%', CURDATE(), '%') - and bvoa.saleTypeKey = '002' + and bvoa.saleTypeKey = '002' and bvo.isDelete = 0 and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or length(bvo.materialTypeValue) = 0) group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss @@ -439,7 +480,7 @@ BEGIN left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bvoa.saleTypeKey = '001' + and bvoa.saleTypeKey = '001' and bvo.isDelete = 0 and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or length(bvo.materialTypeValue) = 0) group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss @@ -457,7 +498,7 @@ BEGIN left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bvoa.saleTypeKey = '002' + and bvoa.saleTypeKey = '002' and bvo.isDelete = 0 and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or length(bvo.materialTypeValue) = 0) group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss @@ -482,7 +523,7 @@ BEGIN left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bvoa.saleTypeKey = '001' + and bvoa.saleTypeKey = '001' and bvo.isDelete = 0 and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or length(bvo.materialTypeValue) = 0) group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss @@ -500,7 +541,7 @@ BEGIN left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bvoa.saleTypeKey = '002' + and bvoa.saleTypeKey = '002' and bvo.isDelete = 0 and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or length(bvo.materialTypeValue) = 0) group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss @@ -1099,7 +1140,8 @@ BEGIN WHERE bo.payTypeKey = 2 and ss.busVinSid is null AND bbv.vehicleState = '0002' - and bo.nodeState = '已办结' and bo.contractNo NOT LIKE '%2023%' + and bo.nodeState = '已办结' + and bo.contractNo NOT LIKE '%2023%' GROUP BY bv.sid, bo.useOrgSid, bm.modelSid, @@ -1210,7 +1252,8 @@ BEGIN WHERE bo.payTypeKey = 2 and ss.busVinSid is null AND bbv.vehicleState = '0002' - and bo.nodeState = '已办结' and bo.contractNo NOT LIKE '%2023%' + and bo.nodeState = '已办结' + and bo.contractNo NOT LIKE '%2023%' GROUP BY bv.sid, bo.useOrgSid, bm.modelSid,