| | |
| | | |
| | | <!-- 查询进出场信息 add by wuxw 2018-07-03 --> |
| | | <select id="getCarInoutInfo" parameterType="Map" resultType="Map"> |
| | | select t.in_time,t.in_time inTime,t.inout_id,t.inout_id inoutId,t.car_num,t.car_num |
| | | carNum,t.status_cd,t.status_cd statusCd,t.state,t.community_id,t.community_id communityId,t.b_id,t.b_id |
| | | bId,t.out_time,t.out_time outTime,td1.name stateName |
| | | from car_inout t,t_dict td1 |
| | | where 1 =1 |
| | | and t.state = td1.status_cd |
| | | and td1.table_name = 'car_inout' |
| | | and td1.table_columns = 'state' |
| | | SELECT |
| | | t.in_time, |
| | | t.in_time AS inTime, |
| | | t.inout_id, |
| | | t.inout_id AS inoutId, |
| | | t.car_num, |
| | | t.car_num AS carNum, |
| | | t.status_cd, |
| | | t.status_cd AS statusCd, |
| | | COALESCE(out_rec.state, t.state) AS state, |
| | | t.community_id, |
| | | t.community_id AS communityId, |
| | | t.b_id, |
| | | t.b_id AS bId, |
| | | out_rec.out_time, |
| | | out_rec.out_time AS outTime, |
| | | td1.name AS stateName, |
| | | out_rec.payment_amount AS money |
| | | FROM |
| | | car_inout t |
| | | -- 先左连接出场记录,确保out_rec表在前面定义 |
| | | LEFT JOIN |
| | | car_inout out_rec ON t.car_num = out_rec.car_num |
| | | AND t.b_id = out_rec.b_id |
| | | AND t.in_time = out_rec.in_time |
| | | AND t.direction = 'entry' |
| | | AND out_rec.direction = 'exit' |
| | | -- 再关联字典表,此时out_rec表已被定义,可以正常引用 |
| | | INNER JOIN |
| | | t_dict td1 ON COALESCE(out_rec.state, t.state) = td1.status_cd |
| | | AND td1.table_name = 'car_inout' |
| | | AND td1.table_columns = 'state' |
| | | WHERE |
| | | t.direction = 'entry' |
| | | <if test="inTime !=null "> |
| | | and t.in_time= #{inTime} |
| | | </if> |
| | |
| | | <if test="startTime != null and startTime != ''"> |
| | | and t.in_time > #{startTime} |
| | | </if> |
| | | <if test="direction != null and direction != ''"> |
| | | and t.direction > #{direction} |
| | | </if> |
| | | <if test="endTime != null and endTime != ''"> |
| | | and t.out_time < #{endTime} |
| | | </if> |
| | |
| | | #{state}, |
| | | #{inTime}, |
| | | #{outTime}, |
| | | <if test="createTime == null"> |
| | | #{createTime}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | now(), |
| | | </if> |
| | | |
| | | #{statusCd}, |
| | | #{paId} |
| | | ) |