feat(anneal-performance): 添加退火性能查询中的钢卷号筛选功能
- 在 WmsAnnealPerformanceMapper.xml 中添加钢卷号筛选的关联查询逻辑 - 在 WmsAnnealPerformanceServiceImpl 中实现钢卷号筛选的功能 - 添加筛选后统计数据重新计算的逻辑 - 实现过滤不匹配钢卷的跳过机制 - 添加过滤后无数据计划的移除处理 - 更新汇总统计信息以反映筛选后的实际数据
This commit is contained in:
@@ -21,6 +21,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -103,6 +104,11 @@ public class WmsAnnealPerformanceServiceImpl implements IWmsAnnealPerformanceSer
|
||||
}
|
||||
}
|
||||
|
||||
// 用于重新计算统计信息
|
||||
Long filteredPlanCount = 0L;
|
||||
Long filteredCoilCount = 0L;
|
||||
BigDecimal filteredTotalWeight = BigDecimal.ZERO;
|
||||
|
||||
// 处理每个计划
|
||||
for (WmsAnnealPerformanceDetailVo detail : details) {
|
||||
Long planId = detail.getPlanId();
|
||||
@@ -134,9 +140,37 @@ public class WmsAnnealPerformanceServiceImpl implements IWmsAnnealPerformanceSer
|
||||
// 设置炉火层级
|
||||
coilVo.setFurnaceLevel(planCoil.getFurnaceLevel());
|
||||
|
||||
// 如果传入了enterCoilNo筛选条件,只保留匹配的钢卷
|
||||
if (bo.getEnterCoilNo() != null && !bo.getEnterCoilNo().isEmpty()) {
|
||||
if (coilVo.getEnterCoilNo() == null ||
|
||||
!coilVo.getEnterCoilNo().contains(bo.getEnterCoilNo())) {
|
||||
continue; // 跳过不匹配的钢卷
|
||||
}
|
||||
}
|
||||
|
||||
coilVos.add(coilVo);
|
||||
}
|
||||
|
||||
// 如果过滤后没有钢卷,跳过该计划
|
||||
if (!coilVos.isEmpty()) {
|
||||
detail.setCoils(coilVos);
|
||||
filteredPlanCount++;
|
||||
filteredCoilCount += coilVos.size();
|
||||
BigDecimal planWeight = coilVos.stream()
|
||||
.map(c -> c.getNetWeight() != null ? c.getNetWeight() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
filteredTotalWeight = filteredTotalWeight.add(planWeight);
|
||||
}
|
||||
}
|
||||
|
||||
// 移除没有钢卷的计划
|
||||
details.removeIf(detail -> detail.getCoils() == null || detail.getCoils().isEmpty());
|
||||
|
||||
// 如果传入了enterCoilNo筛选条件,重新计算统计信息
|
||||
if (bo.getEnterCoilNo() != null && !bo.getEnterCoilNo().isEmpty()) {
|
||||
summary.setPlanCount(filteredPlanCount);
|
||||
summary.setCoilCount(filteredCoilCount);
|
||||
summary.setTotalWeight(filteredTotalWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
p.end_time AS endTime
|
||||
FROM wms_furnace_plan p
|
||||
LEFT JOIN wms_furnace f ON f.furnace_id = p.target_furnace_id
|
||||
<if test="enterCoilNo != null and enterCoilNo != ''">
|
||||
INNER JOIN wms_furnace_plan_coil pc ON pc.plan_id = p.plan_id AND pc.del_flag = 0
|
||||
INNER JOIN wms_material_coil mc ON mc.coil_id = pc.coil_id AND mc.del_flag = 0
|
||||
</if>
|
||||
<include refid="AnnealPerformanceWhere" />
|
||||
GROUP BY p.plan_id, p.plan_no, p.target_furnace_id, f.furnace_name, p.actual_start_time, p.end_time
|
||||
ORDER BY p.actual_start_time DESC, p.plan_no DESC
|
||||
|
||||
Reference in New Issue
Block a user