MachineServiceDaoImplMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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="machineServiceDaoImpl">
  6. <!-- 保存设备信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessMachineInfo" parameterType="Map">
  8. insert into business_machine(
  9. machine_mac,machine_id,machine_code,auth_code,operate,machine_version,community_id,b_id,
  10. machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state,direction,heartbeat_time,type_id
  11. ) values (
  12. #{machineMac},#{machineId},#{machineCode},#{authCode},#{operate},#{machineVersion},
  13. #{communityId},#{bId},#{machineName},#{machineTypeCd},#{machineIp},
  14. #{locationTypeCd},#{locationObjId},#{state},#{direction},#{heartbeatTime},#{typeId}
  15. )
  16. </insert>
  17. <!-- 查询设备信息(Business) add by wuxw 2018-07-03 -->
  18. <select id="getBusinessMachineInfo" parameterType="Map" resultType="Map">
  19. select t.machine_mac,t.machine_mac machineMac,t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code
  20. machineCode,t.auth_code,t.auth_code authCode,t.operate,t.machine_version,t.machine_version
  21. machineVersion,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.machine_name,t.machine_name
  22. machineName,t.machine_type_cd,t.machine_type_cd machineTypeCd,t.machine_ip,t.machine_ip machineIp,
  23. t.location_type_cd,t.location_obj_id,t.state,t.location_type_cd,t.location_obj_id,t.location_type_cd
  24. locationTypeCd,t.location_obj_id locationObjId,t.direction,t.heartbeat_time,t.heartbeat_time heartbeatTime,t.type_id typeId
  25. from business_machine t
  26. where 1 =1
  27. <if test="machineMac !=null and machineMac != ''">
  28. and t.machine_mac= #{machineMac}
  29. </if>
  30. <if test="machineId !=null and machineId != ''">
  31. and t.machine_id= #{machineId}
  32. </if>
  33. <if test="machineCode !=null and machineCode != ''">
  34. and t.machine_code= #{machineCode}
  35. </if>
  36. <if test="authCode !=null and authCode != ''">
  37. and t.auth_code= #{authCode}
  38. </if>
  39. <if test="operate !=null and operate != ''">
  40. and t.operate= #{operate}
  41. </if>
  42. <if test="machineVersion !=null and machineVersion != ''">
  43. and t.machine_version= #{machineVersion}
  44. </if>
  45. <if test="communityId !=null and communityId != ''">
  46. and t.community_id= #{communityId}
  47. </if>
  48. <if test="bId !=null and bId != ''">
  49. and t.b_id= #{bId}
  50. </if>
  51. <if test="machineName !=null and machineName != ''">
  52. and t.machine_name= #{machineName}
  53. </if>
  54. <if test="machineTypeCd !=null and machineTypeCd != ''">
  55. and t.machine_type_cd= #{machineTypeCd}
  56. </if>
  57. <if test="machineIp !=null and machineIp != ''">
  58. and t.machine_ip= #{machineIp}
  59. </if>
  60. <if test="typeId !=null and typeId != ''">
  61. and t.type_id= #{typeId}
  62. </if>
  63. <if test="locationTypeCd !=null and locationTypeCd != ''">
  64. and t.location_type_cd= #{locationTypeCd}
  65. </if>
  66. <if test="locationObjId !=null and locationObjId != ''">
  67. and t.location_obj_id= #{locationObjId}
  68. </if>
  69. <if test="state !=null and state != ''">
  70. and t.state = #{state}
  71. </if>
  72. <if test="direction !=null and direction != ''">
  73. and t.direction = #{direction}
  74. </if>
  75. </select>
  76. <!-- 保存设备信息至 instance表中 add by wuxw 2018-07-03 -->
  77. <insert id="saveMachineInfoInstance" parameterType="Map">
  78. insert into machine(
  79. machine_mac,machine_id,machine_code,auth_code,machine_version,status_cd,
  80. community_id,b_id,machine_name,machine_type_cd,machine_ip,
  81. location_type_cd,location_obj_id,state,direction,heartbeat_time,type_id
  82. ) select
  83. t.machine_mac,t.machine_id,t.machine_code,t.auth_code,t.machine_version,'0',t.community_id,t.b_id,
  84. t.machine_name,t.machine_type_cd,t.machine_ip,
  85. t.location_type_cd,t.location_obj_id,t.state,t.direction,t.heartbeat_time,type_id
  86. from business_machine t where 1=1
  87. <if test="machineMac !=null and machineMac != ''">
  88. and t.machine_mac= #{machineMac}
  89. </if>
  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. <if test="authCode !=null and authCode != ''">
  97. and t.auth_code= #{authCode}
  98. </if>
  99. and t.operate= 'ADD'
  100. <if test="machineVersion !=null and machineVersion != ''">
  101. and t.machine_version= #{machineVersion}
  102. </if>
  103. <if test="communityId !=null and communityId != ''">
  104. and t.community_id= #{communityId}
  105. </if>
  106. <if test="bId !=null and bId != ''">
  107. and t.b_id= #{bId}
  108. </if>
  109. <if test="typeId !=null and typeId != ''">
  110. and t.type_id= #{typeId}
  111. </if>
  112. <if test="machineName !=null and machineName != ''">
  113. and t.machine_name= #{machineName}
  114. </if>
  115. <if test="machineTypeCd !=null and machineTypeCd != ''">
  116. and t.machine_type_cd= #{machineTypeCd}
  117. </if>
  118. <if test="machineIp !=null and machineIp != ''">
  119. and t.machine_ip= #{machineIp}
  120. </if>
  121. <if test="locationTypeCd !=null and locationTypeCd != ''">
  122. and t.location_type_cd= #{locationTypeCd}
  123. </if>
  124. <if test="locationObjId !=null and locationObjId != ''">
  125. and t.location_obj_id= #{locationObjId}
  126. </if>
  127. <if test="state !=null and state != ''">
  128. and t.state = #{state}
  129. </if>
  130. <if test="direction !=null and direction != ''">
  131. and t.direction = #{direction}
  132. </if>
  133. </insert>
  134. <!-- 查询设备信息 add by wuxw 2018-07-03 -->
  135. <select id="getMachineInfo" parameterType="Map" resultType="Map">
  136. select t.machine_mac,t.machine_mac machineMac,t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code
  137. machineCode,t.auth_code,t.auth_code authCode,t.machine_version,t.machine_version
  138. machineVersion,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id
  139. bId,t.machine_name,t.machine_name machineName,t.machine_type_cd,t.machine_type_cd
  140. machineTypeCd,t.machine_ip,t.machine_ip machineIp,td.name machineTypeCdName,
  141. t.state,c.location_id locationTypeCd, c.location_name locationTypeName, t.location_obj_id locationObjId,
  142. t.location_type_cd,t.location_obj_id,t.heartbeat_time,t.heartbeat_time heartbeatTime,
  143. td1.name stateName,t.create_time createTime,t.direction,td3.name directionName,t.type_id typeId
  144. from machine t
  145. left join t_dict td on t.machine_type_cd=td.status_cd and td.table_name='machine' and td.table_columns='machine_type_cd'
  146. left join t_dict td1 on t.state = td1.status_cd and td1.table_name='machine' and td1.table_columns='state'
  147. left join t_dict td3 on t.direction = td3.status_cd and td3.table_name='machine' and td3.table_columns='direction'
  148. left join community_location c on t.location_type_cd = c.location_id and t.status_cd = '0'
  149. where 1 =1
  150. <if test="machineMac !=null and machineMac != ''">
  151. and t.machine_mac= #{machineMac}
  152. </if>
  153. <if test="machineId !=null and machineId != ''">
  154. and t.machine_id= #{machineId}
  155. </if>
  156. <if test="machineCode !=null and machineCode != ''">
  157. and t.machine_code= #{machineCode}
  158. </if>
  159. <if test="authCode !=null and authCode != ''">
  160. and t.auth_code= #{authCode}
  161. </if>
  162. <if test="machineVersion !=null and machineVersion != ''">
  163. and t.machine_version= #{machineVersion}
  164. </if>
  165. <if test="statusCd !=null and statusCd != ''">
  166. and t.status_cd= #{statusCd}
  167. </if>
  168. <if test="communityId !=null and communityId != ''">
  169. and t.community_id= #{communityId}
  170. </if>
  171. <if test="bId !=null and bId != ''">
  172. and t.b_id= #{bId}
  173. </if>
  174. <if test="machineName !=null and machineName != ''">
  175. and t.machine_name= #{machineName}
  176. </if>
  177. <if test="machineTypeCd !=null and machineTypeCd != ''">
  178. and t.machine_type_cd= #{machineTypeCd}
  179. </if>
  180. <if test="machineIp !=null and machineIp != ''">
  181. and t.machine_ip= #{machineIp}
  182. </if>
  183. <if test="locationTypeCd !=null and locationTypeCd != ''">
  184. and t.location_type_cd= #{locationTypeCd}
  185. </if>
  186. <if test="machineTypeCds != null ">
  187. and t.machine_type_cd in
  188. <foreach collection="machineTypeCds" item="item" open="(" close=")" separator=",">
  189. #{item}
  190. </foreach>
  191. </if>
  192. <if test="typeId !=null and typeId != ''">
  193. and t.type_id= #{typeId}
  194. </if>
  195. <if test="locationObjId !=null and locationObjId != ''">
  196. and t.location_obj_id= #{locationObjId}
  197. </if>
  198. <if test="locationObjIds != null ">
  199. and t.location_obj_id in
  200. <foreach collection="locationObjIds" item="item" open="(" close=")" separator=",">
  201. #{item}
  202. </foreach>
  203. </if>
  204. <if test="state !=null and state != ''">
  205. and t.state = #{state}
  206. </if>
  207. <if test="direction !=null and direction != ''">
  208. and t.direction = #{direction}
  209. </if>
  210. order by t.create_time desc
  211. <if test="page != -1 and page != null ">
  212. limit #{page}, #{row}
  213. </if>
  214. </select>
  215. <!-- 修改设备信息 add by wuxw 2018-07-03 -->
  216. <update id="updateMachineInfoInstance" parameterType="Map">
  217. update machine t set t.status_cd = #{statusCd}
  218. <if test="newBId != null and newBId != ''">
  219. ,t.b_id = #{newBId}
  220. </if>
  221. <if test="machineMac !=null and machineMac != ''">
  222. , t.machine_mac= #{machineMac}
  223. </if>
  224. <if test="machineCode !=null and machineCode != ''">
  225. , t.machine_code= #{machineCode}
  226. </if>
  227. <if test="authCode !=null and authCode != ''">
  228. , t.auth_code= #{authCode}
  229. </if>
  230. <if test="machineVersion !=null and machineVersion != ''">
  231. , t.machine_version= #{machineVersion}
  232. </if>
  233. <if test="communityId !=null and communityId != ''">
  234. , t.community_id= #{communityId}
  235. </if>
  236. <if test="machineName !=null and machineName != ''">
  237. , t.machine_name= #{machineName}
  238. </if>
  239. <if test="machineTypeCd !=null and machineTypeCd != ''">
  240. , t.machine_type_cd= #{machineTypeCd}
  241. </if>
  242. <if test="machineIp !=null and machineIp != ''">
  243. , t.machine_ip= #{machineIp}
  244. </if>
  245. <if test="locationTypeCd !=null and locationTypeCd != ''">
  246. , t.location_type_cd= #{locationTypeCd}
  247. </if>
  248. <if test="locationObjId !=null and locationObjId != ''">
  249. , t.location_obj_id= #{locationObjId}
  250. </if>
  251. <if test="state !=null and state != ''">
  252. , t.state = #{state}
  253. </if>
  254. <if test="typeId !=null and typeId != ''">
  255. , t.type_id = #{typeId}
  256. </if>
  257. <if test="direction !=null and direction != ''">
  258. , t.direction = #{direction}
  259. </if>
  260. <if test="heartbeatTime !=null ">
  261. , t.heartbeat_time = #{heartbeatTime}
  262. </if>
  263. where 1=1
  264. <if test="machineId !=null and machineId != ''">
  265. and t.machine_id= #{machineId}
  266. </if>
  267. <if test="bId !=null and bId != ''">
  268. and t.b_id= #{bId}
  269. </if>
  270. </update>
  271. <!-- 查询设备数量 add by wuxw 2018-07-03 -->
  272. <select id="queryMachinesCount" parameterType="Map" resultType="Map">
  273. select count(1) count
  274. from machine t
  275. left join t_dict td on t.machine_type_cd=td.status_cd and td.table_name='machine' and td.table_columns='machine_type_cd'
  276. left join t_dict td1 on t.state = td1.status_cd and td1.table_name='machine' and td1.table_columns='state'
  277. left join t_dict td3 on t.direction = td3.status_cd and td3.table_name='machine' and td3.table_columns='direction'
  278. left join community_location c on t.location_type_cd = c.location_id and t.status_cd = '0'
  279. where 1 =1
  280. <if test="machineMac !=null and machineMac != ''">
  281. and t.machine_mac= #{machineMac}
  282. </if>
  283. <if test="machineId !=null and machineId != ''">
  284. and t.machine_id= #{machineId}
  285. </if>
  286. <if test="machineCode !=null and machineCode != ''">
  287. and t.machine_code= #{machineCode}
  288. </if>
  289. <if test="authCode !=null and authCode != ''">
  290. and t.auth_code= #{authCode}
  291. </if>
  292. <if test="typeId !=null and typeId != ''">
  293. and t.type_id= #{typeId}
  294. </if>
  295. <if test="machineVersion !=null and machineVersion != ''">
  296. and t.machine_version= #{machineVersion}
  297. </if>
  298. <if test="statusCd !=null and statusCd != ''">
  299. and t.status_cd= #{statusCd}
  300. </if>
  301. <if test="communityId !=null and communityId != ''">
  302. and t.community_id= #{communityId}
  303. </if>
  304. <if test="bId !=null and bId != ''">
  305. and t.b_id= #{bId}
  306. </if>
  307. <if test="machineName !=null and machineName != ''">
  308. and t.machine_name= #{machineName}
  309. </if>
  310. <if test="machineTypeCd !=null and machineTypeCd != ''">
  311. and t.machine_type_cd= #{machineTypeCd}
  312. </if>
  313. <if test="machineTypeCds != null ">
  314. and t.machine_type_cd in
  315. <foreach collection="machineTypeCds" item="item" open="(" close=")" separator=",">
  316. #{item}
  317. </foreach>
  318. </if>
  319. <if test="machineIp !=null and machineIp != ''">
  320. and t.machine_ip= #{machineIp}
  321. </if>
  322. <if test="locationTypeCd !=null and locationTypeCd != ''">
  323. and t.location_type_cd= #{locationTypeCd}
  324. </if>
  325. <if test="locationObjId !=null and locationObjId != ''">
  326. and t.location_obj_id= #{locationObjId}
  327. </if>
  328. <if test="locationObjIds != null ">
  329. and t.location_obj_id in
  330. <foreach collection="locationObjIds" item="item" open="(" close=")" separator=",">
  331. #{item}
  332. </foreach>
  333. </if>
  334. <if test="state !=null and state != ''">
  335. and t.state = #{state}
  336. </if>
  337. </select>
  338. </mapper>