提交基础采购
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.klp.erp.mapper.ErpPurchaseReportMapper">
|
||||
|
||||
<select id="sumTotalAmount" resultType="java.math.BigDecimal">
|
||||
SELECT COALESCE(SUM(total_amount), 0)
|
||||
FROM erp_purchase_order
|
||||
WHERE del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND create_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="sumAmountBySupplier" resultType="java.util.HashMap">
|
||||
SELECT supplier_id AS supplierId,
|
||||
COALESCE(SUM(total_amount), 0) AS totalAmount,
|
||||
COUNT(*) AS orderCount
|
||||
FROM erp_purchase_order
|
||||
WHERE del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND create_time <= #{endTime}
|
||||
</if>
|
||||
GROUP BY supplier_id
|
||||
ORDER BY totalAmount DESC
|
||||
</select>
|
||||
|
||||
<select id="selectPriceTrend" resultType="java.util.HashMap">
|
||||
SELECT DATE_FORMAT(po.order_date, '%Y-%m') AS period,
|
||||
poi.material_type_code AS materialCode,
|
||||
COALESCE(AVG(poi.unit_price), 0) AS avgPrice
|
||||
FROM erp_purchase_order po
|
||||
JOIN erp_purchase_order_item poi ON po.order_id = poi.order_id
|
||||
WHERE po.del_flag = 0
|
||||
AND poi.del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND po.order_date >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND po.order_date <= #{endTime}
|
||||
</if>
|
||||
GROUP BY period, poi.material_type_code
|
||||
ORDER BY period ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSupplierQuality" resultType="java.util.HashMap">
|
||||
SELECT po.supplier_id AS supplierId,
|
||||
COALESCE(SUM(pr.received_qty), 0) AS receivedQty,
|
||||
COALESCE(SUM(CASE WHEN r.status = 1 THEN ri.return_qty ELSE 0 END), 0) AS returnQty,
|
||||
COALESCE(SUM(CASE WHEN r.status = 1 THEN ri.return_qty ELSE 0 END), 0) /
|
||||
NULLIF(COALESCE(SUM(pr.received_qty), 0), 0) AS returnRate
|
||||
FROM erp_purchase_order po
|
||||
LEFT JOIN erp_purchase_receipt pr
|
||||
ON pr.order_id = po.order_id AND pr.del_flag = 0
|
||||
LEFT JOIN erp_purchase_return r
|
||||
ON r.order_id = po.order_id AND r.del_flag = 0
|
||||
LEFT JOIN erp_purchase_return_item ri
|
||||
ON ri.return_id = r.return_id AND ri.del_flag = 0
|
||||
WHERE po.del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND po.create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND po.create_time <= #{endTime}
|
||||
</if>
|
||||
GROUP BY po.supplier_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user