MachineAttrServiceDaoImplMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="machineAttrServiceDaoImpl">
  6. <!-- 保存设备属性信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessMachineAttrInfo" parameterType="Map">
  8. insert into business_machine_attrs(
  9. machine_id,attr_id,operate,spec_cd,community_id,b_id,value
  10. ) values (
  11. #{machineId},#{attrId},#{operate},#{specCd},#{communityId},#{bId},#{value}
  12. )
  13. </insert>
  14. <!-- 查询设备属性信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessMachineAttrInfo" parameterType="Map" resultType="Map">
  16. select t.machine_id,t.machine_id machineId,t.attr_id,t.attr_id attrId,t.operate,t.spec_cd,t.spec_cd
  17. specCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value
  18. from business_machine_attrs t
  19. where 1 =1
  20. <if test="machineId !=null and machineId != ''">
  21. and t.machine_id= #{machineId}
  22. </if>
  23. <if test="attrId !=null and attrId != ''">
  24. and t.attr_id= #{attrId}
  25. </if>
  26. <if test="operate !=null and operate != ''">
  27. and t.operate= #{operate}
  28. </if>
  29. <if test="specCd !=null and specCd != ''">
  30. and t.spec_cd= #{specCd}
  31. </if>
  32. <if test="communityId !=null and communityId != ''">
  33. and t.community_id= #{communityId}
  34. </if>
  35. <if test="bId !=null and bId != ''">
  36. and t.b_id= #{bId}
  37. </if>
  38. <if test="value !=null and value != ''">
  39. and t.value= #{value}
  40. </if>
  41. </select>
  42. <!-- 保存设备属性信息至 instance表中 add by wuxw 2018-07-03 -->
  43. <insert id="saveMachineAttrInfoInstance" parameterType="Map">
  44. insert into machine_attrs(
  45. machine_id,attr_id,spec_cd,status_cd,community_id,b_id,value
  46. ) select t.machine_id,t.attr_id,t.spec_cd,'0',t.community_id,t.b_id,t.value from business_machine_attrs t where
  47. 1=1
  48. <if test="machineId !=null and machineId != ''">
  49. and t.machine_id= #{machineId}
  50. </if>
  51. <if test="attrId !=null and attrId != ''">
  52. and t.attr_id= #{attrId}
  53. </if>
  54. and t.operate= 'ADD'
  55. <if test="specCd !=null and specCd != ''">
  56. and t.spec_cd= #{specCd}
  57. </if>
  58. <if test="communityId !=null and communityId != ''">
  59. and t.community_id= #{communityId}
  60. </if>
  61. <if test="bId !=null and bId != ''">
  62. and t.b_id= #{bId}
  63. </if>
  64. <if test="value !=null and value != ''">
  65. and t.value= #{value}
  66. </if>
  67. </insert>
  68. <!-- 查询设备属性信息 add by wuxw 2018-07-03 -->
  69. <select id="getMachineAttrInfo" parameterType="Map" resultType="Map">
  70. select t.machine_id,t.machine_id machineId,t.attr_id,t.attr_id attrId,t.spec_cd,t.spec_cd
  71. specCd,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value
  72. from machine_attrs t
  73. where 1 =1
  74. <if test="machineId !=null and machineId != ''">
  75. and t.machine_id= #{machineId}
  76. </if>
  77. <if test="machineIds !=null ">
  78. and t.machine_id in
  79. <foreach collection="machineIds" item="item" index="index" open="(" close=")" separator=",">
  80. #{item}
  81. </foreach>
  82. </if>
  83. <if test="attrId !=null and attrId != ''">
  84. and t.attr_id= #{attrId}
  85. </if>
  86. <if test="specCd !=null and specCd != ''">
  87. and t.spec_cd= #{specCd}
  88. </if>
  89. <if test="statusCd !=null and statusCd != ''">
  90. and t.status_cd= #{statusCd}
  91. </if>
  92. <if test="communityId !=null and communityId != ''">
  93. and t.community_id= #{communityId}
  94. </if>
  95. <if test="bId !=null and bId != ''">
  96. and t.b_id= #{bId}
  97. </if>
  98. <if test="value !=null and value != ''">
  99. and t.value= #{value}
  100. </if>
  101. <if test="page != -1 and page != null ">
  102. limit #{page}, #{row}
  103. </if>
  104. </select>
  105. <!-- 修改设备属性信息 add by wuxw 2018-07-03 -->
  106. <update id="updateMachineAttrInfoInstance" parameterType="Map">
  107. update machine_attrs t set t.status_cd = #{statusCd}
  108. <if test="newBId != null and newBId != ''">
  109. ,t.b_id = #{newBId}
  110. </if>
  111. <if test="machineId !=null and machineId != ''">
  112. , t.machine_id= #{machineId}
  113. </if>
  114. <if test="specCd !=null and specCd != ''">
  115. , t.spec_cd= #{specCd}
  116. </if>
  117. <if test="communityId !=null and communityId != ''">
  118. , t.community_id= #{communityId}
  119. </if>
  120. <if test="value !=null and value != ''">
  121. , t.value= #{value}
  122. </if>
  123. where 1=1
  124. <if test="attrId !=null and attrId != ''">
  125. and t.attr_id= #{attrId}
  126. </if>
  127. <if test="bId !=null and bId != ''">
  128. and t.b_id= #{bId}
  129. </if>
  130. </update>
  131. <!-- 查询设备属性数量 add by wuxw 2018-07-03 -->
  132. <select id="queryMachineAttrsCount" parameterType="Map" resultType="Map">
  133. select count(1) count
  134. from machine_attrs t
  135. where 1 =1
  136. <if test="machineId !=null and machineId != ''">
  137. and t.machine_id= #{machineId}
  138. </if>
  139. <if test="machineIds !=null ">
  140. and t.machine_id in
  141. <foreach collection="machineIds" item="item" index="index" open="(" close=")" separator=",">
  142. #{item}
  143. </foreach>
  144. </if>
  145. <if test="attrId !=null and attrId != ''">
  146. and t.attr_id= #{attrId}
  147. </if>
  148. <if test="specCd !=null and specCd != ''">
  149. and t.spec_cd= #{specCd}
  150. </if>
  151. <if test="statusCd !=null and statusCd != ''">
  152. and t.status_cd= #{statusCd}
  153. </if>
  154. <if test="communityId !=null and communityId != ''">
  155. and t.community_id= #{communityId}
  156. </if>
  157. <if test="bId !=null and bId != ''">
  158. and t.b_id= #{bId}
  159. </if>
  160. <if test="value !=null and value != ''">
  161. and t.value= #{value}
  162. </if>
  163. </select>
  164. </mapper>