<?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.stylefeng.guns.modular.crossCity.dao.LineMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.crossCity.model.Line">
|
<id column="id" property="id"/>
|
<result column="name" property="name"/>
|
<result column="shiftInterval" property="shiftInterval"/>
|
<result column="rakeRate" property="rakeRate"/>
|
<result column="state" property="state"/>
|
<result column="insertTime" property="insertTime"/>
|
<result column="dispatchPhone" property="dispatchPhone"/>
|
</resultMap>
|
|
|
<select id="queryLines" resultType="map">
|
select
|
a.id as id,
|
a.name as name,
|
a.dispatchPhone as dispatchPhone,
|
c.name as siteName
|
from t_line a
|
left join t_line_site b on (a.id = b.lineId)
|
left join t_site c on (b.siteId = c.id)
|
where a.state = 1 and b.siteId = #{siteId} and b.type = #{type}
|
order by a.id asc
|
</select>
|
|
|
<select id="scanCodeQueryLines" resultType="map">
|
select
|
b.id as id,
|
b.`name` as `name`
|
from t_driver_line a
|
left join t_line b on (a.lineId = b.id)
|
where b.state = 1 and a.driverId = #{driverId}
|
</select>
|
|
<select id="queryFutureLinesByDriver" resultType="map">
|
SELECT *
|
FROM (
|
select
|
startSite.id as startSiteId,
|
startSite.`name` as startSiteName,
|
endSite.id as endSiteId,
|
endSite.`name` as endSiteName,
|
l.`name` as lineName,
|
date_format(lsd.`day`, '%Y-%m-%d') as `day`,
|
ls.startTime as startTime,
|
ls.endTime as endTime,
|
l.id as lineId,
|
ls.id as lineShiftId,
|
lsd.id as lineShiftDriverId,
|
lsd.laveSeat AS laveSeat,
|
lsd.laveSeatNumber AS laveSeatNumber
|
from t_line_shift_driver lsd
|
left join t_line_shift ls on ls.id = lsd.lineShiftId
|
left join t_line l on l.id = ls.lineId
|
left join t_line_site startLineSite on startLineSite.lineId = l.id and startLineSite.type = 1
|
left join t_site startSite on startSite.id = startLineSite.siteId
|
left join t_line_site endLineSite on endLineSite.lineId = l.id and endLineSite.type = 2
|
left join t_site endSite on endSite.id = endLineSite.siteId
|
where lsd.driverId = #{driverId}
|
and lsd.`day` is not null
|
and lsd.lineShiftId != -1
|
and ls.state = 1
|
and l.state = 1
|
and str_to_date(concat(date_format(lsd.`day`, '%Y-%m-%d'), ' ', ls.endTime), '%Y-%m-%d %H:%i') >= now()
|
|
UNION ALL
|
|
select
|
0 - (st.id * 10 + 1) as startSiteId,
|
st.startCityName as startSiteName,
|
0 - (st.id * 10 + 2) as endSiteId,
|
st.endCityName as endSiteName,
|
concat(st.startCityName,'-',st.endCityName) as lineName,
|
date_format(lsd.`day`, '%Y-%m-%d') as `day`,
|
st.startTime as startTime,
|
st.startTime as endTime,
|
0 - lsd.customerId as lineId,
|
-1 as lineShiftId,
|
lsd.id as lineShiftDriverId,
|
lsd.laveSeat AS laveSeat,
|
lsd.laveSeatNumber AS laveSeatNumber
|
from t_line_shift_driver lsd
|
inner join t_driver_self_trip st on st.id = lsd.customerId and st.state = 1
|
where lsd.driverId = #{driverId}
|
and lsd.`day` is not null
|
and lsd.lineShiftId = -1
|
and str_to_date(concat(date_format(lsd.`day`, '%Y-%m-%d'), ' ', st.startTime), '%Y-%m-%d %H:%i') >= now()
|
) t
|
order by t.`day` asc, t.startTime asc, t.lineShiftDriverId asc
|
</select>
|
|
<select id="queryLineDestinations" resultType="map">
|
select
|
id,
|
lineId,
|
`name`,
|
fenceType,
|
coordinate,
|
defaultPointLon,
|
defaultPointLat,
|
price5,
|
price7,
|
`state`,
|
isMain,
|
addTime,
|
insertTime
|
from t_line_destination
|
where lineId = #{lineId}
|
and state != 3
|
order by isMain desc, id asc
|
</select>
|
|
<select id="queryLineDestinationById" resultType="map">
|
select
|
id,
|
lineId,
|
price5,
|
price7,
|
state
|
from t_line_destination
|
where id = #{id}
|
and state != 3
|
<if test="lineId != null">
|
and lineId = #{lineId}
|
</if>
|
limit 1
|
</select>
|
</mapper>
|