|
@@ -24,7 +24,7 @@
|
|
|
LEFT JOIN contract c ON po.contract_id = c.id
|
|
|
${ew.customSqlSegment}
|
|
|
</select>
|
|
|
- <select id="getSchedulingList" resultType="com.fjhx.mes.entity.production.vo.ProductionOrderVo">
|
|
|
+ <select id="getSchedulingList" resultType="com.fjhx.mes.entity.production.vo.ProductionOrderVo">
|
|
|
SELECT po.id,
|
|
|
po.`code`,
|
|
|
GROUP_CONCAT(pi.`name` SEPARATOR ',') AS productName,
|
|
@@ -38,5 +38,37 @@
|
|
|
LEFT JOIN product_info pi ON pod.product_id = pi.id
|
|
|
${ew.customSqlSegment}
|
|
|
</select>
|
|
|
+ <select id="materialBalanceList" resultType="com.fjhx.mes.entity.MaterialBalanceBo">
|
|
|
+ SELECT t1.material_id,
|
|
|
+ t1.quantity,
|
|
|
+ (t1.quantity - t1.receiptQuantity) AS unclaimedQuantity,
|
|
|
+ t1.receiptQuantity AS receivedQuantity,
|
|
|
+ (t1.receiptQuantity - t1.usedQuantity) AS workshopInventoryQuantity,
|
|
|
+ IFNULL(t1.purchaseTransitQuantity, 0) AS purchaseTransitQuantity
|
|
|
+ FROM (SELECT cpb.product_name,
|
|
|
+ cpb.material_id,
|
|
|
+ sum(cpb.quantity * cp.quantity) AS quantity,
|
|
|
+ (SELECT sum(receipt_quantity)
|
|
|
+ FROM stock_wait_details swd
|
|
|
+ JOIN stock_wait sw ON swd.stock_wait_id = sw.id
|
|
|
+ WHERE sw.business_id = po.id
|
|
|
+ AND swd.product_id = cpb.material_id) AS receiptQuantity,
|
|
|
+ (SELECT sum(pod.finish_quantity * cpb1.quantity)
|
|
|
+ FROM production_order_detail pod
|
|
|
+ JOIN contract_product_bom cpb1 ON cpb1.contract_product_id = pod.contract_detail_id
|
|
|
+ WHERE cpb1.id = cpb.id
|
|
|
+ AND pod.produce_order_id = po.id) AS usedQuantity,
|
|
|
+ (SELECT sum(pp.quantity) - IFNULL(sum(ad.quantity), 0)
|
|
|
+ FROM subscribe_detail sd
|
|
|
+ JOIN ehsd_purchase_product pp ON pp.subscribe_detail_id = sd.id
|
|
|
+ LEFT JOIN arrival_detail ad ON ad.purchase_detail_id = pp.id
|
|
|
+ WHERE pp.product_id = cpb.material_id
|
|
|
+ AND sd.contract_id = po.contract_id) AS purchaseTransitQuantity
|
|
|
+ FROM production_order po
|
|
|
+ LEFT JOIN contract_product cp ON cp.contract_id = po.contract_id
|
|
|
+ LEFT JOIN contract_product_bom cpb ON cpb.contract_product_id = cp.id
|
|
|
+ WHERE po.id = #{orderID}
|
|
|
+ GROUP BY cpb.material_id) t1
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|