EscortAttendanceMapper.xml
4.24 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
<?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>
<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="findEscortTime" resultType="java.lang.Long">
select SUM(ESCORT_TIME) from rw_escort_attendance
where USER_ID= #{ request.userId }
<if test="request.dateId != null">AND `DATE_ID`=#{ request.dateId }</if>
and TYPE ='LAID_OFF'
</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="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>
</mapper>