Commit 22b1af5b by 泽锋 李

采购在途全链路算法修改

parent 44068f8e
...@@ -1447,7 +1447,29 @@ sum(ifnull(t1.`quantity_arrival`,0)) as 'quantity_arrival', ...@@ -1447,7 +1447,29 @@ sum(ifnull(t1.`quantity_arrival`,0)) as 'quantity_arrival',
sum(ifnull(t1.`quantity_inbound`,0)) as 'quantity_inbound', sum(ifnull(t1.`quantity_inbound`,0)) as 'quantity_inbound',
sum(ifnull(t1.`quantity_not_inbound`,0)) as 'quantity_not_inbound' sum(ifnull(t1.`quantity_not_inbound`,0)) as 'quantity_not_inbound'
from dc_base_purchase_details as t1 from ( select
t1.purchase_id,
t1.`count` as quantity_purchase,
t1.buy_status,
t1.estimated_arrival_time,
t1.price,
t3.quantity_inbound,
t3.quantity_arrival,
t3.last_signtime,
t1.bailun_sku,
t1.warehouse_code,
t1.transport_type,
sum(t2.`count`) purchase_inbound_count,
t1.`count` - ifnull( sum(t2.`count`),0) as 'quantity_not_inbound'
from dc_base_purchase as t1
left join dc_base_purchase_inbound t2 on t1.bailun_sku = t2.bailun_sku and t1.parent_id = t2.parent_id
left join dc_base_purchase_details t3 on t1.bailun_sku = t3.bailun_sku and t1.purchase_id = t3.purchase_id
where t1.buy_status in (0, 1, 2, 3, 9)
and t1.has_delete = 0
and t1.`count` > 0
and (t1.`count` > t2.`count` or t2.`count` is null)
group by t1.id
) as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
"; ";
if ((categoryModels != null && categoryModels.Count >= 1) || !string.IsNullOrWhiteSpace(search_data.buyer_name) || search_data.product_type > 0) if ((categoryModels != null && categoryModels.Count >= 1) || !string.IsNullOrWhiteSpace(search_data.buyer_name) || search_data.product_type > 0)
...@@ -1462,7 +1484,7 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code ...@@ -1462,7 +1484,7 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
{ {
sql += " left join dc_auto_config_sku_warehouse as t10 on t1.bailun_sku = t10.bailun_sku and t1.warehouse_code = t10.warehouse_code "; sql += " left join dc_auto_config_sku_warehouse as t10 on t1.bailun_sku = t10.bailun_sku and t1.warehouse_code = t10.warehouse_code ";
} }
sql += " where t1.`status` not in (-1,4) and t1.has_delete =0 and t1.quantity_not_inbound > 0 "; sql += " where t1.quantity_not_inbound>0 ";
} }
else else
{ {
...@@ -1488,19 +1510,41 @@ t7.type as 'forecast_type', ...@@ -1488,19 +1510,41 @@ t7.type as 'forecast_type',
t1.purchase_id as 'purchase_id', t1.purchase_id as 'purchase_id',
t1.quantity_purchase as 'quantity_purchase', t1.quantity_purchase as 'quantity_purchase',
t1.`status` as 'purchase_status', t1.`buy_status` as 'purchase_status',
t1.`last_signtime` as 'last_signtime', t1.`last_signtime` as 'last_signtime',
t1.`quantity_arrival` as 'quantity_arrival', t1.`quantity_arrival` as 'quantity_arrival',
t1.`quantity_inbound` as 'quantity_inbound', t1.`quantity_inbound` as 'quantity_inbound',
t1.`quantity_not_inbound` as 'quantity_not_inbound', t1.`quantity_not_inbound` as 'quantity_not_inbound',
t1.`arrivaldate` as 'purchase_arrivaldate', t1.`estimated_arrival_time` as 'purchase_arrivaldate',
t8.`status` as 'prod_status', t8.`status` as 'prod_status',
t8.distribution_quantity as 'prod_distribution_quantity', t8.distribution_quantity as 'prod_distribution_quantity',
( t8.order_quantity - t8.distribution_quantity) as 'prod_not_distribution_quantity', ( t8.order_quantity - t8.distribution_quantity) as 'prod_not_distribution_quantity',
t8.prod_quantity as 'prod_quantity' t8.prod_quantity as 'prod_quantity'
from dc_base_purchase_details as t1 from ( select
t1.purchase_id,
t1.`count` as quantity_purchase,
t1.buy_status,
t1.estimated_arrival_time,
t1.price,
t3.quantity_inbound,
t3.quantity_arrival,
t3.last_signtime,
t1.bailun_sku,
t1.warehouse_code,
t1.transport_type,
sum(t2.`count`) purchase_inbound_count,
t1.`count` - ifnull( sum(t2.`count`),0) as 'quantity_not_inbound'
from dc_base_purchase as t1
left join dc_base_purchase_inbound t2 on t1.bailun_sku = t2.bailun_sku and t1.parent_id = t2.parent_id
left join dc_base_purchase_details t3 on t1.bailun_sku = t3.bailun_sku and t1.purchase_id = t3.purchase_id
where t1.buy_status in (0, 1, 2, 3, 9)
and t1.has_delete = 0
and t1.`count` > 0
and (t1.`count` > t2.`count` or t2.`count` is null)
group by t1.id
) as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_base_stock as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code left join dc_base_stock as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
...@@ -1519,7 +1563,7 @@ left join dc_base_prod_order as t8 on t1.bailun_sku = t8.bailun_sku and t1.purc ...@@ -1519,7 +1563,7 @@ left join dc_base_prod_order as t8 on t1.bailun_sku = t8.bailun_sku and t1.purc
{ {
sql += " left join dc_auto_config_sku_warehouse as t10 on t1.bailun_sku = t10.bailun_sku and t1.warehouse_code = t10.warehouse_code "; sql += " left join dc_auto_config_sku_warehouse as t10 on t1.bailun_sku = t10.bailun_sku and t1.warehouse_code = t10.warehouse_code ";
} }
sql += " where t1.`status` not in (-1,4) and t1.has_delete =0 and t1.quantity_not_inbound > 0 "; sql += " where t1.quantity_not_inbound>0 ";
} }
...@@ -1527,7 +1571,29 @@ left join dc_base_prod_order as t8 on t1.bailun_sku = t8.bailun_sku and t1.purc ...@@ -1527,7 +1571,29 @@ left join dc_base_prod_order as t8 on t1.bailun_sku = t8.bailun_sku and t1.purc
select select
count(1) count(1)
from from
dc_base_purchase_details as t1 ( select
t1.purchase_id,
t1.`count` as quantity_purchase,
t1.buy_status,
t1.estimated_arrival_time,
t1.price,
t3.quantity_inbound,
t3.quantity_arrival,
t3.last_signtime,
t1.bailun_sku,
t1.warehouse_code,
t1.transport_type,
sum(t2.`count`) purchase_inbound_count,
t1.`count` - ifnull( sum(t2.`count`),0) as 'quantity_not_inbound'
from dc_base_purchase as t1
left join dc_base_purchase_inbound t2 on t1.bailun_sku = t2.bailun_sku and t1.parent_id = t2.parent_id
left join dc_base_purchase_details t3 on t1.bailun_sku = t3.bailun_sku and t1.purchase_id = t3.purchase_id
where t1.buy_status in (0, 1, 2, 3, 9)
and t1.has_delete = 0
and t1.`count` > 0
and (t1.`count` > t2.`count` or t2.`count` is null)
group by t1.id
) as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
"; ";
if ((categoryModels != null && categoryModels.Count >= 1) || !string.IsNullOrWhiteSpace(search_data.buyer_name) || search_data.product_type > 0) if ((categoryModels != null && categoryModels.Count >= 1) || !string.IsNullOrWhiteSpace(search_data.buyer_name) || search_data.product_type > 0)
...@@ -1543,7 +1609,7 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code ...@@ -1543,7 +1609,7 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
countSql += " left join dc_auto_config_sku_warehouse as t10 on t1.bailun_sku = t10.bailun_sku and t1.warehouse_code = t10.warehouse_code "; countSql += " left join dc_auto_config_sku_warehouse as t10 on t1.bailun_sku = t10.bailun_sku and t1.warehouse_code = t10.warehouse_code ";
} }
countSql += " where t1.`status` not in (-1,4) and t1.has_delete =0 and t1.quantity_not_inbound > 0 "; countSql += " where t1.quantity_not_inbound>0 ";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment