feat(wms): 新增发货计划统计功能
- 在 IWmsDeliveryPlanService 接口中新增 getDeliveryPlanStatistics 方法 - 在 WmsDeliveryPlanController 中添加 /statistics 接口用于获取统计信息 - 在 WmsDeliveryPlanMapper 中新增 selectDeliveryPlanStatistics 查询方法 - 在 WmsDeliveryPlanMapper.xml 中编写对应的 SQL 查询语句 - 在 WmsDeliveryPlanServiceImpl 中实现统计方法调用 Mapper 层 - 新增 WmsDeliveryPlanStatisticsVo 类用于封装统计结果数据 - 引入相关类导入依赖以支持新功能开发
This commit is contained in:
@@ -16,5 +16,46 @@
|
||||
<result property="updateBy" column="update_by"/>
|
||||
</resultMap>
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user