Browse Source

报表销售添加isDelete的条件

master
dimengzhe 12 months ago
parent
commit
71afdbce94
  1. 87
      doc/databases/统计报表更新.sql

87
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,

Loading…
Cancel
Save