wujianwei
2025-08-18 8d258026876dd93bd0407d5440d48294f41120ba
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
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
<?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.PendingSettlementBusinessMapper">
 
    <resultMap type="com.ruoyi.cwgl.domain.PendingSettlementBusiness" id="PendingSettlementBusinessResult">
        <result property="id"    column="id"    />
        <result property="bookingNo"    column="booking_no"    />
        <result property="customerId"    column="customer_id"    />
        <result property="carrierId"    column="carrier_id"    />
        <result property="projectName"    column="project_name"    />
        <result property="dispatchNo"    column="dispatch_no"    />
        <result property="createdTime"    column="created_time"    />
        <result property="transportMode"    column="transport_mode"    />
        <result property="productId"    column="product_id"    />
        <result property="customerName"    column="customer_name"    />
        <result property="operationMode"    column="operation_mode"    />
        <result property="carrierName"    column="carrier_name"    />
        <result property="departureLocation"    column="departure_location"    />
        <result property="arrivalLocation"    column="arrival_location"    />
        <result property="vehicleId"    column="vehicle_id"    />
        <result property="licensePlateNumber"    column="license_plate_number"    />
        <result property="vehicleType"    column="vehicle_type"    />
        <result property="mainDriver"    column="main_driver"    />
        <result property="assistantDriver"    column="assistant_driver"    />
        <result property="pointNum"    column="point_num"    />
        <result property="businessContact"    column="business_contact"    />
        <result property="estimatedTotalIncome"    column="estimated_total_income"    />
        <result property="estimatedTotalCost"    column="estimated_total_cost"    />
        <result property="estimatedProfit"    column="estimated_profit"    />
        <result property="electronicLock"    column="electronic_lock"    />
        <result property="reWeighingWeight"    column="re_weighing_weight"    />
        <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="emptyMileage"    column="empty_mileage"    />
        <result property="emptyFuel"    column="empty_fuel"    />
        <result property="heavyMileage"    column="heavy_mileage"    />
        <result property="heavyFuel"    column="heavy_fuel"    />
        <result property="beScheduled"    column="be_scheduled"    />
        <result property="trackingNo"    column="tracking_no"    />
        <result property="sealNo"    column="seal_no"    />
        <result property="scheduleNo"    column="schedule_no"    />
        <result property="transportStatus"    column="transport_status"    />
        <result property="estimatedBillId"    column="estimated_bill_id"    />
        <result property="settlementBillId"    column="settlement_bill_id"    />
        <result property="settlementStatus"    column="settlement_status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isCreate"    column="is_create"    />
        <result property="billId"    column="bill_id"    />
        <result property="billName"    column="bill_name"    />
        <result property="confirmedTotalIncome"    column="confirmed_total_income"    />
        <result property="confirmedTotalCost"    column="confirmed_total_cost"    />
        <result property="isIncomeMatched"    column="is_income_matched"    />
        <result property="isCostMatched"    column="is_cost_matched"    />
        <result property="relatedBillStatus"    column="related_bill_status"    />
    </resultMap>
 
    <sql id="selectPendingSettlementBusinessVo">
        select thisTab.id, thisTab.booking_no, thisTab.customer_id, thisTab.carrier_id, thisTab.project_name, thisTab.dispatch_no, thisTab.created_time, thisTab.transport_mode, thisTab.product_id, thisTab.customer_name, thisTab.operation_mode, thisTab.carrier_name, thisTab.departure_location, thisTab.arrival_location, thisTab.vehicle_id, thisTab.license_plate_number, thisTab.vehicle_type, thisTab.main_driver, thisTab.assistant_driver, thisTab.point_num, thisTab.business_contact, thisTab.estimated_total_income, thisTab.estimated_total_cost, thisTab.estimated_profit, thisTab.electronic_lock, thisTab.re_weighing_weight, 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.empty_mileage, thisTab.empty_fuel, thisTab.heavy_mileage, thisTab.heavy_fuel, thisTab.be_scheduled, thisTab.tracking_no, thisTab.seal_no, thisTab.schedule_no, thisTab.transport_status, thisTab.estimated_bill_id, thisTab.settlement_bill_id, thisTab.bill_id, thisTab.settlement_status, thisTab.create_time, thisTab.update_time, thisTab.is_create, thisTab.bill_name, thisTab.confirmed_total_income, thisTab.confirmed_total_cost, thisTab.is_income_matched, thisTab.is_cost_matched, thisTab.related_bill_status from pending_settlement_business AS thisTab
    </sql>
    <sql id="selectPendingSettlementBusinessVoCount">
        select count(0) from pending_settlement_business as thisTab
    </sql>
 
    <sql id="whereCondition">
        <if test="bookingNo != null  and bookingNo != ''"> and thisTab.booking_no = #{bookingNo}</if>
        <if test="customerId != null  and customerId != ''"> and thisTab.customer_id = #{customerId}</if>
        <if test="carrierId != null  and carrierId != ''"> and thisTab.carrier_id = #{carrierId}</if>
        <if test="projectName != null  and projectName != ''"> and  thisTab.project_name like concat('%', #{projectName}, '%')</if>
        <if test="dispatchNo != null  and dispatchNo != ''"> and thisTab.dispatch_no = #{dispatchNo}</if>
        <if test="createdTime != null "> and thisTab.created_time = #{createdTime}</if>
        <if test="transportMode != null  and transportMode != ''"> and thisTab.transport_mode = #{transportMode}</if>
        <if test="productId != null  and productId != ''"> and thisTab.product_id = #{productId}</if>
        <if test="customerName != null  and customerName != ''"> and  thisTab.customer_name like concat('%', #{customerName}, '%')</if>
        <if test="operationMode != null  and operationMode != ''"> and thisTab.operation_mode = #{operationMode}</if>
        <if test="carrierName != null  and carrierName != ''"> and  thisTab.carrier_name like concat('%', #{carrierName}, '%')</if>
        <if test="departureLocation != null  and departureLocation != ''"> and thisTab.departure_location = #{departureLocation}</if>
        <if test="arrivalLocation != null  and arrivalLocation != ''"> and thisTab.arrival_location = #{arrivalLocation}</if>
        <if test="vehicleId != null  and vehicleId != ''"> and thisTab.vehicle_id = #{vehicleId}</if>
        <if test="licensePlateNumber != null  and licensePlateNumber != ''"> and thisTab.license_plate_number = #{licensePlateNumber}</if>
        <if test="vehicleType != null  and vehicleType != ''"> and thisTab.vehicle_type = #{vehicleType}</if>
        <if test="mainDriver != null  and mainDriver != ''"> and thisTab.main_driver = #{mainDriver}</if>
        <if test="assistantDriver != null  and assistantDriver != ''"> and thisTab.assistant_driver = #{assistantDriver}</if>
        <if test="pointNum != null "> and thisTab.point_num = #{pointNum}</if>
        <if test="businessContact != null  and businessContact != ''"> and thisTab.business_contact = #{businessContact}</if>
        <if test="estimatedTotalIncome != null "> and thisTab.estimated_total_income = #{estimatedTotalIncome}</if>
        <if test="estimatedTotalCost != null "> and thisTab.estimated_total_cost = #{estimatedTotalCost}</if>
        <if test="estimatedProfit != null "> and thisTab.estimated_profit = #{estimatedProfit}</if>
        <if test="electronicLock != null  and electronicLock != ''"> and thisTab.electronic_lock = #{electronicLock}</if>
        <if test="reWeighingWeight != null "> and thisTab.re_weighing_weight = #{reWeighingWeight}</if>
        <if test="quantity != null "> and thisTab.quantity = #{quantity}</if>
        <if test="actualDepartureTimeBegin != null and actualDepartureTimeBegin != '' and actualDepartureTimeEnd != null and actualDepartureTimeEnd != ''"> and  thisTab.actual_departure_time between #{actualDepartureTimeBegin} and #{actualDepartureTimeEnd}</if>
        <if test="requiredArrivalTimeBegin != null and requiredArrivalTimeBegin != '' and requiredArrivalTimeEnd != null and requiredArrivalTimeEnd != ''"> and  thisTab.required_arrival_time between #{requiredArrivalTimeBegin} and #{requiredArrivalTimeEnd}</if>
        <if test="actualArrivalTimeBegin != null and actualArrivalTimeBegin != '' and actualArrivalTimeEnd != null and actualArrivalTimeEnd != ''"> and  thisTab.actual_arrival_time between #{actualArrivalTimeBegin} and #{actualArrivalTimeEnd}</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="emptyMileage != null "> and thisTab.empty_mileage = #{emptyMileage}</if>
        <if test="emptyFuel != null "> and thisTab.empty_fuel = #{emptyFuel}</if>
        <if test="isCreate != null "> and thisTab.is_create = #{isCreate}</if>
        <if test="billId != null "> and thisTab.bill_id = #{billId}</if>
        <if test="heavyMileage != null "> and thisTab.heavy_mileage = #{heavyMileage}</if>
        <if test="heavyFuel != null "> and thisTab.heavy_fuel = #{heavyFuel}</if>
        <if test="confirmedTotalIncome != null "> and thisTab.confirmed_total_income = #{confirmedTotalIncome}</if>
        <if test="confirmedTotalCost != null "> and thisTab.confirmed_total_cost = #{confirmedTotalCost}</if>
        <if test="isIncomeMatched != null "> and thisTab.is_income_matched = #{isIncomeMatched}</if>
        <if test="isCostMatched != null "> and thisTab.is_cost_matched = #{isCostMatched}</if>
        <if test="beScheduled != null  and beScheduled != ''"> and thisTab.be_scheduled = #{beScheduled}</if>
        <if test="trackingNo != null  and trackingNo != ''"> and thisTab.tracking_no = #{trackingNo}</if>
        <if test="sealNo != null  and sealNo != ''"> and thisTab.seal_no = #{sealNo}</if>
        <if test="scheduleNo != null  and scheduleNo != ''"> and thisTab.schedule_no = #{scheduleNo}</if>
        <if test="transportStatus != null  and transportStatus != ''"> and thisTab.transport_status = #{transportStatus}</if>
        <if test="estimatedBillId != null  and estimatedBillId != ''"> and thisTab.estimated_bill_id = #{estimatedBillId}</if>
        <if test="settlementBillId != null  and settlementBillId != ''"> and thisTab.settlement_bill_id = #{settlementBillId}</if>
        <if test="settlementStatus != null  and settlementStatus != ''"> and thisTab.settlement_status = #{settlementStatus}</if>
    </sql>
 
    <!--查询-->
    <select id="selectPendingSettlementBusinessById" parameterType="Integer" resultMap="PendingSettlementBusinessResult">
        <include refid="selectPendingSettlementBusinessVo"/>
        where id = #{id}
    </select>
 
    <select id="selectPendingSettlementBusinessCount" parameterType="com.ruoyi.cwgl.domain.PendingSettlementBusiness" resultType="int">
        <include refid="selectPendingSettlementBusinessVoCount"/>
        <where>
            <include refid="whereCondition"/>
        </where>
    </select>
 
    <select id="selectPendingSettlementBusinessList" parameterType="com.ruoyi.cwgl.domain.PendingSettlementBusiness" resultMap="PendingSettlementBusinessResult">
        <include refid="selectPendingSettlementBusinessVo"/>
        <where>
            <include refid="whereCondition"/>
        </where>
        order by thisTab.id desc
    </select>
    <select id="selectPendingSettlement2Cw" resultType="com.ruoyi.cwgl.domain.PendingSettlementBusiness">
SELECT
-- ord.BOOKING_NO '客户订单号',
-- ord.CUSTOMER_ID,
-- ts.CARRIER_ID,
ts.ID as serviceId,
brd.PROJECT_NAME as projectName,
ts.DISPATCH_NO as dispatchNo,
ts.CREATED_TIME as createdTime,
-- ts.TRANSPORT_MODE '运输方式',
-- ts.PRODUCT_ID '服务产品',
customer.NAME as customerName,
        case when ts.CARRIER_ID=50 then
        '自营'
        else '外协'
        end as  operationMode,
bp.NAME as carrierName,
location_d.NAME_TREE as departureLocation,
location_a.NAME_TREE as arrivalLocation,
-- ts.VEHICLE_ID '运输工具ID',
vhc.LICENSE_PLATE_NUMBER as licensePlateNumber,
bvt.NAME as vehicleType,
driver_m.NAME as mainDriver,
ts.POINT_NUM as pointNum,
        ts.CREATOR as businessContact,
 
-- ts.ELECTRONIC_LOCK '电子锁',
-- ts.RE_WEIGHING_WEIGHT '复磅重量',
ts.QUANTITY as quantity,
driver_a.NAME as assistantDriver,
ts.ACTUAL_DEPARTURE_TIME as actualDepartureTime,
ts.REQUIRED_ARRIVAL_TIME as requiredArrivalTime,
ts.ACTUAL_ARRIVAL_TIME as actualArrivalTime,
ts.BE_RETURN as beReturn,
ts.DISPATCH_QUANTITY as dispatchQuantity,
ts.DISPATCH_WEIGHT as dispatchWeight,
ts.DISPATCH_VOLUME as dispatchVolume,
-- ts.EMPTY_MILEAGE '空载里程(公里)',
-- ts.EMPTY_FUEL '空载油耗(升)',
-- ts.HEAVY_MILEAGE '重载里程(公里)',
-- ts.HEAVY_FUEL '重载油耗(升)',
-- ts.BE_SCHEDULED '是否按班次',
-- ts.TRACKING_NO '快递单号',
-- ts.SEAL_NO '铅封号',
-- ts.SCHEDULE_NO '班次号',
CASE ts.STATUS
        WHEN 'A' THEN '生效'
        WHEN 'O' THEN '打开'
        WHEN 'J' THEN '已接单'
        WHEN 'K' THEN '已到库'
        WHEN 'Z' THEN '已装车'
        WHEN 'T' THEN '在途'
        WHEN 'F' THEN '已复磅'
        WHEN 'D' THEN '已运抵'
        ELSE '未知状态'
    END AS transportStatus
 
 
        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_vehicle_type bvt on bvt.ID=vhc.VEHICLE_TYPE_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 base_plan_road_detail prd on prd.ID =ts.PLAN_ROAD_DETAIL_ID
        -- 路线表
    LEFT join base_road_survey brd on brd.ID = prd.ROAD_SURVEY_ID
 
 
    where  ts.STATUS='D'
    and ts.IS_SYNC = 0
 
 
 
    </select>
    <select id="selectReceivableLineTruckPriceRule"
            resultType="com.ruoyi.cwgl.domain.ReceivableLineTruckPriceRule">
 
        SELECT
    rtd.id as id,
    rtd.REFERENCE1 as feeType,
    rtd.REFERENCE2 as customerName,
    rtd.REFERENCE3 as departureCity,
    rtd.REFERENCE4 as departureDistrict,
    rtd.REFERENCE5 as arrivalCity,
    rtd.REFERENCE6 as arrivalDistrict,
    rtd.REFERENCE7 as vehicleType,
    rtd.VALUE1 as freight,
    rtd.CREATED_TIME as createdTime
FROM
    thorn_rule_table_detail rtd
    LEFT JOIN thorn_rule_version rv ON rtd.VERSION_ID = rv.id
    LEFT JOIN thorn_rule_table rt ON rv.RULE_TABLE_ID = rt.id
WHERE
    rt.STATUS = 'ACTIVE'
    AND rt.NAME = '应收线路整车价格' and rtd.REFERENCE1='运费'
 
    </select>
    <select id="selectPayableLineTruckPriceRule"
            resultType="com.ruoyi.cwgl.domain.ReceivableLineTruckPriceRule">
 
        SELECT
    rtd.id as id,
    rtd.REFERENCE1 as feeType,
    rtd.REFERENCE2 as customerName,
    rtd.REFERENCE3 as departureCity,
    rtd.REFERENCE4 as departureDistrict,
    rtd.REFERENCE5 as arrivalCity,
    rtd.REFERENCE6 as arrivalDistrict,
    rtd.REFERENCE7 as vehicleType,
    rtd.VALUE1 as freight,
    rtd.CREATED_TIME as createdTime
FROM
    thorn_rule_table_detail rtd
    LEFT JOIN thorn_rule_version rv ON rtd.VERSION_ID = rv.id
    LEFT JOIN thorn_rule_table rt ON rv.RULE_TABLE_ID = rt.id
WHERE
    rt.STATUS = 'ACTIVE'
    AND rt.NAME = '应付线路整车价格' and rtd.REFERENCE1='运费'
    </select>
    <select id="selectCustomName" resultType="java.lang.String">
        SELECT customer_name from pending_settlement_business group by customer_name
 
    </select>
    <select id="selectPendingSettlementBusinessDispatchNos" resultType="java.lang.String">
        SELECT dispatch_no from pending_settlement_business where  bill_id =    #{id}
 
    </select>
    <select id="selectPendingSettlementBusinessByNo"
            resultMap="PendingSettlementBusinessResult">
        <include refid="selectPendingSettlementBusinessVo"/>
        where dispatch_no = #{dispatchNo}
 
    </select>
 
    <!-- 新增 -->
    <insert id="insertPendingSettlementBusiness" parameterType="com.ruoyi.cwgl.domain.PendingSettlementBusiness"  useGeneratedKeys="true" keyProperty="id">
        insert into pending_settlement_business
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bookingNo != null">booking_no,</if>
            <if test="customerId != null">customer_id,</if>
            <if test="carrierId != null">carrier_id,</if>
            <if test="projectName != null">project_name,</if>
            <if test="dispatchNo != null and dispatchNo != ''">dispatch_no,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="transportMode != null">transport_mode,</if>
            <if test="productId != null">product_id,</if>
            <if test="customerName != null">customer_name,</if>
            <if test="operationMode != null">operation_mode,</if>
            <if test="carrierName != null">carrier_name,</if>
            <if test="departureLocation != null">departure_location,</if>
            <if test="arrivalLocation != null">arrival_location,</if>
            <if test="vehicleId != null">vehicle_id,</if>
            <if test="licensePlateNumber != null">license_plate_number,</if>
            <if test="vehicleType != null">vehicle_type,</if>
            <if test="mainDriver != null">main_driver,</if>
            <if test="assistantDriver != null">assistant_driver,</if>
            <if test="pointNum != null">point_num,</if>
            <if test="businessContact != null">business_contact,</if>
            <if test="estimatedTotalIncome != null">estimated_total_income,</if>
            <if test="estimatedTotalCost != null">estimated_total_cost,</if>
            <if test="estimatedProfit != null">estimated_profit,</if>
            <if test="electronicLock != null">electronic_lock,</if>
            <if test="reWeighingWeight != null">re_weighing_weight,</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="emptyMileage != null">empty_mileage,</if>
            <if test="emptyFuel != null">empty_fuel,</if>
            <if test="heavyMileage != null">heavy_mileage,</if>
            <if test="heavyFuel != null">heavy_fuel,</if>
            <if test="beScheduled != null">be_scheduled,</if>
            <if test="trackingNo != null">tracking_no,</if>
            <if test="sealNo != null">seal_no,</if>
            <if test="scheduleNo != null">schedule_no,</if>
            <if test="transportStatus != null">transport_status,</if>
            <if test="estimatedBillId != null">estimated_bill_id,</if>
            <if test="settlementBillId != null">settlement_bill_id,</if>
            <if test="settlementStatus != null">settlement_status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isCreate != null">is_create,</if>
            <if test="confirmedTotalIncome != null">confirmed_total_income,</if>
            <if test="confirmedTotalCost != null">confirmed_total_cost,</if>
            <if test="isIncomeMatched != null">is_income_matched,</if>
            <if test="isCostMatched != null">is_cost_matched,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bookingNo != null">#{bookingNo},</if>
            <if test="customerId != null">#{customerId},</if>
            <if test="carrierId != null">#{carrierId},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="dispatchNo != null and dispatchNo != ''">#{dispatchNo},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="transportMode != null">#{transportMode},</if>
            <if test="productId != null">#{productId},</if>
            <if test="customerName != null">#{customerName},</if>
            <if test="operationMode != null">#{operationMode},</if>
            <if test="carrierName != null">#{carrierName},</if>
            <if test="departureLocation != null">#{departureLocation},</if>
            <if test="arrivalLocation != null">#{arrivalLocation},</if>
            <if test="vehicleId != null">#{vehicleId},</if>
            <if test="licensePlateNumber != null">#{licensePlateNumber},</if>
            <if test="vehicleType != null">#{vehicleType},</if>
            <if test="mainDriver != null">#{mainDriver},</if>
            <if test="assistantDriver != null">#{assistantDriver},</if>
            <if test="pointNum != null">#{pointNum},</if>
            <if test="businessContact != null">#{businessContact},</if>
            <if test="estimatedTotalIncome != null">#{estimatedTotalIncome},</if>
            <if test="estimatedTotalCost != null">#{estimatedTotalCost},</if>
            <if test="estimatedProfit != null">#{estimatedProfit},</if>
            <if test="electronicLock != null">#{electronicLock},</if>
            <if test="reWeighingWeight != null">#{reWeighingWeight},</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="emptyMileage != null">#{emptyMileage},</if>
            <if test="emptyFuel != null">#{emptyFuel},</if>
            <if test="heavyMileage != null">#{heavyMileage},</if>
            <if test="heavyFuel != null">#{heavyFuel},</if>
            <if test="beScheduled != null">#{beScheduled},</if>
            <if test="trackingNo != null">#{trackingNo},</if>
            <if test="sealNo != null">#{sealNo},</if>
            <if test="scheduleNo != null">#{scheduleNo},</if>
            <if test="transportStatus != null">#{transportStatus},</if>
            <if test="estimatedBillId != null">#{estimatedBillId},</if>
            <if test="settlementBillId != null">#{settlementBillId},</if>
            <if test="settlementStatus != null">#{settlementStatus},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isCreate != null">#{isCreate},</if>
            <if test="confirmedTotalIncome != null">#{confirmedTotalIncome},</if>
            <if test="confirmedTotalCost != null">#{confirmedTotalCost},</if>
            <if test="isIncomeMatched != null">#{isIncomeMatched},</if>
            <if test="isCostMatched != null">#{isCostMatched},</if>
         </trim>
    </insert>
 
    <insert id="insertPendingSettlementBusinessBatch" parameterType="java.util.List">
        insert into pending_settlement_business
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            booking_no,customer_id,carrier_id,project_name,dispatch_no,created_time,transport_mode,product_id,customer_name,operation_mode,carrier_name,departure_location,arrival_location,vehicle_id,license_plate_number,vehicle_type,main_driver,assistant_driver,point_num,business_contact,estimated_total_income,estimated_total_cost,estimated_profit,electronic_lock,re_weighing_weight,quantity,actual_departure_time,required_arrival_time,actual_arrival_time,be_return,dispatch_quantity,dispatch_weight,dispatch_volume,empty_mileage,empty_fuel,heavy_mileage,heavy_fuel,be_scheduled,tracking_no,seal_no,schedule_no,transport_status,estimated_bill_id,settlement_bill_id,settlement_status,create_time,update_time,is_create,is_income_matched,is_cost_matched,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.bookingNo},#{item.customerId},#{item.carrierId},#{item.projectName},#{item.dispatchNo},#{item.createdTime},#{item.transportMode},#{item.productId},#{item.customerName},#{item.operationMode},#{item.carrierName},#{item.departureLocation},#{item.arrivalLocation},#{item.vehicleId},#{item.licensePlateNumber},#{item.vehicleType},#{item.mainDriver},#{item.assistantDriver},#{item.pointNum},#{item.businessContact},#{item.estimatedTotalIncome},#{item.estimatedTotalCost},#{item.estimatedProfit},#{item.electronicLock},#{item.reWeighingWeight},#{item.quantity},#{item.actualDepartureTime},#{item.requiredArrivalTime},#{item.actualArrivalTime},#{item.beReturn},#{item.dispatchQuantity},#{item.dispatchWeight},#{item.dispatchVolume},#{item.emptyMileage},#{item.emptyFuel},#{item.heavyMileage},#{item.heavyFuel},#{item.beScheduled},#{item.trackingNo},#{item.sealNo},#{item.scheduleNo},#{item.transportStatus},#{item.estimatedBillId},#{item.settlementBillId},#{item.settlementStatus},#{item.createTime},#{item.updateTime},#{item.isCreate},#{item.isIncomeMatched},#{item.isCostMatched},
            </trim>
        </foreach>
    </insert>
 
    <!-- 修改 -->
    <update id="updatePendingSettlementBusiness" parameterType="com.ruoyi.cwgl.domain.PendingSettlementBusiness">
        update pending_settlement_business
        <trim prefix="SET" suffixOverrides=",">
            <if test="bookingNo != null">booking_no = #{bookingNo},</if>
            <if test="customerId != null">customer_id = #{customerId},</if>
            <if test="carrierId != null">carrier_id = #{carrierId},</if>
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="dispatchNo != null and dispatchNo != ''">dispatch_no = #{dispatchNo},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="transportMode != null">transport_mode = #{transportMode},</if>
            <if test="productId != null">product_id = #{productId},</if>
            <if test="customerName != null">customer_name = #{customerName},</if>
            <if test="operationMode != null">operation_mode = #{operationMode},</if>
            <if test="carrierName != null">carrier_name = #{carrierName},</if>
            <if test="departureLocation != null">departure_location = #{departureLocation},</if>
            <if test="arrivalLocation != null">arrival_location = #{arrivalLocation},</if>
            <if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
            <if test="licensePlateNumber != null">license_plate_number = #{licensePlateNumber},</if>
            <if test="vehicleType != null">vehicle_type = #{vehicleType},</if>
            <if test="mainDriver != null">main_driver = #{mainDriver},</if>
            <if test="assistantDriver != null">assistant_driver = #{assistantDriver},</if>
            <if test="pointNum != null">point_num = #{pointNum},</if>
            <if test="businessContact != null">business_contact = #{businessContact},</if>
            <if test="estimatedTotalIncome != null">estimated_total_income = #{estimatedTotalIncome},</if>
            <if test="estimatedTotalCost != null">estimated_total_cost = #{estimatedTotalCost},</if>
            <if test="estimatedProfit != null">estimated_profit = #{estimatedProfit},</if>
            <if test="electronicLock != null">electronic_lock = #{electronicLock},</if>
            <if test="reWeighingWeight != null">re_weighing_weight = #{reWeighingWeight},</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="emptyMileage != null">empty_mileage = #{emptyMileage},</if>
            <if test="emptyFuel != null">empty_fuel = #{emptyFuel},</if>
            <if test="heavyMileage != null">heavy_mileage = #{heavyMileage},</if>
            <if test="heavyFuel != null">heavy_fuel = #{heavyFuel},</if>
            <if test="beScheduled != null">be_scheduled = #{beScheduled},</if>
            <if test="trackingNo != null">tracking_no = #{trackingNo},</if>
            <if test="sealNo != null">seal_no = #{sealNo},</if>
            <if test="scheduleNo != null">schedule_no = #{scheduleNo},</if>
            <if test="transportStatus != null">transport_status = #{transportStatus},</if>
            <if test="estimatedBillId != null">estimated_bill_id = #{estimatedBillId},</if>
            <if test="settlementBillId != null">settlement_bill_id = #{settlementBillId},</if>
            <if test="settlementStatus != null">settlement_status = #{settlementStatus},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isCreate != null">is_create = #{isCreate},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 修改 -->
    <update id="updatePendingSettlementBusinessBatch" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" separator=";">
            update pending_settlement_business
            <trim prefix="SET" suffixOverrides=",">
                <if test="item.bookingNo != null">booking_no = #{item.bookingNo},</if>
                <if test="item.customerId != null">customer_id = #{item.customerId},</if>
                <if test="item.carrierId != null">carrier_id = #{item.carrierId},</if>
                <if test="item.projectName != null">project_name = #{item.projectName},</if>
                <if test="item.dispatchNo != null and item.dispatchNo != ''">dispatch_no = #{item.dispatchNo},</if>
                <if test="item.createdTime != null">created_time = #{item.createdTime},</if>
                <if test="item.transportMode != null">transport_mode = #{item.transportMode},</if>
                <if test="item.productId != null">product_id = #{item.productId},</if>
                <if test="item.customerName != null">customer_name = #{item.customerName},</if>
                <if test="item.operationMode != null">operation_mode = #{item.operationMode},</if>
                <if test="item.carrierName != null">carrier_name = #{item.carrierName},</if>
                <if test="item.departureLocation != null">departure_location = #{item.departureLocation},</if>
                <if test="item.arrivalLocation != null">arrival_location = #{item.arrivalLocation},</if>
                <if test="item.vehicleId != null">vehicle_id = #{item.vehicleId},</if>
                <if test="item.licensePlateNumber != null">license_plate_number = #{item.licensePlateNumber},</if>
                <if test="item.vehicleType != null">vehicle_type = #{item.vehicleType},</if>
                <if test="item.mainDriver != null">main_driver = #{item.mainDriver},</if>
                <if test="item.assistantDriver != null">assistant_driver = #{item.assistantDriver},</if>
                <if test="item.pointNum != null">point_num = #{item.pointNum},</if>
                <if test="item.businessContact != null">business_contact = #{item.businessContact},</if>
                <if test="item.estimatedTotalIncome != null">estimated_total_income = #{item.estimatedTotalIncome},</if>
                <if test="item.estimatedTotalCost != null">estimated_total_cost = #{item.estimatedTotalCost},</if>
                <if test="item.estimatedProfit != null">estimated_profit = #{item.estimatedProfit},</if>
                <if test="item.electronicLock != null">electronic_lock = #{item.electronicLock},</if>
                <if test="item.reWeighingWeight != null">re_weighing_weight = #{item.reWeighingWeight},</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.emptyMileage != null">empty_mileage = #{item.emptyMileage},</if>
                <if test="item.emptyFuel != null">empty_fuel = #{item.emptyFuel},</if>
                <if test="item.heavyMileage != null">heavy_mileage = #{item.heavyMileage},</if>
                <if test="item.heavyFuel != null">heavy_fuel = #{item.heavyFuel},</if>
                <if test="item.beScheduled != null">be_scheduled = #{item.beScheduled},</if>
                <if test="item.trackingNo != null">tracking_no = #{item.trackingNo},</if>
                <if test="item.sealNo != null">seal_no = #{item.sealNo},</if>
                <if test="item.scheduleNo != null">schedule_no = #{item.scheduleNo},</if>
                <if test="item.transportStatus != null">transport_status = #{item.transportStatus},</if>
                <if test="item.estimatedBillId != null">estimated_bill_id = #{item.estimatedBillId},</if>
                <if test="item.settlementBillId != null">settlement_bill_id = #{item.settlementBillId},</if>
                <if test="item.settlementStatus != null">settlement_status = #{item.settlementStatus},</if>
                <if test="item.createTime != null">create_time = #{item.createTime},</if>
                <if test="item.updateTime != null">update_time = #{item.updateTime},</if>
                <if test="item.isCreate != null">is_create = #{item.isCreate},</if>
            </trim>
        where id = #{item.id}
        </foreach>
    </update>
    <update id="updeteCwData">
        update pending_settlement_business set IS_SYNC = 1
        where ID in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
 
    </update>
    <update id="updatePendingSettlementBusinessIsCreate">
 
        UPDATE pending_settlement_business
        SET is_create = 1 ,bill_id = #{id},bill_name = #{billName},related_bill_status = 1
        WHERE dispatch_no IN
        <foreach item="item" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>
    <update id="updatePendingSettlementBusinessByBillId">
            UPDATE pending_settlement_business p
            JOIN estimated_receivable e ON p.dispatch_no = e.dispatch_no
            SET
            p.bill_name = #{billName},
            e.related_bill_name = #{billName}
            WHERE p.bill_id = #{id};
    </update>
    <update id="updateEstimatedReceivableBillStatus">
        UPDATE pending_settlement_business p
        JOIN estimated_receivable e ON p.dispatch_no = e.dispatch_no
        SET
        p.is_create = 1,
        p.bill_id = #{id},
        p.bill_name = #{billName},
        p.related_bill_status = 1,
        e.related_bill_name = #{billName}
        WHERE p.dispatch_no IN
        <foreach item="item" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>
 
    <!--删除-->
    <delete id="deletePendingSettlementBusinessById" parameterType="Integer">
        delete from pending_settlement_business where id = #{id}
    </delete>
    <delete id="deletePendingSettlementBusinessByIds" parameterType="Integer">
        delete from pending_settlement_business where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="cancelRelevancy">
       UPDATE pending_settlement_business p
LEFT JOIN estimated_receivable e ON p.dispatch_no = e.dispatch_no
SET
    p.bill_id = NULL,
    p.bill_name = NULL,
    p.is_create = 0,
    p.related_bill_status = 0,
    e.related_bill_name = NULL
    WHERE p.id = #{id}
    </delete>
 
</mapper>