| | |
| | | <select id="selectSalesLedgerProductList" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct"> |
| | | SELECT |
| | | T1.*, |
| | | t3.shipping_car_number, |
| | | t3.shipping_date, |
| | | t3.status as shippingStatus, |
| | | t3.shipping_date, |
| | | CASE |
| | | WHEN t2.qualitity > T1.quantity THEN 1 |
| | | ELSE 0 |
| | |
| | | FROM |
| | | sales_ledger_product T1 |
| | | LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id |
| | | LEFT JOIN shipping_info t3 ON T1.id = t3.sales_ledger_product_id |
| | | <where> |
| | | 1=1 |
| | | <if test="salesLedgerProduct.salesLedgerId != null and salesLedgerProduct.salesLedgerId != '' "> |
| | |
| | | AND T1.type = #{salesLedgerProduct.type} |
| | | </if> |
| | | </where> |
| | | ORDER BY T1.register_date DESC |
| | | </select> |
| | | <select id="selectSalesLedgerProductByMainId" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct"> |
| | | select slp.* |
| | |
| | | slp.type = 2 |
| | | <if test="req.purchaseContractNumber != null and req.purchaseContractNumber != '' "> |
| | | AND sl.purchase_contract_number like concat('%',#{req.purchaseContractNumber},'%') |
| | | </if> |
| | | <if test="req.approvalStatus != null and req.approvalStatus != ''"> |
| | | and sl.approval_status = #{req.approvalStatus} |
| | | </if> |
| | | <if test="req.customerContractNo != null and req.customerContractNo != '' "> |
| | | AND sl.customer_contract_no like concat('%',#{req.customerContractNo},'%') |
| | |
| | | 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 |
| | | WHERE sl.id = #{salesLedegerId}) A |
| | | group by a.model, a.product_name, a.unit |
| | | </select> |
| | | <select id="selectProduct" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct"> |
| | | select |
| | | p.product_name as product_category, |
| | | pm.model as specification_model, |
| | | pm.id |
| | | pm.id as product_model_id |
| | | from product_model pm |
| | | left join product p on pm.product_id = p.id |
| | | </select> |
| | | </mapper> |
| | | |
| | | <select id="selectProductSalesAnalysis" resultType="java.util.LinkedHashMap"> |
| | | SELECT |
| | | product_category as name, |
| | | SUM( tax_inclusive_total_price ) AS value |
| | | FROM |
| | | sales_ledger_product |
| | | WHERE |
| | | type = 1 |
| | | GROUP BY |
| | | product_category |
| | | ORDER BY |
| | | value DESC |
| | | LIMIT 5 |
| | | </select> |
| | | |
| | | <select id="selectRawMaterialPurchaseAnalysis" resultType="java.util.LinkedHashMap"> |
| | | SELECT |
| | | pr.product_name AS name, |
| | | SUM( slp.tax_inclusive_total_price ) AS value |
| | | FROM |
| | | sales_ledger_product slp |
| | | JOIN product pr ON slp.product_id = pr.id |
| | | WHERE |
| | | slp.type = 2 |
| | | AND pr.parent_id = ( SELECT id FROM product WHERE product_name = '原材料' ) |
| | | GROUP BY |
| | | pr.id, |
| | | pr.product_name |
| | | ORDER BY |
| | | value DESC |
| | | LIMIT 5 |
| | | </select> |
| | | |
| | | <select id="selectProductCountByTypeAndDate" resultType="int"> |
| | | SELECT COUNT(*) |
| | | FROM sales_ledger_product |
| | | WHERE type = #{type} |
| | | AND register_date >= #{startDate} |
| | | AND register_date <= #{endDate} |
| | | </select> |
| | | |
| | | </mapper> |