longz
2026-06-04 da780b14b8db78043d2c0f27d3bfd73111e6d550
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
<?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>