| | |
| | | GROUP BY slp.product_category |
| | | <!-- 按产品大类排序 --> |
| | | ORDER BY slp.product_category |
| | | </select> |
| | | <select id="selectProductBomStructure" resultType="com.ruoyi.sales.dto.LossProductModelDto"> |
| | | select |
| | | a.model, |
| | | a.product_name, |
| | | a.unit, |
| | | sum(a.single_quantity) AS loss_num |
| | | from (SELECT ps.unit, |
| | | ps.unit_quantity, |
| | | pm1.model, |
| | | p.product_name, |
| | | ps.unit_quantity * slp.quantity AS single_quantity |
| | | FROM sales_ledger sl |
| | | LEFT JOIN sales_ledger_product slp ON slp.sales_ledger_id = sl.id |
| | | LEFT JOIN product_model pm ON pm.id = slp.product_model_id |
| | | LEFT JOIN product_bom pb ON pb.product_model_id = pm.id |
| | | LEFT JOIN product_structure ps ON pb.id = ps.bom_id |
| | | LEFT JOIN product_model pm1 ON pm1.id = ps.product_model_id |
| | | LEFT JOIN product p ON p.id = pm1.product_id |
| | | WHERE sl.id = #{salesLedegerId}) A |
| | | group by a.model, a.product_name, a.unit |
| | | </select> |
| | | </mapper> |