2025-11-25 15:44:19 +08:00
|
|
|
<?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.mapper.WmsDeliveryPlanMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap type="com.klp.domain.WmsDeliveryPlan" id="WmsDeliveryPlanResult">
|
|
|
|
|
<result property="planId" column="plan_id"/>
|
|
|
|
|
<result property="planName" column="plan_name"/>
|
|
|
|
|
<result property="planDate" column="plan_date"/>
|
|
|
|
|
<result property="remark" column="remark"/>
|
|
|
|
|
<result property="delFlag" column="del_flag"/>
|
|
|
|
|
<result property="createTime" column="create_time"/>
|
|
|
|
|
<result property="createBy" column="create_by"/>
|
|
|
|
|
<result property="updateTime" column="update_time"/>
|
|
|
|
|
<result property="updateBy" column="update_by"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
2025-11-25 16:58:47 +08:00
|
|
|
<select id="selectDeliveryPlanStatistics" resultType="com.klp.domain.vo.WmsDeliveryPlanStatisticsVo">
|
|
|
|
|
SELECT
|
|
|
|
|
dp.plan_id as planId,
|
|
|
|
|
dp.plan_name as planName,
|
|
|
|
|
COUNT(DISTINCT dw.waybill_id) as waybillCount,
|
|
|
|
|
COALESCE(SUM(completed_waybills.completed_count), 0) as completedWaybillCount,
|
|
|
|
|
COALESCE(SUM(detail_stats.total_coil_count), 0) as totalCoilCount,
|
|
|
|
|
COALESCE(SUM(detail_stats.total_weight), 0) as totalWeight,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN COUNT(DISTINCT dw.waybill_id) > 0 THEN
|
|
|
|
|
ROUND((COALESCE(SUM(completed_waybills.completed_count), 0) * 100.0) / COUNT(DISTINCT dw.waybill_id), 2)
|
|
|
|
|
ELSE 0
|
|
|
|
|
END as completionRate
|
|
|
|
|
FROM wms_delivery_plan dp
|
|
|
|
|
LEFT JOIN wms_delivery_waybill dw ON dp.plan_id = dw.plan_id AND dw.del_flag = 0
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
waybill_id,
|
|
|
|
|
COUNT(*) as total_coil_count,
|
|
|
|
|
SUM(weight/1000.0) as total_weight
|
|
|
|
|
FROM wms_delivery_waybill_detail
|
|
|
|
|
WHERE del_flag = 0
|
|
|
|
|
GROUP BY waybill_id
|
|
|
|
|
) detail_stats ON dw.waybill_id = detail_stats.waybill_id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
plan_id,
|
|
|
|
|
COUNT(*) as completed_count
|
|
|
|
|
FROM wms_delivery_waybill
|
|
|
|
|
WHERE status = 2 AND del_flag = 0
|
|
|
|
|
GROUP BY plan_id
|
|
|
|
|
) completed_waybills ON dp.plan_id = completed_waybills.plan_id
|
|
|
|
|
WHERE dp.del_flag = 0
|
|
|
|
|
<if test="planId != null">
|
|
|
|
|
AND dp.plan_id = #{planId}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY dp.plan_id, dp.plan_name
|
|
|
|
|
ORDER BY dp.create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
2025-11-25 15:44:19 +08:00
|
|
|
|
|
|
|
|
</mapper>
|