@ -118,4 +120,104 @@ public interface HistoryDataPreMapper extends BaseMapper<HistoryDataPre> {
@Select("select top 1 id, building_id, cur_date, env_min_temp, env_max_temp from history_data_pre where building_id = #{buildingId} and cur_date = #{curDate} ")
@Select("select top 1 id, building_id, cur_date, env_min_temp, env_max_temp from history_data_pre where building_id = #{buildingId} and cur_date = #{curDate} ")
" isnull(t.water_value_pre, 0) as cur_yes_data, "+
" isnull(t1.water_value, 0) as yes_data, "+
" isnull(t1.water_value_pre, 0) as pre_yes_data, "+
" CASE WHEN t1.water_value_pre > 0 THEN CONVERT(decimal(18, 2), ABS(isnull(t1.water_value_pre, 0) - isnull(t1.water_value, 0)) / t1.water_value_pre * 100) ELSE '0' END as error_data"+
" </when>"+
" <when test='type == \"2\"'>"+
" isnull(t.elect_value_pre, 0) as cur_yes_data, "+
" isnull(t1.elect_value, 0) as yes_data, "+
" isnull(t1.elect_value_pre, 0) as pre_yes_data, "+
" CASE WHEN t1.elect_value_pre > 0 THEN CONVERT(decimal(18, 2), ABS(isnull(t1.elect_value_pre, 0) - isnull(t1.elect_value, 0)) / t1.elect_value_pre * 100) ELSE '0' END as error_data"+
" </when>"+
" <when test='type == \"3\"'>"+
" isnull(t.water_level_pre, 0) as cur_yes_data, "+
" isnull(t1.water_level, 0) as yes_data, "+
" isnull(t1.water_level_pre, 0) as pre_yes_data, "+
" CASE WHEN t1.water_level_pre > 0 THEN CONVERT(decimal(18, 2), ABS(isnull(t1.water_level_pre, 0) - isnull(t1.water_level, 0)) / t1.water_level_pre * 100) ELSE '0' END as error_data"+
" </when>"+
" <otherwise>null</otherwise>"+
" </choose>"+
"FROM ("+
" SELECT "+
" building_id, "+
" water_value, "+
" elect_value, "+
" water_level, "+
" water_value_pre, "+
" elect_value_pre, "+
" water_level_pre "+
" FROM history_data_pre "+
" WHERE cur_date = CONVERT(varchar(10), GETDATE(), 120) AND building_id = #{buildingId}"+
") t "+
"JOIN ("+
" SELECT "+
" building_id, "+
" water_value, "+
" elect_value, "+
" water_level, "+
" water_value_pre, "+
" elect_value_pre, "+
" water_level_pre "+
" FROM history_data_pre "+
" WHERE cur_date = CONVERT(varchar(10), DATEADD(day, -1, GETDATE()), 120) AND building_id = #{buildingId}"+