feat(mes): 添加在制品跟踪报表总数查询功能

- 在 ProdReportMapper 中新增 wipTrackingReportCount 方法- 在 ProdReportMapper.xml 中添加对应的 SQL 查询语句- 在 ProdReportServiceImpl 中调用新方法以恢复分页总条数显示- 优化分页查询逻辑,关闭自动 count 避免复杂 SQL 解析失败
- 添加异常处理确保简化版 count 失败不影响列表数据返回
master
zangch@mesnac.com 2 months ago
parent 18a5823a73
commit 7857b1c5f1

@ -118,6 +118,11 @@ public interface ProdReportMapper {
*/
List<WipTrackingReportVo> wipTrackingReportList(@Param("map") Map hashMap);
/**
* count
*/
Long wipTrackingReportCount(@Param("map") Map hashMap);
/**
*
*/

@ -209,11 +209,24 @@ public class ProdReportServiceImpl implements IProdReportService {
@Override
public TableDataInfo<WipTrackingReportVo> wipTrackingReportList(Map hashMap, PageQuery pageQuery) {
// 使用优化后的SQL查询大部分计算已在数据库层完成
Page<WipTrackingReportVo> page = prodReportMapper.wipTrackingReportList(hashMap, pageQuery.build());
// 关闭自动 count避免对复杂 CTE SQL 的解析失败
Page<WipTrackingReportVo> mpPage = pageQuery.build();
mpPage.setSearchCount(false);
Page<WipTrackingReportVo> page = prodReportMapper.wipTrackingReportList(hashMap, mpPage);
// 批量获取工序进度信息以提升性能
enrichWithProcessProgressBatch(page.getRecords());
// 使用简化版 count SQL 统计总数,恢复分页总条数显示
try {
Long total = prodReportMapper.wipTrackingReportCount(hashMap);
if (total != null) {
page.setTotal(total);
}
} catch (Exception ignore) {
// 简化 count 失败时不影响列表数据返回
}
return TableDataInfo.build(page);
}

@ -400,7 +400,7 @@
o.plan_end_time AS planEndTime,
GETDATE() AS currentTime,
CAST(ISNULL(ps.totalProcessCount, 0) AS VARCHAR(10)) + '道' AS totalProcessCount,
-- 清理工序名称中的多余逗号和空格
LTRIM(RTRIM(REPLACE(REPLACE(ISNULL(ps.wipProcessNames, ''), ',,', ','), ',', ','))) AS wipProcesses,
LTRIM(RTRIM(REPLACE(REPLACE(ISNULL(ps.remainingProcessNames, ''), ',,', ','), ',', ','))) AS remainingProcesses,
-- 整体进度计算:已完成数量占比 + 在制品进度占比
@ -462,6 +462,33 @@
ORDER BY o.order_code DESC
</select>
<!-- 在制品跟踪报表总数(简化版 count避免复杂 CTE/聚合,保持与筛选条件一致 -->
<select id="wipTrackingReportCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM prod_order_info o
INNER JOIN base_material_info m ON m.material_id = o.material_id
WHERE m.del_flag = '0'
<if test="map.beginDate != null and map.beginDate != '' and map.endDate != null and map.endDate != ''">
AND o.plan_begin_time <![CDATA[>=]]> CAST(#{map.beginDate} AS DATETIME)
AND o.plan_begin_time <![CDATA[<]]> DATEADD(day, 1, CAST(#{map.endDate} AS DATETIME))
</if>
<if test="map.orderCode != null and map.orderCode != ''">
AND o.order_code LIKE CONCAT('%', #{map.orderCode}, '%')
</if>
<if test="map.materialName != null and map.materialName != ''">
AND m.material_name LIKE CONCAT('%', #{map.materialName}, '%')
</if>
<if test="map.materialCode != null and map.materialCode != ''">
AND m.material_code LIKE CONCAT('%', #{map.materialCode}, '%')
</if>
<if test="map.progressStatus != null and map.progressStatus != ''">
AND CASE
WHEN o.plan_end_time IS NOT NULL AND GETDATE() > o.plan_end_time AND ISNULL(o.complete_amount,0) <![CDATA[<]]> o.plan_amount THEN '延期'
ELSE '正常'
END = #{map.progressStatus}
</if>
</select>
<!-- 获取订单的工序进度详情 - 高性能优化版本保留单订单查询不返回productOrderId以兼容旧用法 -->
<select id="getOrderProcessProgress" resultType="org.dromara.mes.domain.vo.ProcessProgressVo">
SELECT

Loading…
Cancel
Save