PlcPolicyCmdMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.PlcPolicyCmdDao">
  4. <insert id="addPlcPolicyCmdZeroType" parameterType="PlcPolicyCmdDTO" keyProperty="id" useGeneratedKeys="true">
  5. insert into plc_policy_cmd(plc_policy_id, policyType, base_time_type,
  6. <if test="startTime1 != null and startTime1 != ''">
  7. starttime1, bright1, color1,
  8. </if>
  9. <if test="endTime1 != null and endTime1 != ''">
  10. endtime1, end_bright1, end_color1,
  11. </if>
  12. <if test="startTime2 != null and startTime2 != ''">
  13. starttime2, bright2, color2,
  14. </if>
  15. <if test="endTime2 != null and endTime2 != ''">
  16. endtime2, end_bright2, end_color2,
  17. </if>
  18. <if test="startTime3 != null and startTime3 != ''">
  19. starttime3, bright3, color3,
  20. </if>
  21. <if test="endTime3 != null and endTime3 != ''">
  22. endtime3, end_bright3, end_color3,
  23. </if>
  24. <if test="startTime4 != null and startTime4 != ''">
  25. starttime4, bright4, color4,
  26. </if>
  27. <if test="endTime4 != null and endTime4 != ''">
  28. endtime4, end_bright4, end_color4,
  29. </if>
  30. <if test="startTime5 != null and startTime5 != ''">
  31. starttime5, bright5, color5,
  32. </if>
  33. <if test="endTime5 != null and endTime5 != ''">
  34. endtime5, end_bright5, end_color5,
  35. </if>
  36. <if test="startTime6 != null and startTime6 != ''">
  37. starttime6, bright6, color6,
  38. </if>
  39. <if test="endTime6 != null and endTime6 != ''">
  40. endtime6, end_bright6, end_color6,
  41. </if>
  42. <if test="weekly != null">
  43. weekly,
  44. </if>
  45. lighter_mask)
  46. values (#{plcPolicyId},#{policyType},#{baseTimeType},
  47. <if test="startTime1 != null and startTime1 != ''">
  48. #{startTime1},#{bright1},#{color1},
  49. </if>
  50. <if test="endTime1 != null and endTime1 != ''">
  51. #{endTime1},#{endBright1},#{endColor1},
  52. </if>
  53. <if test="startTime2 != null and startTime2 != ''">
  54. #{startTime2},#{bright2},#{color2},
  55. </if>
  56. <if test="endTime2 != null and endTime2 != ''">
  57. #{endTime2},#{endBright2},#{endColor2},
  58. </if>
  59. <if test="startTime3 != null and startTime3 != ''">
  60. #{startTime3},#{bright3},#{color3},
  61. </if>
  62. <if test="endTime3 != null and endTime3 != ''">
  63. #{endTime3},#{endBright3},#{endColor3},
  64. </if>
  65. <if test="startTime4 != null and startTime4 != ''">
  66. #{startTime4},#{bright4},#{color4},
  67. </if>
  68. <if test="endTime4 != null and endTime4 != ''">
  69. #{endTime4},#{endBright4},#{endColor4},
  70. </if>
  71. <if test="startTime5 != null and startTime5 != ''">
  72. #{startTime5},#{bright5},#{color5},
  73. </if>
  74. <if test="endTime5 != null and endTime5 != ''">
  75. #{endTime5},#{endBright5},#{endColor5},
  76. </if>
  77. <if test="startTime6 != null and startTime6 != ''">
  78. #{startTime6},#{bright6},#{color6},
  79. </if>
  80. <if test="endTime6 != null and endTime6 != ''">
  81. #{endTime6},#{endBright6},#{endColor6},
  82. </if>
  83. <if test="weekly != null">
  84. #{weekly},
  85. </if>
  86. #{lighterMask})
  87. </insert>
  88. <insert id="addPlcPolicyCmdSunType" useGeneratedKeys="true" keyProperty="id" parameterType="PlcPolicyCmdDTO">
  89. insert into plc_policy_cmd(plc_policy_id, policyType, base_time_type,
  90. sunrise, start_delay_time, start_bright, start_color,
  91. sunset, end_delay_time, end_bright, end_color,
  92. <if test="weekly != null">
  93. weekly,
  94. </if>
  95. lighter_mask)
  96. values (#{plcPolicyId},#{policyType},#{baseTimeType},
  97. #{sunrise},#{startDelayTime},#{startBright},#{startColor},
  98. #{sunset},#{endDelayTime},#{endBright},#{endColor},
  99. <if test="weekly != null">
  100. #{weekly},
  101. </if>
  102. #{lighterMask})
  103. </insert>
  104. <delete id="deletePlcPolicyCmdByPlcPolicyId">
  105. delete
  106. from plc_policy_cmd
  107. where plc_policy_id = #{plcPolicyId};
  108. </delete>
  109. <select id="getPlcPolicyCmdListByPolicyId" resultType="PlcPolicyCmdDTO">
  110. select
  111. p.id, p.plc_policy_id as plcPolicyId, p.policyType, p.base_time_type as baseTimeType,
  112. p.lighter_mask as lighterMask, p.starttime1 as startTime1, p.bright1, p.color1,
  113. p.endtime1 as endTime1,p.end_bright1 as endBright1, p.end_color1 as endColor1,
  114. p.starttime2 as startTime2, p.bright2, p.color2, p.endtime2 as endTime2, p.end_bright2 as endBright2, p.end_color2 as endColor2,
  115. p.starttime3 as startTime3, p.endtime3 as endTime3, p.bright3, p.color3, p.end_bright3 as endBright3, p.end_color3 as endColor3,
  116. p.starttime4 as startTime4, p.endtime4 as endTime4, p.bright4, p.color4, p.end_bright4 as endBright4, p.end_color4 as endColor4,
  117. p.starttime5 as startTime5, p.endtime5 as endTime5, p.bright5, p.color5, p.end_bright5 as endBright5, p.end_color5 as endColor5,
  118. p.starttime6 as startTime6, p.endtime6 as endTime6, p.bright6, p.color6, p.end_bright6 as endBright6, p.end_color6 as endColor6,
  119. p.sunrise, p.start_delay_time as startDelayTime, p.start_bright as startBright, p.start_color as startColor,
  120. p.sunset, p.end_delay_time as endDelayTime, p.end_bright as endBright, p.end_color as endColor,
  121. p.weekly, p.holiday_date as holidayDate, p.holiday_day as holidayDay
  122. from plc_policy_cmd p
  123. where p.plc_policy_id in
  124. <foreach collection="policyIds" item="item" open="(" separator="," close=")">
  125. #{item}
  126. </foreach>
  127. </select>
  128. <select id="getPlcPolicyCmdByPolicyId" resultType="PlcPolicyCmdDTO">
  129. select
  130. p.id, p.plc_policy_id as plcPolicyId, p.policyType, p.base_time_type as baseTimeType,
  131. p.lighter_mask as lighterMask, p.starttime1 as startTime1, p.bright1, p.color1,
  132. p.endtime1 as endTime1,p.end_bright1 as endBright1, p.end_color1 as endColor1,
  133. p.starttime2 as startTime2, p.bright2, p.color2, p.endtime2 as endTime2, p.end_bright2 as endBright2, p.end_color2 as endColor2,
  134. p.starttime3 as startTime3, p.endtime3 as endTime3, p.bright3, p.color3, p.end_bright3 as endBright3, p.end_color3 as endColor3,
  135. p.starttime4 as startTime4, p.endtime4 as endTime4, p.bright4, p.color4, p.end_bright4 as endBright4, p.end_color4 as endColor4,
  136. p.starttime5 as startTime5, p.endtime5 as endTime5, p.bright5, p.color5, p.end_bright5 as endBright5, p.end_color5 as endColor5,
  137. p.starttime6 as startTime6, p.endtime6 as endTime6, p.bright6, p.color6, p.end_bright6 as endBright6, p.end_color6 as endColor6,
  138. p.sunrise, p.start_delay_time as startDelayTime, p.start_bright as startBright, p.start_color as startColor,
  139. p.sunset, p.end_delay_time as endDelayTime, p.end_bright as endBright, p.end_color as endColor,
  140. p.weekly, p.holiday_date as holidayDate, p.holiday_day as holidayDay
  141. from plc_policy_cmd p
  142. where p.plc_policy_id = #{policyId}
  143. </select>
  144. </mapper>