AirSwitchInfoMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.welampiot.dao.AirSwitchInfoDao">
  4. <select id="getAirSwitchInfoByBoxId" resultType="AirSwitchInfoDTO" parameterType="Integer">
  5. select a.id,a.name,a.address,a.online,a.status,a.type,a.volA,a.curA,a.powerA,a.tempA,
  6. a.alarm_info alarmInfo,a.leakagecurA as leakageCurA,a.volB,a.curB,a.powerB,a.tempB,
  7. a.alarm_infoB alarmInfoB,a.leakagecurB as leakageCurB,a.volC,a.curC,a.powerC,a.tempC,
  8. a.alarm_infoC alarmInfoC,a.leakagecurC as leakageCurC,a.policyid as policyId,a.alarm_status alarmStatus,
  9. a.alarm_statusB alarmStatusB,a.alarm_statusC alarmStatusC,a.logtime as logTime,lp.name policyName,s.timezone
  10. 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
  11. left join section s on e.sectionid = s.id
  12. where a.box_id = #{boxId}
  13. <choose>
  14. <when test="online == 1">
  15. and a.online = 1
  16. </when>
  17. <when test="online == 2">
  18. and a.online = 0
  19. </when>
  20. </choose>
  21. order by convert(a.name using gbk) asc,a.id desc
  22. </select>
  23. <select id="getCountByBoxId" resultType="Integer" parameterType="Integer">
  24. select count(a.id) from air_switch_info a where a.box_id = #{boxId}
  25. </select>
  26. <select id="getCountByBoxIdAndType" resultType="Integer" parameterType="Integer">
  27. select count(a.id) from air_switch_info a where a.box_id = #{boxId} and a.type = #{type}
  28. </select>
  29. <select id="getCountByBoxIdAndAlarmStatus" resultType="Integer" parameterType="Integer">
  30. select count(a.id) from air_switch_info a
  31. where a.box_id = #{boxId} and (a.alarm_status = 1 or a.alarm_statusB = 1 or a.alarm_statusC = 1)
  32. </select>
  33. <select id="getPolicyIdByBoxId" resultType="Integer" parameterType="Integer">
  34. select e.policyid from electric_box e where e.id = #{boxId}
  35. </select>
  36. <select id="getPolicyNameByPolicyId" resultType="String" parameterType="Integer">
  37. select lp.name policyName from loop_policy lp where lp.id = #{policyId}
  38. </select>
  39. <select id="getAirSwitchDetailById" resultType="AirSwitchInfoDTO" parameterType="Integer">
  40. select a.name,a.box_id boxId,a.address,a.type from air_switch_info a where a.id = #{id}
  41. </select>
  42. <insert id="add" parameterType="com.welampiot.dto.AirSwitchInfoDTO" useGeneratedKeys="true" keyProperty="id"
  43. >
  44. insert into air_switch_info(name,address,type,p_num,createtime,module_id
  45. <if test="boxId != null">,box_id</if>
  46. <if test="lampPoleId != null">,lamp_pole_id</if>
  47. <if test="boxAddress != null">,box_address</if>
  48. <if test="serialPort != null">,serial_port</if>
  49. )
  50. values
  51. (#{name},#{address},#{type},#{pNum},#{createTime},#{moduleId}
  52. <if test="boxId != null">,#{boxId}</if>
  53. <if test="lampPoleId != null">,#{lampPoleId}</if>
  54. <if test="boxAddress != null">,#{boxAddress}</if>
  55. <if test="serialPort != null">,#{serialPort}</if>
  56. )
  57. </insert>
  58. <update id="update" parameterType="com.welampiot.dto.AirSwitchInfoDTO"
  59. >
  60. update air_switch_info
  61. set
  62. name=#{name},
  63. address=#{address},
  64. type=#{type},
  65. p_num=#{pum},
  66. createtime=#{createTime},
  67. module_id=#{moduleId}
  68. <if test="boxId != null">,box_id=#{boxId},</if>
  69. <if test="lampPoleId != null">,lamp_pole_id=#{lampPoleId}</if>
  70. <if test="boxAddress != null">,box_address=#{boxAddress}</if>
  71. <if test="serialPort != null">,serial_port=#{serialPort}</if>
  72. where id = #{id}
  73. </update>
  74. <delete id="delete" parameterType="com.welampiot.dto.AirSwitchInfoDTO">
  75. delete from air_switch_info where id=#{id}
  76. </delete>
  77. <delete id="deleteByBoxId" parameterType="int">
  78. delete from air_switch_info where box_id=#{boxId}
  79. </delete>
  80. </mapper>