MachineTranslateServiceDaoImplMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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,m.machine_name machineName,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,td2.`name` machineCmdName,t.obj_b_id objBId,t.remark
  134. from machine_translate t
  135. inner join t_dict td on t.type_cd=td.status_cd and td.table_name='machine_translate' and td.table_columns='type_cd'
  136. inner join t_dict td1 on t.state=td1.status_cd and td1.table_name='machine_translate' and td1.table_columns='state'
  137. inner join t_dict td2 on t.machine_cmd = td2.status_cd and td2.table_name='machine_translate' and td2.table_columns='machine_cmd'
  138. left join machine m on t.machine_id = m.machine_id and m.status_cd = '0' and t.community_id = m.community_id
  139. where 1 =1
  140. <if test="machineId !=null and machineId != ''">
  141. and t.machine_id= #{machineId}
  142. </if>
  143. <if test="machineCode !=null and machineCode != ''">
  144. and t.machine_code= #{machineCode}
  145. </if>
  146. <if test="typeCd !=null and typeCd != ''">
  147. and t.type_cd= #{typeCd}
  148. </if>
  149. <if test="machineTranslateId !=null and machineTranslateId != ''">
  150. and t.machine_translate_id= #{machineTranslateId}
  151. </if>
  152. <if test="objId !=null and objId != ''">
  153. and t.obj_id= #{objId}
  154. </if>
  155. <if test="machineCmd !=null and machineCmd != ''">
  156. and t.machine_cmd= #{machineCmd}
  157. </if>
  158. <if test='isNow !=null and isNow == "Y"'>
  159. and to_days(t.create_time) = to_days(now())
  160. </if>
  161. <if test="statusCd !=null and statusCd != ''">
  162. and t.status_cd= #{statusCd}
  163. </if>
  164. <if test="objName !=null and objName != ''">
  165. and t.obj_name= #{objName}
  166. </if>
  167. <if test="state !=null and state != ''">
  168. and t.state= #{state}
  169. </if>
  170. <if test="communityId !=null and communityId != ''">
  171. and t.community_id= #{communityId}
  172. </if>
  173. <if test="bId !=null and bId != ''">
  174. and t.b_id= #{bId}
  175. </if>
  176. order by t.update_time desc
  177. <if test="page != -1 and page != null ">
  178. limit #{page}, #{row}
  179. </if>
  180. </select>
  181. <!-- 修改设备同步信息 add by wuxw 2018-07-03 -->
  182. <update id="updateMachineTranslateInfoInstance" parameterType="Map">
  183. update machine_translate t set t.status_cd = #{statusCd}
  184. <if test="newBId != null and newBId != ''">
  185. ,t.b_id = #{newBId}
  186. </if>
  187. <if test="machineId !=null and machineId != ''">
  188. , t.machine_id= #{machineId}
  189. </if>
  190. <if test="machineCode !=null and machineCode != ''">
  191. , t.machine_code= #{machineCode}
  192. </if>
  193. <if test="typeCd !=null and typeCd != ''">
  194. , t.type_cd= #{typeCd}
  195. </if>
  196. <if test="objId !=null and objId != ''">
  197. , t.obj_id= #{objId}
  198. </if>
  199. <if test="objName !=null and objName != ''">
  200. , t.obj_name= #{objName}
  201. </if>
  202. <if test="state !=null and state != ''">
  203. , t.state= #{state}
  204. </if>
  205. <if test="communityId !=null and communityId != ''">
  206. , t.community_id= #{communityId}
  207. </if>
  208. <if test="remark !=null and remark != ''">
  209. ,t.remark= #{remark}
  210. </if>
  211. where 1=1
  212. <if test="machineTranslateId !=null and machineTranslateId != ''">
  213. and t.machine_translate_id= #{machineTranslateId}
  214. </if>
  215. <if test="bId !=null and bId != ''">
  216. and t.b_id= #{bId}
  217. </if>
  218. </update>
  219. <!-- 查询设备同步数量 add by wuxw 2018-07-03 -->
  220. <select id="queryMachineTranslatesCount" parameterType="Map" resultType="Map">
  221. select count(1) count
  222. from machine_translate t
  223. inner join t_dict td on t.type_cd=td.status_cd and td.table_name='machine_translate' and td.table_columns='type_cd'
  224. inner join t_dict td1 on t.state=td1.status_cd and td1.table_name='machine_translate' and td1.table_columns='state'
  225. inner join t_dict td2 on t.machine_cmd = td2.status_cd and td2.table_name='machine_translate' and td2.table_columns='machine_cmd'
  226. left join machine m on t.machine_id = m.machine_id and m.status_cd = '0' and t.community_id = m.community_id
  227. where 1 =1
  228. <if test="machineId !=null and machineId != ''">
  229. and t.machine_id= #{machineId}
  230. </if>
  231. <if test="machineCode !=null and machineCode != ''">
  232. and t.machine_code= #{machineCode}
  233. </if>
  234. <if test="typeCd !=null and typeCd != ''">
  235. and t.type_cd= #{typeCd}
  236. </if>
  237. <if test="machineTranslateId !=null and machineTranslateId != ''">
  238. and t.machine_translate_id= #{machineTranslateId}
  239. </if>
  240. <if test="objId !=null and objId != ''">
  241. and t.obj_id= #{objId}
  242. </if>
  243. <if test="machineCmd !=null and machineCmd != ''">
  244. and t.machine_cmd= #{machineCmd}
  245. </if>
  246. <if test='isNow !=null and isNow == "Y"'>
  247. and to_days(t.create_time) = to_days(now())
  248. </if>
  249. <if test="statusCd !=null and statusCd != ''">
  250. and t.status_cd= #{statusCd}
  251. </if>
  252. <if test="objName !=null and objName != ''">
  253. and t.obj_name= #{objName}
  254. </if>
  255. <if test="state !=null and state != ''">
  256. and t.state= #{state}
  257. </if>
  258. <if test="communityId !=null and communityId != ''">
  259. and t.community_id= #{communityId}
  260. </if>
  261. <if test="bId !=null and bId != ''">
  262. and t.b_id= #{bId}
  263. </if>
  264. </select>
  265. <update id="updateMachineTranslateState" parameterType="Map">
  266. update machine_translate t
  267. <set>
  268. <if test="statusCd !=null and statusCd != ''">
  269. t.status_cd= #{statusCd},
  270. </if>
  271. <if test="state !=null and state != ''">
  272. t.state= #{state},
  273. </if>
  274. <if test="updateTime !=null ">
  275. t.update_time= #{updateTime},
  276. </if>
  277. <if test="remark !=null and remark != ''">
  278. t.remark= #{remark}
  279. </if>
  280. </set>
  281. where
  282. 1=1
  283. <if test="machineCode !=null and machineCode != ''">
  284. and t.machine_code= #{machineCode}
  285. </if>
  286. <if test="communityId !=null and communityId != ''">
  287. and t.community_id= #{communityId}
  288. </if>
  289. <if test="objId !=null and objId != ''">
  290. and t.obj_id= #{objId}
  291. </if>
  292. <if test="machineTranslateId !=null and machineTranslateId != ''">
  293. and t.machine_translate_id= #{machineTranslateId}
  294. </if>
  295. </update>
  296. </mapper>