LightStripGroupMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.LightStripGroupDao">
  4. <select id="getLightStripGroupByDTO" resultType="LightStripGroupDTO">
  5. select
  6. <choose>
  7. <when test="version == 0">
  8. gl.chinese_name as area,
  9. </when>
  10. <when test="version == 1">
  11. gl.english_name as area,
  12. </when>
  13. <otherwise>
  14. gl.ru_name as area,
  15. </otherwise>
  16. </choose>
  17. l.id,l.name,l.number,l.lightcount as lightCount,l.type,l.value,s.name as section,lsp.name as policyName,lsp.id as policyId
  18. from light_strip_group l left join lamp_pole lp on l.sectionid = lp.sectionid
  19. left join light_strip_dev lsd on lp.id = lsd.lamp_pole_id
  20. left join light_strip_policy lsp on lsd.policyid = lsp.id
  21. left join section s on lp.sectionid = s.id
  22. left join global_location gl on s.pid = gl.id
  23. where 1=1
  24. <if test="sectionList != null and !sectionList.isEmpty()">
  25. and lp.sectionid in
  26. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  27. #{dto}
  28. </foreach>
  29. </if>
  30. <if test="areaId != null and areaId != 0">
  31. and l.areaid = #{areaId}
  32. </if>
  33. <if test="sectionId != null and sectionId != 0">
  34. and l.sectionid = #{sectionId}
  35. </if>
  36. <if test="keyword != null and keyword != ''">
  37. and (l.number like '%${keyword}%' or l.name like '%${keyword}%')
  38. </if>
  39. order by convert(l.name using gbk) desc,l.number asc
  40. <if test="page >= 0 and count > 0">
  41. limit #{page},#{count}
  42. </if>
  43. </select>
  44. <select id="getLightStripPolicyData" resultType="LightStripPolicyDTO">
  45. select l.id,l.type
  46. from light_strip_policy l
  47. where l.id = #{policyId}
  48. </select>
  49. <select id="getLightStripGroupDetailsById" resultType="LightStripGroupDTO">
  50. select
  51. <choose>
  52. <when test="version == 0">
  53. gl.chinese_name as area,
  54. </when>
  55. <when test="version == 1">
  56. gl.english_name as area,
  57. </when>
  58. <otherwise>
  59. gl.ru_name as area,
  60. </otherwise>
  61. </choose>
  62. l.areaid as areaId,l.sectionid as sectionId,s.name as section,l.number,l.lightcount as lightCount,l.type,l.value
  63. from light_strip_group l left join section s on l.sectionid = s.id
  64. left join global_location gl on s.pid = gl.id
  65. where l.id = #{id}
  66. </select>
  67. <select id="getLightStripPolicyName" resultType="String">
  68. select l.name
  69. from light_strip_policy l
  70. where l.id = #{policyId}
  71. </select>
  72. <insert id="addLightStripGroupData" parameterType="LightStripGroupDTO" keyProperty="id" useGeneratedKeys="true">
  73. insert into light_strip_group(areaid,sectionid,name,number,
  74. <if test="lightStripIds != null and lightStripIds != ''">
  75. light_strip_ids,
  76. </if>
  77. createtime,updatetime)
  78. values (#{areaId},#{sectionId},#{name},#{number},
  79. <if test="lightStripIds != null and lightStripIds != ''">
  80. #{lightStripIds},
  81. </if>
  82. #{createTime},#{updateTime})
  83. </insert>
  84. <select id="getLightStripGroupById" resultType="LightStripGroupDTO">
  85. select l.id,l.type,l.value
  86. from light_strip_group l
  87. where l.id = #{id}
  88. </select>
  89. <update id="updateLightStripGroupData" parameterType="LightStripGroupDTO">
  90. update
  91. light_strip_group l
  92. set
  93. l.areaid = #{areaId},
  94. l.sectionid = #{sectionId},
  95. l.name = #{name},
  96. <if test="lightStripIds != null and lightStripIds != ''">
  97. l.light_strip_ids = #{lightStripIds},
  98. </if>
  99. l.number = #{number},
  100. l.updatetime = #{updateTime}
  101. where
  102. l.id = #{id}
  103. </update>
  104. <select id="checkLightStripGroupData" resultType="Integer">
  105. select
  106. count(*)
  107. from light_strip_group l
  108. where 1=1
  109. <if test="sectionId != null and sectionId != 0">
  110. and l.sectionid= #{sectionId}
  111. </if>
  112. <if test="name != null and name != ''">
  113. and l.name = #{name}
  114. </if>
  115. <if test="number != null and number != ''">
  116. and l.number = #{number}
  117. </if>
  118. <if test="id != null and id != 0">
  119. and l.id != #{id}
  120. </if>
  121. </select>
  122. <delete id="deleteLightStripGroupDataByIds">
  123. delete
  124. from light_strip_group
  125. where id in
  126. <foreach collection="ids" item="item" open="(" separator="," close=")">
  127. #{item}
  128. </foreach>
  129. </delete>
  130. </mapper>