| | |
| | | AND slp.pending_tickets_total > 0 |
| | | </if> |
| | | <if test="req.supplierNameOrContractNo != null and req.supplierNameOrContractNo != ''"> |
| | | AND (sl.supplier_name like concat('%',#{req.supplierNameOrContractNo},'%') or sl.purchase_contract_number like concat('%',#{req.supplierNameOrContractNo},'%')) |
| | | AND (sl.supplier_name like concat('%',#{req.supplierNameOrContractNo},'%') or |
| | | sl.purchase_contract_number like concat('%',#{req.supplierNameOrContractNo},'%')) |
| | | </if> |
| | | </where> |
| | | order by slp.register_date desc |
| | |
| | | SELECT |
| | | t1.sales_ledger_product_id, |
| | | t1.return_quantity, |
| | | IF(q.sum_qty = 0 OR q.sum_qty IS NULL, 0, (t2.total_amount * (t1.return_quantity / q.sum_qty))) AS allocated_return_amount |
| | | IF(q.sum_qty = 0 OR q.sum_qty IS NULL, 0, (t2.total_amount * (t1.return_quantity / q.sum_qty))) AS |
| | | allocated_return_amount |
| | | FROM purchase_return_order_products t1 |
| | | INNER JOIN purchase_return_orders t2 ON t2.id = t1.purchase_return_order_id |
| | | INNER JOIN ( |
| | |
| | | LEFT JOIN ( |
| | | SELECT |
| | | t1.sales_ledger_product_id, |
| | | IF(q.sum_qty = 0 OR q.sum_qty IS NULL, 0, (t2.total_amount * (t1.return_quantity / q.sum_qty))) AS allocated_return_amount |
| | | IF(q.sum_qty = 0 OR q.sum_qty IS NULL, 0, (t2.total_amount * (t1.return_quantity / q.sum_qty))) AS |
| | | allocated_return_amount |
| | | FROM purchase_return_order_products t1 |
| | | INNER JOIN purchase_return_orders t2 ON t2.id = t1.purchase_return_order_id |
| | | INNER JOIN ( |
| | |
| | | </select> |
| | | |
| | | <select id="selectProductBomStructure" resultType="com.ruoyi.sales.dto.LossProductModelDto"> |
| | | select |
| | | a.model, |
| | | select a.model, |
| | | a.product_name, |
| | | a.unit, |
| | | sum(a.single_quantity) AS loss_num |
| | |
| | | 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, |
| | | select p.product_name as product_category, |
| | | pm.model as specification_model, |
| | | pm.id as product_model_id |
| | | from product_model pm |
| | |
| | | </select> |
| | | |
| | | <select id="selectProductSalesAnalysis" resultType="java.util.Map"> |
| | | SELECT |
| | | product_category as name, |
| | | 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 |
| | | FROM sales_ledger_product |
| | | WHERE type = 1 |
| | | GROUP BY product_category |
| | | ORDER BY value DESC |
| | | LIMIT 5 |
| | | </select> |
| | | |
| | | <select id="selectRawMaterialPurchaseAnalysis" resultType="java.util.Map"> |
| | | SELECT |
| | | pr.product_name AS name, |
| | | SELECT pr.product_name AS name, |
| | | SUM( slp.tax_inclusive_total_price ) AS value |
| | | FROM |
| | | sales_ledger_product slp |
| | | FROM sales_ledger_product slp |
| | | JOIN product pr ON slp.product_id = pr.id |
| | | WHERE |
| | | slp.type = 2 |
| | | WHERE slp.type = 2 |
| | | AND pr.parent_id = ( SELECT id FROM product WHERE product_name = '原材料' ) |
| | | GROUP BY |
| | | pr.id, |
| | | GROUP BY pr.id, |
| | | pr.product_name |
| | | ORDER BY |
| | | value DESC |
| | | ORDER BY value DESC |
| | | LIMIT 5 |
| | | </select> |
| | | |
| | | <select id="selectProductCountByTypeAndDate" resultType="int"> |
| | | SELECT IFNULL(COUNT(*), 0) |
| | | SELECT IFNULL(COUNT(DISTINCT product_model_id), 0) |
| | | FROM sales_ledger_product |
| | | WHERE type = #{type} |
| | | <where> |
| | | <if test="type != null"> |
| | | AND type = #{type} |
| | | </if> |
| | | <if test="startDate != null"> |
| | | AND register_date >= #{startDate} |
| | | </if> |
| | | <if test="endDate != null"> |
| | | AND register_date <= #{endDate} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectRawMaterialExpense" resultType="java.math.BigDecimal"> |