wujianwei
2025-09-10 de448cb8a94591b85a99816d741480bf4c227879
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<?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.DispatchOrderMapper">
 
    <resultMap type="com.ruoyi.cwgl.domain.DispatchOrder" id="DispatchOrderResult">
        <result property="id"    column="id"    />
        <result property="dispatchNo"    column="dispatch_no"    />
        <result property="customerName"    column="customer_name"    />
        <result property="transportMode"    column="transport_mode"    />
        <result property="productName"    column="product_name"    />
        <result property="carrierName"    column="carrier_name"    />
        <result property="departureLocationName"    column="departure_location_name"    />
        <result property="arrivalLocationName"    column="arrival_location_name"    />
        <result property="licensePlateNumber"    column="license_plate_number"    />
        <result property="vehiclePlateId"    column="vehicle_plate_id"    />
        <result property="mainDriverName"    column="main_driver_name"    />
        <result property="assistantDriverName"    column="assistant_driver_name"    />
        <result property="pointNum"    column="point_num"    />
        <result property="quantity"    column="quantity"    />
        <result property="actualDepartureTime"    column="actual_departure_time"    />
        <result property="requiredArrivalTime"    column="required_arrival_time"    />
        <result property="actualArrivalTime"    column="actual_arrival_time"    />
        <result property="beReturn"    column="be_return"    />
        <result property="dispatchQuantity"    column="dispatch_quantity"    />
        <result property="dispatchWeight"    column="dispatch_weight"    />
        <result property="dispatchVolume"    column="dispatch_volume"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDeleted"    column="is_deleted"    />
    </resultMap>
 
    <sql id="selectDispatchOrderVo">
        select thisTab.id, thisTab.dispatch_no, thisTab.transport_mode, thisTab.product_name, thisTab.carrier_name, thisTab.departure_location_name, thisTab.arrival_location_name, thisTab.license_plate_number, thisTab.vehicle_plate_id, thisTab.main_driver_name, thisTab.assistant_driver_name, thisTab.point_num, thisTab.quantity, thisTab.actual_departure_time, thisTab.required_arrival_time, thisTab.actual_arrival_time, thisTab.be_return, thisTab.dispatch_quantity, thisTab.dispatch_weight, thisTab.dispatch_volume, thisTab.status, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.is_deleted from dispatch_order AS thisTab
    </sql>
    <sql id="selectDispatchOrderVoCount">
        select count(0) from dispatch_order as thisTab
    </sql>
 
    <sql id="whereCondition">
        <if test="dispatchNo != null  and dispatchNo != ''"> and thisTab.dispatch_no = #{dispatchNo}</if>
        <if test="transportMode != null  and transportMode != ''"> and thisTab.transport_mode = #{transportMode}</if>
        <if test="productName != null  and productName != ''"> and  thisTab.product_name like concat('%', #{productName}, '%')</if>
        <if test="carrierName != null  and carrierName != ''"> and  thisTab.carrier_name like concat('%', #{carrierName}, '%')</if>
        <if test="departureLocationName != null  and departureLocationName != ''"> and  thisTab.departure_location_name like concat('%', #{departureLocationName}, '%')</if>
        <if test="arrivalLocationName != null  and arrivalLocationName != ''"> and  thisTab.arrival_location_name like concat('%', #{arrivalLocationName}, '%')</if>
        <if test="licensePlateNumber != null  and licensePlateNumber != ''"> and thisTab.license_plate_number = #{licensePlateNumber}</if>
        <if test="vehiclePlateId != null  and vehiclePlateId != ''"> and thisTab.vehicle_plate_id = #{vehiclePlateId}</if>
        <if test="mainDriverName != null  and mainDriverName != ''"> and  thisTab.main_driver_name like concat('%', #{mainDriverName}, '%')</if>
        <if test="assistantDriverName != null  and assistantDriverName != ''"> and  thisTab.assistant_driver_name like concat('%', #{assistantDriverName}, '%')</if>
        <if test="pointNum != null "> and thisTab.point_num = #{pointNum}</if>
        <if test="quantity != null "> and thisTab.quantity = #{quantity}</if>
        <if test="actualDepartureTime != null "> and thisTab.actual_departure_time = #{actualDepartureTime}</if>
        <if test="requiredArrivalTime != null "> and thisTab.required_arrival_time = #{requiredArrivalTime}</if>
        <if test="actualArrivalTime != null "> and thisTab.actual_arrival_time = #{actualArrivalTime}</if>
        <if test="beReturn != null  and beReturn != ''"> and thisTab.be_return = #{beReturn}</if>
        <if test="dispatchQuantity != null "> and thisTab.dispatch_quantity = #{dispatchQuantity}</if>
        <if test="dispatchWeight != null "> and thisTab.dispatch_weight = #{dispatchWeight}</if>
        <if test="dispatchVolume != null "> and thisTab.dispatch_volume = #{dispatchVolume}</if>
        <if test="status != null  and status != ''"> and thisTab.status = #{status}</if>
        <if test="isDeleted != null "> and thisTab.is_deleted = #{isDeleted}</if>
    </sql>
    <sql id="whereCondition2">
        <if test="dispatchNo != null  and dispatchNo != ''"> and ts.DISPATCH_NO like concat('%', #{dispatchNo}, '%')</if>
        <if test="customerName != null  and customerName != ''"> and customer.`NAME` like concat('%', #{customerName}, '%')</if>
        <if test="transportMode != null  and transportMode != ''"> and ts.TRANSPORT_MODE = #{transportMode}</if>
        <if test="productName != null  and productName != ''"> and  ts.PRODUCT_ID like concat('%', #{productName}, '%')</if>
        <if test="carrierName != null  and carrierName != ''"> and  bp.NAME  like concat('%', #{carrierName}, '%')</if>
        <if test="departureLocationName != null  and departureLocationName != ''"> and  location_d.NAME_TREE like concat('%', #{departureLocationName}, '%')</if>
        <if test="arrivalLocationName != null  and arrivalLocationName != ''"> and location_a.NAME_TREE like concat('%', #{arrivalLocationName}, '%')</if>
        <if test="licensePlateNumber != null  and licensePlateNumber != ''"> and vhc.LICENSE_PLATE_NUMBER = #{licensePlateNumber}</if>
        <if test="vehiclePlateId != null  and vehiclePlateId != ''"> and ts.VEHICLE_PLATE_ID = #{vehiclePlateId}</if>
        <if test="mainDriverName != null  and mainDriverName != ''"> and  driver_m.NAME  like concat('%', #{mainDriverName}, '%')</if>
        <if test="assistantDriverName != null  and assistantDriverName != ''"> and  driver_a.NAME like concat('%', #{assistantDriverName}, '%')</if>
        <if test="pointNum != null "> and ts.POINT_NUM = #{pointNum}</if>
        <if test="quantity != null "> and ts.QUANTITY = #{quantity}</if>
        <if test="actualDepartureTimeBegin != null and actualDepartureTimeBegin!='' and actualDepartureTimeEnd != null and actualDepartureTimeEnd!='' "> and ts.ACTUAL_DEPARTURE_TIME between #{actualDepartureTimeBegin} and #{actualDepartureTimeEnd}</if>
        <if test="requiredArrivalTimeBegin != null and requiredArrivalTimeBegin!='' and requiredArrivalTimeEnd != null and requiredArrivalTimeEnd!='' "> and ts.REQUIRED_ARRIVAL_TIME between #{requiredArrivalTimeBegin} and #{requiredArrivalTimeEnd}</if>
        <if test="actualArrivalTimeBegin != null and actualArrivalTimeBegin!='' and actualArrivalTimeEnd != null and actualArrivalTimeEnd!='' "> and ts.ACTUAL_ARRIVAL_TIME between #{actualArrivalTimeBegin} and #{actualArrivalTimeEnd}</if>
        <if test="beReturn != null  and beReturn != ''"> and ts.BE_RETURN = #{beReturn}</if>
        <if test="dispatchQuantity != null "> and ts.DISPATCH_QUANTITY = #{dispatchQuantity}</if>
        <if test="dispatchWeight != null "> and ts.DISPATCH_WEIGHT = #{dispatchWeight}</if>
        <if test="dispatchVolume != null "> and ts.DISPATCH_VOLUME = #{dispatchVolume}</if>
        <if test="status != null  and status != ''"> and ts.STATUS = #{status}</if>
    </sql>
 
    <!--查询-->
    <select id="selectDispatchOrderById" parameterType="Integer" resultMap="DispatchOrderResult">
        <include refid="selectDispatchOrderVo"/>
        where id = #{id}
    </select>
 
    <select id="selectDispatchOrderCount" parameterType="com.ruoyi.cwgl.domain.DispatchOrder" resultType="int">
        <include refid="selectDispatchOrderVoCount"/>
        <where>
            <include refid="whereCondition"/>
        </where>
    </select>
 
    <select id="selectDispatchOrderList" parameterType="com.ruoyi.cwgl.domain.DispatchOrder" resultMap="DispatchOrderResult">
        <include refid="selectDispatchOrderVo"/>
        <where>
            <include refid="whereCondition"/>
        </where>
        order by thisTab.id desc
    </select>
 
    <select id="selectDispatchOrderList2" parameterType="com.ruoyi.cwgl.domain.DispatchOrder" resultMap="DispatchOrderResult">
        SELECT
        ts.DISPATCH_NO as 'dispatch_no',
        customer.`NAME` as 'customer_name',
        ts.TRANSPORT_MODE as 'transport_mode',
        ts.PRODUCT_ID as 'product_name',
        bp.NAME as 'carrier_name',
        location_d.NAME_TREE as 'departure_location_name',
        -- ts.ARRIVAL_LOCATION_ID '目的地ID',
        location_a.NAME_TREE  as 'arrival_location_name',
        -- ts.VEHICLE_ID '运输工具ID',
        vhc.LICENSE_PLATE_NUMBER  as 'license_plate_number',
        ts.VEHICLE_PLATE_ID as 'vehicle_plate_id',
        driver_m.NAME as 'main_driver_name',
        driver_a.NAME as 'assistant_driver_name',
        ts.POINT_NUM as 'point_num',
        -- ts.ELECTRONIC_LOCK '电子锁',
        -- ts.RE_WEIGHING_WEIGHT '复磅重量',
        ts.QUANTITY as 'quantity',
        ts.ACTUAL_DEPARTURE_TIME as'actual_departure_time',
        ts.REQUIRED_ARRIVAL_TIME as 'required_arrival_time',
        ts.ACTUAL_ARRIVAL_TIME as 'actual_arrival_time',
        ts.BE_RETURN as 'be_return',
        ts.DISPATCH_QUANTITY as 'dispatch_quantity',
        ts.DISPATCH_WEIGHT as 'dispatch_weight',
        ts.CREATED_TIME as 'create_time',
        ts.DISPATCH_VOLUME as 'dispatch_volume',
        -- ts.EMPTY_MILEAGE '空载里程(公里)',
        -- ts.EMPTY_FUEL '空载油耗(升)',
        -- ts.HEAVY_MILEAGE '重载里程(公里)',
        -- ts.HEAVY_FUEL '重载油耗(升)',
        -- ts.BE_SCHEDULED '是否按班次',
        -- ts.TRACKING_NO '快递单号',
        -- ts.SEAL_NO '铅封号',
        -- ts.SCHEDULE_NO '班次号',
         ts.STATUS AS 'status',
        -- ts.ESTIMATED_COST '预估费用',
        -- ts.ESTIMATED_CARRIER_NUM '预估承运商数',
        -- ts.ESTIMATED_COST_SAVING '预估节约费用',
        -- ts.TRANSPORT_LINE '运输线路',
        ts.REMARK 'remark'
        -- ts.DISPATCH_PERMISSION_GROUP '调度权限分组',
        -- ts.DISPATCH_GROUP '调度分组',
        -- ts.ROUTE_CODE '线路号',
 
        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
        -- 地区表
        left join base_location location_a on location_a.ID =ts.ARRIVAL_LOCATION_ID
        -- 地区表
        left join base_location location_d on location_d.ID =ts.DEPARTURE_LOCATION_ID
--         where ts.CREATED_TIME >'2025-07-01 00:00:01'
             <where>
            <include refid="whereCondition2"/>
        </where>
        order by ts.CREATED_TIME desc
    </select>
 
    <select id="selectDispatchOrderItemByNos" resultType="com.ruoyi.cwgl.domain.DispatchOrderItem">
        SELECT
        bfd.ENTITY_ID as 'dispatch_no',
            bfd.CREATED_TIME AS feeDataCreatedTime,
            bfd.CHECK_STATUS AS checkStatus,
            bfd.CURRENCY_TYPE AS currencyType,
            bfd.FEE_ITEM AS feeItem,
            bfd.FEE_TIME AS feeTime,
            bfd.REMARK AS remark,
            bfd.SETTLE_FEE AS settleFee,
            bfd.STATUS AS feeDataStatus,
 
            bill.NAME AS billName,
            bill.STATUS AS billStatus,
 
            fb.TYPE AS billType,
            bt.FIELDS AS settableFeeItems
 
        FROM bms_fee_data bfd
                 LEFT JOIN bms_bill bill ON bill.ID = bfd.BILL_ID
                 LEFT JOIN bms_fee_book fb ON fb.ID = bill.FEE_BOOK_ID
                 LEFT JOIN bms_bill_template bt ON bt.ID = bill.BILL_TEMPLATE_ID
                 LEFT JOIN oms_order ord ON bfd.ENTITY_ID = ord.DISPATCH_CODE
 
        WHERE bfd.ENTITY_ID in
        <foreach collection="nos" item="no" open="(" separator="," close=")">
            #{no}
        </foreach>
 
 
    </select>
 
 
 
    <select id="selectDispatchOrderItemByNo" resultType="com.ruoyi.cwgl.domain.DispatchOrderItem">
            SELECT
ts.CREATED_TIME as createdTime,
ts.DISPATCH_NO as dispatchNo,
ts.TRANSPORT_MODE as transportMode,
ts.LOAD_MODE as loadMode,
ts.PRODUCT_ID as productId,
bp.NAME as carrierName,
ts.VEHICLE_TYPE_ID as vehicleTypeId,
vhc.LICENSE_PLATE_NUMBER as licensePlateNumber,
ts.VEHICLE_PLATE_ID as vehiclePlateId,
-- ts.MAIN_DRIVER_ID '主驾驶员ID',
-- ts.ASSISTANT_DRIVER_ID '副驾驶员ID',
driver_m.NAME as mainDriverName,
driver_a.NAME as assistantDriverName,
ts.POINT_NUM as pointNum,
ts.RE_WEIGHING_WEIGHT as reWeighingWeight,
ts.QUANTITY as quantity,
ts.REQUIRED_ARRIVAL_TIME as requiredArrivalTime,
ts.ACTUAL_DEPARTURE_TIME as actualDepartureTime,
ts.ACTUAL_ARRIVAL_TIME as actualArrivalTime,
-- ts.BE_RETURN '是否回程',
ts.DISPATCH_QUANTITY as dispatchQuantity,
ts.DISPATCH_WEIGHT as dispatchWeight,
ts.DISPATCH_VOLUME as dispatchVolume,
-- bfd.ID '账单明细Id',
ts.STATUS as status,
ts.TRANSPORT_LINE as transportLine,
-- ts.REMARK '调度单备注',
-- ts.ROUTE_CODE '线路号',
-- ts.DEPARTURE_LOCATION_ID '出发地ID',
location_d.NAME_TREE as departureLocationName,
-- ts.ARRIVAL_LOCATION_ID '目的地ID',
location_a.NAME_TREE as arrivalLocationName,
-- bill.id '账单ID',
fb.type AS billType,
 
bfd.CREATED_TIME as feeDataCreatedTime,
-- bfd.BILL_ID '账单明细ID',
bfd.CHECK_STATUS as checkStatus,
bfd.CURRENCY_TYPE as currencyType,
-- bfd.ENTITY_LEVEL2 '二级主体',
-- bfd.ENTITY_LEVEL3 '三级主体',
-- bfd.FEE_BOOK_ID '账本ID',
bfd.FEE_ITEM as feeItem,
-- bfd.FEE_SOURCE '费用来源',
bfd.FEE_TIME as feeTime,
bfd.REMARK as remark,
bfd.SETTLE_FEE as settleFee,
bfd.STATUS as feeDataStatus,
bt.FIELDS as settableFeeItems,
bill.NAME as billName,
-- bill.CHECK_ONLINE'在线对账',
 bill.STATUS AS  billStatus
FROM
-- 账单明细表
    bms_fee_data bfd
-- 订单表
    LEFT JOIN oms_order ord
    ON bfd.ENTITY_ID = ord.DISPATCH_CODE
-- 调度单表
    LEFT JOIN tms_shipment ts
        ON ts.DISPATCH_NO = ord.DISPATCH_CODE
-- 账单主表
    left join bms_bill bill on bill.id= bfd.BILL_ID
-- 账册表
    LEFT JOIN bms_fee_book fb ON fb.id = bill.FEE_BOOK_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
-- 地区表
    left join base_location location_a on location_a.ID =ts.ARRIVAL_LOCATION_ID
    -- 地区表
    left join base_location location_d on location_d.ID =ts.DEPARTURE_LOCATION_ID
    -- 账单模板表
    left join bms_bill_template bt on bt.ID=bill.BILL_TEMPLATE_ID
WHERE
    bfd.ENTITY_ID = #{no}
 
    </select>
    <select id="selectDispatchOrderAttachment" resultType="com.ruoyi.cwgl.domain.vo.DispatchOrderAttachmentVo">
SELECT
--     image.PATH,
    CONCAT('https://tms.ygalogisticspark.com/ImageViewServlet?id=',image.id) as imageUrl,
    -- tof.FEE_TYPE_ID '费用类型ID',
    bfi.FEE_TYPE as feeItem,
    tof.account as account,
    case tof.CURRENCY_ID
        when 1 then '港币'
        when 2 then '人民币'
        else '未知'
    end as currency
 
FROM
-- 其他费用表
    Tms_Other_Fee tof
-- 调度单表
    LEFT JOIN tms_shipment ts ON tof.dispatch_Order_Id = ts.id
-- 附件表
    LEFT JOIN Thorn_Attachment image ON image.OBJ_ID = tof.id
-- 费用类型表
    left join base_fee_item bfi on bfi.id=tof.FEE_TYPE_ID
WHERE
    ts.DISPATCH_NO =  #{no}
    AND image.biz_Type = 'com.vtradex.tms.core.model.entity.fee.TmsOtherFee'
 
 
    </select>
 
    <!-- 新增 -->
    <insert id="insertDispatchOrder" parameterType="com.ruoyi.cwgl.domain.DispatchOrder"  useGeneratedKeys="true" keyProperty="id">
        insert into dispatch_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dispatchNo != null and dispatchNo != ''">dispatch_no,</if>
            <if test="transportMode != null">transport_mode,</if>
            <if test="productName != null">product_name,</if>
            <if test="carrierName != null">carrier_name,</if>
            <if test="departureLocationName != null">departure_location_name,</if>
            <if test="arrivalLocationName != null">arrival_location_name,</if>
            <if test="licensePlateNumber != null">license_plate_number,</if>
            <if test="vehiclePlateId != null">vehicle_plate_id,</if>
            <if test="mainDriverName != null">main_driver_name,</if>
            <if test="assistantDriverName != null">assistant_driver_name,</if>
            <if test="pointNum != null">point_num,</if>
            <if test="quantity != null">quantity,</if>
            <if test="actualDepartureTime != null">actual_departure_time,</if>
            <if test="requiredArrivalTime != null">required_arrival_time,</if>
            <if test="actualArrivalTime != null">actual_arrival_time,</if>
            <if test="beReturn != null">be_return,</if>
            <if test="dispatchQuantity != null">dispatch_quantity,</if>
            <if test="dispatchWeight != null">dispatch_weight,</if>
            <if test="dispatchVolume != null">dispatch_volume,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDeleted != null">is_deleted,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dispatchNo != null and dispatchNo != ''">#{dispatchNo},</if>
            <if test="transportMode != null">#{transportMode},</if>
            <if test="productName != null">#{productName},</if>
            <if test="carrierName != null">#{carrierName},</if>
            <if test="departureLocationName != null">#{departureLocationName},</if>
            <if test="arrivalLocationName != null">#{arrivalLocationName},</if>
            <if test="licensePlateNumber != null">#{licensePlateNumber},</if>
            <if test="vehiclePlateId != null">#{vehiclePlateId},</if>
            <if test="mainDriverName != null">#{mainDriverName},</if>
            <if test="assistantDriverName != null">#{assistantDriverName},</if>
            <if test="pointNum != null">#{pointNum},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="actualDepartureTime != null">#{actualDepartureTime},</if>
            <if test="requiredArrivalTime != null">#{requiredArrivalTime},</if>
            <if test="actualArrivalTime != null">#{actualArrivalTime},</if>
            <if test="beReturn != null">#{beReturn},</if>
            <if test="dispatchQuantity != null">#{dispatchQuantity},</if>
            <if test="dispatchWeight != null">#{dispatchWeight},</if>
            <if test="dispatchVolume != null">#{dispatchVolume},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDeleted != null">#{isDeleted},</if>
         </trim>
    </insert>
 
    <insert id="insertDispatchOrderBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="id">
        insert into dispatch_order
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            id,dispatch_no,transport_mode,product_name,carrier_name,departure_location_name,arrival_location_name,license_plate_number,vehicle_plate_id,main_driver_name,assistant_driver_name,point_num,quantity,actual_departure_time,required_arrival_time,actual_arrival_time,be_return,dispatch_quantity,dispatch_weight,dispatch_volume,status,remark,create_by,create_time,update_by,update_time,is_deleted,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.id},#{item.dispatchNo},#{item.transportMode},#{item.productName},#{item.carrierName},#{item.departureLocationName},#{item.arrivalLocationName},#{item.licensePlateNumber},#{item.vehiclePlateId},#{item.mainDriverName},#{item.assistantDriverName},#{item.pointNum},#{item.quantity},#{item.actualDepartureTime},#{item.requiredArrivalTime},#{item.actualArrivalTime},#{item.beReturn},#{item.dispatchQuantity},#{item.dispatchWeight},#{item.dispatchVolume},#{item.status},#{item.remark},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.isDeleted},
            </trim>
        </foreach>
    </insert>
 
    <!-- 修改 -->
    <update id="updateDispatchOrder" parameterType="com.ruoyi.cwgl.domain.DispatchOrder">
        update dispatch_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="dispatchNo != null and dispatchNo != ''">dispatch_no = #{dispatchNo},</if>
            <if test="transportMode != null">transport_mode = #{transportMode},</if>
            <if test="productName != null">product_name = #{productName},</if>
            <if test="carrierName != null">carrier_name = #{carrierName},</if>
            <if test="departureLocationName != null">departure_location_name = #{departureLocationName},</if>
            <if test="arrivalLocationName != null">arrival_location_name = #{arrivalLocationName},</if>
            <if test="licensePlateNumber != null">license_plate_number = #{licensePlateNumber},</if>
            <if test="vehiclePlateId != null">vehicle_plate_id = #{vehiclePlateId},</if>
            <if test="mainDriverName != null">main_driver_name = #{mainDriverName},</if>
            <if test="assistantDriverName != null">assistant_driver_name = #{assistantDriverName},</if>
            <if test="pointNum != null">point_num = #{pointNum},</if>
            <if test="quantity != null">quantity = #{quantity},</if>
            <if test="actualDepartureTime != null">actual_departure_time = #{actualDepartureTime},</if>
            <if test="requiredArrivalTime != null">required_arrival_time = #{requiredArrivalTime},</if>
            <if test="actualArrivalTime != null">actual_arrival_time = #{actualArrivalTime},</if>
            <if test="beReturn != null">be_return = #{beReturn},</if>
            <if test="dispatchQuantity != null">dispatch_quantity = #{dispatchQuantity},</if>
            <if test="dispatchWeight != null">dispatch_weight = #{dispatchWeight},</if>
            <if test="dispatchVolume != null">dispatch_volume = #{dispatchVolume},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 修改 -->
    <update id="updateDispatchOrderBatch" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" separator=";">
            update dispatch_order
            <trim prefix="SET" suffixOverrides=",">
                <if test="item.dispatchNo != null and item.dispatchNo != ''">dispatch_no = #{item.dispatchNo},</if>
                <if test="item.transportMode != null">transport_mode = #{item.transportMode},</if>
                <if test="item.productName != null">product_name = #{item.productName},</if>
                <if test="item.carrierName != null">carrier_name = #{item.carrierName},</if>
                <if test="item.departureLocationName != null">departure_location_name = #{item.departureLocationName},</if>
                <if test="item.arrivalLocationName != null">arrival_location_name = #{item.arrivalLocationName},</if>
                <if test="item.licensePlateNumber != null">license_plate_number = #{item.licensePlateNumber},</if>
                <if test="item.vehiclePlateId != null">vehicle_plate_id = #{item.vehiclePlateId},</if>
                <if test="item.mainDriverName != null">main_driver_name = #{item.mainDriverName},</if>
                <if test="item.assistantDriverName != null">assistant_driver_name = #{item.assistantDriverName},</if>
                <if test="item.pointNum != null">point_num = #{item.pointNum},</if>
                <if test="item.quantity != null">quantity = #{item.quantity},</if>
                <if test="item.actualDepartureTime != null">actual_departure_time = #{item.actualDepartureTime},</if>
                <if test="item.requiredArrivalTime != null">required_arrival_time = #{item.requiredArrivalTime},</if>
                <if test="item.actualArrivalTime != null">actual_arrival_time = #{item.actualArrivalTime},</if>
                <if test="item.beReturn != null">be_return = #{item.beReturn},</if>
                <if test="item.dispatchQuantity != null">dispatch_quantity = #{item.dispatchQuantity},</if>
                <if test="item.dispatchWeight != null">dispatch_weight = #{item.dispatchWeight},</if>
                <if test="item.dispatchVolume != null">dispatch_volume = #{item.dispatchVolume},</if>
                <if test="item.status != null">status = #{item.status},</if>
                <if test="item.remark != null">remark = #{item.remark},</if>
                <if test="item.createBy != null">create_by = #{item.createBy},</if>
                <if test="item.createTime != null">create_time = #{item.createTime},</if>
                <if test="item.updateBy != null">update_by = #{item.updateBy},</if>
                <if test="item.updateTime != null">update_time = #{item.updateTime},</if>
                <if test="item.isDeleted != null">is_deleted = #{item.isDeleted},</if>
            </trim>
        where id = #{item.id}
        </foreach>
    </update>
 
    <!--删除-->
    <delete id="deleteDispatchOrderById" parameterType="Integer">
        delete from dispatch_order where id = #{id}
    </delete>
    <delete id="deleteDispatchOrderByIds" parameterType="Integer">
        delete from dispatch_order where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>