select a.id,a.name,a.address,a.online,a.status,a.type,a.volA,a.curA,a.powerA,a.tempA,
a.alarm_info alarmInfo,a.leakagecurA as leakageCurA,a.volB,a.curB,a.powerB,a.tempB,
a.alarm_infoB alarmInfoB,a.leakagecurB as leakageCurB,a.volC,a.curC,a.powerC,a.tempC,
a.alarm_infoC alarmInfoC,a.leakagecurC as leakageCurC,a.policyid as policyId,a.alarm_status alarmStatus,
a.alarm_statusB alarmStatusB,a.alarm_statusC alarmStatusC,a.logtime as logTime,lp.name policyName,s.timezone
from air_switch_info a left join loop_policy lp on a.policyId = lp.id left join electric_box e on a.box_id = e.id
left join section s on e.sectionid = s.id
where a.box_id = #{boxId}
and a.online = 1
and a.online = 0
order by convert(a.name using gbk) asc,a.id desc
select count(a.id) from air_switch_info a where a.box_id = #{boxId}
select count(a.id) from air_switch_info a where a.box_id = #{boxId} and a.type = #{type}
select count(a.id) from air_switch_info a
where a.box_id = #{boxId} and (a.alarm_status = 1 or a.alarm_statusB = 1 or a.alarm_statusC = 1)
select e.policyid from electric_box e where e.id = #{boxId}
select lp.name policyName from loop_policy lp where lp.id = #{policyId}
select a.name,a.box_id boxId,a.address,a.type from air_switch_info a where a.id = #{id}
insert into air_switch_info(name,address,type,p_num,createtime,module_id
,box_id
,lamp_pole_id
,box_address
,serial_port
)
values
(#{name},#{address},#{type},#{pNum},#{createTime},#{moduleId}
,#{boxId}
,#{lampPoleId}
,#{boxAddress}
,#{serialPort}
)
update air_switch_info
set
name=#{name},
address=#{address},
type=#{type},
p_num=#{pum},
createtime=#{createTime},
module_id=#{moduleId}
,box_id=#{boxId},
,lamp_pole_id=#{lampPoleId}
,box_address=#{boxAddress}
,serial_port=#{serialPort}
where id = #{id}
delete from air_switch_info where id=#{id}
delete from air_switch_info where box_id=#{boxId}
select a.address,em.address as moduleAddress,a.module_id as moduleId
from air_switch_info a
left join electric_module em on a.module_id = em.id
where a.id = #{id}
select a.id,a.address,em.address as moduleAddress,a.policyid as policyId
from air_switch_info a
left join electric_module em on a.module_id = em.id
where a.module_id = #{moduleId}
update air_switch_info a
set
a.status = #{status}
where a.id = #{id}
select
a.id,
a.name,
a.address,
a.box_address as boxAddress
from air_switch_info a
left join electric_module e on a.module_id = e.id
where e.address = #{address}
select
count(*)
from air_switch_info a
left join electric_module e on e.id = a.module_id
where e.address = #{address}
select E.id
from air_switch_info M
left join electric_box E on M.box_id = E.id
where E.areaid = #{areaId} and E.sectionid = #{sectionid}
and M.address = #{address}
and M.name = #{name}
and M.address = #{address} and M.name = #{name}