|
@@ -31,7 +31,9 @@
|
|
|
JOIN production_order_detail pod ON pod.contract_detail_id = cp.id
|
|
|
WHERE cp.contract_id = t1.id)
|
|
|
, 0) AS settledAmount,
|
|
|
- po.delivery_period as prodDeliveryPeriod
|
|
|
+ po.delivery_period as prodDeliveryPeriod,
|
|
|
+ t4.deliverQuantity,
|
|
|
+ t4.notDeliverQuantity
|
|
|
FROM contract t1
|
|
|
left join customer c on t1.buy_corporation_id = c.id
|
|
|
left join sys_user us on c.user_id = us.user_id
|
|
@@ -41,7 +43,17 @@
|
|
|
IFNULL(sum(swd.receipt_quantity), 0) AS receipt_quantity
|
|
|
FROM production_order_detail pod
|
|
|
JOIN stock_wait_details swd ON swd.prod_task_id = pod.id
|
|
|
- GROUP BY pod.contract_id) t3 ON t3.contract_id = t1.id) t1
|
|
|
+ GROUP BY pod.contract_id) t3 ON t3.contract_id = t1.id
|
|
|
+ LEFT JOIN (SELECT t1.contract_id,
|
|
|
+ t1.quantity,
|
|
|
+ t1.deliverQuantity,
|
|
|
+ (t1.quantity - t1.deliverQuantity) notDeliverQuantity
|
|
|
+ FROM (SELECT cp.contract_id,
|
|
|
+ IFNULL(sum(cp.quantity), 0) AS quantity,
|
|
|
+ IFNULL(sum(cor.quantity), 0) AS deliverQuantity
|
|
|
+ FROM contract_product cp
|
|
|
+ LEFT JOIN contract_outbound_records cor ON cp.contract_id = cor.contract_id
|
|
|
+ GROUP BY cp.contract_id) t1) t4 ON t4.contract_id = t1.id) t1
|
|
|
GROUP BY t1.id) t1
|
|
|
${ew.customSqlSegment}
|
|
|
</select>
|