O
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

353 lines
13 KiB

4 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xujie.sys.modules.pms.mapper.MesTidEpcLogMapper">
  4. <!-- rqrq - 分页查询日志列表 -->
  5. <select id="searchList" parameterType="MesTidEpcLogData" resultType="MesTidEpcLogData">
  6. SELECT
  7. id,
  8. site,
  9. bu_no AS buNo,
  10. seq_no AS seqNo,
  11. epc,
  12. tid,
  13. user_area AS userArea,
  14. lock_bits AS lockBits,
  15. secret_key AS secretKey,
  16. write_success AS writeSuccess,
  17. read_success AS readSuccess,
  18. epc_locked AS epcLocked,
  19. signal_strength AS signalStrength,
  20. scan_time AS scanTime,
  21. count_info AS countInfo,
  22. batch_no AS batchNo,
  23. file_name AS fileName,
  24. upload_by AS uploadBy,
  25. upload_time AS uploadTime,
  26. remark
  27. FROM mes_tid_epc_log
  28. WHERE 1 = 1
  29. <if test="query.site != null and query.site != ''">
  30. AND site = #{query.site}
  31. </if>
  32. <if test="query.buNo != null and query.buNo != ''">
  33. AND bu_no = #{query.buNo}
  34. </if>
  35. <if test="query.searchSeqNo != null and query.searchSeqNo != ''">
  36. AND seq_no LIKE '%' + #{query.searchSeqNo} + '%'
  37. </if>
  38. <if test="query.searchEpc != null and query.searchEpc != ''">
  39. AND epc LIKE '%' + #{query.searchEpc} + '%'
  40. </if>
  41. <if test="query.searchTid != null and query.searchTid != ''">
  42. AND tid LIKE '%' + #{query.searchTid} + '%'
  43. </if>
  44. <if test="query.searchUserArea != null and query.searchUserArea != ''">
  45. AND user_area LIKE '%' + #{query.searchUserArea} + '%'
  46. </if>
  47. <if test="query.scanTimeStart != null ">
  48. AND scan_time &gt;= #{query.scanTimeStart}
  49. </if>
  50. <if test="query.scanTimeEnd != null ">
  51. AND scan_time &lt;= #{query.scanTimeEnd}
  52. </if>
  53. <if test="query.searchBatchNo != null and query.searchBatchNo != ''">
  54. AND batch_no LIKE '%' + #{query.searchBatchNo} + '%'
  55. </if>
  56. ORDER BY upload_time DESC, id DESC
  57. </select>
  58. <!-- rqrq - 查询日志列表(不分页,用于导出)-->
  59. <select id="getExportList" parameterType="MesTidEpcLogData" resultType="MesTidEpcLogData">
  60. SELECT
  61. id,
  62. site,
  63. bu_no AS buNo,
  64. seq_no AS seqNo,
  65. epc,
  66. tid,
  67. user_area AS userArea,
  68. lock_bits AS lockBits,
  69. secret_key AS secretKey,
  70. write_success AS writeSuccess,
  71. read_success AS readSuccess,
  72. epc_locked AS epcLocked,
  73. signal_strength AS signalStrength,
  74. scan_time AS scanTime,
  75. count_info AS countInfo,
  76. batch_no AS batchNo,
  77. file_name AS fileName,
  78. upload_by AS uploadBy,
  79. upload_time AS uploadTime,
  80. remark
  81. FROM mes_tid_epc_log
  82. WHERE 1 = 1
  83. <if test="query.site != null and query.site != ''">
  84. AND site = #{query.site}
  85. </if>
  86. <if test="query.buNo != null and query.buNo != ''">
  87. AND bu_no = #{query.buNo}
  88. </if>
  89. <if test="query.searchSeqNo != null and query.searchSeqNo != ''">
  90. AND seq_no LIKE '%' + #{query.searchSeqNo} + '%'
  91. </if>
  92. <if test="query.searchEpc != null and query.searchEpc != ''">
  93. AND epc LIKE '%' + #{query.searchEpc} + '%'
  94. </if>
  95. <if test="query.searchTid != null and query.searchTid != ''">
  96. AND tid LIKE '%' + #{query.searchTid} + '%'
  97. </if>
  98. <if test="query.searchUserArea != null and query.searchUserArea != ''">
  99. AND user_area LIKE '%' + #{query.searchUserArea} + '%'
  100. </if>
  101. <if test="query.scanTimeStart != null and query.scanTimeStart != ''">
  102. AND scan_time &gt;= #{query.scanTimeStart}
  103. </if>
  104. <if test="query.scanTimeEnd != null and query.scanTimeEnd != ''">
  105. AND scan_time &lt;= #{query.scanTimeEnd}
  106. </if>
  107. <if test="query.searchBatchNo != null and query.searchBatchNo != ''">
  108. AND batch_no LIKE '%' + #{query.searchBatchNo} + '%'
  109. </if>
  110. ORDER BY upload_time DESC, id DESC
  111. </select>
  112. <!-- rqrq - 查询导出数据总数(一次性COUNT,避免多次COUNT)-->
  113. <select id="getExportCount" parameterType="MesTidEpcLogData" resultType="long">
  114. SELECT COUNT(id)
  115. FROM mes_tid_epc_log
  116. WHERE 1 = 1
  117. <if test="query.site != null and query.site != ''">
  118. AND site = #{query.site}
  119. </if>
  120. <if test="query.buNo != null and query.buNo != ''">
  121. AND bu_no = #{query.buNo}
  122. </if>
  123. <if test="query.searchSeqNo != null and query.searchSeqNo != ''">
  124. AND seq_no LIKE '%' + #{query.searchSeqNo} + '%'
  125. </if>
  126. <if test="query.searchEpc != null and query.searchEpc != ''">
  127. AND epc LIKE '%' + #{query.searchEpc} + '%'
  128. </if>
  129. <if test="query.searchTid != null and query.searchTid != ''">
  130. AND tid LIKE '%' + #{query.searchTid} + '%'
  131. </if>
  132. <if test="query.searchUserArea != null and query.searchUserArea != ''">
  133. AND user_area LIKE '%' + #{query.searchUserArea} + '%'
  134. </if>
  135. <if test="query.scanTimeStart != null">
  136. AND scan_time &gt;= #{query.scanTimeStart}
  137. </if>
  138. <if test="query.scanTimeEnd != null">
  139. AND scan_time &lt;= #{query.scanTimeEnd}
  140. </if>
  141. <if test="query.searchBatchNo != null and query.searchBatchNo != ''">
  142. AND batch_no LIKE '%' + #{query.searchBatchNo} + '%'
  143. </if>
  144. </select>
  145. <!-- rqrq - 手动分页查询导出数据(普通List,无IPage开销,直接拼接分页条件)-->
  146. <select id="searchExportListManual" resultType="MesTidEpcLogExportData">
  147. SELECT
  148. seq_no AS seqNo,
  149. epc,
  150. tid,
  151. user_area AS userArea,
  152. lock_bits AS lockBits,
  153. secret_key AS secretKey,
  154. write_success AS writeSuccess,
  155. read_success AS readSuccess,
  156. epc_locked AS epcLocked,
  157. signal_strength AS signalStrength,
  158. scan_time AS scanTime,
  159. count_info AS countInfo
  160. FROM mes_tid_epc_log
  161. WHERE 1 = 1
  162. <if test="query.site != null and query.site != ''">
  163. AND site = #{query.site}
  164. </if>
  165. <if test="query.buNo != null and query.buNo != ''">
  166. AND bu_no = #{query.buNo}
  167. </if>
  168. <if test="query.searchSeqNo != null and query.searchSeqNo != ''">
  169. AND seq_no LIKE '%' + #{query.searchSeqNo} + '%'
  170. </if>
  171. <if test="query.searchEpc != null and query.searchEpc != ''">
  172. AND epc LIKE '%' + #{query.searchEpc} + '%'
  173. </if>
  174. <if test="query.searchTid != null and query.searchTid != ''">
  175. AND tid LIKE '%' + #{query.searchTid} + '%'
  176. </if>
  177. <if test="query.searchUserArea != null and query.searchUserArea != ''">
  178. AND user_area LIKE '%' + #{query.searchUserArea} + '%'
  179. </if>
  180. <if test="query.scanTimeStart != null">
  181. AND scan_time &gt;= #{query.scanTimeStart}
  182. </if>
  183. <if test="query.scanTimeEnd != null">
  184. AND scan_time &lt;= #{query.scanTimeEnd}
  185. </if>
  186. <if test="query.searchBatchNo != null and query.searchBatchNo != ''">
  187. AND batch_no LIKE '%' + #{query.searchBatchNo} + '%'
  188. </if>
  189. ORDER BY upload_time DESC, id DESC
  190. OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY
  191. </select>
  192. <!-- rqrq - 分页查询导出数据(直接返回ExportData,只查询12个字段,避免BeanUtils转换开销)-->
  193. <select id="searchExportList" parameterType="MesTidEpcLogData" resultType="MesTidEpcLogExportData">
  194. SELECT
  195. seq_no AS seqNo,
  196. epc,
  197. tid,
  198. user_area AS userArea,
  199. lock_bits AS lockBits,
  200. secret_key AS secretKey,
  201. write_success AS writeSuccess,
  202. read_success AS readSuccess,
  203. epc_locked AS epcLocked,
  204. signal_strength AS signalStrength,
  205. scan_time AS scanTime,
  206. count_info AS countInfo
  207. FROM mes_tid_epc_log
  208. WHERE 1 = 1
  209. <if test="query.site != null and query.site != ''">
  210. AND site = #{query.site}
  211. </if>
  212. <if test="query.buNo != null and query.buNo != ''">
  213. AND bu_no = #{query.buNo}
  214. </if>
  215. <if test="query.searchSeqNo != null and query.searchSeqNo != ''">
  216. AND seq_no LIKE '%' + #{query.searchSeqNo} + '%'
  217. </if>
  218. <if test="query.searchEpc != null and query.searchEpc != ''">
  219. AND epc LIKE '%' + #{query.searchEpc} + '%'
  220. </if>
  221. <if test="query.searchTid != null and query.searchTid != ''">
  222. AND tid LIKE '%' + #{query.searchTid} + '%'
  223. </if>
  224. <if test="query.searchUserArea != null and query.searchUserArea != ''">
  225. AND user_area LIKE '%' + #{query.searchUserArea} + '%'
  226. </if>
  227. <if test="query.scanTimeStart != null">
  228. AND scan_time &gt;= #{query.scanTimeStart}
  229. </if>
  230. <if test="query.scanTimeEnd != null">
  231. AND scan_time &lt;= #{query.scanTimeEnd}
  232. </if>
  233. <if test="query.searchBatchNo != null and query.searchBatchNo != ''">
  234. AND batch_no LIKE '%' + #{query.searchBatchNo} + '%'
  235. </if>
  236. ORDER BY upload_time DESC, id DESC
  237. </select>
  238. <!-- rqrq - 流式查询导出数据(真正的逐行读取,配合ResultHandler使用)-->
  239. <!--
  240. 【流式查询说明】
  241. 1. 使用 resultSetType="FORWARD_ONLY" 和 fetchSize="1000"
  242. 2. 配合JDBC URL中的 responseBuffering=adaptive
  243. 3. 数据从数据库逐行读取,不会全部加载到内存
  244. 4. ORDER BY id 保证数据顺序稳定
  245. -->
  246. <select id="streamExportList" resultType="MesTidEpcLogExportData" resultSetType="FORWARD_ONLY" fetchSize="1000">
  247. SELECT
  248. seq_no AS seqNo,
  249. epc,
  250. tid,
  251. user_area AS userArea,
  252. lock_bits AS lockBits,
  253. secret_key AS secretKey,
  254. write_success AS writeSuccess,
  255. read_success AS readSuccess,
  256. epc_locked AS epcLocked,
  257. signal_strength AS signalStrength,
  258. scan_time AS scanTime,
  259. count_info AS countInfo
  260. FROM mes_tid_epc_log
  261. WHERE 1 = 1
  262. <if test="query.site != null and query.site != ''">
  263. AND site = #{query.site}
  264. </if>
  265. <if test="query.buNo != null and query.buNo != ''">
  266. AND bu_no = #{query.buNo}
  267. </if>
  268. <if test="query.searchSeqNo != null and query.searchSeqNo != ''">
  269. AND seq_no LIKE '%' + #{query.searchSeqNo} + '%'
  270. </if>
  271. <if test="query.searchEpc != null and query.searchEpc != ''">
  272. AND epc LIKE '%' + #{query.searchEpc} + '%'
  273. </if>
  274. <if test="query.searchTid != null and query.searchTid != ''">
  275. AND tid LIKE '%' + #{query.searchTid} + '%'
  276. </if>
  277. <if test="query.searchUserArea != null and query.searchUserArea != ''">
  278. AND user_area LIKE '%' + #{query.searchUserArea} + '%'
  279. </if>
  280. <if test="query.scanTimeStart != null">
  281. AND scan_time &gt;= #{query.scanTimeStart}
  282. </if>
  283. <if test="query.scanTimeEnd != null">
  284. AND scan_time &lt;= #{query.scanTimeEnd}
  285. </if>
  286. <if test="query.searchBatchNo != null and query.searchBatchNo != ''">
  287. AND batch_no LIKE '%' + #{query.searchBatchNo} + '%'
  288. </if>
  289. ORDER BY id ASC
  290. </select>
  291. <!-- rqrq - 批量插入日志数据 -->
  292. <insert id="batchInsert" parameterType="java.util.List">
  293. INSERT INTO mes_tid_epc_log (
  294. site,
  295. bu_no,
  296. seq_no,
  297. epc,
  298. tid,
  299. user_area,
  300. lock_bits,
  301. secret_key,
  302. write_success,
  303. read_success,
  304. epc_locked,
  305. signal_strength,
  306. scan_time,
  307. count_info,
  308. batch_no,
  309. file_name,
  310. upload_by,
  311. upload_time,
  312. remark
  313. ) VALUES
  314. <foreach collection="list" item="item" separator=",">
  315. (
  316. #{item.site},
  317. #{item.buNo},
  318. #{item.seqNo},
  319. #{item.epc},
  320. #{item.tid},
  321. #{item.userArea},
  322. #{item.lockBits},
  323. #{item.secretKey},
  324. #{item.writeSuccess},
  325. #{item.readSuccess},
  326. #{item.epcLocked},
  327. #{item.signalStrength},
  328. #{item.scanTime},
  329. #{item.countInfo},
  330. #{item.batchNo},
  331. #{item.fileName},
  332. #{item.uploadBy},
  333. #{item.uploadTime},
  334. #{item.remark}
  335. )
  336. </foreach>
  337. </insert>
  338. <!-- rqrq - 获取当天最大批次号 -->
  339. <select id="getMaxBatchNoByDate" resultType="java.lang.String">
  340. SELECT MAX(batch_no)
  341. FROM mes_tid_epc_log
  342. WHERE batch_no LIKE #{dateStr} + '%'
  343. </select>
  344. </mapper>