| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?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>
- </mapper>
|