LightStripDevMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.LightStripDevDao">
  4. <select id="getLightStripTotalByDTO" resultType="Integer">
  5. select count(l.id) as total
  6. from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
  7. <if test="sectionList != null and !sectionList.isEmpty()">
  8. where lp.sectionid in
  9. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  10. #{dto}
  11. </foreach>
  12. </if>
  13. </select>
  14. <select id="getLightStripOnlineTotalByDTO" resultType="Integer">
  15. select count(l.id) as total
  16. from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
  17. where l.online = 1
  18. <if test="sectionList != null and !sectionList.isEmpty()">
  19. and lp.sectionid in
  20. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  21. #{dto}
  22. </foreach>
  23. </if>
  24. </select>
  25. <select id="getLightStripOpenTotalByDTO" resultType="Integer">
  26. select count(l.id) as total
  27. from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
  28. where l.online = 1 and l.status = 1
  29. <if test="sectionList != null and !sectionList.isEmpty()">
  30. and lp.sectionid in
  31. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  32. #{dto}
  33. </foreach>
  34. </if>
  35. </select>
  36. <select id="getLightStripListByDTO" resultType="LightStripDevDTO">
  37. select
  38. <choose>
  39. <when test="version == 0">
  40. gl.chinese_name as area,
  41. </when>
  42. <when test="version == 1">
  43. gl.english_name as area,
  44. </when>
  45. <otherwise>
  46. gl.ru_name as area,
  47. </otherwise>
  48. </choose>
  49. l.id,l.lamp_pole_id lampPoleId,lp.name as lampPoleName,s.name as section,l.name,l.number,l.model,l.online,l.online2,
  50. l.online3,l.address,l.status,l.color,l.factory,w.model as cloudBoxModel,l.serial_port serialPort,l.type,l.mode,l.netType,
  51. l.imei,l.patrol,l.createtime as createTime,l.updatetime as updateTime,l.powerSwitch,l.gridVolt,l.gridCurr,l.power,l.freq,
  52. l.soft_verson softVersion,l.hard_version hardVersion,l.usedEnergyTotal,l.gridVolt2,l.gridCurr2,l.power2,l.usedEnergyTotal2,l.groupid as groupId,
  53. l.batVolt,l.batCurr,l.batPower,l.solarCurr,l.solarPower,l.charge_type chargeType,l.solarVolt,l.policyid as policyId,lsp.name as policyName,
  54. l.install_date installDate,l.expiration_date expirationDate,s.timezone,sd.id as mpptDevId,sd.address as mpptDevAddress,sd.type as mpptDevType,
  55. sd.serial_port as mpptDevSerialPort,sd.number as mpptDevNumber,sd.name as mpptDevName,l.solarSwitchVol as solarVoltage,l.switchVol as voltage
  56. from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
  57. left join light_strip_policy lsp on l.policyid = lsp.id
  58. left join solar_dev sd on lp.id = sd.lamp_pole_id
  59. left join wifi w on lp.id = w.lamp_pole_id
  60. left join section s on lp.sectionid = s.id
  61. left join global_location gl on s.pid = gl.id
  62. where 1=1
  63. <if test="sectionList != null and !sectionList.isEmpty()">
  64. and lp.sectionid in
  65. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  66. #{dto}
  67. </foreach>
  68. </if>
  69. <if test="keyword != null and keyword != ''">
  70. and (l.number like '%${keyword}%' or l.name like '%${keyword}%')
  71. </if>
  72. <choose>
  73. <when test="onlineState == 1">
  74. and l.online = 0
  75. </when>
  76. <when test="onlineState == 2">
  77. and l.online = 1
  78. </when>
  79. </choose>
  80. <if test="areaId != null and areaId != 0">
  81. and l.areaid = #{areaId}
  82. </if>
  83. <if test="sectionId != null and sectionId != 0">
  84. and l.sectionid = #{sectionId}
  85. </if>
  86. order by convert(l.name using gbk) desc,l.number asc
  87. <if test="page >= 0 and count > 0">
  88. limit #{page},#{count}
  89. </if>
  90. </select>
  91. <update id="updateLightStripVoltage" parameterType="LightStripDevDTO">
  92. update
  93. light_strip_dev l
  94. set
  95. l.solarSwitchVol = #{solarVoltage},
  96. l.switchVol = #{voltage}
  97. where
  98. l.id = #{id}
  99. </update>
  100. <update id="updateLightStripData" parameterType="LightStripDevDTO">
  101. update
  102. light_strip_dev l
  103. set
  104. l.address = #{address},
  105. l.number = #{number},
  106. l.name = #{name},
  107. l.model = #{model},
  108. l.factory = #{factory},
  109. <if test="imei != null and imei != ''">
  110. l.imei = #{imei},
  111. </if>
  112. <if test="serialPort != null and serialPort != ''">
  113. l.serial_port = #{serialPort},
  114. </if>
  115. <if test="installDate != null and installDate != ''">
  116. l.install_date = #{installDate},
  117. </if>
  118. <if test="expirationDate != null and expirationDate != ''">
  119. l.expiration_date = #{expirationDate},
  120. </if>
  121. l.netType = #{netType},
  122. l.updatetime = #{updateTime}
  123. where
  124. l.id = #{id}
  125. </update>
  126. <delete id="deleteLightStripDevData">
  127. delete
  128. from light_strip_dev
  129. where id = #{id};
  130. </delete>
  131. </mapper>