|
|
|
|
@ -11,8 +11,9 @@
|
|
|
|
|
<select id="selectCustomRfidReadRecordVoList" resultMap="RfidReadRecordResult">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
t.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
t.read_status,
|
|
|
|
|
TRIM(t.barcode) as barcode,
|
|
|
|
|
t.record_time,
|
|
|
|
|
@ -22,6 +23,7 @@
|
|
|
|
|
t.alarm_action
|
|
|
|
|
from ${tableName} t
|
|
|
|
|
left join rfid_device d on t.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
<if test="ew != null">
|
|
|
|
|
${ew.customSqlSegment}
|
|
|
|
|
</if>
|
|
|
|
|
@ -33,8 +35,9 @@
|
|
|
|
|
<select id="selectCustomRfidReadRecordVoListMultiTable" resultMap="RfidReadRecordResult">
|
|
|
|
|
select combined.id,
|
|
|
|
|
combined.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
combined.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
combined.read_status,
|
|
|
|
|
TRIM(combined.barcode) as barcode,
|
|
|
|
|
combined.record_time,
|
|
|
|
|
@ -46,6 +49,7 @@
|
|
|
|
|
<foreach collection="tableNames" item="tbl" separator=" UNION ALL ">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
t.device_code,
|
|
|
|
|
t.read_status,
|
|
|
|
|
TRIM(t.barcode) as barcode,
|
|
|
|
|
t.record_time,
|
|
|
|
|
@ -60,6 +64,7 @@
|
|
|
|
|
</foreach>
|
|
|
|
|
) combined
|
|
|
|
|
left join rfid_device d on combined.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
order by combined.record_time desc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
@ -67,8 +72,9 @@
|
|
|
|
|
<select id="selectCustomRfidReadRecordVoById" resultMap="RfidReadRecordResult">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
t.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
t.read_status,
|
|
|
|
|
TRIM(t.barcode) as barcode,
|
|
|
|
|
t.record_time,
|
|
|
|
|
@ -78,6 +84,7 @@
|
|
|
|
|
t.alarm_action
|
|
|
|
|
from ${tableName} t
|
|
|
|
|
left join rfid_device d on t.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
where t.id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
@ -85,8 +92,9 @@
|
|
|
|
|
<select id="selectCustomRfidReadRecordVoByIds" resultMap="RfidReadRecordResult">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
t.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
t.read_status,
|
|
|
|
|
TRIM(t.barcode) as barcode,
|
|
|
|
|
t.record_time,
|
|
|
|
|
@ -96,6 +104,7 @@
|
|
|
|
|
t.alarm_action
|
|
|
|
|
from ${tableName} t
|
|
|
|
|
left join rfid_device d on t.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
where t.id in
|
|
|
|
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
@ -128,8 +137,9 @@
|
|
|
|
|
<select id="selectCustomRfidReadRecordVoPage" resultMap="RfidReadRecordResult">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
t.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
t.read_status,
|
|
|
|
|
TRIM(t.barcode) as barcode,
|
|
|
|
|
t.record_time,
|
|
|
|
|
@ -139,6 +149,7 @@
|
|
|
|
|
t.alarm_action
|
|
|
|
|
from ${tableName} t
|
|
|
|
|
left join rfid_device d on t.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
<if test="ew != null">
|
|
|
|
|
${ew.customSqlSegment}
|
|
|
|
|
</if>
|
|
|
|
|
@ -150,8 +161,9 @@
|
|
|
|
|
<select id="selectCustomRfidReadRecordVoPageMultiTable" resultMap="RfidReadRecordResult">
|
|
|
|
|
select combined.id,
|
|
|
|
|
combined.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
combined.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
combined.read_status,
|
|
|
|
|
TRIM(combined.barcode) as barcode,
|
|
|
|
|
combined.record_time,
|
|
|
|
|
@ -163,6 +175,7 @@
|
|
|
|
|
<foreach collection="tableNames" item="tbl" separator=" UNION ALL ">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
t.device_code,
|
|
|
|
|
t.read_status,
|
|
|
|
|
TRIM(t.barcode) as barcode,
|
|
|
|
|
t.record_time,
|
|
|
|
|
@ -177,6 +190,7 @@
|
|
|
|
|
</foreach>
|
|
|
|
|
) combined
|
|
|
|
|
left join rfid_device d on combined.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
order by combined.record_time desc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
@ -185,6 +199,7 @@
|
|
|
|
|
insert into ${tableName}(
|
|
|
|
|
id,
|
|
|
|
|
device_id,
|
|
|
|
|
device_code,
|
|
|
|
|
read_status,
|
|
|
|
|
barcode,
|
|
|
|
|
record_time,
|
|
|
|
|
@ -196,6 +211,7 @@
|
|
|
|
|
values (
|
|
|
|
|
#{entity.id},
|
|
|
|
|
#{entity.deviceId},
|
|
|
|
|
#{entity.deviceCode},
|
|
|
|
|
#{entity.readStatus},
|
|
|
|
|
#{entity.barcode},
|
|
|
|
|
#{entity.recordTime},
|
|
|
|
|
@ -211,6 +227,7 @@
|
|
|
|
|
insert into ${tableName}(
|
|
|
|
|
id,
|
|
|
|
|
device_id,
|
|
|
|
|
device_code,
|
|
|
|
|
read_status,
|
|
|
|
|
barcode,
|
|
|
|
|
record_time,
|
|
|
|
|
@ -224,6 +241,7 @@
|
|
|
|
|
(
|
|
|
|
|
#{item.id},
|
|
|
|
|
#{item.deviceId},
|
|
|
|
|
#{item.deviceCode},
|
|
|
|
|
#{item.readStatus},
|
|
|
|
|
#{item.barcode},
|
|
|
|
|
#{item.recordTime},
|
|
|
|
|
@ -242,6 +260,9 @@
|
|
|
|
|
<if test="entity.deviceId != null">
|
|
|
|
|
device_id = #{entity.deviceId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="entity.deviceCode != null">
|
|
|
|
|
device_code = #{entity.deviceCode},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="entity.readStatus != null and entity.readStatus != ''">
|
|
|
|
|
read_status = #{entity.readStatus},
|
|
|
|
|
</if>
|
|
|
|
|
@ -275,6 +296,9 @@
|
|
|
|
|
<if test="item.deviceId != null">
|
|
|
|
|
device_id = #{item.deviceId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="item.deviceCode != null">
|
|
|
|
|
device_code = #{item.deviceCode},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="item.readStatus != null and item.readStatus != ''">
|
|
|
|
|
read_status = #{item.readStatus},
|
|
|
|
|
</if>
|
|
|
|
|
@ -352,8 +376,9 @@
|
|
|
|
|
<select id="selectLatestRecordByDevice" resultMap="RfidReadRecordResult">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
t.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
t.read_status,
|
|
|
|
|
TRIM(t.barcode) as barcode,
|
|
|
|
|
t.record_time,
|
|
|
|
|
@ -376,6 +401,7 @@
|
|
|
|
|
group by device_id
|
|
|
|
|
) latest on t.device_id = latest.device_id and t.record_time = latest.max_time
|
|
|
|
|
left join rfid_device d on t.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
order by t.device_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
@ -383,8 +409,9 @@
|
|
|
|
|
<select id="selectLatestRecordByDeviceMultiTable" resultMap="RfidReadRecordResult">
|
|
|
|
|
select combined.id,
|
|
|
|
|
combined.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
combined.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
combined.read_status,
|
|
|
|
|
TRIM(combined.barcode) as barcode,
|
|
|
|
|
combined.record_time,
|
|
|
|
|
@ -394,11 +421,11 @@
|
|
|
|
|
combined.alarm_action
|
|
|
|
|
from (
|
|
|
|
|
<!-- 合并所有分表数据,按设备分组取最新记录 -->
|
|
|
|
|
select t1.id, t1.device_id, t1.read_status, t1.barcode, t1.record_time,
|
|
|
|
|
select t1.id, t1.device_id, t1.device_code, t1.read_status, t1.barcode, t1.record_time,
|
|
|
|
|
t1.alarm_flag, t1.alarm_level, t1.alarm_type, t1.alarm_action
|
|
|
|
|
from (
|
|
|
|
|
<foreach collection="tableNames" item="tbl" separator=" UNION ALL ">
|
|
|
|
|
select id, device_id, read_status, barcode, record_time,
|
|
|
|
|
select id, device_id, device_code, read_status, barcode, record_time,
|
|
|
|
|
alarm_flag, alarm_level, alarm_type, alarm_action
|
|
|
|
|
from ${tbl}
|
|
|
|
|
<where>
|
|
|
|
|
@ -430,6 +457,7 @@
|
|
|
|
|
) latest on t1.device_id = latest.device_id and t1.record_time = latest.max_time
|
|
|
|
|
) combined
|
|
|
|
|
left join rfid_device d on combined.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
order by combined.device_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
@ -450,7 +478,7 @@
|
|
|
|
|
<select id="selectAlarmRecordList" resultMap="RfidReadRecordResult">
|
|
|
|
|
select t.id,
|
|
|
|
|
t.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
t.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
t.read_status,
|
|
|
|
|
@ -476,8 +504,9 @@
|
|
|
|
|
<select id="selectWithSampling" resultMap="RfidReadRecordResult">
|
|
|
|
|
select t1.id,
|
|
|
|
|
t1.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
t1.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
t1.read_status,
|
|
|
|
|
TRIM(t1.barcode) as barcode,
|
|
|
|
|
t1.record_time,
|
|
|
|
|
@ -487,6 +516,7 @@
|
|
|
|
|
t1.alarm_action
|
|
|
|
|
from ${tableName} t1
|
|
|
|
|
left join rfid_device d on t1.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
inner join (
|
|
|
|
|
<!-- 子查询:按 device_id + time_slot 分组,取每个时间槽的最新记录 -->
|
|
|
|
|
select
|
|
|
|
|
@ -507,8 +537,9 @@
|
|
|
|
|
<select id="selectWithSamplingMultiTable" resultMap="RfidReadRecordResult">
|
|
|
|
|
select sampled.id,
|
|
|
|
|
sampled.device_id,
|
|
|
|
|
d.device_code as deviceCode,
|
|
|
|
|
sampled.device_code as deviceCode,
|
|
|
|
|
d.device_name as deviceName,
|
|
|
|
|
l.location_alias as locationAlias,
|
|
|
|
|
sampled.read_status,
|
|
|
|
|
TRIM(sampled.barcode) as barcode,
|
|
|
|
|
sampled.record_time,
|
|
|
|
|
@ -520,6 +551,7 @@
|
|
|
|
|
<foreach collection="tableNames" item="tbl" separator=" UNION ALL ">
|
|
|
|
|
select t1.id,
|
|
|
|
|
t1.device_id,
|
|
|
|
|
t1.device_code,
|
|
|
|
|
t1.read_status,
|
|
|
|
|
TRIM(t1.barcode) as barcode,
|
|
|
|
|
t1.record_time,
|
|
|
|
|
@ -543,6 +575,7 @@
|
|
|
|
|
</foreach>
|
|
|
|
|
) sampled
|
|
|
|
|
left join rfid_device d on sampled.device_id = d.id
|
|
|
|
|
left join rfid_location l on d.location_id = l.id
|
|
|
|
|
order by sampled.device_id asc, sampled.record_time desc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|