EscortAttendanceMapper.xml
5.48 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?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.EscortAttendanceMapper">
<sql id="whereForFindList">
<if test="request.userId != null">AND `USER_ID`=#{ request.userId }</if>
<if test="request.dateId != null">AND `DATE_ID`=#{ request.dateId }</if>
<if test="request.type != null">AND `TYPE`=#{ request.type }</if>
</sql>
<sql id="whereForSearchList">
AND
(
1=0
)
</sql>
<sql id="whereForFindCount">
<if test="request.type != null">
AND ID IN(
SELECT
ID
FROM
rw_escort_attendance
WHERE
id IN (
SELECT
max(id)
FROM
rw_escort_attendance
GROUP BY
USER_ID
)
AND TYPE = #{ request.type })</if>
</sql>
<select id="findDistinct" resultMap="escortAttendancePO">
select * from rw_escort_attendance where id in (select max(id) from rw_escort_attendance GROUP BY USER_ID ) and TYPE ='LAID_ON'
</select>
<select id="findDistinctCount" resultType="java.lang.Long">
select count(1) from rw_escort_attendance where id in (select max(id) from rw_escort_attendance GROUP BY USER_ID ) and TYPE ='LAID_ON'
</select>
<select id="find" resultMap="escortAttendancePO">
SELECT
<include refid="entityColumnList"/>
FROM
`RW_ESCORT_ATTENDANCE`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<include refid="whereForFindList" />
ORDER BY LAID_TIME DESC
<if test="request.pageSize !=0">
LIMIT #{ request.beginItemIndex }, #{ request.pageSize }
</if>
</select>
<select id="findCount" resultType="java.lang.Long">
SELECT
COUNT(*)
FROM
`RW_ESCORT_ATTENDANCE`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<include refid="whereForFindList" />
</select>
<select id="findCountTrainCarriage" resultType="java.lang.Long">
SELECT COUNT(*) FROM(
SELECT
COUNT(*)
FROM
`RW_ESCORT_ATTENDANCE`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<include refid="whereForFindList"/>
GROUP BY TRAIN_ID,TRAIN_CARRIAGE_ID
)t
</select>
<select id="search" resultMap="escortAttendancePO">
SELECT
<include refid="entityColumnList"/>
FROM
`RW_ESCORT_ATTENDANCE`
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(*)
FROM
`RW_ESCORT_ATTENDANCE`
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(*)
FROM
`RW_ESCORT_ATTENDANCE`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
AND `ID` != #{id}
AND `CODE` = #{code}
</select>
<update id="update">
UPDATE
`RW_ESCORT_ATTENDANCE`
SET
`USER_ID`=#{ request.userId },
`USER_NAME`=#{ request.userName },
`TYPE`=#{ request.type },
`DATE_ID`=#{ request.dateId },
`LAID_TIME`=#{ request.laidTime },
`ESCORT_TIME`=#{ request.escortTime },
`LAID_LOCATION`=#{ request.laidLocation },
`TRAIN_ID`=#{ request.trainId },
`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>
<select id="getRailwayPartyBranchRankNumber" resultMap="railwayPartyBranchRankNumberPO">
SELECT COUNT(1) ATTRIBUTE ,ro.NAME from rw_safety_escort rse
LEFT JOIN rw_user ru ON ru.ID = rse.USER_ID
LEFT JOIN rw_organization ro ON ru.PARTY_ID = ro.ID
WHERE
ru.IS_PARTY_MEMBER = 1
GROUP BY ru.PARTY_ID
ORDER BY ATTRIBUTE desc
</select>
<select id="getRailwayUserLaidDetail" resultMap="escortAttendancePO">
SELECT
<include refid="entityColumnList"/>
FROM
`RW_ESCORT_ATTENDANCE`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
ORDER BY LAID_TIME DESC
<if test="request.pageSize !=0">
LIMIT #{ request.beginItemIndex }, #{ request.pageSize }
</if>
</select>
</mapper>