sen
2025-09-10 9578ae952527cdafc64d642f5183aa60ef92b7f2
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?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.ruoyi.cwgl.mapper.KeyCollectionInfoMapper">
 
    <resultMap type="com.ruoyi.cwgl.domain.KeyCollectionInfo" id="KeyCollectionInfoResult">
        <result property="id"    column="id"    />
        <result property="customerName"    column="customer_name"    />
        <result property="carrier"    column="carrier"    />
        <result property="dispatchNo"    column="dispatch_no"    />
        <result property="driverName"    column="driver_name"    />
        <result property="driverMobile"    column="driver_mobile"    />
        <result property="licensePlateNumber"    column="license_plate_number"    />
        <result property="orderTime"    column="order_time"    />
        <result property="orderCreatedTime"    column="order_created_time"    />
        <result property="dispatchCreatedTime"    column="dispatch_created_time"    />
        <result property="keyCollectionTime"    column="key_collection_time"    />
        <result property="estimatedDepartureTime"    column="estimated_departure_time"    />
        <result property="requiredArrivalTime"    column="required_arrival_time"    />
        <result property="consignorAddress"    column="consignor_address"    />
        <result property="consigneeAddress"    column="consignee_address"    />
        <result property="mainDriver"    column="main_driver"    />
        <result property="pointNum"    column="point_num"    />
        <result property="transportMode"    column="transport_mode"    />
        <result property="assistantDriver"    column="assistant_driver"    />
        <result property="quantity"    column="quantity"    />
        <result property="dispatchQuantity"    column="dispatch_quantity"    />
        <result property="remark"    column="remark"    />
        <result property="boxNum"    column="box_num"    />
    </resultMap>
 
    <sql id="selectKeyCollectionInfoVo">
        select thisTab.id, thisTab.customer_name, thisTab.carrier, thisTab.dispatch_no, thisTab.driver_name, thisTab.driver_mobile, thisTab.license_plate_number, thisTab.order_time, thisTab.order_created_time, thisTab.dispatch_created_time, thisTab.key_collection_time, thisTab.estimated_departure_time, thisTab.required_arrival_time, thisTab.consignor_address, thisTab.consignee_address, thisTab.main_driver, thisTab.point_num, thisTab.transport_mode, thisTab.assistant_driver, thisTab.quantity, thisTab.dispatch_quantity, thisTab.remark, thisTab.box_num from key_collection_info AS thisTab
    </sql>
    <sql id="selectKeyCollectionInfoVoCount">
        select count(0) from key_collection_info as thisTab
    </sql>
 
    <sql id="whereCondition">
        <if test="customerName != null  and customerName != ''"> and  thisTab.customer_name like concat('%', #{customerName}, '%')</if>
        <if test="carrier != null  and carrier != ''"> and thisTab.carrier = #{carrier}</if>
        <if test="dispatchNo != null  and dispatchNo != ''"> and thisTab.dispatch_no = #{dispatchNo}</if>
        <if test="driverName != null  and driverName != ''"> and  thisTab.driver_name like concat('%', #{driverName}, '%')</if>
        <if test="driverMobile != null  and driverMobile != ''"> and thisTab.driver_mobile = #{driverMobile}</if>
        <if test="licensePlateNumber != null  and licensePlateNumber != ''"> and thisTab.license_plate_number = #{licensePlateNumber}</if>
        <if test="orderTime != null "> and thisTab.order_time = #{orderTime}</if>
        <if test="orderCreatedTime != null "> and thisTab.order_created_time = #{orderCreatedTime}</if>
        <if test="dispatchCreatedTime != null "> and thisTab.dispatch_created_time = #{dispatchCreatedTime}</if>
        <if test="keyCollectionTime != null "> and thisTab.key_collection_time = #{keyCollectionTime}</if>
        <if test="estimatedDepartureTime != null "> and thisTab.estimated_departure_time = #{estimatedDepartureTime}</if>
        <if test="requiredArrivalTime != null "> and thisTab.required_arrival_time = #{requiredArrivalTime}</if>
        <if test="consignorAddress != null  and consignorAddress != ''"> and thisTab.consignor_address = #{consignorAddress}</if>
        <if test="consigneeAddress != null  and consigneeAddress != ''"> and thisTab.consignee_address = #{consigneeAddress}</if>
        <if test="mainDriver != null  and mainDriver != ''"> and thisTab.main_driver = #{mainDriver}</if>
        <if test="pointNum != null "> and thisTab.point_num = #{pointNum}</if>
        <if test="transportMode != null  and transportMode != ''"> and thisTab.transport_mode = #{transportMode}</if>
        <if test="assistantDriver != null  and assistantDriver != ''"> and thisTab.assistant_driver = #{assistantDriver}</if>
        <if test="quantity != null "> and thisTab.quantity = #{quantity}</if>
        <if test="boxNum != null "> and thisTab.box_num = #{boxNum}</if>
        <if test="dispatchQuantity != null "> and thisTab.dispatch_quantity = #{dispatchQuantity}</if>
    </sql>
 
    <!--查询-->
    <select id="selectKeyCollectionInfoById" parameterType="Integer" resultMap="KeyCollectionInfoResult">
        <include refid="selectKeyCollectionInfoVo"/>
        where id = #{id}
    </select>
 
    <select id="selectKeyCollectionInfoCount" parameterType="com.ruoyi.cwgl.domain.KeyCollectionInfo" resultType="int">
        <include refid="selectKeyCollectionInfoVoCount"/>
        <where>
            <include refid="whereCondition"/>
        </where>
    </select>
 
    <select id="selectKeyCollectionInfoList" parameterType="com.ruoyi.cwgl.domain.KeyCollectionInfo" resultMap="KeyCollectionInfoResult">
        <include refid="selectKeyCollectionInfoVo"/>
        <where>
            <include refid="whereCondition"/>
        </where>
        order by thisTab.id desc
    </select>
    <select id="selectCwData" resultType="com.ruoyi.cwgl.domain.KeyCollectionInfo">
        SELECT
        customer.`NAME` as customerName,
        bp.`NAME` as carrier,
        ts.DISPATCH_NO as dispatchNo,
        driver_m.`NAME` as driverName,
        driver_m.MOBILE as driverMobile,
        vhc.LICENSE_PLATE_NUMBER as licensePlateNumber,
        vhc.NAME as boxNum,
        ord.ORDER_TIME as orderTime,
        ord.CREATED_TIME as orderCreatedTime,
        ts.CREATED_TIME as dispatchCreatedTime,
        now() as keyCollectionTime, -- 放请求查询到的时间
        ord.REQUIRED_DEPARTURE_TIME as estimatedDepartureTime,
        ord.CONSIGNOR_ADDRESS_ADDR_INFO as consignorAddress,
        ord.CONSIGNEE_ADDRESS_ADDR_INFO as consigneeAddress,
        driver_m.`NAME` as mainDriver,
        ts.POINT_NUM as pointNum,
        ts.TRANSPORT_MODE as transportMode,
        driver_a.`NAME` as assistantDriver,
        ts.QUANTITY as quantity,
        ts.REQUIRED_ARRIVAL_TIME as requiredArrivalTime,  -- 添加别名
        ts.DISPATCH_QUANTITY as dispatchQuantity,
        ts.REMARK as remark,
        TIMESTAMPDIFF(HOUR, ord.ORDER_TIME, ord.CREATED_TIME) as schedulingTimeout,
        TIMESTAMPDIFF(HOUR, ord.REQUIRED_DEPARTURE_TIME, NOW()) as keyTimeout
 
        FROM
        tms_shipment ts
        LEFT JOIN oms_order ord ON ts.DISPATCH_NO = ord.DISPATCH_CODE
        LEFT JOIN base_customer customer ON customer.ID = ord.CUSTOMER_ID
        LEFT JOIN tms_vehicle vhc ON ts.VEHICLE_ID = vhc.id
        LEFT JOIN base_provider bp ON bp.ID = ts.CARRIER_ID
        LEFT JOIN tms_driver driver_m ON driver_m.ID = ts.MAIN_DRIVER_ID
        LEFT JOIN tms_driver driver_a ON driver_a.ID = ts.ASSISTANT_DRIVER_ID
 
        WHERE
        ts.`STATUS` = 'A'
        <if test="driverCode != null and driverCode != ''">
            AND driver_m.MOBILE = #{driverCode}
        </if>
        <if test="driverName != null and driverName != ''">
            AND driver_m.NAME = #{driverName}
        </if>
 
        ORDER BY ord.ESTIMATED_DEPARTURE_TIME ASC
        LIMIT 1
    </select>
 
    <!-- 新增 -->
    <insert id="insertKeyCollectionInfo" parameterType="com.ruoyi.cwgl.domain.KeyCollectionInfo"  useGeneratedKeys="true" keyProperty="id">
        insert into key_collection_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="customerName != null">customer_name,</if>
            <if test="carrier != null">carrier,</if>
            <if test="dispatchNo != null">dispatch_no,</if>
            <if test="driverName != null">driver_name,</if>
            <if test="driverMobile != null">driver_mobile,</if>
            <if test="licensePlateNumber != null">license_plate_number,</if>
            <if test="orderTime != null">order_time,</if>
            <if test="orderCreatedTime != null">order_created_time,</if>
            <if test="dispatchCreatedTime != null">dispatch_created_time,</if>
            <if test="keyCollectionTime != null">key_collection_time,</if>
            <if test="estimatedDepartureTime != null">estimated_departure_time,</if>
            <if test="requiredArrivalTime != null">required_arrival_time,</if>
            <if test="consignorAddress != null">consignor_address,</if>
            <if test="consigneeAddress != null">consignee_address,</if>
            <if test="mainDriver != null">main_driver,</if>
            <if test="pointNum != null">point_num,</if>
            <if test="transportMode != null">transport_mode,</if>
            <if test="assistantDriver != null">assistant_driver,</if>
            <if test="quantity != null">quantity,</if>
            <if test="dispatchQuantity != null">dispatch_quantity,</if>
            <if test="remark != null">remark,</if>
            <if test="boxNum != null">box_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="customerName != null">#{customerName},</if>
            <if test="carrier != null">#{carrier},</if>
            <if test="dispatchNo != null">#{dispatchNo},</if>
            <if test="driverName != null">#{driverName},</if>
            <if test="driverMobile != null">#{driverMobile},</if>
            <if test="licensePlateNumber != null">#{licensePlateNumber},</if>
            <if test="orderTime != null">#{orderTime},</if>
            <if test="orderCreatedTime != null">#{orderCreatedTime},</if>
            <if test="dispatchCreatedTime != null">#{dispatchCreatedTime},</if>
            <if test="keyCollectionTime != null">#{keyCollectionTime},</if>
            <if test="estimatedDepartureTime != null">#{estimatedDepartureTime},</if>
            <if test="requiredArrivalTime != null">#{requiredArrivalTime},</if>
            <if test="consignorAddress != null">#{consignorAddress},</if>
            <if test="consigneeAddress != null">#{consigneeAddress},</if>
            <if test="mainDriver != null">#{mainDriver},</if>
            <if test="pointNum != null">#{pointNum},</if>
            <if test="transportMode != null">#{transportMode},</if>
            <if test="assistantDriver != null">#{assistantDriver},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="dispatchQuantity != null">#{dispatchQuantity},</if>
            <if test="remark != null">#{remark},</if>
            <if test="boxNum != null">#{boxNum},</if>
         </trim>
    </insert>
 
    <insert id="insertKeyCollectionInfoBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="id">
        insert into key_collection_info
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            id,customer_name,carrier,dispatch_no,driver_name,driver_mobile,license_plate_number,order_time,order_created_time,dispatch_created_time,key_collection_time,estimated_departure_time,required_arrival_time,consignor_address,consignee_address,main_driver,point_num,transport_mode,assistant_driver,quantity,dispatch_quantity,remark,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.id},#{item.customerName},#{item.carrier},#{item.dispatchNo},#{item.driverName},#{item.driverMobile},#{item.licensePlateNumber},#{item.orderTime},#{item.orderCreatedTime},#{item.dispatchCreatedTime},#{item.keyCollectionTime},#{item.estimatedDepartureTime},#{item.requiredArrivalTime},#{item.consignorAddress},#{item.consigneeAddress},#{item.mainDriver},#{item.pointNum},#{item.transportMode},#{item.assistantDriver},#{item.quantity},#{item.dispatchQuantity},#{item.remark},
            </trim>
        </foreach>
    </insert>
 
    <!-- 修改 -->
    <update id="updateKeyCollectionInfo" parameterType="com.ruoyi.cwgl.domain.KeyCollectionInfo">
        update key_collection_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="customerName != null">customer_name = #{customerName},</if>
            <if test="carrier != null">carrier = #{carrier},</if>
            <if test="dispatchNo != null">dispatch_no = #{dispatchNo},</if>
            <if test="driverName != null">driver_name = #{driverName},</if>
            <if test="driverMobile != null">driver_mobile = #{driverMobile},</if>
            <if test="licensePlateNumber != null">license_plate_number = #{licensePlateNumber},</if>
            <if test="orderTime != null">order_time = #{orderTime},</if>
            <if test="orderCreatedTime != null">order_created_time = #{orderCreatedTime},</if>
            <if test="dispatchCreatedTime != null">dispatch_created_time = #{dispatchCreatedTime},</if>
            <if test="keyCollectionTime != null">key_collection_time = #{keyCollectionTime},</if>
            <if test="estimatedDepartureTime != null">estimated_departure_time = #{estimatedDepartureTime},</if>
            <if test="requiredArrivalTime != null">required_arrival_time = #{requiredArrivalTime},</if>
            <if test="consignorAddress != null">consignor_address = #{consignorAddress},</if>
            <if test="consigneeAddress != null">consignee_address = #{consigneeAddress},</if>
            <if test="mainDriver != null">main_driver = #{mainDriver},</if>
            <if test="pointNum != null">point_num = #{pointNum},</if>
            <if test="transportMode != null">transport_mode = #{transportMode},</if>
            <if test="assistantDriver != null">assistant_driver = #{assistantDriver},</if>
            <if test="quantity != null">quantity = #{quantity},</if>
            <if test="dispatchQuantity != null">dispatch_quantity = #{dispatchQuantity},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 修改 -->
    <update id="updateKeyCollectionInfoBatch" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" separator=";">
            update key_collection_info
            <trim prefix="SET" suffixOverrides=",">
                <if test="item.customerName != null">customer_name = #{item.customerName},</if>
                <if test="item.carrier != null">carrier = #{item.carrier},</if>
                <if test="item.dispatchNo != null">dispatch_no = #{item.dispatchNo},</if>
                <if test="item.driverName != null">driver_name = #{item.driverName},</if>
                <if test="item.driverMobile != null">driver_mobile = #{item.driverMobile},</if>
                <if test="item.licensePlateNumber != null">license_plate_number = #{item.licensePlateNumber},</if>
                <if test="item.orderTime != null">order_time = #{item.orderTime},</if>
                <if test="item.orderCreatedTime != null">order_created_time = #{item.orderCreatedTime},</if>
                <if test="item.dispatchCreatedTime != null">dispatch_created_time = #{item.dispatchCreatedTime},</if>
                <if test="item.keyCollectionTime != null">key_collection_time = #{item.keyCollectionTime},</if>
                <if test="item.estimatedDepartureTime != null">estimated_departure_time = #{item.estimatedDepartureTime},</if>
                <if test="item.requiredArrivalTime != null">required_arrival_time = #{item.requiredArrivalTime},</if>
                <if test="item.consignorAddress != null">consignor_address = #{item.consignorAddress},</if>
                <if test="item.consigneeAddress != null">consignee_address = #{item.consigneeAddress},</if>
                <if test="item.mainDriver != null">main_driver = #{item.mainDriver},</if>
                <if test="item.pointNum != null">point_num = #{item.pointNum},</if>
                <if test="item.transportMode != null">transport_mode = #{item.transportMode},</if>
                <if test="item.assistantDriver != null">assistant_driver = #{item.assistantDriver},</if>
                <if test="item.quantity != null">quantity = #{item.quantity},</if>
                <if test="item.dispatchQuantity != null">dispatch_quantity = #{item.dispatchQuantity},</if>
                <if test="item.remark != null">remark = #{item.remark},</if>
            </trim>
        where id = #{item.id}
        </foreach>
    </update>
 
    <!--删除-->
    <delete id="deleteKeyCollectionInfoById" parameterType="Integer">
        delete from key_collection_info where id = #{id}
    </delete>
    <delete id="deleteKeyCollectionInfoByIds" parameterType="Integer">
        delete from key_collection_info where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>