|
|
@@ -39,7 +39,8 @@
|
|
|
|
|
|
<!-- 通用查询结果列 -->
|
|
|
<sql id="Base_Column_List">
|
|
|
- id,
|
|
|
+ id
|
|
|
+ ,
|
|
|
is_handwheel,
|
|
|
is_fixed,
|
|
|
is_electronic_tag,
|
|
|
@@ -75,38 +76,42 @@
|
|
|
parameterType="com.zd.bottle.vo.BottleStorageVo">
|
|
|
select * from (
|
|
|
select bs.*,
|
|
|
- (select count(1) from ab_use_record ur where ur.storage_id=bs.id) numberPersons,
|
|
|
+ (select count(1) from ( select user_id,storage_id,count(1) from ab_use_record GROUP BY user_id,storage_id ) t
|
|
|
+ where t.storage_id=bs.id order by user_id) numberPersons,
|
|
|
( select max(ur.use_time) from ab_use_record ur where ur.storage_id=bs.id ORDER BY use_time desc ) lastTime
|
|
|
from ab_bottle_storage bs
|
|
|
<where>
|
|
|
- <if test="electronicTag != null and electronicTag != ''">
|
|
|
- and bs.electronic_tag = #{electronicTag}
|
|
|
- </if>
|
|
|
- <if test="searchValue != null and searchValue != ''">
|
|
|
- and (
|
|
|
- bs.electronic_tag like concat('%', #{searchValue}, '%')
|
|
|
- or bs.air_number like concat('%', #{searchValue}, '%')
|
|
|
- or bs.user_name like concat('%', #{searchValue}, '%')
|
|
|
+ <if test="electronicTag != null and electronicTag != ''">
|
|
|
+ and bs.electronic_tag = #{electronicTag}
|
|
|
+ </if>
|
|
|
+ <if test="searchValue != null and searchValue != ''">
|
|
|
+ and (
|
|
|
+ bs.electronic_tag like concat('%', #{searchValue}, '%')
|
|
|
+ or bs.air_number like concat('%', #{searchValue}, '%')
|
|
|
+ or bs.user_name like concat('%', #{searchValue}, '%')
|
|
|
)
|
|
|
- </if>
|
|
|
- <if test="storageStatus != null ">and storage_status = #{storageStatus}</if>
|
|
|
- <if test="ids != null ">
|
|
|
- and bs.id in
|
|
|
- <foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
|
- #{id}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
+ </if>
|
|
|
+ <if test="storageStatus != null ">and storage_status = #{storageStatus}</if>
|
|
|
+ <if test="ids != null ">
|
|
|
+ and bs.id in
|
|
|
+ <foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
</where>
|
|
|
) t
|
|
|
<where>
|
|
|
- <if test="startTime != null ">
|
|
|
- and date_format(t.lastTime,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')</if>
|
|
|
- <if test="endTime != null ">
|
|
|
- and date_format(t.lastTime,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')</if>
|
|
|
+ <if test="startTime != null ">
|
|
|
+ and date_format(t.lastTime,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null ">
|
|
|
+ and date_format(t.lastTime,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
- <select id="returnGas" parameterType="com.zd.bottle.vo.BottleStorageUseVo" resultType="com.zd.bottle.vo.BottleStorageUseVo">
|
|
|
+ <select id="returnGas" parameterType="com.zd.bottle.vo.BottleStorageUseVo"
|
|
|
+ resultType="com.zd.bottle.vo.BottleStorageUseVo">
|
|
|
SELECT bs.*,ur.use_time receivingTime,ur.`user_id` useUserId
|
|
|
FROM ab_bottle_storage bs
|
|
|
INNER JOIN ab_use_record ur ON bs.`id` = ur.storage_id
|