<select id="queryS1ToS4Count" resultType="com.fawvw.digital.vo.S1ToS4CountVo">
select c.name, coalesce(cr.count, 0) as count
from component as c
left join (select count(*) as count, component_id
from component_record
where equipment_id = 1
and value = 'true'
group by component_id) as cr
on cr.component_id = c.id
where c.name in ('s1', 's2', 's3', 's4')
</select>
<select id="queryS1ToS4Record" resultType="com.fawvw.digital.dto.S1ToS4RecordVo">
select c.name, cr.record_time
from component_record as cr
join component as c
on c.name in ('s1', 's2', 's3', 's4')
where cr.equipment_id = #{equipmentId}
and cr.value = 'true'
</select>
<select id="queryMnpMinusActiveCmpSecond" resultType="java.lang.Integer">
select coalesce(time_to_sec(MAX(mr.record_time),MAX(cr.record_time)), 0)
from manipulation_record as mr
join component_record as cr
on cr.id = #{cmpId}
and mr.record_time > cr.record_time
and cr.value = 'true'
where mr.id = #{mnpId}
</select>
<select id="queryMnpMinusMnpSecond" resultType="java.lang.Integer">
select coalesce(time_to_sec(MAX(af.record_time),MAX(bf.record_time)), 0)
from manipulation_record as af
join manipulation_record as bf
on bf.id = #{bfId}
where af.id = #{afId}
</select>