Commit 3a0dd0c3a2e092e471a1e9347167b5555dfd8c92

Authored by 娄高锋
1 parent f58c1bbe

充电量接口,通过车牌号查找车辆自编号。

src/main/java/com/bsth/entity/JdlReception.java
1   -package com.bsth.entity;
2   -
3   -import java.util.Date;
4   -
5   -import javax.persistence.Entity;
6   -import javax.persistence.GeneratedValue;
7   -import javax.persistence.GenerationType;
8   -import javax.persistence.Id;
9   -import javax.persistence.Table;
10   -
11   -import org.springframework.format.annotation.DateTimeFormat;
12   -
13   -/**
14   ---------------------------------------------------------
15   - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
16   - `station_name` varchar(255) DEFAULT NULL COMMENT '站点名称',
17   - `connector_id` varchar(255) DEFAULT NULL COMMENT '枪编号',
18   - `order_no` varchar(255) DEFAULT NULL COMMENT '订单编号',
19   - `start_time` varchar(255) DEFAULT NULL COMMENT '充电开始时间',
20   - `end_time` varchar(255) DEFAULT NULL COMMENT '充电结束时间',
21   - `start_soc` double(11,2) DEFAULT NULL COMMENT '开始 SOC(%)',
22   - `end_soc` double(11,2) DEFAULT NULL COMMENT '结束 SOC(%)',
23   - `stop_reason` varchar(255) DEFAULT NULL COMMENT '终止原因',
24   - `charge_capacity` double(11,3) DEFAULT NULL COMMENT '充电量,单位:度',
25   - `electric_charge` double(11,2) DEFAULT NULL COMMENT '电费,单位:元',
26   - `service_charge` double(11,2) DEFAULT NULL COMMENT '服务费,单位:元',
27   - `total_amount` double(11,2) DEFAULT NULL COMMENT '总费用,单位:元',
28   - `vin_code` varchar(255) DEFAULT NULL COMMENT '卡号',
29   - `card_no` varchar(255) DEFAULT NULL COMMENT 'VIN,车架号',
30   - `car_code` varchar(255) DEFAULT NULL COMMENT '车牌号',
31   - `date_str` varchar(255) DEFAULT NULL COMMENT '营运日期',
32   - `origin` int(2) NOT NULL DEFAULT '0' COMMENT '数据源(0:接口获取;1:导入)',
33   - `sum_time` bigint(11) DEFAULT NULL COMMENT '总计充电时间(分钟)',
34   - `create_by` varchar(255) DEFAULT NULL COMMENT '创建人',
35   - `create_date` datetime DEFAULT NULL COMMENT '创建时间',
36   - `update_by` varchar(255) DEFAULT NULL COMMENT '修改人',
37   - `update_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
38   -*/
39   -@Entity
40   -@Table(name = "bsth_c_jdl_reception")
41   -public class JdlReception {
42   - @Id
43   - @GeneratedValue(strategy = GenerationType.IDENTITY)
44   - private Long id;
45   - private String stationName;
46   - private String connectorId;
47   - private String orderNo;
48   - private String startTime;
49   - private String endTime;
50   - private Double startSoc;
51   - private Double endSoc;
52   - private String stopReason;
53   - private Double chargeCapacity;
54   - private Double electricCharge;
55   - private Double serviceCharge;
56   - private Double totalAmount;
57   - private String vinCode;
58   - private String cardNo;
59   - private String carCode;
60   - private String dateStr;
61   - private Integer origin;
62   - private Integer sumTime;
63   - private String createBy;
64   - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
65   - private Date createDate;
66   - private String updateBy;
67   - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
68   - private Date updateDate;
69   -
70   -
71   - public Long getId() {
72   - return id;
73   - }
74   - public void setId(Long id) {
75   - this.id = id;
76   - }
77   - public String getStationName() {
78   - return stationName;
79   - }
80   - public void setStationName(String stationName) {
81   - this.stationName = stationName;
82   - }
83   - public String getConnectorId() {
84   - return connectorId;
85   - }
86   - public void setConnectorId(String connectorId) {
87   - this.connectorId = connectorId;
88   - }
89   - public String getOrderNo() {
90   - return orderNo;
91   - }
92   - public void setOrderNo(String orderNo) {
93   - this.orderNo = orderNo;
94   - }
95   - public String getStartTime() {
96   - return startTime;
97   - }
98   - public void setStartTime(String startTime) {
99   - this.startTime = startTime;
100   - }
101   - public String getEndTime() {
102   - return endTime;
103   - }
104   - public void setEndTime(String endTime) {
105   - this.endTime = endTime;
106   - }
107   - public Double getStartSoc() {
108   - return startSoc;
109   - }
110   - public void setStartSoc(Double startSoc) {
111   - this.startSoc = startSoc;
112   - }
113   - public Double getEndSoc() {
114   - return endSoc;
115   - }
116   - public void setEndSoc(Double endSoc) {
117   - this.endSoc = endSoc;
118   - }
119   - public String getStopReason() {
120   - return stopReason;
121   - }
122   - public void setStopReason(String stopReason) {
123   - this.stopReason = stopReason;
124   - }
125   - public Double getChargeCapacity() {
126   - return chargeCapacity;
127   - }
128   - public void setChargeCapacity(Double chargeCapacity) {
129   - this.chargeCapacity = chargeCapacity;
130   - }
131   - public Double getElectricCharge() {
132   - return electricCharge;
133   - }
134   - public void setElectricCharge(Double electricCharge) {
135   - this.electricCharge = electricCharge;
136   - }
137   - public Double getServiceCharge() {
138   - return serviceCharge;
139   - }
140   - public void setServiceCharge(Double serviceCharge) {
141   - this.serviceCharge = serviceCharge;
142   - }
143   - public Double getTotalAmount() {
144   - return totalAmount;
145   - }
146   - public void setTotalAmount(Double totalAmount) {
147   - this.totalAmount = totalAmount;
148   - }
149   - public String getVinCode() {
150   - return vinCode;
151   - }
152   - public void setVinCode(String vinCode) {
153   - this.vinCode = vinCode;
154   - }
155   - public String getCardNo() {
156   - return cardNo;
157   - }
158   - public void setCardNo(String cardNo) {
159   - this.cardNo = cardNo;
160   - }
161   - public String getCarCode() {
162   - return carCode;
163   - }
164   - public void setCarCode(String carCode) {
165   - this.carCode = carCode;
166   - }
167   - public String getDateStr() {
168   - return dateStr;
169   - }
170   - public void setDateStr(String dateStr) {
171   - this.dateStr = dateStr;
172   - }
173   - public Integer getOrigin() {
174   - return origin;
175   - }
176   - public void setOrigin(Integer origin) {
177   - this.origin = origin;
178   - }
179   - public Integer getSumTime() {
180   - return sumTime;
181   - }
182   - public void setSumTime(Integer sumTime) {
183   - this.sumTime = sumTime;
184   - }
185   - public String getCreateBy() {
186   - return createBy;
187   - }
188   - public void setCreateBy(String createBy) {
189   - this.createBy = createBy;
190   - }
191   - public Date getCreateDate() {
192   - return createDate;
193   - }
194   - public void setCreateDate(Date createDate) {
195   - this.createDate = createDate;
196   - }
197   - public String getUpdateBy() {
198   - return updateBy;
199   - }
200   - public void setUpdateBy(String updateBy) {
201   - this.updateBy = updateBy;
202   - }
203   - public Date getUpdateDate() {
204   - return updateDate;
205   - }
206   - public void setUpdateDate(Date updateDate) {
207   - this.updateDate = updateDate;
208   - }
209   -
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.Date;
  4 +
  5 +import javax.persistence.Entity;
  6 +import javax.persistence.GeneratedValue;
  7 +import javax.persistence.GenerationType;
  8 +import javax.persistence.Id;
  9 +import javax.persistence.Table;
  10 +
  11 +import org.springframework.format.annotation.DateTimeFormat;
  12 +
  13 +/**
  14 +--------------------------------------------------------
  15 + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  16 + `station_name` varchar(255) DEFAULT NULL COMMENT '站点名称',
  17 + `connector_id` varchar(255) DEFAULT NULL COMMENT '枪编号',
  18 + `order_no` varchar(255) DEFAULT NULL COMMENT '订单编号',
  19 + `start_time` varchar(255) DEFAULT NULL COMMENT '充电开始时间',
  20 + `end_time` varchar(255) DEFAULT NULL COMMENT '充电结束时间',
  21 + `start_soc` double(11,2) DEFAULT NULL COMMENT '开始 SOC(%)',
  22 + `end_soc` double(11,2) DEFAULT NULL COMMENT '结束 SOC(%)',
  23 + `stop_reason` varchar(255) DEFAULT NULL COMMENT '终止原因',
  24 + `charge_capacity` double(11,3) DEFAULT NULL COMMENT '充电量,单位:度',
  25 + `electric_charge` double(11,2) DEFAULT NULL COMMENT '电费,单位:元',
  26 + `service_charge` double(11,2) DEFAULT NULL COMMENT '服务费,单位:元',
  27 + `total_amount` double(11,2) DEFAULT NULL COMMENT '总费用,单位:元',
  28 + `vin_code` varchar(255) DEFAULT NULL COMMENT '卡号',
  29 + `card_no` varchar(255) DEFAULT NULL COMMENT 'VIN,车架号',
  30 + `car_code` varchar(255) DEFAULT NULL COMMENT '自编号',
  31 + `car_plate` varchar(255) DEFAULT NULL COMMENT '牌照号',
  32 + `date_str` varchar(255) DEFAULT NULL COMMENT '营运日期',
  33 + `origin` int(2) NOT NULL DEFAULT '0' COMMENT '数据源(0:接口获取;1:导入)',
  34 + `sum_time` bigint(11) DEFAULT NULL COMMENT '总计充电时间(分钟)',
  35 + `create_by` varchar(255) DEFAULT NULL COMMENT '创建人',
  36 + `create_date` datetime DEFAULT NULL COMMENT '创建时间',
  37 + `update_by` varchar(255) DEFAULT NULL COMMENT '修改人',
  38 + `update_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  39 +*/
  40 +@Entity
  41 +@Table(name = "bsth_c_jdl_reception")
  42 +public class JdlReception {
  43 + @Id
  44 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  45 + private Long id;
  46 + private String stationName;
  47 + private String connectorId;
  48 + private String orderNo;
  49 + private String startTime;
  50 + private String endTime;
  51 + private Double startSoc;
  52 + private Double endSoc;
  53 + private String stopReason;
  54 + private Double chargeCapacity;
  55 + private Double electricCharge;
  56 + private Double serviceCharge;
  57 + private Double totalAmount;
  58 + private String vinCode;
  59 + private String cardNo;
  60 + private String carCode;
  61 + private String carPlate;
  62 + private String dateStr;
  63 + private Integer origin;
  64 + private Integer sumTime;
  65 + private String createBy;
  66 + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
  67 + private Date createDate;
  68 + private String updateBy;
  69 + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
  70 + private Date updateDate;
  71 +
  72 +
  73 + public Long getId() {
  74 + return id;
  75 + }
  76 + public void setId(Long id) {
  77 + this.id = id;
  78 + }
  79 + public String getStationName() {
  80 + return stationName;
  81 + }
  82 + public void setStationName(String stationName) {
  83 + this.stationName = stationName;
  84 + }
  85 + public String getConnectorId() {
  86 + return connectorId;
  87 + }
  88 + public void setConnectorId(String connectorId) {
  89 + this.connectorId = connectorId;
  90 + }
  91 + public String getOrderNo() {
  92 + return orderNo;
  93 + }
  94 + public void setOrderNo(String orderNo) {
  95 + this.orderNo = orderNo;
  96 + }
  97 + public String getStartTime() {
  98 + return startTime;
  99 + }
  100 + public void setStartTime(String startTime) {
  101 + this.startTime = startTime;
  102 + }
  103 + public String getEndTime() {
  104 + return endTime;
  105 + }
  106 + public void setEndTime(String endTime) {
  107 + this.endTime = endTime;
  108 + }
  109 + public Double getStartSoc() {
  110 + return startSoc;
  111 + }
  112 + public void setStartSoc(Double startSoc) {
  113 + this.startSoc = startSoc;
  114 + }
  115 + public Double getEndSoc() {
  116 + return endSoc;
  117 + }
  118 + public void setEndSoc(Double endSoc) {
  119 + this.endSoc = endSoc;
  120 + }
  121 + public String getStopReason() {
  122 + return stopReason;
  123 + }
  124 + public void setStopReason(String stopReason) {
  125 + this.stopReason = stopReason;
  126 + }
  127 + public Double getChargeCapacity() {
  128 + return chargeCapacity;
  129 + }
  130 + public void setChargeCapacity(Double chargeCapacity) {
  131 + this.chargeCapacity = chargeCapacity;
  132 + }
  133 + public Double getElectricCharge() {
  134 + return electricCharge;
  135 + }
  136 + public void setElectricCharge(Double electricCharge) {
  137 + this.electricCharge = electricCharge;
  138 + }
  139 + public Double getServiceCharge() {
  140 + return serviceCharge;
  141 + }
  142 + public void setServiceCharge(Double serviceCharge) {
  143 + this.serviceCharge = serviceCharge;
  144 + }
  145 + public Double getTotalAmount() {
  146 + return totalAmount;
  147 + }
  148 + public void setTotalAmount(Double totalAmount) {
  149 + this.totalAmount = totalAmount;
  150 + }
  151 + public String getVinCode() {
  152 + return vinCode;
  153 + }
  154 + public void setVinCode(String vinCode) {
  155 + this.vinCode = vinCode;
  156 + }
  157 + public String getCardNo() {
  158 + return cardNo;
  159 + }
  160 + public void setCardNo(String cardNo) {
  161 + this.cardNo = cardNo;
  162 + }
  163 + public String getCarCode() {
  164 + return carCode;
  165 + }
  166 + public void setCarCode(String carCode) {
  167 + this.carCode = carCode;
  168 + }
  169 + public String getCarPlate() {
  170 + return carPlate;
  171 + }
  172 + public void setCarPlate(String carPlate) {
  173 + this.carPlate = carPlate;
  174 + }
  175 + public String getDateStr() {
  176 + return dateStr;
  177 + }
  178 + public void setDateStr(String dateStr) {
  179 + this.dateStr = dateStr;
  180 + }
  181 + public Integer getOrigin() {
  182 + return origin;
  183 + }
  184 + public void setOrigin(Integer origin) {
  185 + this.origin = origin;
  186 + }
  187 + public Integer getSumTime() {
  188 + return sumTime;
  189 + }
  190 + public void setSumTime(Integer sumTime) {
  191 + this.sumTime = sumTime;
  192 + }
  193 + public String getCreateBy() {
  194 + return createBy;
  195 + }
  196 + public void setCreateBy(String createBy) {
  197 + this.createBy = createBy;
  198 + }
  199 + public Date getCreateDate() {
  200 + return createDate;
  201 + }
  202 + public void setCreateDate(Date createDate) {
  203 + this.createDate = createDate;
  204 + }
  205 + public String getUpdateBy() {
  206 + return updateBy;
  207 + }
  208 + public void setUpdateBy(String updateBy) {
  209 + this.updateBy = updateBy;
  210 + }
  211 + public Date getUpdateDate() {
  212 + return updateDate;
  213 + }
  214 + public void setUpdateDate(Date updateDate) {
  215 + this.updateDate = updateDate;
  216 + }
  217 +
210 218 }
211 219 \ No newline at end of file
... ...
src/main/java/com/bsth/repository/JdlReceptionRepository.java
1   -package com.bsth.repository;
2   -
3   -import org.springframework.data.repository.PagingAndSortingRepository;
4   -import org.springframework.stereotype.Repository;
5   -
6   -import com.bsth.entity.JdlReception;
7   -
8   -@Repository
9   -public interface JdlReceptionRepository extends PagingAndSortingRepository<JdlReception, Integer>{
10   -
  1 +package com.bsth.repository;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.springframework.data.jpa.repository.Query;
  6 +import org.springframework.data.repository.PagingAndSortingRepository;
  7 +import org.springframework.stereotype.Repository;
  8 +
  9 +import com.bsth.entity.JdlReception;
  10 +
  11 +@Repository
  12 +public interface JdlReceptionRepository extends PagingAndSortingRepository<JdlReception, Integer>{
  13 +
  14 + @Query(value="select c.inside_code, c.car_plate from bsth_c_cars c ",nativeQuery=true)
  15 + List<Object[]> queryAllCar();
  16 +
  17 + @Query(value="select c.inside_code, c.car_plate from bsth_c_cars c where REPLACE(c.car_plate, '-', '') = ?1 ",nativeQuery=true)
  18 + List<Object[]> queryCarByPlate(String carPlate);
  19 +
11 20 }
12 21 \ No newline at end of file
... ...
src/main/java/com/bsth/server_rs/electric/ElectricService.java
... ... @@ -77,19 +77,20 @@ public class ElectricService {
77 77 JdlReception jdlReception = new JdlReception();
78 78 jdlReception.setStationName(body.getString("stationName"));
79 79 jdlReception.setConnectorId(body.getString("connectorId"));
80   - jdlReception.setOrderNo(body.getString("orderNo"));
  80 + jdlReception.setOrderNo(body.getString("startChargeSeq"));
81 81 jdlReception.setStartTime(startTime);
82 82 jdlReception.setEndTime(endTime);
83 83 jdlReception.setStartSoc(body.getDouble("startSoc"));
84 84 jdlReception.setEndSoc(body.getDouble("endSoc"));
85 85 jdlReception.setStopReason(body.getString("stopReason"));
86   - jdlReception.setChargeCapacity(body.getDouble("chargeCapacity"));
87   - jdlReception.setElectricCharge(body.getDouble("electricCharge"));
88   - jdlReception.setServiceCharge(body.getDouble("serviceCharge"));
89   - jdlReception.setTotalAmount(body.getDouble("totalAmount"));
  86 + jdlReception.setChargeCapacity(body.getDouble("totalPower"));
  87 + jdlReception.setElectricCharge(body.getDouble("totalElecMoney"));
  88 + jdlReception.setServiceCharge(body.getDouble("totalSeviceMoney"));
  89 + jdlReception.setTotalAmount(body.getDouble("totalMoney"));
90 90 jdlReception.setVinCode(body.getString("vinCode"));
91 91 jdlReception.setCardNo(body.getString("cardNo"));
92 92 jdlReception.setCarCode(body.getString("carCode"));
  93 + jdlReception.setCarPlate(body.getString("carPlate"));
93 94 jdlReception.setOrigin(0);
94 95 jdlReception.setCreateBy("接口接入");
95 96 jdlReception.setCreateDate(new Date());
... ... @@ -101,6 +102,15 @@ public class ElectricService {
101 102 jdlReception.setDateStr(startDate);
102 103 jdlReception.setSumTime(Integer.valueOf(((endTime_Date.getTime() - startTime_Date.getTime()) / 60000)+""));
103 104  
  105 + if((jdlReception.getCarCode() == null || jdlReception.getCarCode().trim().length() == 0)
  106 + && jdlReception.getCarPlate() != null && jdlReception.getCarPlate().trim().length() > 0){
  107 + List<Object[]> queryCarByPlate = jdlReceptionRepository.queryCarByPlate(jdlReception.getCarPlate().replaceAll("-", ""));
  108 + if(queryCarByPlate != null && queryCarByPlate.size() > 0){
  109 + Object[] objects = queryCarByPlate.get(0);
  110 + jdlReception.setCarCode(objects[0].toString());
  111 + }
  112 + }
  113 +
104 114 jdlReceptionRepository.save(jdlReception);
105 115  
106 116 resMap.put("Status", 0);
... ...