puzhibing
2023-08-01 98bc380ae322eaac2ee7e21d0c565e30eacce2b5
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
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
package com.stylefeng.guns.modular.system.util;
 
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.dao.ServerCarModelMapper;
import com.stylefeng.guns.modular.system.dao.SystemPriceMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.ICarService;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IOrderPositionService;
import com.stylefeng.guns.modular.system.service.ITransactionDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
 
/**
 * 交通部接口
 */
@Component
public class PushMinistryOfTransportUtil {
 
    @Autowired
    private ICarService carService;
 
    @Autowired
    private HttpClientUtil httpClientUtil;
 
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
 
    @Resource
    private SystemPriceMapper systemPriceMapper;
 
    @Autowired
    private IDriverService driverService;
 
    @Autowired
    private IOrderPositionService orderPositionService;
 
    @Autowired
    private GDMapElectricFenceUtil gdMapElectricFenceUtil;
 
    @Autowired
    private RedisUtil redisUtil;
 
    @Resource
    private ServerCarModelMapper serverCarModelMapper;
 
    @Autowired
    private ITransactionDetailsService transactionDetailsService;
 
    @Autowired
    private GeodesyUtil geodesyUtil;
 
    private String path = "http://120.77.11.218:8868/";
 
 
    /**
     * 网约车车辆里程信息
     * @param id
     */
    public void baseInfoVehicleTotalMile(Integer id){
        Car car = carService.selectById(id);
        List<OrderPrivateCar> list = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().eq("carId", id));
        int mileage = 0;
        for(OrderPrivateCar orderPrivateCar : list){
            mileage += (orderPrivateCar.getMileage() == null ? 0 : orderPrivateCar.getMileage());
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("Address", 450204);//注册地行政区划代码
        jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
        jsonObject.put("TotalMile", Integer.valueOf(mileage / 1000));//行驶总里程(km)
        jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
        jsonObject.put("UpdateTime", new Date());
        Map<String, Object> map = new HashMap<>();
        map.put("baseInfoVehicleTotalMile", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/baseInfoVehicleTotalMile", map, header,"form");
        System.err.println("--------------------------网约车车辆里程信息------------------------:" + result);
    }
 
 
    /**
     * 订单发起接口
     * @param orderId
     */
    public void orderCreate(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        Map<String, Object> query = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("Address", 450204);//发起第行政区划代码
        jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单编号
        jsonObject.put("DepartTime", orderPrivateCar.getTravelTime());//预计用车时间YYYYMMDDhhmmss
        jsonObject.put("OrderTime", orderPrivateCar.getInsertTime());//订单发起时间YYYYMMDDhhmmss
        jsonObject.put("PassengerNote", "");//乘客备注
        jsonObject.put("Departure", orderPrivateCar.getStartAddress());//预计出发地点详细地址
        jsonObject.put("DepLongitude", orderPrivateCar.getStartLon());//预计出发地点经度
        jsonObject.put("DepLatitude", orderPrivateCar.getStartLat());//预计出发地点纬度
        jsonObject.put("Destination", orderPrivateCar.getEndAddress());//预计目的地
        jsonObject.put("DestLongitude", orderPrivateCar.getEndLon());//预计目的地经度
        jsonObject.put("DestLatitude", orderPrivateCar.getEndLat());//预计目的地纬度
        jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
        jsonObject.put("FareType", query.get("id").toString());//运价类型编码
        Map<String, Object> map = new HashMap<>();
        map.put("orderCreate", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/orderCreate", map, header,"form");
        System.err.println("---------------------------订单发起接口----------------------:" + result);
    }
 
 
    /**
     * 订单成功接口
     * @param orderId
     */
    public void orderMatch(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        Car car = carService.selectById(orderPrivateCar.getCarId());
        String value = redisUtil.getValue("DRIVER" + orderPrivateCar.getDriverId());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("Address", 450204);//发起地行政区划代码
        jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单编号
        jsonObject.put("Longitude", Double.valueOf(value.split(",")[0]));//车辆经度
        jsonObject.put("Latitude", Double.valueOf(value.split(",")[1]));//车辆纬度
        jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证编号
        jsonObject.put("DriverPhone", driver.getPhone());//驾驶员手机号
        jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
        jsonObject.put("DistributeTime", new Date());//派单成功时间YYYYMMDDhhmmss
        Map<String, Object> map = new HashMap<>();
        map.put("orderMatch", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/orderMatch", map, header,"form");
        System.err.println("--------------------------------订单成功接口---------------------------:" + result);
    }
 
 
    /**
     * 车辆经营上线接口
     * @param driverId
     */
    public void operateLogin(Integer driverId){
        Driver driver = driverService.selectById(driverId);
        Car car = carService.selectById(driver.getCarId());
        String value = redisUtil.getValue("DRIVER" + driverId);
        if(ToolUtil.isNotEmpty(value)){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
            jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
            jsonObject.put("LoginTime", new Date());//车辆经营上线时间YYYYMMDDhhmmss
            jsonObject.put("Longitude", Double.valueOf(value.split(",")[0]));//上线经度
            jsonObject.put("Latitude", Double.valueOf(value.split(",")[1]));//上线纬度
            jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
            Map<String, Object> map = new HashMap<>();
            map.put("operateLogin", jsonObject.toJSONString());
 
            Map<String, String> header = new HashMap<>();
            header.put("Connection", "keep-alive");
            header.put("Content-Type", "application/x-www-form-urlencoded");
            header.put("Accept", "*/*");
            header.put("Accept-Encoding", "gzip");
            header.put("Accept-Charset", "utf-8");
            String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/operateLogin", map, header,"form");
            System.err.println("--------------------------车辆经营上线接口------------------------:" + result);
        }
    }
 
 
    /**
     * 车辆经营下线接口
     * @param driverId
     */
    public void operateLogout(Integer driverId){
        Driver driver = driverService.selectById(driverId);
        Car car = carService.selectById(driver.getCarId());
        String value = redisUtil.getValue("DRIVER" + driverId);
        if(ToolUtil.isNotEmpty(value)){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
            jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
            jsonObject.put("LogoutTime", new Date());//车辆经营下线时间YYYYMMDDhhmmss
            jsonObject.put("Longitude", Double.valueOf(value.split(",")[0]));//下线经度
            jsonObject.put("Latitude", Double.valueOf(value.split(",")[1]));//下线纬度
            jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
            Map<String, Object> map = new HashMap<>();
            map.put("operateLogout", jsonObject.toJSONString());
 
            Map<String, String> header = new HashMap<>();
            header.put("Connection", "keep-alive");
            header.put("Content-Type", "application/x-www-form-urlencoded");
            header.put("Accept", "*/*");
            header.put("Accept-Encoding", "gzip");
            header.put("Accept-Charset", "utf-8");
            String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/operateLogout", map, header,"form");
            System.err.println("--------------------------------车辆经营下线接口------------------------:" + result);
        }
    }
 
 
    /**
     * 经营出发接口
     * @param orderId
     */
    public void operateDepart(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        Map<String, Object> query = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
        Car car = carService.selectById(orderPrivateCar.getCarId());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单号
        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
        jsonObject.put("FareType", query.get("id").toString());//运价类型编码
        jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
        jsonObject.put("DepLongitude", Double.valueOf(orderPrivateCar.getBoardingLon()));//车辆出发经度
        jsonObject.put("DepLatitude", Double.valueOf(orderPrivateCar.getBoardingLat()));//车辆出发纬度
        jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
        jsonObject.put("DepTime", orderPrivateCar.getBoardingTime());//上车时间YYYYMMDDhhmmss
 
        List<OrderPosition> orderPositions = null;
        try {
            orderPositions = orderPositionService.queryPosition(orderId, 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        int distance = 0;
        if(orderPositions.size() > 0){
            OrderPosition orderPosition = orderPositions.get(0);
            Map<String, String> distance1 = gdMapElectricFenceUtil.getDistance(orderPosition.getLon() + "," + orderPosition.getLat(), orderPrivateCar.getBoardingLon() + "," + orderPrivateCar.getBoardingLat(), 1);
            distance = Integer.valueOf(distance1.get("distance")) / 1000;
        }
        jsonObject.put("WaitMile", distance);//空驶里程(km)
        jsonObject.put("WaitTime", (null != orderPrivateCar.getWait() ? orderPrivateCar.getWait() : 0) * 60);//等待时间(秒)
        Map<String, Object> map = new HashMap<>();
        map.put("operateDepart", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/operateDepart", map,header,"form");
        System.err.println("--------------------------------经营出发接口-------------------------:" + result);
    }
 
 
    /**
     * 经营到达接口
     * @param orderId
     */
    public void operateArrive(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单号
        jsonObject.put("DestLongitude", orderPrivateCar.getGetoffLon());//车辆到达经度
        jsonObject.put("DestLatitude", orderPrivateCar.getGetoffLat());//车辆到达纬度
        jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
        jsonObject.put("DestTime", orderPrivateCar.getGetoffTime());//下车时间YYYYMMDDhhmmss
        jsonObject.put("DriveMile", Double.valueOf(orderPrivateCar.getMileage() / 1000).intValue());//载客里程(km)
        jsonObject.put("DriveTime", Double.valueOf((orderPrivateCar.getGetoffTime().getTime() - orderPrivateCar.getBoardingTime().getTime()) / 1000).intValue());//载客时间(秒)
        Map<String, Object> map = new HashMap<>();
        map.put("operateArrive", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/operateArrive", map, header,"form");
        System.err.println("-------------------------------经营到达接口-------------------------:" + result);
    }
 
 
    /**
     * 经营支付接口
     * @param orderId
     */
    public void operatePay(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        Map<String, Object> query = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
        Car car = carService.selectById(orderPrivateCar.getCarId());
        ServerCarModel serverCarModel = serverCarModelMapper.selectById(orderPrivateCar.getServerCarModelId());
        TransactionDetails transactionDetails = transactionDetailsService.selectById(new EntityWrapper<TransactionDetails>().eq("orderType", 1).eq("orderId", orderId));
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单号
        jsonObject.put("OnArea", 450204);//上车位置行政区划代码
        jsonObject.put("DriverName", driver.getName());//机动车驾驶员
        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
        jsonObject.put("FareType", query.get("id").toString());//运价类型编码(由网约车公司定义,与运价信息接口保持一街)
        jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
        jsonObject.put("BookDepTime", orderPrivateCar.getTravelTime());//预计上车时间YYYYMMDDhhmmss
        jsonObject.put("WaitTime", orderPrivateCar.getWait() * 60);//等待时间(秒)
        jsonObject.put("DepLongitude", orderPrivateCar.getBoardingLon());//车辆出发经度
        jsonObject.put("DepLatitude", orderPrivateCar.getBoardingLat());//车辆出发纬度
        jsonObject.put("DepArea", orderPrivateCar.getBoardingAddress());//上车点
        jsonObject.put("DepTime", orderPrivateCar.getBoardingTime());//上车时间YYYYMMDDhhmmss
        jsonObject.put("DestLongitude", orderPrivateCar.getGetoffLon());//车辆到达经度
        jsonObject.put("DestLatitude", orderPrivateCar.getGetoffLat());//车辆到达纬度
        jsonObject.put("DestArea", orderPrivateCar.getGetoffAddress());//下车地点
        jsonObject.put("DestTime", orderPrivateCar.getGetoffTime());//下车时间YYYYMMDDhhmmss
        jsonObject.put("BookModel", serverCarModel.getName());//预定车型
        jsonObject.put("Model", serverCarModel.getName());//实际使用车型
        jsonObject.put("DriveMile", Double.valueOf(orderPrivateCar.getMileage() / 1000).intValue());//载客里程(km)
        jsonObject.put("DriveTime", Double.valueOf((orderPrivateCar.getGetoffTime().getTime() - orderPrivateCar.getBoardingTime().getTime()) / 1000).intValue());//载客时间(秒)
        List<OrderPosition> orderPositions = null;
        try {
            orderPositions = orderPositionService.queryPosition(orderId, 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        int distance = 0;
        if(orderPositions.size() > 0){
            OrderPosition orderPosition = orderPositions.get(0);
            Map<String, String> distance1 = gdMapElectricFenceUtil.getDistance(orderPosition.getLon() + "," + orderPosition.getLat(), orderPrivateCar.getBoardingLon() + "," + orderPrivateCar.getBoardingLat(), 1);
            distance = Integer.valueOf(distance1.get("distance")) / 1000;
        }
        jsonObject.put("WaitMile", distance);//空驶里程(km)
        jsonObject.put("FactPrice", orderPrivateCar.getPayMoney());//实收金额(元)
        jsonObject.put("Price", orderPrivateCar.getOrderMoney());//应收金额(元)
        jsonObject.put("CashPrice", orderPrivateCar.getPayType() == 3 ? orderPrivateCar.getPayMoney() : 0);//现金支付金额(元)
        jsonObject.put("LineName", orderPrivateCar.getPayType() != 3 ? "" : "");//电子支付机构
        jsonObject.put("LinePrice", orderPrivateCar.getPayType() != 3 ? orderPrivateCar.getPayMoney() : 0);//电子支付金额(元)
        jsonObject.put("PosName", "");//POS机支付机构
        jsonObject.put("PosPrice", 0);//POS机支付金额(元)
        jsonObject.put("BenfitPrice", (orderPrivateCar.getRedPacketMoney() == null ? 0 : orderPrivateCar.getRedPacketMoney())
                + (orderPrivateCar.getCouponMoney() == null ? 0 : orderPrivateCar.getCouponMoney())
                + (orderPrivateCar.getDurationMoney() == null ? 0 : orderPrivateCar.getDurationMoney()));//优惠金额(元)
        jsonObject.put("BookTip", 0);//预约服务费(元)
        jsonObject.put("PassengerTip", (orderPrivateCar.getParkMoney() == null ? 0 : orderPrivateCar.getParkMoney())
                + (orderPrivateCar.getRoadTollMoney() == null ? 0 : orderPrivateCar.getRoadTollMoney()));//附加费(元)
        Map<String, Double> map1 = this.setMoney(orderPrivateCar);
        Double amount3 = map1.get("amount3");//其他时间段
        Double amount2 = map1.get("amount2");//高峰时段
        Double amount1 = map1.get("amount1");//夜间时段
        jsonObject.put("PeakUpPrice", null != amount2 ? (amount2 - amount3) : 0);//高峰时段时间加价金额(元)
        jsonObject.put("NightUpPrice", null != amount1 ? (amount1 - amount3) : 0);//夜间时段里程加价金额(元)
        jsonObject.put("FarUpPrice", orderPrivateCar.getLongDistanceMoney() == null ? 0 : orderPrivateCar.getLongDistanceMoney());//远途加价金额(元)
        jsonObject.put("OtherUpPrice", (orderPrivateCar.getDurationMoney() == null ? 0 : orderPrivateCar.getDurationMoney())
                + (orderPrivateCar.getWaitMoney() == null ? 0 : orderPrivateCar.getWaitMoney()));//其他加价金额(元)
        jsonObject.put("PayState", 1);//结算状态(0:未结算,1:已结算,2:未知)
        jsonObject.put("PayTime", null != transactionDetails ? transactionDetails.getInsertTime() : new Date());//乘客结算时间YYYYMMDDhhmmss
        jsonObject.put("OrderMatchTime", null != transactionDetails ? transactionDetails.getInsertTime() : new Date());//订单完成时间YYYYMMDDhhmmss
        jsonObject.put("InvoiceStatus", "0");//发票状态(0:未开票,1:已开票,2:未知)
        Map<String, Object> map = new HashMap<>();
        map.put("operatePay", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/operatePay", map, header,"form");
        System.err.println("-----------------------经营支付接口-----------------------:" + result);
    }
 
 
    /**
     * 驾驶员定位信息
     * @param orderId
     */
    public void positionDriver(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        Car car = carService.selectById(orderPrivateCar.getCarId());
        List<OrderPosition> orderPositions = null;
        try {
            orderPositions = orderPositionService.queryPosition(orderId, 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Double Longitude = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getLon()) : 0D;
        Double Latitude = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getLat()) : 0D;
        Double Direction = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getDirectionAngle()) : 0D;
        Double Elevation = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getAltitude()) : 0D;
        Double Speed = 0D;
        if(orderPositions != null && orderPositions.size() > 1){
//            Map<String, String> distance = gdMapElectricFenceUtil.getDistance(orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(),
//                    orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(), 0);
            Map<String, Double> distance = geodesyUtil.getDistance(orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(),
                    orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat());
            Speed = distance != null ? Double.valueOf(distance.get("WGS84")) / 1000 : 0D;
        }
        Integer state = 4;
        String orderNum = "0";
        if(orderPrivateCar.getState() == 2){
            state = 2;
            orderNum = orderPrivateCar.getOrderNum();
        }
        if(orderPrivateCar.getState() == 3 || orderPrivateCar.getState() == 4){
            state = 3;
            orderNum = orderPrivateCar.getOrderNum();
        }
        if(orderPrivateCar.getState() == 5 || orderPrivateCar.getState() == 6 || orderPrivateCar.getState() == 11){
            state = 1;
            orderNum = orderPrivateCar.getOrderNum();
        }
 
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
        jsonObject.put("DriverRegionCode", 450204);//行政区划代码
        jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
        jsonObject.put("PositionTime", new Date());//定位时间(时间戳)
        jsonObject.put("Longitude", Longitude);//经度
        jsonObject.put("Latitude", Latitude);//纬度
        jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
        jsonObject.put("Direction", Direction);//方向角
        jsonObject.put("Elevation", Elevation);//海拔高度
        jsonObject.put("Speed", Speed);//瞬时速度(km/h)
        jsonObject.put("BizStatus", state);//营运状态(1:载客,2:接单,3:空驶,4:停运)
        jsonObject.put("OrderId", orderNum);//订单编号
        Map<String, Object> map = new HashMap<>();
        map.put("positionDriver", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/positionDriver", map, header,"form");
        System.err.println("-----------------------------驾驶员定位信息------------------------:" + result);
    }
 
 
    /**
     * 车辆定位信息
     * @param orderId
     */
    public void positionVehicle(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        Car car = carService.selectById(orderPrivateCar.getCarId());
        List<OrderPosition> orderPositions = null;
        try {
            orderPositions = orderPositionService.queryPosition(orderId, 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Double Longitude = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getLon()) : 0D;
        Double Latitude = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getLat()) : 0D;
        Double Direction = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getDirectionAngle()) : 0D;
        Double Elevation = orderPositions != null && orderPositions.size() > 0 ? Double.valueOf(orderPositions.get(orderPositions.size() - 1).getAltitude()) : 0D;
        Double Speed = 0D;
        if(orderPositions != null && orderPositions.size() > 1){
//            Map<String, String> distance = gdMapElectricFenceUtil.getDistance(orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(),
//                    orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(), 0);
            Map<String, Double> distance = geodesyUtil.getDistance(orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(),
                    orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat());
            Speed = distance != null ? Double.valueOf(distance.get("WGS84")) / 1000 : 0D;
        }
        Integer state = 4;
        String orderNum = "0";
        if(orderPrivateCar.getState() == 2){
            state = 2;
            orderNum = orderPrivateCar.getOrderNum();
        }
        if(orderPrivateCar.getState() == 3 || orderPrivateCar.getState() == 4){
            state = 3;
            orderNum = orderPrivateCar.getOrderNum();
        }
        if(orderPrivateCar.getState() == 5 || orderPrivateCar.getState() == 6 || orderPrivateCar.getState() == 11){
            state = 1;
            orderNum = orderPrivateCar.getOrderNum();
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
        jsonObject.put("VehicleRegionCode", 450204);//行政区划代码
        jsonObject.put("PositionTime", new Date());//定位时间(时间戳)
        jsonObject.put("Longitude", Longitude);//经度
        jsonObject.put("Latitude", Latitude);//纬度
        jsonObject.put("Speed", Speed);//瞬时速度(km/h)
        jsonObject.put("Direction", Direction);//方向角
        jsonObject.put("Elevation", Elevation);//海拔高度
        jsonObject.put("Mileage", orderPrivateCar.getMileage() / 1000);//行驶里程(KM)
        jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
        jsonObject.put("WarnStatus", 0);//预警状态
        jsonObject.put("VehStatus", 0);//车辆状态
        jsonObject.put("BizStatus", state);//营运状态(1:载客,2:接单,3:空驶,4:停运)
        jsonObject.put("OrderId", orderNum);//订单编号(非营运状态下填"0")
        Map<String, Object> map = new HashMap<>();
        map.put("positionVehicle", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/positionVehicle", map, header,"form");
        System.err.println("----------------------------车辆定位信息---------------------------:" + result);
    }
 
 
 
 
 
 
 
 
 
 
 
 
    /**
     * 计算价格
     * @param orderPrivateCar
     * @return
     * @throws Exception
     */
    private Map<String, Double> setMoney(OrderPrivateCar orderPrivateCar) {
        Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
        Map<String, Double> map = new HashMap<>();
        //开始根据不同的方式计算金额
        double amount1 = 0;
        double amount2 = 0;
        double amount3 = 0;
        JSONObject jsonObject = JSON.parseObject(query1.get("content").toString());
        Double num1 = jsonObject.getDouble("num1");//起步价(元)
        Double num2 = jsonObject.getDouble("num2");//起步公里(公里)
        Double num3 = jsonObject.getDouble("num3");//起步时间(分钟)
        Double num4 = jsonObject.getDouble("num4");//里程费(元)
        Double num5 = jsonObject.getDouble("num5");//时长费(分钟)
        Double num6 = jsonObject.getDouble("num6");//等待费(分钟)
        Double num7 = jsonObject.getDouble("num7");//等待费(元)
        Double num8 = jsonObject.getDouble("num8");//远途费(公里)
        Double num9 = jsonObject.getDouble("num9");//远途费(公里)
        Double num10 = jsonObject.getDouble("num10");//远途费(元)
        Double num11 = jsonObject.getDouble("num11");//远途费(公里)
        Double num12 = jsonObject.getDouble("num12");//远途费(公里)
        Double num13 = jsonObject.getDouble("num13");//远途费(元)
        Double num14 = jsonObject.getDouble("num14");//远途费(公里)
        Double num15 = jsonObject.getDouble("num15");//远途费(元)
        String num16 = jsonObject.getString("num16");//夜间费(开始时间)
        Double num17 = jsonObject.getDouble("num17");//夜间费(元)
        Double num18 = jsonObject.getDouble("num18");//夜间费(元)
        Double num19 = jsonObject.getDouble("num19");//夜间费(元)
        Double num20 = jsonObject.getDouble("num20");//夜间费(元)
        Double num21 = jsonObject.getDouble("num21");//夜间费(元)
        Double num22 = jsonObject.getDouble("num22");//夜间费(元)
        String num23 = jsonObject.getString("num23");//高峰费(开始时间)
        String num24 = jsonObject.getString("num24");//高峰费(开始时间)
        Double num25 = jsonObject.getDouble("num25");//高峰费(元)
        Double num26 = jsonObject.getDouble("num26");//高峰费(元)
        Double num27 = jsonObject.getDouble("num27");//高峰费(元)
        Double num28 = jsonObject.getDouble("num28");//高峰费(元)
        Double num29 = jsonObject.getDouble("num29");//高峰费(元)
        Double num30 = jsonObject.getDouble("num30");//高峰费(元)
 
        Date date = new Date();
        double d = (null == orderPrivateCar.getMileage() ? 0D : orderPrivateCar.getMileage()) / 1000;//实际公里
        double t = ((orderPrivateCar.getEndServiceTime().getTime() - orderPrivateCar.getStartServiceTime().getTime()) / 60000) + 1;//实际时间(不满一分钟按一分钟算)
        double w = ((orderPrivateCar.getStartServiceTime().getTime() - orderPrivateCar.getArriveTime().getTime()) / 60000) + 1;//等待分钟(不满一分钟按一分钟算)
        double d1 = (d - num2) < 0 ? 0 : d - num2;//超出起步里程的公里
        double t1 = (t - num3) < 0 ? 0 : new BigDecimal(t - num3).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超过起步分钟数的时间
        double w1 = (w - num6) < 0 ? 0 : new BigDecimal(w - num6).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超出等待时间的时间
        double yt1 = 0;//远途1段
        double yt2 = 0;//远途2段
        double yt3 = 0;//远途3段
 
 
        //夜间服务处理逻辑
        Calendar s = Calendar.getInstance();
        s.setTime(date);
        s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[0].split(":")[0]));
        s.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[0].split(":")[1]));
 
        Calendar e = Calendar.getInstance();
        e.setTime(date);
        e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[1].split(":")[0]));
        e.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[1].split(":")[1]));
 
        if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){
            if(d > num8.doubleValue() && d <= num9.doubleValue()){
                yt1 = num20 * (d - num8);
            }
            if(d > num9.doubleValue()){
                yt1 = num20 * (num9 - num8);
            }
            if(d > num11.doubleValue() || d <= num12.doubleValue()){
                yt2 = num21 * (d - num11);
            }
            if(d > num12.doubleValue()){
                yt2 = num21 * (num12 - num11);
            }
            if(d > num14.doubleValue()){
                yt3 = num22 * (d - num14);
            }
            amount1 = num17 + (d1 * num18) + (t1 * num19) + (w1 * num7) + yt1 + yt2 + yt3;
            map.put("amount1", amount1);
        }
 
 
        //高峰时段处理逻辑
        Calendar s1 = Calendar.getInstance();
        s1.setTime(date);
        s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[0].split(":")[0]));
        s1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[0].split(":")[1]));
 
        Calendar e1 = Calendar.getInstance();
        e1.setTime(date);
        e1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[1].split(":")[0]));
        e1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[1].split(":")[1]));
 
        Calendar s2 = Calendar.getInstance();
        s2.setTime(date);
        s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[0].split(":")[0]));
        s2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[0].split(":")[1]));
 
        Calendar e2 = Calendar.getInstance();
        e2.setTime(date);
        e2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[1].split(":")[0]));
        e2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[1].split(":")[1]));
 
        if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis()) || (date.getTime() > s2.getTimeInMillis() && date.getTime() < e2.getTimeInMillis())){
            if(d > num8.doubleValue() && d <= num9.doubleValue()){
                yt1 = num28 * (d - num8);
            }
            if(d > num9.doubleValue()){
                yt1 = num28 * (num9 - num8);
            }
            if(d > num11.doubleValue() && d <= num12.doubleValue()){
                yt2 = num29 * (d - num11);
            }
            if(d > num12.doubleValue()){
                yt2 = num29 * (num12 - num11);
            }
            if(d > num14.doubleValue()){
                yt3 = num30 * (d - num14);
            }
            amount2 = num25 + (d1 * num26) + (t1 * num27) + (w1 * num7) + yt1 + yt2 + yt3;
            map.put("amount2", amount2);
        }
 
        //其他时间段的计算
        if(d > num8.doubleValue() && d <= num9.doubleValue()){
            yt1 = num10 * (d - num8);
        }
        if(d > num9.doubleValue()){
            yt1 = num10 * (num9 - num8);
        }
        if(d > num11.doubleValue() && d <= num12.doubleValue()){
            yt2 = num13 * (d - num11);
        }
        if(d > num12.doubleValue()){
            yt2 = num13 * (num12 - num11);
        }
        if(d > num14.doubleValue()){
            yt3 = num15 * (d - num14);
        }
        amount3 = num1 + (d1 * num4) + (t1 * num5) + (w1 * num7) + yt1 + yt2 + yt3;
        map.put("amount3", amount3);
        return map;
    }
 
}