MachineTranslateServiceDaoImplMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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="machineTranslateServiceDaoImpl">
  6. <!-- 保存设备同步信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveMachineTranslate" parameterType="Map">
  8. insert into machine_translate(
  9. machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
  10. ) values (
  11. #{machineId},#{machineCode},'0',#{typeCd},#{machineTranslateId},#{objId},#{objName},#{state},#{communityId},#{bId}
  12. )
  13. </insert>
  14. <update id="updateMachineTranslate" parameterType="Map">
  15. update machine_translate t set
  16. <if test="statusCd !=null and statusCd != ''">
  17. t.status_cd= #{statusCd},
  18. </if>
  19. <if test="state !=null and state != ''">
  20. t.state= #{state},
  21. </if>
  22. <if test="updateTime !=null ">
  23. t.update_time= #{updateTime}
  24. </if>
  25. where 1=1
  26. <if test="communityId !=null and communityId != ''">
  27. and t.community_id= #{communityId}
  28. </if>
  29. <if test="objId !=null and objId != ''">
  30. and t.obj_id= #{objId}
  31. </if>
  32. <if test="machineId !=null and machineId != ''">
  33. and t.machine_id= #{machineId}
  34. </if>
  35. </update>
  36. <!-- 保存设备同步信息 add by wuxw 2018-07-03 -->
  37. <insert id="saveBusinessMachineTranslateInfo" parameterType="Map">
  38. insert into business_machine_translate(
  39. machine_id,machine_code,operate,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
  40. ) values (
  41. #{machineId},#{machineCode},#{operate},#{typeCd},#{machineTranslateId},#{objId},#{objName},#{state},#{communityId},#{bId}
  42. )
  43. </insert>
  44. <!-- 查询设备同步信息(Business) add by wuxw 2018-07-03 -->
  45. <select id="getBusinessMachineTranslateInfo" parameterType="Map" resultType="Map">
  46. select t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code
  47. machineCode,t.operate,t.type_cd,t.type_cd typeCd,t.machine_translate_id,t.machine_translate_id
  48. machineTranslateId,t.obj_id,t.obj_id objId,t.obj_name,t.obj_name objName,t.state,t.community_id,t.community_id
  49. communityId,t.b_id,t.b_id bId
  50. from business_machine_translate t
  51. where 1 =1
  52. <if test="machineId !=null and machineId != ''">
  53. and t.machine_id= #{machineId}
  54. </if>
  55. <if test="machineCode !=null and machineCode != ''">
  56. and t.machine_code= #{machineCode}
  57. </if>
  58. <if test="operate !=null and operate != ''">
  59. and t.operate= #{operate}
  60. </if>
  61. <if test="typeCd !=null and typeCd != ''">
  62. and t.type_cd= #{typeCd}
  63. </if>
  64. <if test="machineTranslateId !=null and machineTranslateId != ''">
  65. and t.machine_translate_id= #{machineTranslateId}
  66. </if>
  67. <if test="objId !=null and objId != ''">
  68. and t.obj_id= #{objId}
  69. </if>
  70. <if test="objName !=null and objName != ''">
  71. and t.obj_name= #{objName}
  72. </if>
  73. <if test="state !=null and state != ''">
  74. and t.state= #{state}
  75. </if>
  76. <if test="communityId !=null and communityId != ''">
  77. and t.community_id= #{communityId}
  78. </if>
  79. <if test="bId !=null and bId != ''">
  80. and t.b_id= #{bId}
  81. </if>
  82. </select>
  83. <!-- 保存设备同步信息至 instance表中 add by wuxw 2018-07-03 -->
  84. <insert id="saveMachineTranslateInfoInstance" parameterType="Map">
  85. insert into machine_translate(
  86. machine_id,machine_code,type_cd,machine_translate_id,obj_id,status_cd,obj_name,state,community_id,b_id
  87. ) select
  88. t.machine_id,t.machine_code,t.type_cd,t.machine_translate_id,t.obj_id,'0',t.obj_name,t.state,t.community_id,t.b_id
  89. from business_machine_translate t where 1=1
  90. <if test="machineId !=null and machineId != ''">
  91. and t.machine_id= #{machineId}
  92. </if>
  93. <if test="machineCode !=null and machineCode != ''">
  94. and t.machine_code= #{machineCode}
  95. </if>
  96. and t.operate= 'ADD'
  97. <if test="typeCd !=null and typeCd != ''">
  98. and t.type_cd= #{typeCd}
  99. </if>
  100. <if test="machineTranslateId !=null and machineTranslateId != ''">
  101. and t.machine_translate_id= #{machineTranslateId}
  102. </if>
  103. <if test="objId !=null and objId != ''">
  104. and t.obj_id= #{objId}
  105. </if>
  106. <if test="objName !=null and objName != ''">
  107. and t.obj_name= #{objName}
  108. </if>
  109. <if test="state !=null and state != ''">
  110. and t.state= #{state}
  111. </if>
  112. <if test="communityId !=null and communityId != ''">
  113. and t.community_id= #{communityId}
  114. </if>
  115. <if test="bId !=null and bId != ''">
  116. and t.b_id= #{bId}
  117. </if>
  118. </insert>
  119. <!-- 查询设备同步信息 add by wuxw 2018-07-03 -->
  120. <select id="getMachineTranslateInfo" parameterType="Map" resultType="Map">
  121. select t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code machineCode,t.type_cd,t.type_cd
  122. typeCd,t.machine_translate_id,t.machine_translate_id machineTranslateId,t.obj_id,t.obj_id
  123. objId,t.status_cd,t.status_cd statusCd,t.obj_name,t.obj_name objName,t.state,t.community_id,t.community_id
  124. communityId,t.b_id,t.b_id bId,td.name typeCdName,td1.name stateName,t.create_time createTime
  125. from machine_translate t,t_dict td,t_dict td1
  126. where 1 =1
  127. and t.type_cd=td.status_cd
  128. and td.table_name='machine_translate'
  129. and td.table_columns='type_cd'
  130. and t.state=td1.status_cd
  131. and td1.table_name='machine_translate'
  132. and td1.table_columns='state'
  133. <if test="machineId !=null and machineId != ''">
  134. and t.machine_id= #{machineId}
  135. </if>
  136. <if test="machineCode !=null and machineCode != ''">
  137. and t.machine_code= #{machineCode}
  138. </if>
  139. <if test="typeCd !=null and typeCd != ''">
  140. and t.type_cd= #{typeCd}
  141. </if>
  142. <if test="machineTranslateId !=null and machineTranslateId != ''">
  143. and t.machine_translate_id= #{machineTranslateId}
  144. </if>
  145. <if test="objId !=null and objId != ''">
  146. and t.obj_id= #{objId}
  147. </if>
  148. <if test="statusCd !=null and statusCd != ''">
  149. and t.status_cd= #{statusCd}
  150. </if>
  151. <if test="objName !=null and objName != ''">
  152. and t.obj_name= #{objName}
  153. </if>
  154. <if test="state !=null and state != ''">
  155. and t.state= #{state}
  156. </if>
  157. <if test="communityId !=null and communityId != ''">
  158. and t.community_id= #{communityId}
  159. </if>
  160. <if test="bId !=null and bId != ''">
  161. and t.b_id= #{bId}
  162. </if>
  163. order by t.update_time desc
  164. <if test="page != -1 and page != null ">
  165. limit #{page}, #{row}
  166. </if>
  167. </select>
  168. <!-- 修改设备同步信息 add by wuxw 2018-07-03 -->
  169. <update id="updateMachineTranslateInfoInstance" parameterType="Map">
  170. update machine_translate t set t.status_cd = #{statusCd}
  171. <if test="newBId != null and newBId != ''">
  172. ,t.b_id = #{newBId}
  173. </if>
  174. <if test="machineId !=null and machineId != ''">
  175. , t.machine_id= #{machineId}
  176. </if>
  177. <if test="machineCode !=null and machineCode != ''">
  178. , t.machine_code= #{machineCode}
  179. </if>
  180. <if test="typeCd !=null and typeCd != ''">
  181. , t.type_cd= #{typeCd}
  182. </if>
  183. <if test="objId !=null and objId != ''">
  184. , t.obj_id= #{objId}
  185. </if>
  186. <if test="objName !=null and objName != ''">
  187. , t.obj_name= #{objName}
  188. </if>
  189. <if test="state !=null and state != ''">
  190. , t.state= #{state}
  191. </if>
  192. <if test="communityId !=null and communityId != ''">
  193. , t.community_id= #{communityId}
  194. </if>
  195. where 1=1
  196. <if test="machineTranslateId !=null and machineTranslateId != ''">
  197. and t.machine_translate_id= #{machineTranslateId}
  198. </if>
  199. <if test="bId !=null and bId != ''">
  200. and t.b_id= #{bId}
  201. </if>
  202. </update>
  203. <!-- 查询设备同步数量 add by wuxw 2018-07-03 -->
  204. <select id="queryMachineTranslatesCount" parameterType="Map" resultType="Map">
  205. select count(1) count
  206. from machine_translate t,t_dict td,t_dict td1
  207. where 1 =1
  208. and t.type_cd=td.status_cd
  209. and td.table_name='machine_translate'
  210. and td.table_columns='type_cd'
  211. and t.state=td1.status_cd
  212. and td1.table_name='machine_translate'
  213. and td1.table_columns='state'
  214. <if test="machineId !=null and machineId != ''">
  215. and t.machine_id= #{machineId}
  216. </if>
  217. <if test="machineCode !=null and machineCode != ''">
  218. and t.machine_code= #{machineCode}
  219. </if>
  220. <if test="typeCd !=null and typeCd != ''">
  221. and t.type_cd= #{typeCd}
  222. </if>
  223. <if test="machineTranslateId !=null and machineTranslateId != ''">
  224. and t.machine_translate_id= #{machineTranslateId}
  225. </if>
  226. <if test="objId !=null and objId != ''">
  227. and t.obj_id= #{objId}
  228. </if>
  229. <if test="statusCd !=null and statusCd != ''">
  230. and t.status_cd= #{statusCd}
  231. </if>
  232. <if test="objName !=null and objName != ''">
  233. and t.obj_name= #{objName}
  234. </if>
  235. <if test="state !=null and state != ''">
  236. and t.state= #{state}
  237. </if>
  238. <if test="communityId !=null and communityId != ''">
  239. and t.community_id= #{communityId}
  240. </if>
  241. <if test="bId !=null and bId != ''">
  242. and t.b_id= #{bId}
  243. </if>
  244. </select>
  245. <update id="updateMachineTranslateState" parameterType="Map">
  246. update machine_translate t set t.state = #{state}
  247. where
  248. t.machine_code= #{machineCode}
  249. <if test="communityId !=null and communityId != ''">
  250. and t.community_id= #{communityId}
  251. </if>
  252. <if test="objId !=null and objId != ''">
  253. and t.obj_id= #{objId}
  254. </if>
  255. </update>
  256. </mapper>