feat(wms): 优化钢卷库区操作记录吞吐报表统计功能

- 后端新增 statistics 接口聚合图表数据,避免前端遍历计算
- 新增 WmsCoilWarehouseOperationLogStatisticsVo 数据传输对象
- 实现按操作人汇总、按日趋势、汇总指标三个维度的数据查询
- 前端 record 页面集成统计卡片、趋势图、饼图、柱状图展示
- 优化分页逻辑,移除前端全量数据存储和分页计算
- 添加完整的 SQL 统计查询语句支持多维度数据聚合
This commit is contained in:
2026-06-22 17:27:08 +08:00
parent 6436d56ab8
commit b5a269a37a
8 changed files with 254 additions and 111 deletions

View File

@@ -129,4 +129,66 @@
ORDER BY log.create_time DESC
</select>
<!-- ==================== 吞吐报表统计 SQL ==================== -->
<!-- 公共过滤条件片段 -->
<sql id="statisticsWhere">
<where>
log.del_flag = 0
<if test="actualWarehouseId != null">
AND log.actual_warehouse_id = #{actualWarehouseId}
</if>
<if test="operationType != null">
AND log.operation_type = #{operationType}
</if>
<if test="inOutType != null">
AND log.in_out_type = #{inOutType}
</if>
<if test="createBy != null and createBy != ''">
AND log.create_by = #{createBy}
</if>
<if test="startTime != null">
AND log.create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND log.create_time &lt;= #{endTime}
</if>
</where>
</sql>
<!-- 汇总指标:总数、总重量、涉及库位数 -->
<select id="selectStatisticsSummary" resultType="com.klp.domain.vo.WmsCoilWarehouseOperationLogStatisticsVo">
SELECT
COUNT(*) AS totalCount,
COALESCE(SUM(mc.net_weight), 0) AS totalWeight,
COUNT(DISTINCT log.actual_warehouse_id) AS warehouseCount
FROM wms_coil_warehouse_operation_log log
LEFT JOIN wms_material_coil mc ON log.coil_id = mc.coil_id AND mc.del_flag = 0
<include refid="statisticsWhere"/>
</select>
<!-- 按操作人汇总 -->
<select id="selectUserSummary" resultType="com.klp.domain.vo.WmsCoilWarehouseOperationLogStatisticsVo$UserSummary">
SELECT
log.create_by AS createBy,
COUNT(*) AS coilCount,
COALESCE(SUM(mc.net_weight), 0) AS totalWeight
FROM wms_coil_warehouse_operation_log log
LEFT JOIN wms_material_coil mc ON log.coil_id = mc.coil_id AND mc.del_flag = 0
<include refid="statisticsWhere"/>
GROUP BY log.create_by
ORDER BY coilCount DESC
</select>
<!-- 按日趋势 -->
<select id="selectTrendData" resultType="com.klp.domain.vo.WmsCoilWarehouseOperationLogStatisticsVo$TrendItem">
SELECT
DATE_FORMAT(log.create_time, '%Y-%m-%d') AS date,
COUNT(*) AS count
FROM wms_coil_warehouse_operation_log log
<include refid="statisticsWhere"/>
GROUP BY DATE_FORMAT(log.create_time, '%Y-%m-%d')
ORDER BY date ASC
</select>
</mapper>