MachineTranslateServiceDaoImplMapper.xml 11 KB

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