MachineAttrServiceDaoImplMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. <insert id="saveMachineAttrs" parameterType="Map">
  15. insert into machine_attrs(
  16. machine_id,attr_id,spec_cd,community_id,b_id,value
  17. ) values (
  18. #{machineId},#{attrId},#{specCd},#{communityId},'-1',#{value}
  19. )
  20. </insert>
  21. <!-- 查询设备属性信息(Business) add by wuxw 2018-07-03 -->
  22. <select id="getBusinessMachineAttrInfo" parameterType="Map" resultType="Map">
  23. select t.machine_id,t.machine_id machineId,t.attr_id,t.attr_id attrId,t.operate,t.spec_cd,t.spec_cd
  24. specCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value
  25. from business_machine_attrs t
  26. where 1 =1
  27. <if test="machineId !=null and machineId != ''">
  28. and t.machine_id= #{machineId}
  29. </if>
  30. <if test="attrId !=null and attrId != ''">
  31. and t.attr_id= #{attrId}
  32. </if>
  33. <if test="operate !=null and operate != ''">
  34. and t.operate= #{operate}
  35. </if>
  36. <if test="specCd !=null and specCd != ''">
  37. and t.spec_cd= #{specCd}
  38. </if>
  39. <if test="communityId !=null and communityId != ''">
  40. and t.community_id= #{communityId}
  41. </if>
  42. <if test="bId !=null and bId != ''">
  43. and t.b_id= #{bId}
  44. </if>
  45. <if test="value !=null and value != ''">
  46. and t.value= #{value}
  47. </if>
  48. </select>
  49. <!-- 保存设备属性信息至 instance表中 add by wuxw 2018-07-03 -->
  50. <insert id="saveMachineAttrInfoInstance" parameterType="Map">
  51. insert into machine_attrs(
  52. machine_id,attr_id,spec_cd,status_cd,community_id,b_id,value
  53. ) 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
  54. 1=1
  55. <if test="machineId !=null and machineId != ''">
  56. and t.machine_id= #{machineId}
  57. </if>
  58. <if test="attrId !=null and attrId != ''">
  59. and t.attr_id= #{attrId}
  60. </if>
  61. and t.operate= 'ADD'
  62. <if test="specCd !=null and specCd != ''">
  63. and t.spec_cd= #{specCd}
  64. </if>
  65. <if test="communityId !=null and communityId != ''">
  66. and t.community_id= #{communityId}
  67. </if>
  68. <if test="bId !=null and bId != ''">
  69. and t.b_id= #{bId}
  70. </if>
  71. <if test="value !=null and value != ''">
  72. and t.value= #{value}
  73. </if>
  74. </insert>
  75. <!-- 查询设备属性信息 add by wuxw 2018-07-03 -->
  76. <select id="getMachineAttrInfo" parameterType="Map" resultType="Map">
  77. select t.machine_id,t.machine_id machineId,t.attr_id,t.attr_id attrId,t.spec_cd,t.spec_cd
  78. specCd,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value,
  79. s.spec_name specName,
  80. v.value_name valueName,
  81. s.list_show listShow
  82. from machine_attrs t
  83. left join attr_spec s on t.spec_cd = s.spec_cd and s.status_cd = '0' and s.table_name = 'machine_attr'
  84. left join attr_value v on t.`value` = v.`value` and t.spec_cd = v.spec_cd and v.status_cd = '0'
  85. where 1 =1
  86. <if test="machineId !=null and machineId != ''">
  87. and t.machine_id= #{machineId}
  88. </if>
  89. <if test="machineIds !=null ">
  90. and t.machine_id in
  91. <foreach collection="machineIds" item="item" index="index" open="(" close=")" separator=",">
  92. #{item}
  93. </foreach>
  94. </if>
  95. <if test="attrId !=null and attrId != ''">
  96. and t.attr_id= #{attrId}
  97. </if>
  98. <if test="specCd !=null and specCd != ''">
  99. and t.spec_cd= #{specCd}
  100. </if>
  101. <if test="statusCd !=null and statusCd != ''">
  102. and t.status_cd= #{statusCd}
  103. </if>
  104. <if test="communityId !=null and communityId != ''">
  105. and t.community_id= #{communityId}
  106. </if>
  107. <if test="bId !=null and bId != ''">
  108. and t.b_id= #{bId}
  109. </if>
  110. <if test="value !=null and value != ''">
  111. and t.value= #{value}
  112. </if>
  113. <if test="page != -1 and page != null ">
  114. limit #{page}, #{row}
  115. </if>
  116. </select>
  117. <!-- 修改设备属性信息 add by wuxw 2018-07-03 -->
  118. <update id="updateMachineAttrInfoInstance" parameterType="Map">
  119. update machine_attrs t set t.status_cd = #{statusCd}
  120. <if test="newBId != null and newBId != ''">
  121. ,t.b_id = #{newBId}
  122. </if>
  123. <if test="machineId !=null and machineId != ''">
  124. , t.machine_id= #{machineId}
  125. </if>
  126. <if test="specCd !=null and specCd != ''">
  127. , t.spec_cd= #{specCd}
  128. </if>
  129. <if test="communityId !=null and communityId != ''">
  130. , t.community_id= #{communityId}
  131. </if>
  132. <if test="value !=null and value != ''">
  133. , t.value= #{value}
  134. </if>
  135. where 1=1
  136. <if test="attrId !=null and attrId != ''">
  137. and t.attr_id= #{attrId}
  138. </if>
  139. <if test="bId !=null and bId != ''">
  140. and t.b_id= #{bId}
  141. </if>
  142. </update>
  143. <!-- 查询设备属性数量 add by wuxw 2018-07-03 -->
  144. <select id="queryMachineAttrsCount" parameterType="Map" resultType="Map">
  145. select count(1) count
  146. from machine_attrs t
  147. where 1 =1
  148. <if test="machineId !=null and machineId != ''">
  149. and t.machine_id= #{machineId}
  150. </if>
  151. <if test="machineIds !=null ">
  152. and t.machine_id in
  153. <foreach collection="machineIds" item="item" index="index" open="(" close=")" separator=",">
  154. #{item}
  155. </foreach>
  156. </if>
  157. <if test="attrId !=null and attrId != ''">
  158. and t.attr_id= #{attrId}
  159. </if>
  160. <if test="specCd !=null and specCd != ''">
  161. and t.spec_cd= #{specCd}
  162. </if>
  163. <if test="statusCd !=null and statusCd != ''">
  164. and t.status_cd= #{statusCd}
  165. </if>
  166. <if test="communityId !=null and communityId != ''">
  167. and t.community_id= #{communityId}
  168. </if>
  169. <if test="bId !=null and bId != ''">
  170. and t.b_id= #{bId}
  171. </if>
  172. <if test="value !=null and value != ''">
  173. and t.value= #{value}
  174. </if>
  175. </select>
  176. </mapper>