From 1424a070273af9a35ac29ea35943e25591eeaf9d Mon Sep 17 00:00:00 2001 From: zch Date: Sat, 7 Jun 2025 17:51:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(ems):=20=E4=BF=AE=E5=A4=8D=20dailyfaultreco?= =?UTF-8?q?rd=20=E6=8F=92=E5=85=A5=E5=92=8C=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86=E6=97=B6=E9=95=BF=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了插入语句中的 handling_duration 字段的空值判断 - 在插入和更新语句中增加了对故障发生时间和处理完成时间的判断 - 使用 CASE 语句计算处理时长,考虑了跨天的情况 - 保留了原有的 handlingDuration 字段值作为备用 --- .../ems/info/DailyFaultRecordMapper.xml | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/os-ems/src/main/resources/mapper/ems/info/DailyFaultRecordMapper.xml b/os-ems/src/main/resources/mapper/ems/info/DailyFaultRecordMapper.xml index 8e2cd2c..41cb072 100644 --- a/os-ems/src/main/resources/mapper/ems/info/DailyFaultRecordMapper.xml +++ b/os-ems/src/main/resources/mapper/ems/info/DailyFaultRecordMapper.xml @@ -55,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" fault_type, fault_occurrence_time, handling_completion_time, - handling_duration, + handling_duration, #{date}, @@ -67,7 +67,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{faultType}, #{faultOccurrenceTime}, #{handlingCompletionTime}, - #{handlingDuration}, + + + CASE + WHEN TIME_TO_SEC(#{handlingCompletionTime}) >= TIME_TO_SEC(#{faultOccurrenceTime}) THEN + TIME_TO_SEC(#{handlingCompletionTime}) - TIME_TO_SEC(#{faultOccurrenceTime}) + ELSE + TIME_TO_SEC(#{handlingCompletionTime}) + 86400 - TIME_TO_SEC(#{faultOccurrenceTime}) + END, + + + #{handlingDuration}, + + @@ -83,7 +95,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" fault_type = #{faultType}, fault_occurrence_time = #{faultOccurrenceTime}, handling_completion_time = #{handlingCompletionTime}, - handling_duration = #{handlingDuration}, + handling_duration = + + + CASE + WHEN TIME_TO_SEC(#{handlingCompletionTime}) >= TIME_TO_SEC(#{faultOccurrenceTime}) THEN + TIME_TO_SEC(#{handlingCompletionTime}) - TIME_TO_SEC(#{faultOccurrenceTime}) + ELSE + TIME_TO_SEC(#{handlingCompletionTime}) + 86400 - TIME_TO_SEC(#{faultOccurrenceTime}) + END + + + #{handlingDuration} + + , where id = #{id}