|
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.xujie.sys.modules.pms.mapper.MesTidEpcLogMapper">
<!-- rqrq - 分页查询日志列表 --> <select id="searchList" parameterType="MesTidEpcLogData" resultType="MesTidEpcLogData"> SELECT id, site, bu_no AS buNo, seq_no AS seqNo, epc, tid, user_area AS userArea, lock_bits AS lockBits, secret_key AS secretKey, write_success AS writeSuccess, read_success AS readSuccess, epc_locked AS epcLocked, signal_strength AS signalStrength, scan_time AS scanTime, count_info AS countInfo, batch_no AS batchNo, file_name AS fileName, upload_by AS uploadBy, upload_time AS uploadTime, remark FROM mes_tid_epc_log WHERE 1 = 1 <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.buNo != null and query.buNo != ''"> AND bu_no = #{query.buNo} </if> <if test="query.searchSeqNo != null and query.searchSeqNo != ''"> AND seq_no LIKE '%' + #{query.searchSeqNo} + '%' </if> <if test="query.searchEpc != null and query.searchEpc != ''"> AND epc LIKE '%' + #{query.searchEpc} + '%' </if> <if test="query.searchTid != null and query.searchTid != ''"> AND tid LIKE '%' + #{query.searchTid} + '%' </if> <if test="query.searchUserArea != null and query.searchUserArea != ''"> AND user_area LIKE '%' + #{query.searchUserArea} + '%' </if> <if test="query.scanTimeStart != null "> AND scan_time >= #{query.scanTimeStart} </if> <if test="query.scanTimeEnd != null "> AND scan_time <= #{query.scanTimeEnd} </if> <if test="query.searchBatchNo != null and query.searchBatchNo != ''"> AND batch_no LIKE '%' + #{query.searchBatchNo} + '%' </if> ORDER BY upload_time DESC, id DESC </select>
<!-- rqrq - 查询日志列表(不分页,用于导出)--> <select id="getExportList" parameterType="MesTidEpcLogData" resultType="MesTidEpcLogData"> SELECT id, site, bu_no AS buNo, seq_no AS seqNo, epc, tid, user_area AS userArea, lock_bits AS lockBits, secret_key AS secretKey, write_success AS writeSuccess, read_success AS readSuccess, epc_locked AS epcLocked, signal_strength AS signalStrength, scan_time AS scanTime, count_info AS countInfo, batch_no AS batchNo, file_name AS fileName, upload_by AS uploadBy, upload_time AS uploadTime, remark FROM mes_tid_epc_log WHERE 1 = 1 <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.buNo != null and query.buNo != ''"> AND bu_no = #{query.buNo} </if> <if test="query.searchSeqNo != null and query.searchSeqNo != ''"> AND seq_no LIKE '%' + #{query.searchSeqNo} + '%' </if> <if test="query.searchEpc != null and query.searchEpc != ''"> AND epc LIKE '%' + #{query.searchEpc} + '%' </if> <if test="query.searchTid != null and query.searchTid != ''"> AND tid LIKE '%' + #{query.searchTid} + '%' </if> <if test="query.searchUserArea != null and query.searchUserArea != ''"> AND user_area LIKE '%' + #{query.searchUserArea} + '%' </if> <if test="query.scanTimeStart != null and query.scanTimeStart != ''"> AND scan_time >= #{query.scanTimeStart} </if> <if test="query.scanTimeEnd != null and query.scanTimeEnd != ''"> AND scan_time <= #{query.scanTimeEnd} </if> <if test="query.searchBatchNo != null and query.searchBatchNo != ''"> AND batch_no LIKE '%' + #{query.searchBatchNo} + '%' </if> ORDER BY upload_time DESC, id DESC </select>
<!-- rqrq - 查询导出数据总数(一次性COUNT,避免多次COUNT)--> <select id="getExportCount" parameterType="MesTidEpcLogData" resultType="long"> SELECT COUNT(id) FROM mes_tid_epc_log WHERE 1 = 1 <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.buNo != null and query.buNo != ''"> AND bu_no = #{query.buNo} </if> <if test="query.searchSeqNo != null and query.searchSeqNo != ''"> AND seq_no LIKE '%' + #{query.searchSeqNo} + '%' </if> <if test="query.searchEpc != null and query.searchEpc != ''"> AND epc LIKE '%' + #{query.searchEpc} + '%' </if> <if test="query.searchTid != null and query.searchTid != ''"> AND tid LIKE '%' + #{query.searchTid} + '%' </if> <if test="query.searchUserArea != null and query.searchUserArea != ''"> AND user_area LIKE '%' + #{query.searchUserArea} + '%' </if> <if test="query.scanTimeStart != null"> AND scan_time >= #{query.scanTimeStart} </if> <if test="query.scanTimeEnd != null"> AND scan_time <= #{query.scanTimeEnd} </if> <if test="query.searchBatchNo != null and query.searchBatchNo != ''"> AND batch_no LIKE '%' + #{query.searchBatchNo} + '%' </if> </select>
<!-- rqrq - 手动分页查询导出数据(普通List,无IPage开销,直接拼接分页条件)--> <select id="searchExportListManual" resultType="MesTidEpcLogExportData"> SELECT seq_no AS seqNo, epc, tid, user_area AS userArea, lock_bits AS lockBits, secret_key AS secretKey, write_success AS writeSuccess, read_success AS readSuccess, epc_locked AS epcLocked, signal_strength AS signalStrength, scan_time AS scanTime, count_info AS countInfo FROM mes_tid_epc_log WHERE 1 = 1 <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.buNo != null and query.buNo != ''"> AND bu_no = #{query.buNo} </if> <if test="query.searchSeqNo != null and query.searchSeqNo != ''"> AND seq_no LIKE '%' + #{query.searchSeqNo} + '%' </if> <if test="query.searchEpc != null and query.searchEpc != ''"> AND epc LIKE '%' + #{query.searchEpc} + '%' </if> <if test="query.searchTid != null and query.searchTid != ''"> AND tid LIKE '%' + #{query.searchTid} + '%' </if> <if test="query.searchUserArea != null and query.searchUserArea != ''"> AND user_area LIKE '%' + #{query.searchUserArea} + '%' </if> <if test="query.scanTimeStart != null"> AND scan_time >= #{query.scanTimeStart} </if> <if test="query.scanTimeEnd != null"> AND scan_time <= #{query.scanTimeEnd} </if> <if test="query.searchBatchNo != null and query.searchBatchNo != ''"> AND batch_no LIKE '%' + #{query.searchBatchNo} + '%' </if> ORDER BY upload_time DESC, id DESC OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY </select>
<!-- rqrq - 分页查询导出数据(直接返回ExportData,只查询12个字段,避免BeanUtils转换开销)--> <select id="searchExportList" parameterType="MesTidEpcLogData" resultType="MesTidEpcLogExportData"> SELECT seq_no AS seqNo, epc, tid, user_area AS userArea, lock_bits AS lockBits, secret_key AS secretKey, write_success AS writeSuccess, read_success AS readSuccess, epc_locked AS epcLocked, signal_strength AS signalStrength, scan_time AS scanTime, count_info AS countInfo FROM mes_tid_epc_log WHERE 1 = 1 <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.buNo != null and query.buNo != ''"> AND bu_no = #{query.buNo} </if> <if test="query.searchSeqNo != null and query.searchSeqNo != ''"> AND seq_no LIKE '%' + #{query.searchSeqNo} + '%' </if> <if test="query.searchEpc != null and query.searchEpc != ''"> AND epc LIKE '%' + #{query.searchEpc} + '%' </if> <if test="query.searchTid != null and query.searchTid != ''"> AND tid LIKE '%' + #{query.searchTid} + '%' </if> <if test="query.searchUserArea != null and query.searchUserArea != ''"> AND user_area LIKE '%' + #{query.searchUserArea} + '%' </if> <if test="query.scanTimeStart != null"> AND scan_time >= #{query.scanTimeStart} </if> <if test="query.scanTimeEnd != null"> AND scan_time <= #{query.scanTimeEnd} </if> <if test="query.searchBatchNo != null and query.searchBatchNo != ''"> AND batch_no LIKE '%' + #{query.searchBatchNo} + '%' </if> ORDER BY upload_time DESC, id DESC </select>
<!-- rqrq - 流式查询导出数据(真正的逐行读取,配合ResultHandler使用)--> <!--
【流式查询说明】 1. 使用 resultSetType="FORWARD_ONLY" 和 fetchSize="1000" 2. 配合JDBC URL中的 responseBuffering=adaptive 3. 数据从数据库逐行读取,不会全部加载到内存 4. ORDER BY id 保证数据顺序稳定 --> <select id="streamExportList" resultType="MesTidEpcLogExportData" resultSetType="FORWARD_ONLY" fetchSize="1000"> SELECT seq_no AS seqNo, epc, tid, user_area AS userArea, lock_bits AS lockBits, secret_key AS secretKey, write_success AS writeSuccess, read_success AS readSuccess, epc_locked AS epcLocked, signal_strength AS signalStrength, scan_time AS scanTime, count_info AS countInfo FROM mes_tid_epc_log WHERE 1 = 1 <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.buNo != null and query.buNo != ''"> AND bu_no = #{query.buNo} </if> <if test="query.searchSeqNo != null and query.searchSeqNo != ''"> AND seq_no LIKE '%' + #{query.searchSeqNo} + '%' </if> <if test="query.searchEpc != null and query.searchEpc != ''"> AND epc LIKE '%' + #{query.searchEpc} + '%' </if> <if test="query.searchTid != null and query.searchTid != ''"> AND tid LIKE '%' + #{query.searchTid} + '%' </if> <if test="query.searchUserArea != null and query.searchUserArea != ''"> AND user_area LIKE '%' + #{query.searchUserArea} + '%' </if> <if test="query.scanTimeStart != null"> AND scan_time >= #{query.scanTimeStart} </if> <if test="query.scanTimeEnd != null"> AND scan_time <= #{query.scanTimeEnd} </if> <if test="query.searchBatchNo != null and query.searchBatchNo != ''"> AND batch_no LIKE '%' + #{query.searchBatchNo} + '%' </if> ORDER BY id ASC </select>
<!-- rqrq - 批量插入日志数据 --> <insert id="batchInsert" parameterType="java.util.List"> INSERT INTO mes_tid_epc_log ( site, bu_no, seq_no, epc, tid, user_area, lock_bits, secret_key, write_success, read_success, epc_locked, signal_strength, scan_time, count_info, batch_no, file_name, upload_by, upload_time, remark ) VALUES <foreach collection="list" item="item" separator=","> ( #{item.site}, #{item.buNo}, #{item.seqNo}, #{item.epc}, #{item.tid}, #{item.userArea}, #{item.lockBits}, #{item.secretKey}, #{item.writeSuccess}, #{item.readSuccess}, #{item.epcLocked}, #{item.signalStrength}, #{item.scanTime}, #{item.countInfo}, #{item.batchNo}, #{item.fileName}, #{item.uploadBy}, #{item.uploadTime}, #{item.remark} ) </foreach> </insert>
<!-- rqrq - 获取当天最大批次号 --> <select id="getMaxBatchNoByDate" resultType="java.lang.String"> SELECT MAX(batch_no) FROM mes_tid_epc_log WHERE batch_no LIKE #{dateStr} + '%' </select>
</mapper>
|