无关风月
2024-09-07 531c94e27fd3dc2abe8ad72485f66e9e141a0bae
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
package com.ruoyi.integration.barrierGate.server;
 
import com.ruoyi.account.api.feignClient.AppUserCarClient;
import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
import com.ruoyi.chargingPile.api.feignClient.ParkingRecordClient;
import com.ruoyi.chargingPile.api.model.TParkingLot;
import com.ruoyi.chargingPile.api.model.TParkingRecord;
import com.ruoyi.chargingPile.api.vo.GetParkingRecord;
import com.ruoyi.integration.barrierGate.model.CloudParkingOrder;
import com.ruoyi.integration.barrierGate.model.CloudParkingSpace;
import com.ruoyi.integration.barrierGate.model.OfflineParkingOrder;
import com.ruoyi.integration.barrierGate.model.OfflineParkingSpace;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
 
/**
 * @author zhibing.pu
 * @Date 2024/9/5 16:15
 */
@Service
public class ParkingOrderService {
    
    @Resource
    private ParkingRecordClient parkingRecordClient;
    
    @Resource
    private AppUserCarClient appUserCarClient;
    
    @Resource
    private ParkingLotClient parkingLotClient;
    
    
    
    
    
    /**
     * 云停车入场记录
     * @param order
     */
    public void cloudParkingInOrder(CloudParkingOrder order) {
        TParkingRecord parkingRecord = new TParkingRecord();
        parkingRecord.setLicensePlate(order.getPlate());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String code = "TC" + Math.random() * 1000 + sdf.format(new Date());
        parkingRecord.setCode(code);
        parkingRecord.setVehicleColor(order.getPlateColor());
        TParkingLot data = parkingLotClient.getParkingLotByAppKey(order.getAppkey()).getData();
        parkingRecord.setParkingLotId(data.getId());
        parkingRecord.setInParkingTime(LocalDateTime.parse(order.getEnterDateTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        parkingRecord.setStatus(1);
        parkingRecord.setCreateTime(LocalDateTime.now());
        parkingRecord.setSerialnumber(order.getId());
        parkingRecordClient.addParkingRecord(parkingRecord);
    }
    
    
    /**
     * 云停车出场记录
     * @param order
     */
    public void cloudParkingOutOrder(CloudParkingOrder order) {
        GetParkingRecord query = new GetParkingRecord();
        query.setLicensePlate(order.getPlate());
        query.setStatus(1);
        TParkingRecord parkingRecord = parkingRecordClient.getParkingRecord(query).getData();
        parkingRecord.setOutParkingTime(LocalDateTime.parse(order.getLeaveDateTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        parkingRecord.setParkingDuration(Integer.valueOf(order.getLongTime()));
        parkingRecord.setOrderAmount(new BigDecimal(order.getReceivable()));
        BigDecimal payment = new BigDecimal(order.getPayment());
        parkingRecord.setStatus(BigDecimal.ZERO.compareTo(payment) == 0 ? 2 : 3);
        parkingRecordClient.updateParkingRecord(parkingRecord);
    }
    
    
    /**
     * 云停车实时车位
     * @param parkingSpace
     */
    public void cloudParkingSpace(CloudParkingSpace parkingSpace){
    
    }
    
    
    /**
     * 线下停车场入场记录
     * @param order
     */
    public void offlineParkingInOrder(OfflineParkingOrder order) {
        TParkingRecord parkingRecord = new TParkingRecord();
        parkingRecord.setLicensePlate(order.getPlatenumber());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String code = "TC" + Math.random() * 1000 + sdf.format(new Date());
        parkingRecord.setCode(code);
        parkingRecord.setVehicleColor(order.getPlatecolor());
        TParkingLot data = parkingLotClient.getParkingLotByAppKey(order.getAppkey()).getData();
        parkingRecord.setParkingLotId(data.getId());
        parkingRecord.setInParkingTime(LocalDateTime.parse(order.getEntertime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        parkingRecord.setStatus(1);
        parkingRecord.setCreateTime(LocalDateTime.now());
        parkingRecord.setSerialnumber(order.getId());
        parkingRecordClient.addParkingRecord(parkingRecord);
    }
    
    
    /**
     * 线下停车场出场记录
     * @param order
     */
    public void offlineParkingOutOrder(OfflineParkingOrder order) {
        GetParkingRecord query = new GetParkingRecord();
        query.setLicensePlate(order.getPlatenumber());
        query.setStatus(1);
        TParkingRecord parkingRecord = parkingRecordClient.getParkingRecord(query).getData();
        parkingRecord.setOutParkingTime(LocalDateTime.parse(order.getLeavetime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        parkingRecord.setParkingDuration(Integer.valueOf(order.getLongTime()));
        parkingRecord.setOrderAmount(new BigDecimal(order.getMoney()));
        parkingRecordClient.updateParkingRecord(parkingRecord);
    }
    
    
    /**
     * 线下停车场实时车位
     * @param parkingSpace
     */
    public void offlineParkingSpace(OfflineParkingSpace parkingSpace){
    
    }
}