MachineRecordServiceDaoImplMapper.xml 11 KB

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