fix(watch): 修复DM8不兼容的睡眠统计SQL函数
WatchStatUserInfoDaySleepMapper.xml 的 insertStat/updateStat 使用了 MySQL 专属的 timediff 和 time_to_sec 函数,DM8 报 "Member access [TIMEDIFF] unresolved"。改用 TIMESTAMPDIFF(SECOND,...) 兼容 DM8。 异常被 DataStepListener.handleStat 吞掉,导致任务显示成功但睡眠 数据从未写入 QH_WAT_STAT_USER_DAY_SLE,且 statCommon 循环中断使 后续 watchNo 的 updateLatestSleep 也不会执行,QH_WAT_DATA(type=4) 长期无值,后台列表睡眠列不显示。
This commit is contained in:
+14
-14
@@ -52,22 +52,22 @@
|
|||||||
(select #{id,jdbcType=VARCHAR},
|
(select #{id,jdbcType=VARCHAR},
|
||||||
s.bind_user_id,
|
s.bind_user_id,
|
||||||
count(case when sm.sleep_type = '1' then 1 end) as long_count,
|
count(case when sm.sleep_type = '1' then 1 end) as long_count,
|
||||||
max(case when sm.sleep_type = '1' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
max(case when sm.sleep_type = '1' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as long_duration_max,
|
60 as long_duration_max,
|
||||||
min(case when sm.sleep_type = '1' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
min(case when sm.sleep_type = '1' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as long_duration_min,
|
60 as long_duration_min,
|
||||||
sum(case when sm.sleep_type = '1' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
sum(case when sm.sleep_type = '1' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as long_duration_total,
|
60 as long_duration_total,
|
||||||
count(case when sm.sleep_type = '2' then 1 end) as short_count,
|
count(case when sm.sleep_type = '2' then 1 end) as short_count,
|
||||||
max(case when sm.sleep_type = '2' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
max(case when sm.sleep_type = '2' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as short_duration_max,
|
60 as short_duration_max,
|
||||||
min(case when sm.sleep_type = '2' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
min(case when sm.sleep_type = '2' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as short_duration_min,
|
60 as short_duration_min,
|
||||||
sum(case when sm.sleep_type = '2' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
sum(case when sm.sleep_type = '2' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as short_duration_total,
|
60 as short_duration_total,
|
||||||
sum(length(sm.status) - length(replace(sm.status, '1', ''))) as deep_sleep_times,
|
sum(length(sm.status) - length(replace(sm.status, '1', ''))) as deep_sleep_times,
|
||||||
sum(length(sm.status) - length(replace(sm.status, '3', ''))) as light_sleep_times,
|
sum(length(sm.status) - length(replace(sm.status, '3', ''))) as light_sleep_times,
|
||||||
sum(time_to_sec(timediff(sm.end_time, sm.start_time))) / 60 as deep_light_times,
|
sum(TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time)) / 60 as deep_light_times,
|
||||||
max(s.id) as sleep_id,
|
max(s.id) as sleep_id,
|
||||||
max(sm.end_time) as last_upload_time,
|
max(sm.end_time) as last_upload_time,
|
||||||
data_date,
|
data_date,
|
||||||
@@ -85,22 +85,22 @@
|
|||||||
update QH_WAT_STAT_USER_DAY_SLE stat
|
update QH_WAT_STAT_USER_DAY_SLE stat
|
||||||
left join (select s.bind_user_id,
|
left join (select s.bind_user_id,
|
||||||
count(case when sm.sleep_type = '1' then 1 end) as long_count,
|
count(case when sm.sleep_type = '1' then 1 end) as long_count,
|
||||||
max(case when sm.sleep_type = '1' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
max(case when sm.sleep_type = '1' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as long_duration_max,
|
60 as long_duration_max,
|
||||||
min(case when sm.sleep_type = '1' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
min(case when sm.sleep_type = '1' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as long_duration_min,
|
60 as long_duration_min,
|
||||||
sum(case when sm.sleep_type = '1' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
sum(case when sm.sleep_type = '1' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as long_duration_total,
|
60 as long_duration_total,
|
||||||
count(case when sm.sleep_type = '2' then 1 end) as short_count,
|
count(case when sm.sleep_type = '2' then 1 end) as short_count,
|
||||||
max(case when sm.sleep_type = '2' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
max(case when sm.sleep_type = '2' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as short_duration_max,
|
60 as short_duration_max,
|
||||||
min(case when sm.sleep_type = '2' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
min(case when sm.sleep_type = '2' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as short_duration_min,
|
60 as short_duration_min,
|
||||||
sum(case when sm.sleep_type = '2' then time_to_sec(timediff(sm.end_time, sm.start_time)) end) /
|
sum(case when sm.sleep_type = '2' then TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time) end) /
|
||||||
60 as short_duration_total,
|
60 as short_duration_total,
|
||||||
sum(length(sm.status) - length(replace(sm.status, '1', ''))) as deep_sleep_times,
|
sum(length(sm.status) - length(replace(sm.status, '1', ''))) as deep_sleep_times,
|
||||||
sum(length(sm.status) - length(replace(sm.status, '3', ''))) as light_sleep_times,
|
sum(length(sm.status) - length(replace(sm.status, '3', ''))) as light_sleep_times,
|
||||||
sum(time_to_sec(timediff(sm.end_time, sm.start_time))) / 60 as deep_light_times,
|
sum(TIMESTAMPDIFF(SECOND, sm.start_time, sm.end_time)) / 60 as deep_light_times,
|
||||||
max(s.id) as sleep_id,
|
max(s.id) as sleep_id,
|
||||||
max(sm.end_time) as last_upload_time,
|
max(sm.end_time) as last_upload_time,
|
||||||
data_date
|
data_date
|
||||||
|
|||||||
Reference in New Issue
Block a user