|
@@ -107,7 +107,7 @@
|
|
|
<sql id="deviceInnerJoins">
|
|
|
inner join sms_scene_type t3 on t1.scene_type_id=t3.id
|
|
|
inner join sms_device_scene t2 on t2.parent_scene_id=t1.id and t2. status = 1
|
|
|
- inner join sms_device t6 on t2.device_id=t6.id and t6. status = 1
|
|
|
+ inner join sms_device t6 on t2.device_id=t6.id and t6. status = 1 and t6.enable_state = 1
|
|
|
inner join sms_scene t4 on t2.scene_id=t4.id
|
|
|
inner join sms_scene_type t5 on t4.scene_type_id=t5.id and t5. status = 1
|
|
|
</sql>
|
|
@@ -115,7 +115,7 @@
|
|
|
<sql id="deviceLeftJoins">
|
|
|
inner join sms_scene_type t3 on t1.scene_type_id=t3.id and t3. status = 1
|
|
|
left join sms_device_scene t2 on t2.parent_scene_id=t1.id and t2. status = 1
|
|
|
- left join sms_device t6 on t2.device_id=t6.id and t6. status = 1
|
|
|
+ left join sms_device t6 on t2.device_id=t6.id and t6. status = 1 and t6.enable_state = 1
|
|
|
left join sms_scene t4 on t2.scene_id=t4.id and t4. status = 1
|
|
|
left join sms_scene_type t5 on t4.scene_type_id=t5.id and t5. status = 1 and t5.scene_type_name = #{sceneTypeName}
|
|
|
</sql>
|
|
@@ -274,10 +274,10 @@
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
left join (
|
|
|
select c1.device_id,c1.attribute_id,c1.latest_value
|
|
|
- from sms_day_report c1
|
|
|
+ from sms_month_report c1
|
|
|
inner join (
|
|
|
select b1.device_id,b1.attribute_id,max(b1.collect_date) collect_date
|
|
|
- from sms_day_report b1
|
|
|
+ from sms_month_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
|
|
|
)t8 on t8.device_id=t2.device_id and t8.attribute_id =t5.attribute_id
|
|
@@ -428,10 +428,10 @@
|
|
|
and t7.parm_type in(16)
|
|
|
left join (
|
|
|
select c1.device_id,c1.attribute_id,c1.latest_value
|
|
|
- from sms_day_report c1
|
|
|
+ from sms_month_report c1
|
|
|
inner join (
|
|
|
select b1.device_id,b1.attribute_id,max(b1.collect_date) collect_date
|
|
|
- from sms_day_report b1
|
|
|
+ from sms_month_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
|