|
@@ -262,10 +262,13 @@
|
|
|
from sms_scene t1
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
left join (
|
|
|
- select b1.device_id,b1.attribute_id,max(latest_value) latest_value
|
|
|
+ select c1.device_id,c1.attribute_id,c1.latest_value
|
|
|
+ from sms_day_report c1
|
|
|
+ inner join (
|
|
|
+ select b1.device_id,b1.attribute_id,max(b1.collect_date) collect_date
|
|
|
from sms_day_report b1
|
|
|
where b1.year = year(now() + interval-1 day) and b1.month = month(now() + interval-1 day) and b1.day = day(now() + interval-1 day)
|
|
|
- group by b1.device_id,b1.attribute_id
|
|
|
+ group by b1.device_id,b1.attribute_id )c2 on c1.device_id=c2.device_id and c1.attribute_id=c2.attribute_id and c1.collect_date=c2.collect_date
|
|
|
)t8 on t8.device_id=t2.device_id and t8.attribute_id =t5.attribute_id
|
|
|
where t1.parent_scene_id = 0 and t1. status = 1
|
|
|
<if test="type == 1 ">
|
|
@@ -404,10 +407,13 @@
|
|
|
<if test="type == 4 ">
|
|
|
and t7.parm_type in(16)
|
|
|
left join (
|
|
|
- select b1.device_id,b1.attribute_id,max(latest_value) latest_value
|
|
|
- from sms_day_report b1
|
|
|
- where b1.year = year(now() + interval-1 day) and b1.month = month(now() + interval-1 day) and b1.day = day(now() + interval-1 day)
|
|
|
- group by b1.device_id,b1.attribute_id
|
|
|
+ select c1.device_id,c1.attribute_id,c1.latest_value
|
|
|
+ from sms_day_report c1
|
|
|
+ inner join (
|
|
|
+ select b1.device_id,b1.attribute_id,max(b1.collect_date) collect_date
|
|
|
+ from sms_day_report b1
|
|
|
+ where b1.year = year(now() + interval-1 day) and b1.month = month(now() + interval-1 day) and b1.day = day(now() + interval-1 day)
|
|
|
+ group by b1.device_id,b1.attribute_id )c2 on c1.device_id=c2.device_id and c1.attribute_id=c2.attribute_id and c1.collect_date=c2.collect_date
|
|
|
)t9 on t9.device_id=t2.device_id and t9.attribute_id =t7.attribute_id
|
|
|
</if>
|
|
|
<if test="type == 5 ">
|