fix(dms):修复报表查询中时间比较逻辑错误

- 将大于等于符号(>=)修正为转义字符(>=)
- 确保停机时间和标准秒数比较逻辑正确
- 统一时间比较表达式的转义格式
- 修复产量损失计算中的条件判断
- 保证故障延迟统计的准确性
master
zangch@mesnac.com 2 months ago
parent 96eb49c294
commit b93fa3243f

@ -34,8 +34,8 @@ coalesce(
公式:停机秒数 ÷ 标准秒/件 = 损失件数
cast(case
when fb.real_begin_time is not null and fb.real_end_time is not null
and fb.real_end_time >= fb.real_begin_time
and fb.standard_seconds_per_unit is not null and fb.standard_seconds_per_unit > 0
and fb.real_end_time >= fb.real_begin_time
and fb.standard_seconds_per_unit is not null and fb.standard_seconds_per_unit > 0
then (datediff(second, fb.real_begin_time, fb.real_end_time) / fb.standard_seconds_per_unit)
else 0.0
end as decimal(18,2)) as output_loss_qty
@ -105,7 +105,7 @@ where mp2.machine_id = fb.machine_id - 同一机台
g.fault_type,
count(1) as fault_count,
sum(g.downtime_hours) as total_downtime_hours,
sum(case when g.real_end_time is not null and g.require_end_time is not null and g.real_end_time > g.require_end_time then 1 else 0 end) as delay_count,
sum(case when g.real_end_time is not null and g.require_end_time is not null and g.real_end_time > g.require_end_time then 1 else 0 end) as delay_count,
sum(g.output_loss_qty) as total_output_loss,
sum(g.order_delay_count) as total_order_delay_count
from (
@ -135,14 +135,14 @@ where mp2.machine_id = fb.machine_id - 同一机台
-- 故障类型:确保转换为字符串类型并处理空值
cast(coalesce(af.fault_type, '') as varchar(10)) as fault_type,
cast(case
when fb.real_begin_time is not null and fb.real_end_time is not null and fb.real_end_time >= fb.real_begin_time
when fb.real_begin_time is not null and fb.real_end_time is not null and fb.real_end_time >= fb.real_begin_time
then datediff(second, fb.real_begin_time, fb.real_end_time) / 3600.0
else 0.0
end as decimal(18,6)) as downtime_hours,
-- 产量损失:停机秒数 / 标准秒/件
cast(case
when fb.real_begin_time is not null and fb.real_end_time is not null and fb.real_end_time >= fb.real_begin_time
and fb.standard_seconds_per_unit is not null and fb.standard_seconds_per_unit > 0
when fb.real_begin_time is not null and fb.real_end_time is not null and fb.real_end_time >= fb.real_begin_time
and fb.standard_seconds_per_unit is not null and fb.standard_seconds_per_unit > 0
then (datediff(second, fb.real_begin_time, fb.real_end_time) / fb.standard_seconds_per_unit)
else 0.0
end as decimal(18,2)) as output_loss_qty,

Loading…
Cancel
Save