EscortAttendanceLogMapper.xml
5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?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.xiniunet.service.railway.dal.EscortAttendanceLogMapper">
<sql id="whereForFindList">
<if test="request.userId!=null"> AND `USER_ID` =#{ request.userId }</if>
</sql>
<sql id="whereForSearchList">
AND
(
1=0
)
</sql>
<select id="findMax" resultMap="escortAttendanceLogPO">
select * from RW_ESCORT_ATTENDANCE_LOG where id in (select max(id) from RW_ESCORT_ATTENDANCE_LOG GROUP BY USER_ID )
<if test="request.userIdList!=null and request.userIdList.size() != 0">
AND `USER_ID` IN
<foreach collection="request.userIdList" item="userId" index="index" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>
</select>
<select id="findMaxCount" resultType="java.lang.Long">
select count(1) from RW_ESCORT_ATTENDANCE_LOG where id in (select max(id) from RW_ESCORT_ATTENDANCE_LOG GROUP BY USER_ID )
<if test="request.userIdList!=null and request.userIdList.size() != 0">
AND `USER_ID` IN
<foreach collection="request.userIdList" item="userId" index="index" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>
</select>
<select id="find" resultMap="escortAttendanceLogPO">
SELECT
<include refid="entityColumnList"/>
FROM
`RW_ESCORT_ATTENDANCE_LOG`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<include refid="whereForFindList" />
<if test="request.pageSize !=0">
LIMIT #{ request.beginItemIndex }, #{ request.pageSize }
</if>
</select>
<select id="findCount" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
`RW_ESCORT_ATTENDANCE_LOG`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<include refid="whereForFindList" />
</select>
<select id="findReal" resultMap="escortAttendanceLogPO">
select * from RW_ESCORT_ATTENDANCE_LOG
WHERE
`IS_DELETED`=0
AND id in (select max(id) from rw_escort_attendance_log GROUP BY USER_ID)
<if test="request.userId != '' and request.userId != null">
AND `USER_ID` LIKE CONCAT(CONCAT('%', #{ request.userId }), '%')
</if>
ORDER BY ID DESC
LIMIT #{ request.requestIndex}, #{ request.pageSize }
</select>
<select id="findRealCount" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
`RW_ESCORT_ATTENDANCE_LOG`
WHERE
`IS_DELETED`=0
AND id in (select max(id) from rw_escort_attendance_log GROUP BY USER_ID)
<if test="request.userId != '' and request.userId != null">
AND `USER_ID` LIKE CONCAT(CONCAT('%', #{ request.userId }), '%')
</if>
</select>
<select id="search" resultMap="escortAttendanceLogPO">
SELECT
<include refid="entityColumnList"/>
FROM
`RW_ESCORT_ATTENDANCE_LOG`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<if test="request.keyword !=null">
<include refid="whereForSearchList" />
</if>
<if test="request.pageSize !=0">
LIMIT #{ request.beginItemIndex }, #{ request.pageSize }
</if>
</select>
<select id="searchCount" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
`RW_ESCORT_ATTENDANCE_LOG`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<if test="request.keyword !=null">
<include refid="whereForSearchList" />
</if>
</select>
<select id="existByCode" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
`RW_ESCORT_ATTENDANCE_LOG`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
AND `ID` != #{id}
AND `CODE` = #{code}
</select>
<update id="update">
UPDATE
`RW_ESCORT_ATTENDANCE_LOG`
SET
`USER_ID`=#{ request.userId },
`LOG_TIME`=#{ request.logTime },
`LAID_LOCATION`=#{ request.laidLocation },
`CURRENT_STATION`=#{ request.currentStation },
`NEXT_STATION`=#{ request.nextStation },
`POSITION_FLAG`=#{ request.positionFlag },
`TRAIN_ID`=#{ request.trainId },
`TRAIN_NO`=#{ request.trainNo },
`TRAIN_GROUP_ID`=#{ request.trainGroupId },
`TRAIN_LINE_ID`=#{ request.trainLineId },
`TRAIN_CARRIAGE_ID`=#{ request.trainCarriageId },
`TRAIN_DOOR_ID`=#{ request.trainDoorId },
`LAST_UPDATED_BY`=#{ passport.userId },
`LAST_UPDATE_TIME`=SYSDATE(),
`ROW_VERSION`=#{ request.rowVersion }+1
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
AND `ID` = #{ request.id }
AND `ROW_VERSION` = #{ request.rowVersion }
</update>
</mapper>