| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.welampiot.dao.AirSwitchInfoDao">
- <select id="getAirSwitchInfoByBoxId" resultType="AirSwitchInfoDTO" parameterType="Integer">
- 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}
- <choose>
- <when test="online == 1">
- and a.online = 1
- </when>
- <when test="online == 2">
- and a.online = 0
- </when>
- </choose>
- order by convert(a.name using gbk) asc,a.id desc
- </select>
- <select id="getCountByBoxId" resultType="Integer" parameterType="Integer">
- select count(a.id) from air_switch_info a where a.box_id = #{boxId}
- </select>
- <select id="getCountByBoxIdAndType" resultType="Integer" parameterType="Integer">
- select count(a.id) from air_switch_info a where a.box_id = #{boxId} and a.type = #{type}
- </select>
- <select id="getCountByBoxIdAndAlarmStatus" resultType="Integer" parameterType="Integer">
- 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>
- <select id="getPolicyIdByBoxId" resultType="Integer" parameterType="Integer">
- select e.policyid from electric_box e where e.id = #{boxId}
- </select>
- <select id="getPolicyNameByPolicyId" resultType="String" parameterType="Integer">
- select lp.name policyName from loop_policy lp where lp.id = #{policyId}
- </select>
- <select id="getAirSwitchDetailById" resultType="AirSwitchInfoDTO" parameterType="Integer">
- select a.name,a.box_id boxId,a.address,a.type from air_switch_info a where a.id = #{id}
- </select>
- <insert id="add" parameterType="com.welampiot.dto.AirSwitchInfoDTO" useGeneratedKeys="true" keyProperty="id"
- >
- insert into air_switch_info(name,address,type,p_num,createtime,module_id
- <if test="boxId != null">,box_id</if>
- <if test="lampPoleId != null">,lamp_pole_id</if>
- <if test="boxAddress != null">,box_address</if>
- <if test="serialPort != null">,serial_port</if>
- )
- values
- (#{name},#{address},#{type},#{pNum},#{createTime},#{moduleId}
- <if test="boxId != null">,#{boxId}</if>
- <if test="lampPoleId != null">,#{lampPoleId}</if>
- <if test="boxAddress != null">,#{boxAddress}</if>
- <if test="serialPort != null">,#{serialPort}</if>
- )
- </insert>
- <update id="update" parameterType="com.welampiot.dto.AirSwitchInfoDTO"
- >
- update air_switch_info
- set
- name=#{name},
- address=#{address},
- type=#{type},
- p_num=#{pum},
- createtime=#{createTime},
- module_id=#{moduleId}
- <if test="boxId != null">,box_id=#{boxId},</if>
- <if test="lampPoleId != null">,lamp_pole_id=#{lampPoleId}</if>
- <if test="boxAddress != null">,box_address=#{boxAddress}</if>
- <if test="serialPort != null">,serial_port=#{serialPort}</if>
- where id = #{id}
- </update>
- <delete id="delete" parameterType="com.welampiot.dto.AirSwitchInfoDTO">
- delete from air_switch_info where id=#{id}
- </delete>
- <delete id="deleteByBoxId" parameterType="int">
- delete from air_switch_info where box_id=#{boxId}
- </delete>
- <select id="getAirSwitchAddressById" resultType="AirSwitchInfoDTO">
- 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>
- <select id="getAirSwitchAddressByModuleId" resultType="AirSwitchInfoDTO">
- 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}
- </select>
- <update id="updateAirSwitchStatusById" parameterType="AirSwitchInfoDTO">
- update air_switch_info a
- set
- a.status = #{status}
- where a.id = #{id}
- </update>
- <select id="getAirSwitchAddressByEleBoxAddr" resultType="AirSwitchInfoDTO">
- 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>
- <select id="getAirSwitchCountByEleBoxAddr" resultType="Integer">
- select
- count(*)
- from air_switch_info a
- left join electric_module e on e.id = a.module_id
- where e.address = #{address}
- </select>
- <select id="getOneAirSwitch" parameterType="HashMap" resultType="AirSwitchInfoDTO">
- 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}
- <choose>
- <when test="address != null and name == null">
- and M.address = #{address}
- </when>
- <when test="address == null and name != null">
- and M.name = #{name}
- </when>
- <otherwise>
- and M.address = #{address} and M.name = #{name}
- </otherwise>
- </choose>
- </select>
- </mapper>
|