evcs cd almost done
This commit is contained in:
parent
d48d2dae4d
commit
c85c0636fd
93
evcs-modules/evcs-common/pom.xml
Normal file
93
evcs-modules/evcs-common/pom.xml
Normal file
@ -0,0 +1,93 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.xhpc</groupId>
|
||||
<artifactId>evcs-modules</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>evcs-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-commons</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>5.3.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>5.3.8</version>
|
||||
</dependency>
|
||||
<!-- Used to support JSONPath usage in testing. -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.9.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.12.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.12.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.76</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Allow for automatic restarts when classpath contents change. -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jpa</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>xhpc-common</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,69 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "ET_AUTH_SEC_TOKEN")
|
||||
public class AuthSecretToken {
|
||||
|
||||
public final static String SECRET_TOKEN_TYPE_IN = "IN";
|
||||
public final static String SECRET_TOKEN_TYPE_OUT = "OUT";
|
||||
|
||||
@Id
|
||||
@GeneratedValue()
|
||||
private Integer id;
|
||||
|
||||
private String operatorId;
|
||||
|
||||
private String operatorId3irdpty;
|
||||
|
||||
private String urlPrefix;
|
||||
|
||||
private String secretTokenType;
|
||||
|
||||
private String operatorSecret;
|
||||
|
||||
private String sigSecret;
|
||||
|
||||
private String dataSecret;
|
||||
|
||||
private String dataSecretIV;
|
||||
|
||||
private String token;
|
||||
|
||||
private Date tokenExpiry;
|
||||
|
||||
private boolean encrypt;
|
||||
|
||||
private Long lastPushOrder;
|
||||
|
||||
public AuthSecretToken() {
|
||||
|
||||
}
|
||||
|
||||
public AuthSecretToken(String operatorId, String secretTokenType) {
|
||||
|
||||
this.operatorId = operatorId;
|
||||
this.secretTokenType = secretTokenType;
|
||||
}
|
||||
|
||||
public Long getLastPushOrder() {
|
||||
|
||||
return lastPushOrder == null ? 0 : lastPushOrder;
|
||||
}
|
||||
|
||||
public void setLastPushOrder(Long lastPushOrder) {
|
||||
|
||||
this.lastPushOrder = lastPushOrder;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.xhpc.evcs.dto.ChargeDetails;
|
||||
import com.xhpc.evcs.utils.DateUtil;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
//@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"ConnectorID",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"ChargeModel",
|
||||
"TotalPower",
|
||||
"TotalElecMoney",
|
||||
"TotalSeviceMoney",
|
||||
"TotalMoney",
|
||||
"StopReason",
|
||||
"SumPeriod",
|
||||
"ChargeDetails",
|
||||
"UserName",
|
||||
"StationID",
|
||||
"EquipmentID",
|
||||
"ConnectorPower",
|
||||
"ChargeLast",
|
||||
"MeterValueStart",
|
||||
"MeterValueEnd"
|
||||
})
|
||||
@Data
|
||||
public class CDChargeOrderInfo4Bonus {
|
||||
|
||||
@Id
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorID;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("ChargeModel")
|
||||
private Integer chargeModel;
|
||||
@JsonProperty("ChargeLast")
|
||||
private Integer chargeLast;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonProperty("UserName")
|
||||
private String userName;
|
||||
@JsonProperty("StationID")
|
||||
private String stationId;
|
||||
@JsonProperty("EquipmentID")
|
||||
private String equipmentId;
|
||||
@JsonProperty("TotalPower")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalPower = 0.0;
|
||||
@JsonProperty("MeterValueStart")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double meterValueStart = 0.0;
|
||||
@JsonProperty("MeterValueEnd")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double meterValueEnd = 0.0;
|
||||
@JsonProperty("TotalElecMoney")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalElecMoney = 0.0;
|
||||
@JsonProperty("TotalSeviceMoney")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalSeviceMoney = 0.0;
|
||||
@JsonProperty("ConnectorPower")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double connectorPower = 0.0;
|
||||
@JsonProperty("TotalMoney")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalMoney = 0.0;
|
||||
@JsonProperty("StopReason")
|
||||
private Integer stopReason;
|
||||
@JsonProperty("SumPeriod")
|
||||
private Integer sumPeriod;
|
||||
@JsonProperty("ChargeDetails")
|
||||
private ChargeDetails[] chargeDetails;
|
||||
|
||||
public CDChargeOrderInfo4Bonus(XhpcHistoryOrder xhpcHistoryOrder, EtOrderMapping etOrderMapping) {
|
||||
|
||||
this.startChargeSeq = etOrderMapping.getEvcsOrderNo();
|
||||
this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16);
|
||||
this.endTime = DateUtil.date2String(xhpcHistoryOrder.getCreateTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
||||
this.startTime = DateUtil.date2String(xhpcHistoryOrder.getStartTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
||||
this.chargeModel = xhpcHistoryOrder.getChargeModelEvcs();
|
||||
this.totalPower = xhpcHistoryOrder.getTotalPower();
|
||||
this.totalElecMoney = xhpcHistoryOrder.getTotalPrice().doubleValue();
|
||||
this.totalSeviceMoney = xhpcHistoryOrder.getServicePriceTotal().doubleValue();
|
||||
this.totalMoney = xhpcHistoryOrder.getTotalPrice().doubleValue();
|
||||
this.stopReason = xhpcHistoryOrder.getStopReasonEvcs();
|
||||
this.sumPeriod = xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList().size();
|
||||
this.chargeDetails = translate(xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList());
|
||||
this.userName = xhpcHistoryOrder.getUserNameEvcs();
|
||||
this.stationId = xhpcHistoryOrder.getChargingStationId().toString();
|
||||
this.equipmentId = xhpcHistoryOrder.getSerialNumber().substring(0, 14);
|
||||
this.connectorPower = xhpcHistoryOrder.getConnectorPowerEvcs();
|
||||
Date starttime = xhpcHistoryOrder.getStartTime();
|
||||
Date endtime = xhpcHistoryOrder.getCreateTime();
|
||||
int cl = 0;
|
||||
if (starttime != null && endtime != null) {
|
||||
cl = Math.toIntExact((endtime.getTime() - starttime.getTime()) / 1000);
|
||||
}
|
||||
this.chargeLast = cl;
|
||||
this.meterValueStart = xhpcHistoryOrder.getMeterValueStartEvcs();
|
||||
this.meterValueEnd = xhpcHistoryOrder.getMeterValueEndEvcs();
|
||||
}
|
||||
|
||||
private ChargeDetails[] translate(List<XhpcStatisticsTimeInterval> xhpcStatisticsTimeIntervalList) {
|
||||
|
||||
List<ChargeDetails> details = new LinkedList<>();
|
||||
for (XhpcStatisticsTimeInterval statistics : xhpcStatisticsTimeIntervalList) {
|
||||
details.add(new ChargeDetails(statistics));
|
||||
}
|
||||
ChargeDetails[] a = new ChargeDetails[details.size()];
|
||||
return details.toArray(a);
|
||||
}
|
||||
|
||||
public CDChargeOrderInfo4Bonus() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this)
|
||||
.append("startChargeSeq", startChargeSeq)
|
||||
.append("connectorID", connectorID)
|
||||
.append("startTime", startTime)
|
||||
.append("chargeModel", chargeModel)
|
||||
.append("chargeLast", chargeLast)
|
||||
.append("endTime", endTime)
|
||||
.append("userName", userName)
|
||||
.append("stationId", stationId)
|
||||
.append("equipmentId", equipmentId)
|
||||
.append("totalPower", totalPower)
|
||||
.append("meterValueStart", meterValueStart)
|
||||
.append("meterValueEnd", meterValueEnd)
|
||||
.append("totalElecMoney", totalElecMoney)
|
||||
.append("totalSeviceMoney", totalSeviceMoney)
|
||||
.append("connectorPower", connectorPower)
|
||||
.append("totalMoney", totalMoney)
|
||||
.append("stopReason", stopReason)
|
||||
.append("sumPeriod", sumPeriod)
|
||||
.append("chargeDetails", chargeDetails)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,234 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.xhpc.evcs.dto.ChargeDetails;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"ConnectorID",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"TotalPower",
|
||||
"TotalElecMoney",
|
||||
"TotalSeviceMoney",
|
||||
"TotalMoney",
|
||||
"StopReason",
|
||||
"SumPeriod"
|
||||
})
|
||||
@Entity
|
||||
@Setter
|
||||
@Getter
|
||||
@Table(name = "ET_CHARGE_ORDER_INFO")
|
||||
public class ChargeOrderInfo {
|
||||
|
||||
@Id
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonIgnore
|
||||
private Integer startChargeSeqStat;
|
||||
@JsonIgnore
|
||||
private Integer failReason;
|
||||
@JsonIgnore
|
||||
private String identCode;
|
||||
@JsonIgnore
|
||||
@Column(updatable = false)
|
||||
private String infraOperatorId;
|
||||
@JsonIgnore
|
||||
@Column(updatable = false)
|
||||
private String billerOperatorId;//biller
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorID;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("ChargeModel")
|
||||
private Integer chargeModel;
|
||||
@JsonProperty("Vin")
|
||||
private String vin;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonProperty("TotalPower")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalPower = 0.0;
|
||||
@JsonProperty("TotalElecMoney")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalElecMoney = 0.0;
|
||||
@JsonProperty("TotalSeviceMoney")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalSeviceMoney = 0.0;
|
||||
@JsonProperty("TotalMoney")
|
||||
@Column(columnDefinition = "Decimal(10,2)")
|
||||
private Double totalMoney = 0.0;
|
||||
@JsonProperty("StopReason")
|
||||
private Integer stopReason;
|
||||
@JsonProperty("SumPeriod")
|
||||
private Integer sumPeriod;
|
||||
@JsonProperty("ChargeDetails")
|
||||
private ChargeDetails[] chargeDetails;
|
||||
@JsonIgnore
|
||||
@Transient
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
public ChargeOrderInfo(XhpcHistoryOrder xhpcHistoryOrder) {
|
||||
// this.connectorID = xhpcHistoryOrder.getTerminalId()
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
public ChargeOrderInfo setStartChargeSeqAndReturn(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
return this;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public String getConnectorID() {
|
||||
|
||||
return connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public void setConnectorID(String connectorID) {
|
||||
|
||||
this.connectorID = connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public String getEndTime() {
|
||||
|
||||
return endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public void setEndTime(String endTime) {
|
||||
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public Double getTotalPower() {
|
||||
|
||||
return totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public void setTotalPower(Double totalPower) {
|
||||
|
||||
this.totalPower = totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalElecMoney")
|
||||
public Double getTotalElecMoney() {
|
||||
|
||||
return totalElecMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalElecMoney")
|
||||
public void setTotalElecMoney(Double totalElecMoney) {
|
||||
|
||||
this.totalElecMoney = totalElecMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalSeviceMoney")
|
||||
public Double getTotalSeviceMoney() {
|
||||
|
||||
return totalSeviceMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalSeviceMoney")
|
||||
public void setTotalSeviceMoney(Double totalSeviceMoney) {
|
||||
|
||||
this.totalSeviceMoney = totalSeviceMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public Double getTotalMoney() {
|
||||
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public void setTotalMoney(Double totalMoney) {
|
||||
|
||||
this.totalMoney = totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("StopReason")
|
||||
public Integer getStopReason() {
|
||||
|
||||
return stopReason;
|
||||
}
|
||||
|
||||
@JsonProperty("StopReason")
|
||||
public void setStopReason(Integer stopReason) {
|
||||
|
||||
this.stopReason = stopReason;
|
||||
}
|
||||
|
||||
@JsonProperty("SumPeriod")
|
||||
public Integer getSumPeriod() {
|
||||
|
||||
return sumPeriod;
|
||||
}
|
||||
|
||||
@JsonProperty("SumPeriod")
|
||||
public void setSumPeriod(Integer sumPeriod) {
|
||||
|
||||
this.sumPeriod = sumPeriod;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
@Transient
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
@Transient
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startChargeSeq", startChargeSeq).append("connectorID", connectorID).append(
|
||||
"startTime", startTime).append("endTime", endTime).append("totalPower", totalPower).append("totalElecMoney",
|
||||
totalElecMoney).append("totalSeviceMoney", totalSeviceMoney).append("totalMoney", totalMoney).append(
|
||||
"stopReason", stopReason).append("sumPeriod", sumPeriod).append("additionalProperties",
|
||||
additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(name = "ET_COMMON_OPERATOR_INFO")
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class CommonOperatorInfo {
|
||||
|
||||
@Id
|
||||
@JsonProperty("OperatorID")
|
||||
String operatorId;
|
||||
@JsonProperty("OperatorName")
|
||||
String operatorName;
|
||||
@JsonProperty("OperatorTel1")
|
||||
String operatorTel1;
|
||||
@JsonProperty("OperatorTel2")
|
||||
String operatorTel2;
|
||||
@JsonProperty("OperatorRegAddress")
|
||||
String operatorRegAddress;
|
||||
@JsonProperty("OperatorNote")
|
||||
String operatorNote;
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "ET_COMMON_STATION_INFO")
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class CommonStationInfo {
|
||||
|
||||
@Id
|
||||
@JsonProperty("StationID")
|
||||
String stationId;
|
||||
@JsonProperty("OperatorID")
|
||||
String operatorId;
|
||||
@JsonProperty("EquipmentOwnerID")
|
||||
String equipmentOwnerId;
|
||||
@JsonProperty("StationName")
|
||||
String stationName;
|
||||
@JsonProperty("CountryCode")
|
||||
String countryCode;
|
||||
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@JsonPropertyOrder({
|
||||
"ConnectorID",
|
||||
"Status"
|
||||
})
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name = "ET_CONNECTOR_STATUS_INFO")
|
||||
public class ConnectorStatusInfo {
|
||||
|
||||
final static int OFF_LINE = 0;//离网
|
||||
final static int FREE = 1;//空闲
|
||||
final static int CONNECTED = 2;//占用(未充电)
|
||||
final static int CHARGING = 3;//占用(充电中)
|
||||
final static int BOOKED = 4;//占用(预约锁定)
|
||||
final static int ERROR = 255;//故障
|
||||
|
||||
@Id
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorID;
|
||||
@JsonProperty("OperatorID")
|
||||
private String operatorID;
|
||||
@JsonProperty("Status")
|
||||
private Integer status;
|
||||
@Transient
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this)
|
||||
.append("connectorID", connectorID)
|
||||
.append("operatorID", operatorID)
|
||||
.append("status", status)
|
||||
.append("additionalProperties", additionalProperties)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ConnectorStatusInfo that = (ConnectorStatusInfo) o;
|
||||
return connectorID.equals(that.connectorID) && operatorID.equals(that.operatorID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(connectorID, operatorID);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "et_order_mapping")
|
||||
@Entity
|
||||
public class EtOrderMapping extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "id", nullable = false)
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Column(name = "xh_order_no", nullable = false, length = 50)
|
||||
private String xhOrderNo;
|
||||
|
||||
@Column(name = "evcs_order_no", nullable = false, length = 50)
|
||||
private String evcsOrderNo;
|
||||
|
||||
public String getEvcsOrderNo() {
|
||||
|
||||
return evcsOrderNo;
|
||||
}
|
||||
|
||||
public void setEvcsOrderNo(String evcsOrderNo) {
|
||||
|
||||
this.evcsOrderNo = evcsOrderNo;
|
||||
}
|
||||
|
||||
public String getXhOrderNo() {
|
||||
|
||||
return xhOrderNo;
|
||||
}
|
||||
|
||||
public void setXhOrderNo(String xhOrderNo) {
|
||||
|
||||
this.xhOrderNo = xhOrderNo;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@Entity
|
||||
@Table(name = "ET_OPERATOR_INFO")
|
||||
public class OperatorInfo extends CommonOperatorInfo {
|
||||
|
||||
@JsonIgnore()
|
||||
@JsonProperty("Key")
|
||||
private String opKey;
|
||||
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.xhpc.evcs.dto.EquipmentInfo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StationID",
|
||||
"OperatorID",
|
||||
"EquipmentOwnerID",
|
||||
"StationName",
|
||||
"CountryCode",
|
||||
"AreaCode",
|
||||
"Address",
|
||||
"ServiceTel",
|
||||
"StationType",
|
||||
"StationStatus",
|
||||
"ParkNums",
|
||||
"StationLng",
|
||||
"StationLat",
|
||||
"Construction",
|
||||
"BusineHours",
|
||||
"ElectricityFee",
|
||||
"ServiceFee",
|
||||
"Payment",
|
||||
"SupportOrder",
|
||||
"EquipmentInfos"
|
||||
})
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@Entity
|
||||
@Table(name = "ET_STATION_INFO")
|
||||
public class StationInfo extends CommonStationInfo {
|
||||
|
||||
@Transient
|
||||
@JsonProperty("AreaCode")
|
||||
public String areaCode;
|
||||
@Transient
|
||||
@JsonProperty("Address")
|
||||
public String address;
|
||||
@Transient
|
||||
@JsonProperty("ServiceTel")
|
||||
public String serviceTel;
|
||||
@Transient
|
||||
@JsonProperty("StationType")
|
||||
public Long stationType;
|
||||
@Transient
|
||||
@JsonProperty("StationStatus")
|
||||
public Long stationStatus;
|
||||
@Transient
|
||||
@JsonProperty("ParkNums")
|
||||
public Long parkNums;
|
||||
@Transient
|
||||
@JsonProperty("StationLng")
|
||||
public Double stationLng;
|
||||
@Transient
|
||||
@JsonProperty("StationLat")
|
||||
public Double stationLat;
|
||||
@Transient
|
||||
@JsonProperty("Construction")
|
||||
public Long construction;
|
||||
@Transient
|
||||
@JsonProperty("BusineHours")
|
||||
public String busineHours;
|
||||
@Transient
|
||||
@JsonProperty("ElectricityFee")
|
||||
public String electricityFee;
|
||||
@Transient
|
||||
@JsonProperty("ServiceFee")
|
||||
public String serviceFee;
|
||||
@Transient
|
||||
@JsonProperty("Payment")
|
||||
public String payment;
|
||||
@Transient
|
||||
@JsonProperty("SupportOrder")
|
||||
public Long supportOrder;
|
||||
@Transient
|
||||
@JsonProperty("EquipmentInfos")
|
||||
public List<EquipmentInfo> equipmentInfos = null;
|
||||
@Transient
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("stationID", getStationId()).append("operatorID", getOperatorId()).append(
|
||||
"equipmentOwnerID", getEquipmentOwnerId()).append("stationName", getStationName()).append("countryCode",
|
||||
getCountryCode()).append("areaCode", areaCode).append("address", address).append("serviceTel", serviceTel).append("stationType", stationType).append("stationStatus", stationStatus).append("parkNums", parkNums).append("stationLng", stationLng).append("stationLat", stationLat).append("construction", construction).append("busineHours", busineHours).append("electricityFee", electricityFee).append("serviceFee", serviceFee).append("payment", payment).append("supportOrder", supportOrder).append("equipmentInfos", equipmentInfos).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,364 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "xhpc_charging_pile")
|
||||
@Entity
|
||||
public class XhpcChargingPile extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "charging_pile_id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "charging_station_id")
|
||||
private Long chargingStationId;
|
||||
|
||||
@Column(name = "name", length = 30)
|
||||
private String name;
|
||||
|
||||
@Column(name = "national_standard", length = 50)
|
||||
private String nationalStandard;
|
||||
|
||||
@Column(name = "power")
|
||||
private Double power;
|
||||
|
||||
@Column(name = "auxiliary_power_supply")
|
||||
private Double auxiliaryPowerSupply;
|
||||
|
||||
@Column(name = "input_voltage")
|
||||
private Double inputVoltage;
|
||||
|
||||
@Column(name = "max_voltage")
|
||||
private Double maxVoltage;
|
||||
|
||||
@Column(name = "min_voltage")
|
||||
private Double minVoltage;
|
||||
|
||||
@Column(name = "max_electric_current")
|
||||
private Double maxElectricCurrent;
|
||||
|
||||
@Column(name = "min_electric_current")
|
||||
private Double minElectricCurrent;
|
||||
|
||||
@Column(name = "serial_number", length = 30)
|
||||
private String serialNumber;
|
||||
|
||||
@Column(name = "type")
|
||||
private Integer type;
|
||||
|
||||
@Column(name = "program_version", length = 20)
|
||||
private String programVersion;
|
||||
|
||||
@Column(name = "network_link_type", length = 20)
|
||||
private String networkLinkType;
|
||||
|
||||
@Column(name = "gun_number")
|
||||
private Integer gunNumber;
|
||||
|
||||
@Column(name = "communication_protocol_version", length = 20)
|
||||
private String communicationProtocolVersion;
|
||||
|
||||
@Column(name = "communication_operator", length = 20)
|
||||
private String communicationOperator;
|
||||
|
||||
@Column(name = "sim_card", length = 30)
|
||||
private String simCard;
|
||||
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "del_flag")
|
||||
private Integer delFlag;
|
||||
|
||||
@Column(name = "rate_model_id")
|
||||
private Long rateModelId;
|
||||
|
||||
@Column(name = "brand_model")
|
||||
private String brandModel;
|
||||
|
||||
@Column(name = "production_date", length = 10)
|
||||
private String productionDate;
|
||||
|
||||
@Column(name = "manufacture_name", length = 30)
|
||||
private String manufactureName;
|
||||
|
||||
@Column(name = "connector_type")
|
||||
private Integer connectorType;
|
||||
|
||||
@Column(name = "current")
|
||||
private Integer current;
|
||||
|
||||
public Integer getCurrent() {
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setCurrent(Integer current) {
|
||||
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public Integer getConnectorType() {
|
||||
|
||||
return connectorType;
|
||||
}
|
||||
|
||||
public void setConnectorType(Integer connectorType) {
|
||||
|
||||
this.connectorType = connectorType;
|
||||
}
|
||||
|
||||
public String getManufactureName() {
|
||||
|
||||
return manufactureName;
|
||||
}
|
||||
|
||||
public void setManufactureName(String manufactureName) {
|
||||
|
||||
this.manufactureName = manufactureName;
|
||||
}
|
||||
|
||||
public String getProductionDate() {
|
||||
|
||||
return productionDate;
|
||||
}
|
||||
|
||||
public void setProductionDate(String productionDate) {
|
||||
|
||||
this.productionDate = productionDate;
|
||||
}
|
||||
|
||||
public String getBrandModel() {
|
||||
|
||||
return brandModel;
|
||||
}
|
||||
|
||||
public void setBrandModel(String brandModel) {
|
||||
|
||||
this.brandModel = brandModel;
|
||||
}
|
||||
|
||||
public Long getRateModelId() {
|
||||
|
||||
return rateModelId;
|
||||
}
|
||||
|
||||
public void setRateModelId(Long rateModelId) {
|
||||
|
||||
this.rateModelId = rateModelId;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getSimCard() {
|
||||
|
||||
return simCard;
|
||||
}
|
||||
|
||||
public void setSimCard(String simCard) {
|
||||
|
||||
this.simCard = simCard;
|
||||
}
|
||||
|
||||
public String getCommunicationOperator() {
|
||||
|
||||
return communicationOperator;
|
||||
}
|
||||
|
||||
public void setCommunicationOperator(String communicationOperator) {
|
||||
|
||||
this.communicationOperator = communicationOperator;
|
||||
}
|
||||
|
||||
public String getCommunicationProtocolVersion() {
|
||||
|
||||
return communicationProtocolVersion;
|
||||
}
|
||||
|
||||
public void setCommunicationProtocolVersion(String communicationProtocolVersion) {
|
||||
|
||||
this.communicationProtocolVersion = communicationProtocolVersion;
|
||||
}
|
||||
|
||||
public Integer getGunNumber() {
|
||||
|
||||
return gunNumber;
|
||||
}
|
||||
|
||||
public void setGunNumber(Integer gunNumber) {
|
||||
|
||||
this.gunNumber = gunNumber;
|
||||
}
|
||||
|
||||
public String getNetworkLinkType() {
|
||||
|
||||
return networkLinkType;
|
||||
}
|
||||
|
||||
public void setNetworkLinkType(String networkLinkType) {
|
||||
|
||||
this.networkLinkType = networkLinkType;
|
||||
}
|
||||
|
||||
public String getProgramVersion() {
|
||||
|
||||
return programVersion;
|
||||
}
|
||||
|
||||
public void setProgramVersion(String programVersion) {
|
||||
|
||||
this.programVersion = programVersion;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSerialNumber() {
|
||||
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
public void setSerialNumber(String serialNumber) {
|
||||
|
||||
this.serialNumber = serialNumber;
|
||||
}
|
||||
|
||||
public Double getMinElectricCurrent() {
|
||||
|
||||
return minElectricCurrent;
|
||||
}
|
||||
|
||||
public void setMinElectricCurrent(Double minElectricCurrent) {
|
||||
|
||||
this.minElectricCurrent = minElectricCurrent;
|
||||
}
|
||||
|
||||
public Double getMaxElectricCurrent() {
|
||||
|
||||
return maxElectricCurrent;
|
||||
}
|
||||
|
||||
public void setMaxElectricCurrent(Double maxElectricCurrent) {
|
||||
|
||||
this.maxElectricCurrent = maxElectricCurrent;
|
||||
}
|
||||
|
||||
public Double getMinVoltage() {
|
||||
|
||||
return minVoltage;
|
||||
}
|
||||
|
||||
public void setMinVoltage(Double minVoltage) {
|
||||
|
||||
this.minVoltage = minVoltage;
|
||||
}
|
||||
|
||||
public Double getMaxVoltage() {
|
||||
|
||||
return maxVoltage;
|
||||
}
|
||||
|
||||
public void setMaxVoltage(Double maxVoltage) {
|
||||
|
||||
this.maxVoltage = maxVoltage;
|
||||
}
|
||||
|
||||
public Double getInputVoltage() {
|
||||
|
||||
return inputVoltage;
|
||||
}
|
||||
|
||||
public void setInputVoltage(Double inputVoltage) {
|
||||
|
||||
this.inputVoltage = inputVoltage;
|
||||
}
|
||||
|
||||
public Double getAuxiliaryPowerSupply() {
|
||||
|
||||
return auxiliaryPowerSupply;
|
||||
}
|
||||
|
||||
public void setAuxiliaryPowerSupply(Double auxiliaryPowerSupply) {
|
||||
|
||||
this.auxiliaryPowerSupply = auxiliaryPowerSupply;
|
||||
}
|
||||
|
||||
public Double getPower() {
|
||||
|
||||
return power;
|
||||
}
|
||||
|
||||
public void setPower(Double power) {
|
||||
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public String getNationalStandard() {
|
||||
|
||||
return nationalStandard;
|
||||
}
|
||||
|
||||
public void setNationalStandard(String nationalStandard) {
|
||||
|
||||
this.nationalStandard = nationalStandard;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getChargingStationId() {
|
||||
|
||||
return chargingStationId;
|
||||
}
|
||||
|
||||
public void setChargingStationId(Long chargingStationId) {
|
||||
|
||||
this.chargingStationId = chargingStationId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,316 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "xhpc_charging_station")
|
||||
@Entity
|
||||
public class XhpcChargingStation extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "charging_station_id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "name", length = 30)
|
||||
private String name;
|
||||
|
||||
@Column(name = "operator_id")
|
||||
private Long operatorId;
|
||||
|
||||
@Column(name = "type")
|
||||
private Integer type;
|
||||
|
||||
@Lob
|
||||
@Column(name = "construction_site")
|
||||
private String constructionSite;
|
||||
|
||||
@Lob
|
||||
@Column(name = "service_facilities")
|
||||
private String serviceFacilities;
|
||||
|
||||
@Lob
|
||||
@Column(name = "periphery_facilities")
|
||||
private String peripheryFacilities;
|
||||
|
||||
@Column(name = "area_code")
|
||||
private Integer areaCode;
|
||||
|
||||
@Column(name = "address", length = 50)
|
||||
private String address;
|
||||
|
||||
@Column(name = "detailed_address", length = 50)
|
||||
private String detailedAddress;
|
||||
|
||||
@Column(name = "longitude", length = 30)
|
||||
private String longitude;
|
||||
|
||||
@Column(name = "latitude", length = 30)
|
||||
private String latitude;
|
||||
|
||||
@Column(name = "parking_instructions")
|
||||
private String parkingInstructions;
|
||||
|
||||
@Column(name = "serial_number", length = 50)
|
||||
private String serialNumber;
|
||||
|
||||
@Column(name = "client_visible", length = 50)
|
||||
private String clientVisible;
|
||||
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "del_flag")
|
||||
private Integer delFlag;
|
||||
|
||||
@Column(name = "rate_model_id")
|
||||
private Long rateModelId;
|
||||
|
||||
@Column(name = "business_instructions")
|
||||
private String businessInstructions;
|
||||
|
||||
@Column(name = "reminder_instructions")
|
||||
private String reminderInstructions;
|
||||
|
||||
@Column(name = "img_id", length = 500)
|
||||
private String imgId;
|
||||
|
||||
@Lob
|
||||
@Column(name = "station_type")
|
||||
private String stationType;
|
||||
|
||||
@Column(name = "operator_id_evcs", length = 20)
|
||||
private String operatorIdEvcs;
|
||||
|
||||
public String getOperatorIdEvcs() {
|
||||
|
||||
return operatorIdEvcs;
|
||||
}
|
||||
|
||||
public void setOperatorIdEvcs(String operatorIdEvcs) {
|
||||
|
||||
this.operatorIdEvcs = operatorIdEvcs;
|
||||
}
|
||||
|
||||
public String getStationType() {
|
||||
|
||||
return stationType;
|
||||
}
|
||||
|
||||
public void setStationType(String stationType) {
|
||||
|
||||
this.stationType = stationType;
|
||||
}
|
||||
|
||||
public String getImgId() {
|
||||
|
||||
return imgId;
|
||||
}
|
||||
|
||||
public void setImgId(String imgId) {
|
||||
|
||||
this.imgId = imgId;
|
||||
}
|
||||
|
||||
public String getReminderInstructions() {
|
||||
|
||||
return reminderInstructions;
|
||||
}
|
||||
|
||||
public void setReminderInstructions(String reminderInstructions) {
|
||||
|
||||
this.reminderInstructions = reminderInstructions;
|
||||
}
|
||||
|
||||
public String getBusinessInstructions() {
|
||||
|
||||
return businessInstructions;
|
||||
}
|
||||
|
||||
public void setBusinessInstructions(String businessInstructions) {
|
||||
|
||||
this.businessInstructions = businessInstructions;
|
||||
}
|
||||
|
||||
public Long getRateModelId() {
|
||||
|
||||
return rateModelId;
|
||||
}
|
||||
|
||||
public void setRateModelId(Long rateModelId) {
|
||||
|
||||
this.rateModelId = rateModelId;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getClientVisible() {
|
||||
|
||||
return clientVisible;
|
||||
}
|
||||
|
||||
public void setClientVisible(String clientVisible) {
|
||||
|
||||
this.clientVisible = clientVisible;
|
||||
}
|
||||
|
||||
public String getSerialNumber() {
|
||||
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
public void setSerialNumber(String serialNumber) {
|
||||
|
||||
this.serialNumber = serialNumber;
|
||||
}
|
||||
|
||||
public String getParkingInstructions() {
|
||||
|
||||
return parkingInstructions;
|
||||
}
|
||||
|
||||
public void setParkingInstructions(String parkingInstructions) {
|
||||
|
||||
this.parkingInstructions = parkingInstructions;
|
||||
}
|
||||
|
||||
public String getLatitude() {
|
||||
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(String latitude) {
|
||||
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getLongitude() {
|
||||
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(String longitude) {
|
||||
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getDetailedAddress() {
|
||||
|
||||
return detailedAddress;
|
||||
}
|
||||
|
||||
public void setDetailedAddress(String detailedAddress) {
|
||||
|
||||
this.detailedAddress = detailedAddress;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public Integer getAreaCode() {
|
||||
|
||||
return areaCode;
|
||||
}
|
||||
|
||||
public void setAreaCode(Integer areaCode) {
|
||||
|
||||
this.areaCode = areaCode;
|
||||
}
|
||||
|
||||
public String getPeripheryFacilities() {
|
||||
|
||||
return peripheryFacilities;
|
||||
}
|
||||
|
||||
public void setPeripheryFacilities(String peripheryFacilities) {
|
||||
|
||||
this.peripheryFacilities = peripheryFacilities;
|
||||
}
|
||||
|
||||
public String getServiceFacilities() {
|
||||
|
||||
return serviceFacilities;
|
||||
}
|
||||
|
||||
public void setServiceFacilities(String serviceFacilities) {
|
||||
|
||||
this.serviceFacilities = serviceFacilities;
|
||||
}
|
||||
|
||||
public String getConstructionSite() {
|
||||
|
||||
return constructionSite;
|
||||
}
|
||||
|
||||
public void setConstructionSite(String constructionSite) {
|
||||
|
||||
this.constructionSite = constructionSite;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Long getOperatorId() {
|
||||
|
||||
return operatorId;
|
||||
}
|
||||
|
||||
public void setOperatorId(Long operatorId) {
|
||||
|
||||
this.operatorId = operatorId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.xhpc.evcs.domain.ConnectorStatusInfo;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Data
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class CDConnectorStatusInfo4BonusRequest {
|
||||
|
||||
@JsonProperty("ConnectorStatusInfo")
|
||||
private ConnectorStatusInfo connectorStatusInfo;
|
||||
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"StartChargeSeqStat",
|
||||
"ConnectorID",
|
||||
"ConnectorStatus",
|
||||
"CurrentA",
|
||||
"CurrentB",
|
||||
"CurrentC",
|
||||
"VoltageA",
|
||||
"VoltageB",
|
||||
"VoltageC",
|
||||
"Soc",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"ChargeModel",
|
||||
"TotalPower",
|
||||
"ElecMoney",
|
||||
"SeviceMoney",
|
||||
"TotalMoney",
|
||||
"SumPeriod",
|
||||
"ChargeDetails"
|
||||
})
|
||||
public class CDEquipChargeStatusCDInfo {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
private Integer startChargeSeqStat = 4;
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorID;
|
||||
@JsonProperty("ConnectorStatus")
|
||||
private Integer connectorStatus = 1;
|
||||
@JsonProperty("CurrentA")
|
||||
private Double currentA = 15.0;
|
||||
@JsonProperty("CurrentB")
|
||||
private Double currentB = 15.0;
|
||||
@JsonProperty("CurrentC")
|
||||
private Double currentC = 15.0;
|
||||
@JsonProperty("VoltageA")
|
||||
private Double voltageA = 220.0;
|
||||
@JsonProperty("VoltageB")
|
||||
private Double voltageB = 220.0;
|
||||
@JsonProperty("VoltageC")
|
||||
private Double voltageC = 220.0;
|
||||
@JsonProperty("Soc")
|
||||
private Double soc = 0.0;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonProperty("ChargeModel")
|
||||
private Integer chargeModel = 0;
|
||||
@JsonProperty("TotalPower")
|
||||
private Double totalPower = 0.0;
|
||||
@JsonProperty("ElecMoney")
|
||||
private Double elecMoney = 0.0;
|
||||
@JsonProperty("SeviceMoney")
|
||||
private Double seviceMoney = 0.0;
|
||||
@JsonProperty("TotalMoney")
|
||||
private Double totalMoney = 0.0;
|
||||
@JsonProperty("SumPeriod")
|
||||
private Integer sumPeriod = 0;
|
||||
@JsonProperty("ChargeDetails")
|
||||
private com.xhpc.evcs.dto.ChargeDetails[] chargeDetails;
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"SuccStat"
|
||||
})
|
||||
public class CDEquipmentChargeStatusResponse {
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
private Integer succStat;
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
|
||||
public Integer getSuccStat() {
|
||||
|
||||
return succStat;
|
||||
}
|
||||
|
||||
public void setSuccStat(Integer succStat) {
|
||||
|
||||
this.succStat = succStat;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.xhpc.evcs.domain.XhpcStatisticsTimeInterval;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ChargeDetails {
|
||||
|
||||
@JsonProperty("DetailStartTime")
|
||||
private String detailStartTime;
|
||||
|
||||
@JsonProperty("DetailEndTime")
|
||||
private String detailEndTime;
|
||||
|
||||
@JsonProperty("ElecPrice")
|
||||
private Double elecPrice = 0.0;
|
||||
|
||||
@JsonProperty("SevicePrice")
|
||||
private Double sevicePrice = 0.0;
|
||||
|
||||
@JsonProperty("DetailPower")
|
||||
private Double detailPower = 0.0;
|
||||
|
||||
@JsonProperty("DetailElecMoney")
|
||||
private Double detailElecMoney = 0.0;
|
||||
|
||||
@JsonProperty("DetailSeviceMoney")
|
||||
private Double detailSeviceMoney = 0.0;
|
||||
|
||||
public ChargeDetails(XhpcStatisticsTimeInterval statistics) {
|
||||
|
||||
this.detailElecMoney = statistics.getPowerPrice().doubleValue();
|
||||
this.detailSeviceMoney = statistics.getServicePrice().doubleValue();
|
||||
this.elecPrice = statistics.getElecPriceEvcs().doubleValue();
|
||||
this.sevicePrice = statistics.getServicePriceEvcs().doubleValue();
|
||||
this.detailPower = statistics.getChargingDegree().doubleValue();
|
||||
this.detailStartTime = statistics.getStartTimeEvcs();
|
||||
this.detailEndTime = statistics.getEndTimeEvcs();
|
||||
}
|
||||
|
||||
public ChargeDetails() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class ChargeInfoByBillerOperatorIdRequest {
|
||||
|
||||
@JsonProperty("BillerOperatorId")
|
||||
String billerOperatorId;
|
||||
|
||||
//当该属性 为 0 时表示查询所有订单信息 当该属性为 1 时表示根据billerOperatorId查询(四九订单)
|
||||
//当该属性为 2 时表示查询四九订单信息 这时数据库字段billerOperatorId值为null
|
||||
@JsonProperty("QueryType")
|
||||
Integer queryType = 0;
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class ChargeInfoRequest {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"TotalPower",
|
||||
"TotalMoney",
|
||||
"StartChargeSeq"
|
||||
})
|
||||
public class ChargeOrder {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("TotalPower")
|
||||
private Integer totalPower;
|
||||
@JsonProperty("TotalMoney")
|
||||
private Integer totalMoney;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public Integer getTotalPower() {
|
||||
|
||||
return totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public void setTotalPower(Integer totalPower) {
|
||||
|
||||
this.totalPower = totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public Integer getTotalMoney() {
|
||||
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public void setTotalMoney(Integer totalMoney) {
|
||||
|
||||
this.totalMoney = totalMoney;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startChargeSeq", startChargeSeq).append("totalPower", totalPower).append(
|
||||
"totalMoney", totalMoney).append("startChargeSeq", startChargeSeq).append("additionalProperties",
|
||||
additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"ConnectorID",
|
||||
"ConfirmResult"
|
||||
})
|
||||
public class ChargeOrderInfoResponse {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorID;
|
||||
@JsonProperty("ConfirmResult")
|
||||
private Integer confirmResult;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public String getConnectorID() {
|
||||
|
||||
return connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public void setConnectorID(String connectorID) {
|
||||
|
||||
this.connectorID = connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("ConfirmResult")
|
||||
public Integer getConfirmResult() {
|
||||
|
||||
return confirmResult;
|
||||
}
|
||||
|
||||
@JsonProperty("ConfirmResult")
|
||||
public void setConfirmResult(Integer confirmResult) {
|
||||
|
||||
this.confirmResult = confirmResult;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startChargeSeq", startChargeSeq).append("connectorID", connectorID).append(
|
||||
"confirmResult", confirmResult).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class ChargeRequest {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
@JsonProperty("ConnectorID")
|
||||
String connectorId;
|
||||
@JsonProperty("QRCode")
|
||||
String QRCode;
|
||||
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"SuccStat",
|
||||
"FailReason",
|
||||
"ConnectorID",
|
||||
"StartChargeSeqStat",
|
||||
"StartChargeSeq"
|
||||
})
|
||||
public class ChargeResponse {
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
private Integer succStat;
|
||||
|
||||
//0 无;
|
||||
//1 此设备不存在
|
||||
//2 此设备离线:
|
||||
//其它 自定义
|
||||
@JsonProperty("FailReason")
|
||||
private Integer failReason;
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorID;
|
||||
|
||||
//1 启动中
|
||||
//2 充电中
|
||||
//3 停止中
|
||||
//4 已结束
|
||||
//其它值 未知
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
private Integer startChargeSeqStat;
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
public Integer getSuccStat() {
|
||||
|
||||
return succStat;
|
||||
}
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
public void setSuccStat(Integer succStat) {
|
||||
|
||||
this.succStat = succStat;
|
||||
}
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
public Integer getFailReason() {
|
||||
|
||||
return failReason;
|
||||
}
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
public void setFailReason(Integer failReason) {
|
||||
|
||||
this.failReason = failReason;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public String getConnectorID() {
|
||||
|
||||
return connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public void setConnectorID(String connectorID) {
|
||||
|
||||
this.connectorID = connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
public Integer getStartChargeSeqStat() {
|
||||
|
||||
return startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
public void setStartChargeSeqStat(Integer startChargeSeqStat) {
|
||||
|
||||
this.startChargeSeqStat = startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("succStat", succStat).append("failReason", failReason).append("connectorID",
|
||||
connectorID).append("startChargeSeqStat", startChargeSeqStat).append("startChargeSeq", startChargeSeq).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@lombok.Data
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
/**
|
||||
* 推送停止充电请求数据dto类
|
||||
*/
|
||||
public class ChargeResultRequest {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
String startChargeSeqStat;
|
||||
@JsonProperty("ConnectorID")
|
||||
String connectorID;
|
||||
@JsonProperty("SuccStat")
|
||||
Integer succStat;
|
||||
@JsonProperty("FailReason")
|
||||
Integer failReason;
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@lombok.Data
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
/**
|
||||
* 推送停止充电结果返回数据dto类
|
||||
*/
|
||||
public class ChargeResultResponse {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
@JsonProperty("SuccStat")
|
||||
Integer succStat;
|
||||
@JsonProperty("FailReason")
|
||||
Integer failReason;
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class ChargeStatusRequest {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
|
||||
}
|
||||
@ -0,0 +1,144 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"CheckOrderSeq",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"OrderCount",
|
||||
"TotalOrderPower",
|
||||
"TotalOrderMoney",
|
||||
"ChargeOrders"
|
||||
})
|
||||
public class CheckChargeOrderRequestData {
|
||||
|
||||
@JsonProperty("CheckOrderSeq")
|
||||
private String checkOrderSeq;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonProperty("OrderCount")
|
||||
private Integer orderCount;
|
||||
@JsonProperty("TotalOrderPower")
|
||||
private Integer totalOrderPower;
|
||||
@JsonProperty("TotalOrderMoney")
|
||||
private Integer totalOrderMoney;
|
||||
@JsonProperty("ChargeOrders")
|
||||
private List<ChargeOrder> chargeOrders = null;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("CheckOrderSeq")
|
||||
public String getCheckOrderSeq() {
|
||||
|
||||
return checkOrderSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("CheckOrderSeq")
|
||||
public void setCheckOrderSeq(String checkOrderSeq) {
|
||||
|
||||
this.checkOrderSeq = checkOrderSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public String getEndTime() {
|
||||
|
||||
return endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public void setEndTime(String endTime) {
|
||||
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("OrderCount")
|
||||
public Integer getOrderCount() {
|
||||
|
||||
return orderCount;
|
||||
}
|
||||
|
||||
@JsonProperty("OrderCount")
|
||||
public void setOrderCount(Integer orderCount) {
|
||||
|
||||
this.orderCount = orderCount;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderPower")
|
||||
public Integer getTotalOrderPower() {
|
||||
|
||||
return totalOrderPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderPower")
|
||||
public void setTotalOrderPower(Integer totalOrderPower) {
|
||||
|
||||
this.totalOrderPower = totalOrderPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderMoney")
|
||||
public Integer getTotalOrderMoney() {
|
||||
|
||||
return totalOrderMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderMoney")
|
||||
public void setTotalOrderMoney(Integer totalOrderMoney) {
|
||||
|
||||
this.totalOrderMoney = totalOrderMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("ChargeOrders")
|
||||
public List<ChargeOrder> getChargeOrders() {
|
||||
|
||||
return chargeOrders;
|
||||
}
|
||||
|
||||
@JsonProperty("ChargeOrders")
|
||||
public void setChargeOrders(List<ChargeOrder> chargeOrders) {
|
||||
|
||||
this.chargeOrders = chargeOrders;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("checkOrderSeq", checkOrderSeq).append("startTime", startTime).append(
|
||||
"endTime", endTime).append("orderCount", orderCount).append("totalOrderPower", totalOrderPower).append(
|
||||
"totalOrderMoney", totalOrderMoney).append("chargeOrders", chargeOrders).append("additionalProperties"
|
||||
, additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"CheckOrderSeq",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"TotalDisputeOrder",
|
||||
"TotalDisputePower",
|
||||
"TotalDisputeMoney",
|
||||
"DisputeOrders"
|
||||
})
|
||||
public class CheckChargeOrderResponseData {
|
||||
|
||||
@JsonProperty("CheckOrderSeq")
|
||||
private String checkOrderSeq;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonProperty("TotalDisputeOrder")
|
||||
private Integer totalDisputeOrder;
|
||||
@JsonProperty("TotalDisputePower")
|
||||
private Double totalDisputePower;
|
||||
@JsonProperty("TotalDisputeMoney")
|
||||
private Double totalDisputeMoney;
|
||||
@JsonProperty("DisputeOrders")
|
||||
private DisputeOrder[] disputeOrders = null;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("CheckOrderSeq")
|
||||
public String getCheckOrderSeq() {
|
||||
|
||||
return checkOrderSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("CheckOrderSeq")
|
||||
public void setCheckOrderSeq(String checkOrderSeq) {
|
||||
|
||||
this.checkOrderSeq = checkOrderSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public String getEndTime() {
|
||||
|
||||
return endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public void setEndTime(String endTime) {
|
||||
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalDisputeOrder")
|
||||
public Integer getTotalDisputeOrder() {
|
||||
|
||||
return totalDisputeOrder;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalDisputeOrder")
|
||||
public void setTotalDisputeOrder(Integer totalDisputeOrder) {
|
||||
|
||||
this.totalDisputeOrder = totalDisputeOrder;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalDisputePower")
|
||||
public Double getTotalDisputePower() {
|
||||
|
||||
return totalDisputePower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalDisputePower")
|
||||
public void setTotalDisputePower(Double totalDisputePower) {
|
||||
|
||||
this.totalDisputePower = totalDisputePower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalDisputeMoney")
|
||||
public Double getTotalDisputeMoney() {
|
||||
|
||||
return totalDisputeMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalDisputeMoney")
|
||||
public void setTotalDisputeMoney(Double totalDisputeMoney) {
|
||||
|
||||
this.totalDisputeMoney = totalDisputeMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("DisputeOrders")
|
||||
public DisputeOrder[] getDisputeOrders() {
|
||||
|
||||
return disputeOrders;
|
||||
}
|
||||
|
||||
@JsonProperty("DisputeOrders")
|
||||
public void setDisputeOrders(DisputeOrder[] disputeOrders) {
|
||||
|
||||
this.disputeOrders = disputeOrders;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("checkOrderSeq", checkOrderSeq).append("startTime", startTime).append(
|
||||
"endTime", endTime).append("totalDisputeOrder", totalDisputeOrder).append("totalDisputePower",
|
||||
totalDisputePower).append("totalDisputeMoney", totalDisputeMoney).append("disputeOrders", disputeOrders).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class CommonRequest<T> {
|
||||
|
||||
@JsonProperty("OperatorID")
|
||||
String operatorId;
|
||||
@JsonProperty("Data")
|
||||
String data;
|
||||
@JsonProperty("TimeStamp")
|
||||
String timeStamp;
|
||||
@JsonProperty("Seq")
|
||||
String seq;
|
||||
@JsonProperty("Sig")
|
||||
String sig;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
|
||||
public T anyDataType(Class<T> clz, String key) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree(data);
|
||||
jsonNode = jsonNode.path(key);
|
||||
return JSONUtil.readParams(jsonNode.toString(), clz);
|
||||
}
|
||||
|
||||
public T anyDataType(Class<T> clz) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree(data);
|
||||
return JSONUtil.readParams(jsonNode.toString(), clz);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRawValue;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import java.io.IOException;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class CommonResponse {
|
||||
|
||||
public static final int SUCCESS = 0;
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore()
|
||||
@JsonProperty("Id")
|
||||
Long id;
|
||||
@JsonProperty("Ret")
|
||||
String ret;
|
||||
@JsonProperty("Data")
|
||||
@JsonRawValue
|
||||
Object data;
|
||||
@JsonProperty("Msg")
|
||||
String msg = "";
|
||||
@JsonProperty("Sig")
|
||||
String sig;
|
||||
|
||||
public Object anyDataTypeList(Class clz, String key) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree((String) data);
|
||||
jsonNode = jsonNode.path(key);
|
||||
return JSONUtil.readParamsList(jsonNode.toString(), clz);
|
||||
}
|
||||
|
||||
public Object anyDataTypeList(Class clz) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree((String) data);
|
||||
return JSONUtil.readParamsList(jsonNode.toString(), clz);
|
||||
}
|
||||
|
||||
public Object anyDataType(Class clz, String key) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree((String) data);
|
||||
jsonNode = jsonNode.path(key);
|
||||
return JSONUtil.readParams(jsonNode.toString(), clz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("Data", this.data).append("Msg", this.msg).append("Ret", this.ret).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"NationalStandard",
|
||||
"ConnectorID",
|
||||
"ConnectorName",
|
||||
"ConnectorType",
|
||||
"VoltageUpperLimits",
|
||||
"VoltageLowerLimits",
|
||||
"Current",
|
||||
"Power"
|
||||
})
|
||||
@Setter
|
||||
@Getter
|
||||
public class ConnectorInfo {
|
||||
|
||||
@JsonProperty("NationalStandard")
|
||||
public Integer nationalStandard;
|
||||
@JsonProperty("ConnectorID")
|
||||
public String connectorID;
|
||||
@JsonProperty("ConnectorName")
|
||||
public String connectorName;
|
||||
@JsonProperty("ConnectorType")
|
||||
public Integer connectorType;
|
||||
@JsonProperty("VoltageUpperLimits")
|
||||
public Integer voltageUpperLimits;
|
||||
@JsonProperty("VoltageLowerLimits")
|
||||
public Integer voltageLowerLimits;
|
||||
@JsonProperty("Current")
|
||||
public Integer current;
|
||||
@JsonProperty("Power")
|
||||
public Double power;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("nationalStandard", nationalStandard).append("connectorID", connectorID).append("connectorName", connectorName).append("connectorType", connectorType).append("voltageUpperLimits", voltageUpperLimits).append("voltageLowerLimits", voltageLowerLimits).append("current", current).append("power", power).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"ConnectorID",
|
||||
"ConnectorElectricity"
|
||||
})
|
||||
public class ConnectorStatsInfo {
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorID;
|
||||
@JsonProperty("ConnectorElectricity")
|
||||
private Double connectorElectricity;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public String getConnectorID() {
|
||||
|
||||
return connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public void setConnectorID(String connectorID) {
|
||||
|
||||
this.connectorID = connectorID;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorElectricity")
|
||||
public Double getConnectorElectricity() {
|
||||
|
||||
return connectorElectricity;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorElectricity")
|
||||
public void setConnectorElectricity(Double connectorElectricity) {
|
||||
|
||||
this.connectorElectricity = connectorElectricity;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.encryption.Aes128Cbc;
|
||||
import com.xhpc.evcs.http.ServerInternalException;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class DTOJsonHelper {
|
||||
|
||||
public static <T> T parseResponseData(String responseBody, Class<T> clz, String jsonListKey) {
|
||||
|
||||
if (responseBody != null) {
|
||||
try {
|
||||
CommonResponse commonResponse = JSONUtil.readParams(responseBody, CommonResponse.class);
|
||||
return (T) commonResponse.anyDataType(clz, jsonListKey);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg);
|
||||
throw new ServerInternalException(msg);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T parseResponseData(String responseBody, Class<T> clz, AuthSecretToken authSecretToken) {
|
||||
|
||||
if (responseBody != null) {
|
||||
try {
|
||||
CommonResponse commonResponse = JSONUtil.readParams(responseBody, CommonResponse.class);
|
||||
String data = (String) commonResponse.getData();
|
||||
if (authSecretToken != null) {
|
||||
data = Aes128Cbc.decryptString(data, authSecretToken.getDataSecret(), authSecretToken.getDataSecretIV());
|
||||
}
|
||||
if (!data.isEmpty()) {
|
||||
return JSONUtil.readParams(data, clz);
|
||||
} else {
|
||||
log.error(commonResponse.getMsg());
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg);
|
||||
throw new ServerInternalException(msg);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T parseResponseData(String responseBody, Class<T> clz) {
|
||||
|
||||
if (responseBody != null) {
|
||||
try {
|
||||
CommonResponse commonResponse = JSONUtil.readParams(responseBody, CommonResponse.class);
|
||||
String data = (String) commonResponse.getData();
|
||||
if (!data.isEmpty()) {
|
||||
return JSONUtil.readParams(data, clz);
|
||||
} else {
|
||||
log.error(commonResponse.getMsg());
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg);
|
||||
throw new ServerInternalException(msg);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> parseResponseDataAsList(String responseBody, Class<T> clz, String jsonListKey) {
|
||||
|
||||
if (responseBody != null) {
|
||||
try {
|
||||
CommonResponse commonResponse = JSONUtil.readParams(responseBody, CommonResponse.class);
|
||||
return (List<T>) commonResponse.anyDataTypeList(clz, jsonListKey);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg);
|
||||
throw new ServerInternalException(msg);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> parseResponseDataAsList(String responseBody, Class<T> clz) {
|
||||
|
||||
if (responseBody != null) {
|
||||
try {
|
||||
CommonResponse commonResponse = JSONUtil.readParams(responseBody, CommonResponse.class);
|
||||
return (List<T>) commonResponse.anyDataTypeList(clz);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg);
|
||||
throw new ServerInternalException(msg);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"TotalPower ",
|
||||
"TotalMoney",
|
||||
"DisputeReason"
|
||||
})
|
||||
public class DisputeOrder {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("TotalPower ")
|
||||
private Double totalPower;
|
||||
@JsonProperty("TotalMoney")
|
||||
private Double totalMoney;
|
||||
@JsonProperty("DisputeReason")
|
||||
private Integer disputeReason;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public Double getTotalPower() {
|
||||
|
||||
return totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public void setTotalPower(Double totalPower) {
|
||||
|
||||
this.totalPower = totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public Double getTotalMoney() {
|
||||
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public void setTotalMoney(Double totalMoney) {
|
||||
|
||||
this.totalMoney = totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("DisputeReason")
|
||||
public Integer getDisputeReason() {
|
||||
|
||||
return disputeReason;
|
||||
}
|
||||
|
||||
@JsonProperty("DisputeReason")
|
||||
public void setDisputeReason(Integer disputeReason) {
|
||||
|
||||
this.disputeReason = disputeReason;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startChargeSeq", startChargeSeq).append("totalPower", totalPower).append(
|
||||
"totalMoney", totalMoney).append("disputeReason", disputeReason).append("additionalProperties",
|
||||
additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class EquipAuthRequest {
|
||||
|
||||
@JsonProperty("EquipAuthSeq")
|
||||
String equipAuthSeq;
|
||||
@JsonProperty("ConnectorID")
|
||||
String connectorId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class EquipBizRequest {
|
||||
|
||||
@JsonProperty("EquipBizSeq")
|
||||
String equipBizSeq;
|
||||
@JsonProperty("ConnectorID")
|
||||
String connectorId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,261 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeqStat",
|
||||
"ConnectorStatus",
|
||||
"CurrentA",
|
||||
"CurrentB",
|
||||
"CurrentC",
|
||||
"VoltageA",
|
||||
"VoltageB",
|
||||
"VoltageC",
|
||||
"Soc",
|
||||
"TotalPower",
|
||||
"ElecMoney",
|
||||
"SeviceMoney",
|
||||
"TotalMoney",
|
||||
"SumPeriod",
|
||||
"StartTime"
|
||||
})
|
||||
public class EquipChargeStatusResponse {
|
||||
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
private Integer startChargeSeqStat;
|
||||
@JsonProperty("ConnectorStatus")
|
||||
private Integer connectorStatus;
|
||||
@JsonProperty("CurrentA")
|
||||
private Double currentA;
|
||||
@JsonProperty("CurrentB")
|
||||
private Double currentB;
|
||||
@JsonProperty("CurrentC")
|
||||
private Double currentC;
|
||||
@JsonProperty("VoltageA")
|
||||
private Double voltageA;
|
||||
@JsonProperty("VoltageB")
|
||||
private Double voltageB;
|
||||
@JsonProperty("VoltageC")
|
||||
private Double voltageC;
|
||||
@JsonProperty("Soc")
|
||||
private Double soc;
|
||||
@JsonProperty("TotalPower")
|
||||
private Double totalPower;
|
||||
@JsonProperty("ElecMoney")
|
||||
private Double elecMoney;
|
||||
@JsonProperty("SeviceMoney")
|
||||
private Double seviceMoney;
|
||||
@JsonProperty("TotalMoney")
|
||||
private Double totalMoney;
|
||||
@JsonProperty("SumPeriod")
|
||||
private Integer sumPeriod;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
public Integer getStartChargeSeqStat() {
|
||||
|
||||
return startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
public void setStartChargeSeqStat(Integer startChargeSeqStat) {
|
||||
|
||||
this.startChargeSeqStat = startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorStatus")
|
||||
public Integer getConnectorStatus() {
|
||||
|
||||
return connectorStatus;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorStatus")
|
||||
public void setConnectorStatus(Integer connectorStatus) {
|
||||
|
||||
this.connectorStatus = connectorStatus;
|
||||
}
|
||||
|
||||
@JsonProperty("CurrentA")
|
||||
public Double getCurrentA() {
|
||||
|
||||
return currentA;
|
||||
}
|
||||
|
||||
@JsonProperty("CurrentA")
|
||||
public void setCurrentA(Double currentA) {
|
||||
|
||||
this.currentA = currentA;
|
||||
}
|
||||
|
||||
@JsonProperty("CurrentB")
|
||||
public Double getCurrentB() {
|
||||
|
||||
return currentB;
|
||||
}
|
||||
|
||||
@JsonProperty("CurrentB")
|
||||
public void setCurrentB(Double currentB) {
|
||||
|
||||
this.currentB = currentB;
|
||||
}
|
||||
|
||||
@JsonProperty("CurrentC")
|
||||
public Double getCurrentC() {
|
||||
|
||||
return currentC;
|
||||
}
|
||||
|
||||
@JsonProperty("CurrentC")
|
||||
public void setCurrentC(Double currentC) {
|
||||
|
||||
this.currentC = currentC;
|
||||
}
|
||||
|
||||
@JsonProperty("VoltageA")
|
||||
public Double getVoltageA() {
|
||||
|
||||
return voltageA;
|
||||
}
|
||||
|
||||
@JsonProperty("VoltageA")
|
||||
public void setVoltageA(Double voltageA) {
|
||||
|
||||
this.voltageA = voltageA;
|
||||
}
|
||||
|
||||
@JsonProperty("VoltageB")
|
||||
public Double getVoltageB() {
|
||||
|
||||
return voltageB;
|
||||
}
|
||||
|
||||
@JsonProperty("VoltageB")
|
||||
public void setVoltageB(Double voltageB) {
|
||||
|
||||
this.voltageB = voltageB;
|
||||
}
|
||||
|
||||
@JsonProperty("VoltageC")
|
||||
public Double getVoltageC() {
|
||||
|
||||
return voltageC;
|
||||
}
|
||||
|
||||
@JsonProperty("VoltageC")
|
||||
public void setVoltageC(Double voltageC) {
|
||||
|
||||
this.voltageC = voltageC;
|
||||
}
|
||||
|
||||
@JsonProperty("Soc")
|
||||
public Double getSoc() {
|
||||
|
||||
return soc;
|
||||
}
|
||||
|
||||
@JsonProperty("Soc")
|
||||
public void setSoc(Double soc) {
|
||||
|
||||
this.soc = soc;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public Double getTotalPower() {
|
||||
|
||||
return totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public void setTotalPower(Double totalPower) {
|
||||
|
||||
this.totalPower = totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("ElecMoney")
|
||||
public Double getElecMoney() {
|
||||
|
||||
return elecMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("ElecMoney")
|
||||
public void setElecMoney(Double elecMoney) {
|
||||
|
||||
this.elecMoney = elecMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("SeviceMoney")
|
||||
public Double getSeviceMoney() {
|
||||
|
||||
return seviceMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("SeviceMoney")
|
||||
public void setSeviceMoney(Double seviceMoney) {
|
||||
|
||||
this.seviceMoney = seviceMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public Double getTotalMoney() {
|
||||
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public void setTotalMoney(Double totalMoney) {
|
||||
|
||||
this.totalMoney = totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("SumPeriod")
|
||||
public Integer getSumPeriod() {
|
||||
|
||||
return sumPeriod;
|
||||
}
|
||||
|
||||
@JsonProperty("SumPeriod")
|
||||
public void setSumPeriod(Integer sumPeriod) {
|
||||
|
||||
this.sumPeriod = sumPeriod;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startChargeSeqStat", startChargeSeqStat).append("connectorStatus",
|
||||
connectorStatus).append("currentA", currentA).append("currentB", currentB).append("currentC", currentC).append("voltageA", voltageA).append("voltageB", voltageB).append("voltageC", voltageC).append("soc", soc).append("totalPower", totalPower).append("elecMoney", elecMoney).append("seviceMoney", seviceMoney).append("totalMoney", totalMoney).append("sumPeriod", sumPeriod).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"EquipmentID",
|
||||
"ManufacturerID",
|
||||
"EquipmentType",
|
||||
"Power",
|
||||
"ConnectorInfos",
|
||||
"EquipmentLng",
|
||||
"EquipmentLat"
|
||||
})
|
||||
@Getter
|
||||
@Setter
|
||||
public class EquipmentInfo {
|
||||
|
||||
@JsonProperty("EquipmentID")
|
||||
public String equipmentID;
|
||||
@JsonProperty("ManufacturerID")
|
||||
public String manufacturerID;
|
||||
@JsonProperty("EquipmentType")
|
||||
public Integer equipmentType;
|
||||
@JsonProperty("Power")
|
||||
public Double power;
|
||||
@JsonProperty("ConnectorInfos")
|
||||
public List<ConnectorInfo> connectorInfos = null;
|
||||
@JsonProperty("EquipmentLng")
|
||||
public Double equipmentLng;
|
||||
@JsonProperty("EquipmentLat")
|
||||
public Double equipmentLat;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("equipmentID", equipmentID).append("manufacturerID", manufacturerID).append(
|
||||
"equipmentType", equipmentType).append("power", power).append("connectorInfos", connectorInfos).append(
|
||||
"equipmentLng", equipmentLng).append("equipmentLat", equipmentLat).append("additionalProperties",
|
||||
additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"EquipmentID",
|
||||
"EquipmentElectricity",
|
||||
"ConnectorStatsInfos"
|
||||
})
|
||||
public class EquipmentStatsInfo {
|
||||
|
||||
@JsonProperty("EquipmentID")
|
||||
private String equipmentID;
|
||||
@JsonProperty("EquipmentElectricity")
|
||||
private Double equipmentElectricity;
|
||||
@JsonProperty("ConnectorStatsInfos")
|
||||
private List<ConnectorStatsInfo> connectorStatsInfos = null;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("EquipmentID")
|
||||
public String getEquipmentID() {
|
||||
|
||||
return equipmentID;
|
||||
}
|
||||
|
||||
@JsonProperty("EquipmentID")
|
||||
public void setEquipmentID(String equipmentID) {
|
||||
|
||||
this.equipmentID = equipmentID;
|
||||
}
|
||||
|
||||
@JsonProperty("EquipmentElectricity")
|
||||
public Double getEquipmentElectricity() {
|
||||
|
||||
return equipmentElectricity;
|
||||
}
|
||||
|
||||
@JsonProperty("EquipmentElectricity")
|
||||
public void setEquipmentElectricity(Double equipmentElectricity) {
|
||||
|
||||
this.equipmentElectricity = equipmentElectricity;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorStatsInfos")
|
||||
public List<ConnectorStatsInfo> getConnectorStatsInfos() {
|
||||
|
||||
return connectorStatsInfos;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorStatsInfos")
|
||||
public void setConnectorStatsInfos(List<ConnectorStatsInfo> connectorStatsInfos) {
|
||||
|
||||
this.connectorStatsInfos = connectorStatsInfos;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class EvShareQueryChargeInfosPagingRequest {
|
||||
|
||||
@JsonProperty("BillerOperatorId")
|
||||
String billerOperatorId;
|
||||
|
||||
//当该属性 为 0 时表示查询所有订单信息 当该属性为 1 时表示根据billerOperatorId查询(四九订单)
|
||||
//当该属性为 2 时表示查询四九订单信息 这时数据库字段billerOperatorId值为null
|
||||
@JsonProperty("QueryType")
|
||||
Integer queryType = 0;
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
|
||||
@JsonProperty("Page")
|
||||
private Integer page;
|
||||
@JsonProperty("PageSize")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class EvShareQueryChargeInfosRequest {
|
||||
|
||||
@JsonProperty("BillerOperatorId")
|
||||
String billerOperatorId;
|
||||
|
||||
//当该属性 为 0 时表示查询所有订单信息 当该属性为 1 时表示根据billerOperatorId查询(四九订单)
|
||||
//当该属性为 2 时表示查询四九订单信息 这时数据库字段billerOperatorId值为null
|
||||
@JsonProperty("QueryType")
|
||||
Integer queryType = 0;
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class NotificationEquipChargeStatusData {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
Integer succStat;
|
||||
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"StartChargeSeqStat",
|
||||
"ConnectorID",
|
||||
"StartTime",
|
||||
"IdentCode"
|
||||
})
|
||||
public class NotificationStartChargeResultRequestData {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
private Integer startChargeSeqStat;
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorId;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("IdentCode")
|
||||
private String identCode;
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public Integer getStartChargeSeqStat() {
|
||||
|
||||
return startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public void setStartChargeSeqStat(Integer startChargeSeqStat) {
|
||||
|
||||
this.startChargeSeqStat = startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public String getConnectorId() {
|
||||
|
||||
return connectorId;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public void setConnectorId(String connectorId) {
|
||||
|
||||
this.connectorId = connectorId;
|
||||
}
|
||||
|
||||
@JsonProperty("IdentCode")
|
||||
public String getIdentCode() {
|
||||
|
||||
return identCode;
|
||||
}
|
||||
|
||||
@JsonProperty("IdentCode")
|
||||
public void setIdentCode(String identCode) {
|
||||
|
||||
this.identCode = identCode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startChargeSeq", startChargeSeq).append("startTime", startTime).append(
|
||||
"startChargeSeqStat", startChargeSeqStat).append("connectorId", connectorId).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"SuccStat",
|
||||
"FailReason",
|
||||
"StartChargeSeq"
|
||||
})
|
||||
public class NotificationStartStopChargeResultResponse {
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
private Integer succStat;
|
||||
@JsonProperty("FailReason")
|
||||
private Integer failReason;
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
public Integer getSuccStat() {
|
||||
|
||||
return succStat;
|
||||
}
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
public void setSuccStat(Integer succStat) {
|
||||
|
||||
this.succStat = succStat;
|
||||
}
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
public Integer getFailReason() {
|
||||
|
||||
return failReason;
|
||||
}
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
public void setFailReason(Integer failReason) {
|
||||
|
||||
this.failReason = failReason;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("succStat", succStat).append("failReason", failReason).append("startChargeSeq"
|
||||
, startChargeSeq).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,113 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartChargeSeq",
|
||||
"StartChargeSeqStat",
|
||||
"ConnectorID",
|
||||
"SuccStat",
|
||||
"FailReason"
|
||||
})
|
||||
public class NotificationStopChargeResultRequestData {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
private Integer startChargeSeqStat;
|
||||
@JsonProperty("ConnectorID")
|
||||
private String connectorId;
|
||||
@JsonProperty("SuccStat")
|
||||
private Integer succStat;
|
||||
@JsonProperty("FailReason")
|
||||
private Integer failReason;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
public Integer getSuccStat() {
|
||||
|
||||
return succStat;
|
||||
}
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
public void setSuccStat(Integer succStat) {
|
||||
|
||||
this.succStat = succStat;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
public Integer getStartChargeSeqStat() {
|
||||
|
||||
return startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("StartChargeSeqStat")
|
||||
public void setStartChargeSeqStat(Integer startChargeSeqStat) {
|
||||
|
||||
this.startChargeSeqStat = startChargeSeqStat;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public String getConnectorId() {
|
||||
|
||||
return connectorId;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorID")
|
||||
public void setConnectorId(String connectorId) {
|
||||
|
||||
this.connectorId = connectorId;
|
||||
}
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
public Integer getFailReason() {
|
||||
|
||||
return failReason;
|
||||
}
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
public void setFailReason(Integer failReason) {
|
||||
|
||||
this.failReason = failReason;
|
||||
}
|
||||
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startChargeSeq", startChargeSeq).append("succStat", succStat).append(
|
||||
"startChargeSeqStat", startChargeSeqStat).append("connectorId", connectorId).append("additionalProperties",
|
||||
additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class OrderInfoPageResponse {
|
||||
|
||||
@JsonProperty("PageCount")
|
||||
Integer PageCount;
|
||||
@JsonProperty("ItemSize")
|
||||
Integer ItemSize;
|
||||
@JsonProperty(value = "PageNo", defaultValue = "1") //CAUTION: PageNo must not wrote as PageNon or anything else
|
||||
Integer PageNo = 1;
|
||||
@JsonProperty(value = "PageSize", defaultValue = "10")
|
||||
Integer PageSize = 10;
|
||||
|
||||
@JsonProperty("Data")
|
||||
String data;
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class OrderSumInfo {
|
||||
|
||||
@JsonProperty("AllElectric")
|
||||
BigDecimal allElectric;
|
||||
|
||||
@JsonProperty("AllElectricMoney")
|
||||
BigDecimal allElectricMoney;
|
||||
|
||||
@JsonProperty("AllServiceMoney")
|
||||
BigDecimal allServiceMoney;
|
||||
|
||||
@JsonProperty("AllMoney")
|
||||
BigDecimal allMoney;
|
||||
|
||||
public OrderSumInfo(BigDecimal allElectric, BigDecimal allElectricMoney, BigDecimal allServiceMoney, BigDecimal allMoney) {
|
||||
|
||||
this.allElectric = allElectric;
|
||||
this.allElectricMoney = allElectricMoney;
|
||||
this.allServiceMoney = allServiceMoney;
|
||||
this.allMoney = allMoney;
|
||||
}
|
||||
|
||||
public OrderSumInfo() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class PageRequest {
|
||||
|
||||
@JsonProperty("LastQueryTime")
|
||||
String lastQueryTime;
|
||||
@JsonProperty(value = "PageNo", defaultValue = "1") //CAUTION: PageNo must not wrote as PageNon or anything else
|
||||
Integer pageNo = 1;
|
||||
@JsonProperty(value = "PageSize", defaultValue = "10")
|
||||
Integer pageSize = 10;
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class PageResponse {
|
||||
|
||||
@JsonProperty("PageCount")
|
||||
Integer PageCount;
|
||||
@JsonProperty("ItemSize")
|
||||
Integer ItemSize;
|
||||
@JsonProperty(value = "PageNo", defaultValue = "1") //CAUTION: PageNo must not wrote as PageNon or anything else
|
||||
Integer PageNo = 1;
|
||||
@JsonProperty(value = "PageSize", defaultValue = "10")
|
||||
Integer PageSize = 10;
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.xhpc.evcs.domain.StationInfo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class PageStationsInfoResponse {
|
||||
|
||||
@JsonProperty("PageCount")
|
||||
Integer PageCount;
|
||||
@JsonProperty("ItemSize")
|
||||
Integer ItemSize;
|
||||
@JsonProperty(value = "PageNo", defaultValue = "1") //CAUTION: PageNo must not wrote as PageNon or anything else
|
||||
Integer PageNo = 1;
|
||||
@JsonProperty("StationInfos")
|
||||
List<StationInfo> stationInfos = new ArrayList<>();
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class PoleStatusInfo {
|
||||
|
||||
@JsonProperty("PoleNo")
|
||||
private String poleNo;
|
||||
//0正常 1故障 2占用
|
||||
@JsonProperty("Status")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StartTime",
|
||||
"EndTime"
|
||||
})
|
||||
public class QueryOrderInfoRequestData {
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public String getEndTime() {
|
||||
|
||||
return endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public void setEndTime(String endTime) {
|
||||
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("startTime", startTime).append("endTime", endTime).append(
|
||||
"additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class QueryTokenResponse {
|
||||
|
||||
@JsonProperty("OperatorID")
|
||||
String operatorId;
|
||||
@JsonProperty("SuccStat")
|
||||
Integer succStat;
|
||||
@JsonProperty("AccessToken")
|
||||
String accessToken;
|
||||
@JsonProperty("TokenAvailableTime")
|
||||
Integer tokenAvailableTime;
|
||||
@JsonProperty("FailReason")
|
||||
Integer failReason;
|
||||
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StationID",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"StationElectricity",
|
||||
"EquipmentStatsInfos"
|
||||
})
|
||||
public class StationStatsInfo {
|
||||
|
||||
@JsonProperty("StationID")
|
||||
private String stationID;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonProperty("StationElectricity")
|
||||
private Double stationElectricity;
|
||||
@JsonProperty("EquipmentStatsInfos")
|
||||
private List<EquipmentStatsInfo> equipmentStatsInfos = null;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StationID")
|
||||
public String getStationID() {
|
||||
|
||||
return stationID;
|
||||
}
|
||||
|
||||
@JsonProperty("StationID")
|
||||
public void setStationID(String stationID) {
|
||||
|
||||
this.stationID = stationID;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StartTime")
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public String getEndTime() {
|
||||
|
||||
return endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("EndTime")
|
||||
public void setEndTime(String endTime) {
|
||||
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
@JsonProperty("StationElectricity")
|
||||
public Double getStationElectricity() {
|
||||
|
||||
return stationElectricity;
|
||||
}
|
||||
|
||||
@JsonProperty("StationElectricity")
|
||||
public void setStationElectricity(Double stationElectricity) {
|
||||
|
||||
this.stationElectricity = stationElectricity;
|
||||
}
|
||||
|
||||
@JsonProperty("EquipmentStatsInfos")
|
||||
public List<EquipmentStatsInfo> getEquipmentStatsInfos() {
|
||||
|
||||
return equipmentStatsInfos;
|
||||
}
|
||||
|
||||
@JsonProperty("EquipmentStatsInfos")
|
||||
public void setEquipmentStatsInfos(List<EquipmentStatsInfo> equipmentStatsInfos) {
|
||||
|
||||
this.equipmentStatsInfos = equipmentStatsInfos;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StationID",
|
||||
"StartTime",
|
||||
"EndTime"
|
||||
})
|
||||
public class StationStatsRequest {
|
||||
|
||||
@JsonProperty("StationID")
|
||||
private Integer stationID;
|
||||
@JsonProperty("StartTime")
|
||||
private String startTime;
|
||||
@JsonProperty("EndTime")
|
||||
private String endTime;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StationStatsInfo"
|
||||
})
|
||||
public class StationStatsWrapper {
|
||||
|
||||
@JsonProperty("StationStats")
|
||||
private StationStatsInfo stationStatsInfo;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StationStats")
|
||||
public StationStatsInfo getStationStatsInfo() {
|
||||
|
||||
return stationStatsInfo;
|
||||
}
|
||||
|
||||
@JsonProperty("StationStats")
|
||||
public void setStationStatsInfo(StationStatsInfo stationStatsInfo) {
|
||||
|
||||
this.stationStatsInfo = stationStatsInfo;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.xhpc.evcs.domain.ConnectorStatusInfo;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"StationID",
|
||||
"ConnectorStatusInfos"
|
||||
})
|
||||
public class StationStatusInfo {
|
||||
|
||||
@JsonProperty("StationID")
|
||||
private String stationID;
|
||||
@JsonProperty("ConnectorStatusInfos")
|
||||
private List<ConnectorStatusInfo> connectorStatusInfos = null;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("StationID")
|
||||
public String getStationID() {
|
||||
|
||||
return stationID;
|
||||
}
|
||||
|
||||
@JsonProperty("StationID")
|
||||
public void setStationID(String stationID) {
|
||||
|
||||
this.stationID = stationID;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorStatusInfos")
|
||||
public List<ConnectorStatusInfo> getConnectorStatusInfos() {
|
||||
|
||||
return connectorStatusInfos;
|
||||
}
|
||||
|
||||
@JsonProperty("ConnectorStatusInfos")
|
||||
public void setConnectorStatusInfos(List<ConnectorStatusInfo> connectorStatusInfos) {
|
||||
|
||||
this.connectorStatusInfos = connectorStatusInfos;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("stationID", stationID).append("connectorStatusInfos", connectorStatusInfos).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"Total",
|
||||
"StationStatusInfos"
|
||||
})
|
||||
public class StationStatusInfoWrapper {
|
||||
|
||||
@JsonProperty("Total")
|
||||
private Integer total;
|
||||
@JsonProperty("StationStatusInfos")
|
||||
private List<StationStatusInfo> stationStatusInfos = null;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("Total")
|
||||
public Integer getTotal() {
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@JsonProperty("Total")
|
||||
public void setTotal(Integer total) {
|
||||
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
@JsonProperty("StationStatusInfos")
|
||||
public List<StationStatusInfo> getStationStatusInfos() {
|
||||
|
||||
return stationStatusInfos;
|
||||
}
|
||||
|
||||
@JsonProperty("StationStatusInfos")
|
||||
public void setStationStatusInfos(List<StationStatusInfo> stationStatusInfos) {
|
||||
|
||||
this.stationStatusInfos = stationStatusInfos;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("total", total).append("stationStatusInfos", stationStatusInfos).append(
|
||||
"additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class StationStatusRequest {
|
||||
|
||||
@JsonProperty("StationIDs")
|
||||
String[] stationIds;
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"Status"
|
||||
})
|
||||
public class Status {
|
||||
|
||||
@JsonProperty("Status")
|
||||
private Integer status;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
public Status() {
|
||||
|
||||
}
|
||||
|
||||
public Status(Integer status) {
|
||||
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@JsonProperty("Status")
|
||||
public Integer getStatus() {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@JsonProperty("Status")
|
||||
public void setStatus(Integer status) {
|
||||
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("status", status).append("additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"OperatorID",
|
||||
"OperatorSecret"
|
||||
})
|
||||
public class TokenRequest {
|
||||
|
||||
@JsonProperty("OperatorID")
|
||||
private String operatorID;
|
||||
@JsonProperty("OperatorSecret")
|
||||
private String operatorSecret;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@JsonProperty("OperatorID")
|
||||
public String getOperatorId() {
|
||||
|
||||
return operatorID;
|
||||
}
|
||||
|
||||
@JsonProperty("OperatorID")
|
||||
public void setOperatorId(String operatorID) {
|
||||
|
||||
this.operatorID = operatorID;
|
||||
}
|
||||
|
||||
@JsonProperty("OperatorSecret")
|
||||
public String getOperatorSecret() {
|
||||
|
||||
return operatorSecret;
|
||||
}
|
||||
|
||||
@JsonProperty("OperatorSecret")
|
||||
public void setOperatorSecret(String operatorSecret) {
|
||||
|
||||
this.operatorSecret = operatorSecret;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setAdditionalProperty(String name, Object value) {
|
||||
|
||||
this.additionalProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("operatorID", operatorID).append("operatorSecret", operatorSecret).append(
|
||||
"additionalProperties", additionalProperties).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@JsonPropertyOrder({
|
||||
"FailReason",
|
||||
"OperatorID",
|
||||
"SuccStat",
|
||||
"AccessToken",
|
||||
"TokenAvailableTime"
|
||||
})
|
||||
public class TokenResponse {
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
Integer failReason;
|
||||
@JsonProperty("OperatorID")
|
||||
String operatorId;
|
||||
@JsonProperty("SuccStat")
|
||||
Integer succStat;
|
||||
@JsonProperty("AccessToken")
|
||||
String accessToken;
|
||||
@JsonProperty("TokenAvailableTime")
|
||||
Integer tokenAvailableTime;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return new ToStringBuilder(this).append("failReason", failReason).append("operatorID", operatorId).append("succStat",
|
||||
succStat).append("accessToken", accessToken).append("tokenAvailableTime", tokenAvailableTime).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
package com.xhpc.evcs.encryption;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
public class Aes128Cbc {
|
||||
|
||||
private static int AES_128 = 128;
|
||||
|
||||
public static String encrypt(String msg, String dataSecret, String dataSecretIV) throws NoSuchAlgorithmException,
|
||||
IllegalBlockSizeException, InvalidKeyException, BadPaddingException,
|
||||
InvalidAlgorithmParameterException, NoSuchPaddingException {
|
||||
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance(CryptoMngr.ALGORITHM);
|
||||
keyGenerator.init(AES_128);
|
||||
byte[] ds = (dataSecret).getBytes(StandardCharsets.UTF_8);
|
||||
ds = Arrays.copyOf(ds, 16);
|
||||
SecretKey key = new SecretKeySpec(ds, "AES");
|
||||
byte[] dsiv = (dataSecretIV).getBytes(StandardCharsets.UTF_8);
|
||||
dsiv = Arrays.copyOf(dsiv, 16);
|
||||
SecretKey IV = new SecretKeySpec(dsiv, "AES");
|
||||
byte[] cipherText = CryptoMngr.encrypt(key.getEncoded(), IV.getEncoded(), msg.getBytes());
|
||||
return Base64.getEncoder().encodeToString(cipherText);
|
||||
}
|
||||
|
||||
public static byte[] decryptBytes(String encryptedMsg, String dataSecret, String dataSecretIV) throws NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException {
|
||||
|
||||
if (encryptedMsg.startsWith("{") || encryptedMsg.startsWith("[")) {
|
||||
throw new IllegalArgumentException("不是合法的加密字符串");
|
||||
}
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance(CryptoMngr.ALGORITHM);
|
||||
keyGenerator.init(AES_128);
|
||||
byte[] ds = (dataSecret).getBytes(StandardCharsets.UTF_8);
|
||||
ds = Arrays.copyOf(ds, 16);
|
||||
SecretKey key = new SecretKeySpec(ds, "AES");
|
||||
byte[] dsiv = (dataSecretIV).getBytes(StandardCharsets.UTF_8);
|
||||
dsiv = Arrays.copyOf(dsiv, 16);
|
||||
SecretKey IV = new SecretKeySpec(dsiv, "AES");
|
||||
byte[] cipherText = Base64.getDecoder().decode(encryptedMsg.getBytes());
|
||||
byte[] decryptedBytes = CryptoMngr.decrypt(key.getEncoded(), IV.getEncoded(), cipherText);
|
||||
return decryptedBytes;
|
||||
}
|
||||
|
||||
public static String decryptString(String encryptedMsg, String dataSecret, String dataSecretIV) throws NoSuchAlgorithmException,
|
||||
IllegalBlockSizeException, InvalidKeyException, BadPaddingException,
|
||||
InvalidAlgorithmParameterException, NoSuchPaddingException {
|
||||
|
||||
if (encryptedMsg == null || encryptedMsg.length() == 0) return "";
|
||||
byte[] decryptedBytes = decryptBytes(encryptedMsg, dataSecret, dataSecretIV);
|
||||
return new String(decryptedBytes);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws BadPaddingException, InvalidAlgorithmParameterException,
|
||||
NoSuchAlgorithmException, IllegalBlockSizeException, UnsupportedEncodingException, NoSuchPaddingException,
|
||||
InvalidKeyException {
|
||||
|
||||
System.out.println(encrypt("{\"PageNo\": \"1\", \"PageSize\": 49}", "8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"));
|
||||
System.out.println(decryptString("ywyEEd5aKPJOTraAY/gXB/bA+UNprpYnSaOhfF5lKc/Zcv" +
|
||||
"/BRasig4KSPJD7UmrH2vjLVIWXPw42EbLgV9bXr5SzUSVAT28ief2nk6hpWnT8Dcvhn3W4bj7UdEY" +
|
||||
"/AdONVXWuq2MZQocGYEVNvWcSD0OVCJ04fNTwPR4hs1xI/QDg9/hqYdQbvWt3go/y" +
|
||||
"+M9wxd4vq8m44RPQ5zjW3vxFxc4oMg2t0oTdk6W5AzJzAGWhU/4xIv+8gLeh6/blpW/VBUK82+4tcdG2JSJv/DcaDM0" +
|
||||
"/7C1LsCYY17o6gGd1mFVDSZhYcaOmOska+h+eyTKL4i8oHpT6uf+hFDRVBUC1OTjDeiL9NyIxcwd" +
|
||||
"/MMfAaF04wHOHrYMavL5wcBUZWwtU1QSLWXkUy7muJNYvVg4dmw92nNKaJtxgFycXVGkSP3Nc6y" +
|
||||
"/sAzYkTz9Wfn4RLVOkpyYJMOo1Tz93/OFEKQFPnjzSRQAVYiuPzuySKjXdcDY8AfqmDqYuVZ2FhH0iVU6FiSsK4" +
|
||||
"+al0hnLOcnftqYtYSd7ir2coP6XtNejOByqFPrShMp4rPQLvDpFibV87clFMwWOGBiB0eFRvRbOSntDYN7PBpFHHJXRkNi3VCMiJ" +
|
||||
"+Y=",
|
||||
"8LpncubmWiPCzY3V"
|
||||
, "av6A8QdnRaVRMXu6"));
|
||||
System.out.println(decryptString("ywyEEd5aKPJOTraAY" +
|
||||
"/gXB5Sz0CiZyWlVKyOoQDHvSZBdtC1aYGzpgAmLAQ7P2f0ArSSVx6xoF8sz2JyXKD00XiHuA4oc1hJnT1mRRetryz8bxmj6m" +
|
||||
"/ClMebuBmtotiKxJqIZr5tayh/hizhcX2L8UUUDmKfp4Q1de1P/swB2VPC8suvrw2Y04r2I2MtF+7mHj1DdDn" +
|
||||
"/DIStLJMLV9tx7xTu2K5fWS1E2ZUv33dVKRcA9qQGFmrI1IFLZyhIFcomv78nzXDg9U6/HRK3/JvtWxm9b6eDO" +
|
||||
"/a5rUwpe1gKPFsVK/MvAXAxU8dmyIzxzC3fLQB1KFcG8XUWrejpakVwh5tKxKhmofWFXlja7FSC" +
|
||||
"/vVdHjL5pOiBAOoxtmBDVPVrua2+/Nz5q9neXdA3olEamKYVCtFSWgSptFjhQb8pGAzSTxwuA+e4fJ5RqeAc+Ka0aHycpvtG" +
|
||||
"/oZZN8+9xhWcnGWj0R8/xsXzFdXOnJ6/DI9SgKOUAzb/AGfHPeJJMibEru+nKrjuo3cNfyue6n6V2hu0Juxr" +
|
||||
"/iLg2zRLVB54wL4Lvy3pi+9ULHzI7SBgKyF6bxxoeuS4YfmaVK+fhseqWNtxk" +
|
||||
"/d8XJu93CqDUoxH5c1IEw16gQ1h9DMhVug2Cg8JbSkIGeFHhCvicOxIuUS2Uc2YgoUTbY0podXkJToBKByGJq7BjNdk49uhFlnHNMO4UZ5LzinsJZxxxdWtUIpqUvTf8a1x210u/IT3BYHQj+K+NeDfbzb2ga6Qdj3+CLL21",
|
||||
"8LpncubmWiPCzY3V"
|
||||
, "av6A8QdnRaVRMXu6"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.xhpc.evcs.encryption;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class CryptoMngr {
|
||||
|
||||
public static String ALGORITHM = "AES";
|
||||
private static String AES_CBS_PADDING = "AES/CBC/PKCS5Padding";
|
||||
|
||||
public static byte[] encrypt(final byte[] key, final byte[] IV, final byte[] message) throws NoSuchPaddingException,
|
||||
InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException,
|
||||
InvalidAlgorithmParameterException {
|
||||
|
||||
return CryptoMngr.encryptDecrypt(Cipher.ENCRYPT_MODE, key, IV, message);
|
||||
}
|
||||
|
||||
public static byte[] decrypt(final byte[] key, final byte[] IV, final byte[] message) throws NoSuchPaddingException,
|
||||
InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException,
|
||||
InvalidAlgorithmParameterException {
|
||||
|
||||
return CryptoMngr.encryptDecrypt(Cipher.DECRYPT_MODE, key, IV, message);
|
||||
}
|
||||
|
||||
private static byte[] encryptDecrypt(final int mode, final byte[] key, final byte[] IV, final byte[] message) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
||||
|
||||
final Cipher cipher = Cipher.getInstance(AES_CBS_PADDING);
|
||||
final SecretKeySpec keySpec = new SecretKeySpec(key, ALGORITHM);
|
||||
final IvParameterSpec ivSpec = new IvParameterSpec(IV);
|
||||
cipher.init(mode, keySpec, ivSpec);
|
||||
return cipher.doFinal(message);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package com.xhpc.evcs.encryption;
|
||||
|
||||
public class EvcsConst {
|
||||
|
||||
public static final String RET_SUCC = "0";//请求成功
|
||||
public static final String RET_FAIl = "1";//请求成功
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.xhpc.evcs.encryption;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@Slf4j
|
||||
public class HMAC {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
System.out.println(hmacDigest("7pogCkwDx5hTmTIimBzlVfl9Qg7RJql+/wqhg2ZvjH2h+ZIGE5wePtN" +
|
||||
"+8TIWseHCPwFZIuw02rY3cV8Q9vgbZMCIdH0CD8SOEdFG7N/2+nfF5liwqUwfM/qKICuiKUQJ9coaOt0lAP85jnQqBITCUDywEau1pO" +
|
||||
"/viFHACpx2OnzyVolyrHc8KjrHSe3VdrHh6lsvDaCamzb79dN96WHTSxuXSuFmDNbJqUvPE0pUicRyc7YYj77OjAaxqeqEO9Sq2Nkf5cG6vfl+UZyKXM5r0YdLrDq8VBLfZn88tJf7D7HQtbtff3XDSrjrK5FSGAp56mlYkQ60+Ia2X0CvJeKa9XyJ14GM/9qaOslOC64F2p4=", "wAeYIVQUwd0iGZsV", "HmacMD5"/*"HmacSHA1"*/));
|
||||
}
|
||||
|
||||
public static String hmacDigest(String operatorID, String data, String timestamp, String seq, String keyString) {
|
||||
|
||||
return hmacDigest(operatorID + data + timestamp + seq, keyString, "HmacMD5");
|
||||
}
|
||||
|
||||
public static String hmacDigest(String msg, String keyString) {
|
||||
|
||||
return hmacDigest(msg, keyString, "HmacMD5");
|
||||
}
|
||||
|
||||
public static String hmacDigest(String msg, String keyString, String algo) {
|
||||
|
||||
String digest = null;
|
||||
try {
|
||||
SecretKeySpec key = new SecretKeySpec(keyString.getBytes(StandardCharsets.UTF_8), algo);
|
||||
Mac mac = Mac.getInstance(algo);
|
||||
mac.init(key);
|
||||
|
||||
byte[] bytes = mac.doFinal(msg.getBytes(StandardCharsets.US_ASCII));
|
||||
|
||||
StringBuffer hash = new StringBuffer();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
String hex = Integer.toHexString(0xFF & bytes[i]);
|
||||
if (hex.length() == 1) {
|
||||
hash.append('0');
|
||||
}
|
||||
hash.append(hex);
|
||||
}
|
||||
digest = hash.toString().toUpperCase();
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();//todo remove pod
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return digest;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.xhpc.evcs.encryption;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class Seq {
|
||||
|
||||
private static Integer seq = null;
|
||||
|
||||
public synchronized static String getNextNIncrease() {
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
DateTime dateTime = new DateTime(calendar);
|
||||
int millisOfSecond = dateTime.getMillisOfSecond();
|
||||
String seqStr;
|
||||
if (seq == null || millisOfSecond == 0) {//第一次获取和新秒重记
|
||||
seq = millisOfSecond;
|
||||
seqStr = String.format("%04d", seq);
|
||||
} else {
|
||||
seq++;
|
||||
seqStr = String.format("%04d", seq);
|
||||
if (seq == 9999) {
|
||||
seq = null; //满9999重记
|
||||
}
|
||||
}
|
||||
return seqStr;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
package com.xhpc.evcs.encryption.cdgov;
|
||||
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* AES 是一种可逆加密算法,对用户的敏感信息加密处理
|
||||
* 对原始数据进行AES加密后,在进行Base64编码转化;
|
||||
* 正确
|
||||
* AES128 位加密,加密模式采用 CBC
|
||||
*/
|
||||
public class AesCBC {
|
||||
/*已确认
|
||||
* 加密用的Key 可以用26个字母和数字组成
|
||||
* 此处使用AES-128-CBC加密模式,key需要为16位。
|
||||
*/
|
||||
|
||||
private static AesCBC instance = null;
|
||||
|
||||
//private static
|
||||
private AesCBC() {
|
||||
|
||||
}
|
||||
|
||||
public static AesCBC getInstance() {
|
||||
|
||||
if (instance == null)
|
||||
instance = new AesCBC();
|
||||
return instance;
|
||||
}
|
||||
|
||||
// 加密
|
||||
public String encrypt(String sSrc, String encodingFormat, String sKey, String ivParameter) throws Exception {
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
byte[] raw = sKey.getBytes();
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
|
||||
IvParameterSpec iv = new IvParameterSpec(ivParameter.getBytes());//使用CBC模式,需要一个向量iv,可增加加密算法的强度
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
|
||||
byte[] encrypted = cipher.doFinal(sSrc.getBytes(encodingFormat));
|
||||
return new String(Base64Utils.encode(encrypted), StandardCharsets.UTF_8);
|
||||
// return new BASE64Encoder().encode(encrypted);//此处使用BASE64做转码。
|
||||
}
|
||||
|
||||
// 解密
|
||||
public String decrypt(String sSrc, String encodingFormat, String sKey, String ivParameter) throws Exception {
|
||||
|
||||
try {
|
||||
byte[] raw = sKey.getBytes("ASCII");
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
IvParameterSpec iv = new IvParameterSpec(ivParameter.getBytes());
|
||||
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
|
||||
byte[] encrypted1 = Base64Utils.decodeFromString(sSrc);//new BASE64Decoder().decodeBuffer(sSrc);//先用base64解密
|
||||
byte[] original = cipher.doFinal(encrypted1);
|
||||
String originalString = new String(original, encodingFormat);
|
||||
return originalString;
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String decrypt(String cSrc) {
|
||||
|
||||
String decrypt = null;
|
||||
try {
|
||||
decrypt = getInstance().decrypt(cSrc, "utf-8", PlatformConfig.sKey, PlatformConfig.ivParameter);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return decrypt;
|
||||
}
|
||||
|
||||
public static String encrypt(String cSrc) throws Exception {
|
||||
|
||||
String encrypt = getInstance().encrypt(cSrc, "utf-8", PlatformConfig.sKey, PlatformConfig.ivParameter);
|
||||
return encrypt.replaceAll("\r", "").replaceAll("\n", "");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// 需要加密的字串
|
||||
String cSrc = "{\"total\":1,\"stationStatusInfo\":{\"operationID\":\"123456789\",\"stationID\":\"111111111111111\"," +
|
||||
"\"con\n" +
|
||||
"nectorStatusInfos\":{\"connectorID\":1,\"equipmentID\":\"10000000000000000000001\",\"status\":4, " +
|
||||
"\"currentA\":0,\"currentB\":0,\"currentC\":0,\"voltageA\":0,\"voltageB\":0,\"voltageC\":0,\"soc\":10,}}}";
|
||||
System.out.println("加密前的字串是:" + cSrc);
|
||||
// 加密
|
||||
String enString = AesCBC.getInstance().encrypt(cSrc, "utf-8", PlatformConfig.sKey, PlatformConfig.ivParameter);
|
||||
System.out.println("加密后的字串是:" + enString);
|
||||
|
||||
System.out.println("1jdzWuniG6UMtoa3T6uNLA==".equals(enString));
|
||||
|
||||
// 解密
|
||||
String DeString = AesCBC.getInstance().decrypt(enString, "utf-8", PlatformConfig.sKey, PlatformConfig.ivParameter);
|
||||
System.out.println("解密后的字串是:" + DeString);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
package com.xhpc.evcs.encryption.cdgov;
|
||||
|
||||
//import com.company.project.platform.config.PlatformConfig;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class HMacMD5 {
|
||||
|
||||
public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
||||
|
||||
String key = "v3i46R8Rsh1CEstf";
|
||||
String OperatorID = "123456789";
|
||||
String Time = "20160729142400";
|
||||
String seq = "0001";
|
||||
String data = "123456789il7B0BSEjFdzpyKzfOFpvg/Se1CP802RItKYFPfSLRxJ3jf0bVl9hvYOEktPAYW2nd7S8MBcyHYy\n" +
|
||||
"acHKbISq5iTmDzG+ivnR+SZJv3USNTYVMz9rCQVSxd0cLlqsJauko79NnwQJbzDTyLooYoIwz7\n" +
|
||||
"5qBOH2/xOMirpeEqRJrF/EQjWekJmGk9RtboXePu2rka+Xm51syBPhiXJAq0GfbfaFu9tNqs/e2Vjj\n" +
|
||||
"a/ltE1M0lqvxfXQ6da6HrThsm5id4ClZFIi0acRfrsPLRixS/IQYtksxghvJwbqOsbIsITail9Ayy4tKcoge\n" +
|
||||
"EZiOO+4Ed264NSKmk7l3wKwJLAFjCFogBx8GE3OBz4pqcAn/ydA=201607291424000001\n" +
|
||||
"9CF107B283E6C9DB44D1CC810476B498";
|
||||
System.out.println(data);
|
||||
String hmacMd5Str = HMacMD5.getHmacMd5Str(key, data);
|
||||
System.out.println(new String(hmacMd5Str));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算参数的md5信息
|
||||
*
|
||||
* @param str 待处理的字节数组
|
||||
* @return md5摘要信息
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static byte[] md5(byte[] str)
|
||||
throws NoSuchAlgorithmException {
|
||||
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str);
|
||||
return md.digest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将待加密数据data,通过密钥key,使用hmac-md5算法进行加密,然后返回加密结果。
|
||||
* 参照rfc2104 HMAC算法介绍实现。
|
||||
*
|
||||
* @param key 密钥
|
||||
* @param data 待加密数据
|
||||
* @return 加密结果
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @author 尹星
|
||||
*/
|
||||
public static byte[] getHmacMd5Bytes(byte[] key, byte[] data) throws NoSuchAlgorithmException {
|
||||
/* HmacMd5 calculation formula: H(K XOR opad, H(K XOR ipad, text))
|
||||
* HmacMd5 计算公式:H(K XOR opad, H(K XOR ipad, text))
|
||||
* H代表hash算法,本类中使用MD5算法,K代表密钥,text代表要加密的数据
|
||||
* ipad为0x36,opad为0x5C。
|
||||
*/
|
||||
int length = 64;
|
||||
byte[] ipad = new byte[length];
|
||||
byte[] opad = new byte[length];
|
||||
for (int i = 0; i < 64; i++) {
|
||||
ipad[i] = 0x36;
|
||||
opad[i] = 0x5C;
|
||||
}
|
||||
byte[] actualKey = key; //Actual key.
|
||||
byte[] keyArr = new byte[length]; //Key bytes of 64 bytes length
|
||||
/*If key's length is longer than 64,then use hash to digest it and use the result as actual key.
|
||||
* 如果密钥长度,大于64字节,就使用哈希算法,计算其摘要,作为真正的密钥。
|
||||
*/
|
||||
if (key.length > length) {
|
||||
actualKey = md5(key);
|
||||
}
|
||||
for (int i = 0; i < actualKey.length; i++) {
|
||||
keyArr[i] = actualKey[i];
|
||||
}
|
||||
|
||||
/*append zeros to K
|
||||
* 如果密钥长度不足64字节,就使用0x00补齐到64字节。
|
||||
*/
|
||||
if (actualKey.length < length) {
|
||||
for (int i = actualKey.length; i < keyArr.length; i++)
|
||||
keyArr[i] = 0x00;
|
||||
}
|
||||
|
||||
/*calc K XOR ipad
|
||||
* 使用密钥和ipad进行异或运算。
|
||||
*/
|
||||
byte[] kIpadXorResult = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
kIpadXorResult[i] = (byte) (keyArr[i] ^ ipad[i]);
|
||||
}
|
||||
|
||||
/*append "text" to the end of "K XOR ipad"
|
||||
* 将待加密数据追加到K XOR ipad计算结果后面。
|
||||
*/
|
||||
byte[] firstAppendResult = new byte[kIpadXorResult.length + data.length];
|
||||
for (int i = 0; i < kIpadXorResult.length; i++) {
|
||||
firstAppendResult[i] = kIpadXorResult[i];
|
||||
}
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
firstAppendResult[i + keyArr.length] = data[i];
|
||||
}
|
||||
|
||||
/*calc H(K XOR ipad, text)
|
||||
* 使用哈希算法计算上面结果的摘要。
|
||||
*/
|
||||
byte[] firstHashResult = md5(firstAppendResult);
|
||||
|
||||
/*calc K XOR opad
|
||||
* 使用密钥和opad进行异或运算。
|
||||
*/
|
||||
byte[] kOpadXorResult = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
kOpadXorResult[i] = (byte) (keyArr[i] ^ opad[i]);
|
||||
}
|
||||
|
||||
/*append "H(K XOR ipad, text)" to the end of "K XOR opad"
|
||||
* 将H(K XOR ipad, text)结果追加到K XOR opad结果后面
|
||||
*/
|
||||
byte[] secondAppendResult = new byte[kOpadXorResult.length + firstHashResult.length];
|
||||
for (int i = 0; i < kOpadXorResult.length; i++) {
|
||||
secondAppendResult[i] = kOpadXorResult[i];
|
||||
}
|
||||
for (int i = 0; i < firstHashResult.length; i++) {
|
||||
secondAppendResult[i + keyArr.length] = firstHashResult[i];
|
||||
}
|
||||
|
||||
/*H(K XOR opad, H(K XOR ipad, text))
|
||||
* 对上面的数据进行哈希运算。
|
||||
*/
|
||||
byte[] hmacMd5Bytes = md5(secondAppendResult);
|
||||
|
||||
return hmacMd5Bytes;
|
||||
|
||||
}
|
||||
|
||||
// public static String getHmacMd5Str(String data){
|
||||
// String hmacMd5Str = getHmacMd5Str(PlatformConfig.SigSecret, data);
|
||||
// return hmacMd5Str;
|
||||
// }
|
||||
public static String getHmacMd5Str(String key, String data) {
|
||||
|
||||
data = data.replaceAll("\n", "").replaceAll("\r", "");
|
||||
String result = "";
|
||||
try {
|
||||
byte[] keyByte = key.getBytes("UTF-8");
|
||||
byte[] dataByte = data.getBytes("UTF-8");
|
||||
byte[] hmacMd5Byte = getHmacMd5Bytes(keyByte, dataByte);
|
||||
StringBuffer md5StrBuff = new StringBuffer();
|
||||
for (int i = 0; i < hmacMd5Byte.length; i++) {
|
||||
if (Integer.toHexString(0xFF & hmacMd5Byte[i]).length() == 1) {
|
||||
|
||||
md5StrBuff.append("0").append(Integer.toHexString(0xFF & hmacMd5Byte[i]));
|
||||
} else {
|
||||
md5StrBuff.append(Integer.toHexString(0xFF & hmacMd5Byte[i]));
|
||||
}
|
||||
}
|
||||
result = md5StrBuff.toString().toUpperCase();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xhpc.evcs.encryption.cdgov;
|
||||
|
||||
/**
|
||||
* @Author lides
|
||||
* @Description
|
||||
* @Date 18-9-15 17:10
|
||||
**/
|
||||
public class PlatformConfig {
|
||||
|
||||
public static final String OperatorID = "734810352";
|
||||
//签名秘钥
|
||||
public static final String SigSecret = "v3i46R8Rsh1CEstf";
|
||||
//秘钥:申请认证使用
|
||||
public static final String OperatorSecret = "Rf5xaS6j7Or2hSBe";
|
||||
//消息秘钥,对数据加秘用
|
||||
public static String sKey = "cPgZQTrkglOuYh2J";
|
||||
//初始化向量
|
||||
public static String ivParameter = "cPgZQTrkglOuYh2J";
|
||||
public static final String notificationUrl = "http://cdhlht.evxian.com:9000/evcs/20160701/";
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package com.xhpc.evcs.http;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class DelegatingServletInputStream extends ServletInputStream {
|
||||
|
||||
private final InputStream sourceStream;
|
||||
|
||||
private boolean finished = false;
|
||||
|
||||
|
||||
/**
|
||||
* Create a DelegatingServletInputStream for the given source stream.
|
||||
*
|
||||
* @param sourceStream the source stream (never {@code null})
|
||||
*/
|
||||
public DelegatingServletInputStream(InputStream sourceStream) {
|
||||
|
||||
this.sourceStream = sourceStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the underlying source stream (never {@code null}).
|
||||
*/
|
||||
public final InputStream getSourceStream() {
|
||||
|
||||
return this.sourceStream;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
|
||||
int data = this.sourceStream.read();
|
||||
if (data == -1) {
|
||||
this.finished = true;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
|
||||
return this.sourceStream.available();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
|
||||
super.close();
|
||||
this.sourceStream.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
|
||||
return this.finished;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.xhpc.evcs.http;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(value = HttpStatus.FORBIDDEN, reason = "Credential is vacant or invalid.")
|
||||
public class ForbiddenException extends RuntimeException {
|
||||
|
||||
public ForbiddenException(String message) {
|
||||
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.xhpc.evcs.http;
|
||||
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.encryption.EvcsConst;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
|
||||
|
||||
@ControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionController extends ResponseEntityExceptionHandler {
|
||||
|
||||
@ExceptionHandler(Throwable.class)
|
||||
public @ResponseBody
|
||||
CommonResponse handleAllException(Throwable e) {
|
||||
|
||||
CommonResponse commonResponse = new CommonResponse();
|
||||
commonResponse.setRet(EvcsConst.RET_FAIl);
|
||||
commonResponse.setMsg(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
return commonResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException e,
|
||||
HttpHeaders headers, HttpStatus status,
|
||||
WebRequest request) {
|
||||
|
||||
String name = e.getParameterName();
|
||||
logger.error(name + " parameter is missing");
|
||||
return super.handleMissingServletRequestParameter(e, headers, status, request);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.xhpc.evcs.http;
|
||||
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpServletRequestRepeatReadWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
private byte[] body;
|
||||
|
||||
public HttpServletRequestRepeatReadWrapper(HttpServletRequest request) {
|
||||
|
||||
super(request);
|
||||
try {
|
||||
body = StreamUtils.copyToByteArray(request.getInputStream());
|
||||
} catch (IOException ex) {
|
||||
body = new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getBody() {
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(byte[] body) {
|
||||
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
|
||||
return new DelegatingServletInputStream(new ByteArrayInputStream(body));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package com.xhpc.evcs.http;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.*;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class HttpServletRequestWritableWrapper extends HttpServletRequestWrapper implements HttpServletRequest {
|
||||
|
||||
private final ByteArrayInputStream decryptedDataBAIS;
|
||||
|
||||
public HttpServletRequestWritableWrapper(HttpServletRequest request, byte[] decryptedData) {
|
||||
|
||||
super(request);
|
||||
decryptedDataBAIS = new ByteArrayInputStream(decryptedData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String headerName) {
|
||||
|
||||
String headerValue = super.getHeader(headerName);
|
||||
if (headerValue != null) {
|
||||
if ("Accept".equalsIgnoreCase(headerName)) {
|
||||
return headerValue.replaceAll(
|
||||
MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_JSON_VALUE);
|
||||
} else if ("Content-Type".equalsIgnoreCase(headerName)) {
|
||||
return headerValue.replaceAll(
|
||||
MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
}
|
||||
return headerValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getHeaders(final String headerName) {
|
||||
|
||||
return super.getHeaders(headerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
|
||||
String contentTypeValue = super.getContentType();
|
||||
if (MediaType.TEXT_PLAIN_VALUE.equalsIgnoreCase(contentTypeValue)) {
|
||||
return MediaType.APPLICATION_JSON_VALUE;
|
||||
}
|
||||
return contentTypeValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws UnsupportedEncodingException {
|
||||
|
||||
return new BufferedReader(new InputStreamReader(decryptedDataBAIS, "UTF-8"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
|
||||
return decryptedDataBAIS.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package com.xhpc.evcs.http;
|
||||
|
||||
public class MediaType {
|
||||
|
||||
public static final String TEXT_PLAIN_VALUE = "text/plain";
|
||||
public static final String APPLICATION_JSON_VALUE = "application/json";
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.xhpc.evcs.http;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public class ServerInternalException extends RuntimeException {
|
||||
|
||||
public ServerInternalException(String message) {
|
||||
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,485 @@
|
||||
package com.xhpc.evcs.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateUtil {
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "yyyyMMddHHmmss";
|
||||
|
||||
public static final String DATE_FORMAT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public static final String DATE_FORMAT_MONTH_TIME = "MM-dd HH:mm";
|
||||
|
||||
public static final String YEAR_MONTH_DAY = "yyyy-MM-dd";
|
||||
|
||||
/**
|
||||
* convert string(such as: 2003-11-26) to Date
|
||||
*
|
||||
* @param dateStr string format of date
|
||||
* @return
|
||||
*/
|
||||
public static final Date string2Date(String dateStr) {
|
||||
|
||||
return string2Date(dateStr + " 00:00:00", DATE_FORMAT_DATE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* string to date, the format is same to SimpleDateFormat for example
|
||||
* "yyyyMMdd" "yyyy-MM-dd HH:mm:ss" etc please see
|
||||
* java.text.SimpleDateFormat
|
||||
*
|
||||
* @param dateStr
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
public static final Date string2Date(String dateStr, String format) {
|
||||
|
||||
if (dateStr == null || dateStr.length() == 0)
|
||||
return null;
|
||||
DateFormat df = new SimpleDateFormat(format);
|
||||
try {
|
||||
return df.parse(dateStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将long型字符串转换成时间格式
|
||||
*
|
||||
* @param dateTime
|
||||
* @return
|
||||
*/
|
||||
public static final String longStr2Date(String dateTime) {
|
||||
|
||||
if (dateTime == null || dateTime.length() == 0)
|
||||
return null;
|
||||
Date date = new Date(Long.parseLong(dateTime));
|
||||
|
||||
return date2String(date, DATE_FORMAT_DATE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert date to string according to default format
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static final String date2String(Date date) {
|
||||
|
||||
return date2String(date, DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert date to string, and the format is same to SimpleDateFormat for
|
||||
* example "yyyyMMdd" "yyyy-MM-dd HH:mm" etc please see
|
||||
* java.text.SimpleDateFormat
|
||||
*
|
||||
* @param date
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
public static final String date2String(Date date, String format) {
|
||||
|
||||
if (date == null) {
|
||||
return "";
|
||||
}
|
||||
DateFormat df = new SimpleDateFormat(format);
|
||||
return df.format(date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* date 2006-04-10 author :zhaopeng
|
||||
*/
|
||||
private static SimpleDateFormat sf = new SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public static Date getWeek(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
|
||||
// int m = c.get(Calendar.DAY_OF_WEEK);
|
||||
// if (m - 1 == 0) {
|
||||
// c.add(Calendar.DAY_OF_WEEK, -6);
|
||||
// } else {
|
||||
// c.add(Calendar.DAY_OF_WEEK, -(m - 2));
|
||||
// }
|
||||
c.add(Calendar.DAY_OF_WEEK, -Calendar.DAY_OF_WEEK);
|
||||
sf.format(c.getTime());
|
||||
return c.getTime();
|
||||
|
||||
}
|
||||
|
||||
public static Date getMonth(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
int m = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
c.add(Calendar.DAY_OF_MONTH, -(m - 1));
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
public static void getMailConsole() {
|
||||
|
||||
}
|
||||
|
||||
public static Date getMonth(Date date, int num) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
c.add(Calendar.MONTH, -num);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
public static Date getYear(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
c.add(Calendar.YEAR, -1);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* add by cjh convert date to string, and the format is same to
|
||||
* SimpleDateFormat for example "yyyyMMdd" "yyyy-MM-dd HH:mm" etc please see
|
||||
* java.text.SimpleDateFormat
|
||||
*
|
||||
* @param date
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
public static final String date2ChineseString(Date date) {
|
||||
|
||||
if (date == null) {
|
||||
return "";
|
||||
}
|
||||
DateFormat df = new SimpleDateFormat("yyyy年M月d日");
|
||||
String str = df.format(date);
|
||||
int yearBorder = str.indexOf("年");
|
||||
int monthBorder = str.indexOf("月");
|
||||
int dayBorder = str.indexOf("日");
|
||||
return getChineseDate(str.substring(0, 1))
|
||||
+ getChineseDate(str.substring(1, 2))
|
||||
+ getChineseDate(str.substring(2, 3))
|
||||
+ getChineseDate(str.substring(3, 4)) + '年'
|
||||
+ getChineseDate(str.substring(yearBorder + 1, monthBorder))
|
||||
+ '月'
|
||||
+ getChineseDate(str.substring(monthBorder + 1, dayBorder))
|
||||
+ '日';
|
||||
}
|
||||
|
||||
/**
|
||||
* add by cjh <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static String getChineseDate(String date) {
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (date.length() == 2) {
|
||||
String ten = date.substring(0, 1); // ʮλ
|
||||
String entries = date.substring(1, 2); // <EFBFBD><EFBFBD>λ
|
||||
if (ten.substring(0).equals("1")) {
|
||||
sb.append("ʮ");
|
||||
}
|
||||
if (ten.substring(0).equals("2")) {
|
||||
sb.append("<EFBFBD><EFBFBD>ʮ");
|
||||
}
|
||||
if (ten.substring(0).equals("3")) {
|
||||
sb.append("<EFBFBD><EFBFBD>ʮ");
|
||||
}
|
||||
if (!entries.equals("0")) {
|
||||
sb.append(number2Chinese(entries));
|
||||
}
|
||||
} else {
|
||||
String entries = date.substring(0);
|
||||
sb.append(number2Chinese(entries));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* add by cjh <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
public static String number2Chinese(String number) {
|
||||
|
||||
char[] numberChars = number.toCharArray();
|
||||
switch (numberChars[0]) {
|
||||
case '0':
|
||||
return "零";
|
||||
case '1':
|
||||
return "一";
|
||||
case '2':
|
||||
return "二";
|
||||
case '3':
|
||||
return "三";
|
||||
case '4':
|
||||
return "四";
|
||||
case '5':
|
||||
return "五";
|
||||
case '6':
|
||||
return "六";
|
||||
case '7':
|
||||
return "七";
|
||||
case '8':
|
||||
return "八";
|
||||
case '9':
|
||||
return "九";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns natural days between beginDate and endDate. Positive number if
|
||||
* beginDate before c2, negative if beginDate after endDate, 0 if beginDate
|
||||
* and endDate represent the same day.
|
||||
*
|
||||
* @param beginDate the begin date
|
||||
* @param endDate the end date
|
||||
* @return natural days between begin date and end date
|
||||
*/
|
||||
|
||||
public static BigDecimal dateToExcel(Date date) {
|
||||
|
||||
Date endDate = DateUtil.string2Date("1900-01-00 00:00", "yyyy-MM-dd HH:mm");
|
||||
int days = naturalDaysBetween(endDate, date);
|
||||
|
||||
return new BigDecimal(days).add(timeToExcel(date));
|
||||
}
|
||||
|
||||
public static BigDecimal timeToExcel(Date date) {
|
||||
|
||||
Calendar c1 = getCalendar(date);
|
||||
|
||||
int hour = c1.get(Calendar.HOUR_OF_DAY);
|
||||
int min = c1.get(Calendar.MINUTE);
|
||||
int sec = c1.get(Calendar.SECOND);
|
||||
System.out.print(new BigDecimal(hour * 3600 + min * 60 + sec).divide(new BigDecimal(86400), 10,
|
||||
BigDecimal.ROUND_HALF_UP).setScale(10, BigDecimal.ROUND_HALF_UP));
|
||||
return new BigDecimal(hour * 3600 + min * 60 + sec).divide(new BigDecimal(86400), 10, BigDecimal.ROUND_HALF_UP).setScale(10, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
|
||||
public static int naturalDaysBetween(Date beginDate, Date endDate) {
|
||||
|
||||
long msPerDay = 1000 * 60 * 60 * 24;
|
||||
Calendar c1 = getCalendar(beginDate);
|
||||
Calendar c2 = getCalendar(endDate);
|
||||
long msDiff = c2.getTimeInMillis() - c1.getTimeInMillis();
|
||||
int days = (int) (msDiff / msPerDay);
|
||||
int msResidue = (int) (msDiff % msPerDay);
|
||||
Calendar c3 = Calendar.getInstance();
|
||||
c3.setTimeInMillis(c2.getTimeInMillis() - msResidue);
|
||||
Calendar c4 = (Calendar) c2.clone();
|
||||
c4.add(Calendar.DAY_OF_MONTH, -1);
|
||||
if (c3.get(Calendar.DAY_OF_MONTH) == c4.get(Calendar.DAY_OF_MONTH))
|
||||
days++;
|
||||
else {
|
||||
c4.add(Calendar.DAY_OF_MONTH, 2);
|
||||
if (c3.get(Calendar.DAY_OF_MONTH) == c4.get(Calendar.DAY_OF_MONTH))
|
||||
days--;
|
||||
}
|
||||
return days;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns natural days,hours and minutes between beginDate and endDate.
|
||||
*
|
||||
* @param beginDate the begin date
|
||||
* @param endDate the end date
|
||||
* @return int[]:[0]:days;[1]:hours;[2]:minutes
|
||||
* @author johnny 2007-1-31
|
||||
*/
|
||||
|
||||
|
||||
public static int[] naturalDHMBetween(Date beginDate, Date endDate) {
|
||||
|
||||
int[] dhm = new int[3];
|
||||
if (beginDate == null || endDate == null)
|
||||
return dhm;
|
||||
long intervalSecond, leftSecond;
|
||||
intervalSecond = leftSecond = (endDate.getTime() - beginDate.getTime()) / 1000;
|
||||
dhm[0] = (int) intervalSecond / (60 * 60 * 24);
|
||||
leftSecond = leftSecond - dhm[0] * 60 * 60 * 24;
|
||||
dhm[1] = (int) leftSecond / (60 * 60);
|
||||
leftSecond = leftSecond - dhm[1] * 60 * 60;
|
||||
dhm[2] = (int) leftSecond / 60;
|
||||
return dhm;
|
||||
}
|
||||
|
||||
public static Calendar getCalendar(Date date) {
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
return c;
|
||||
}
|
||||
|
||||
public static Date earliestOfDate(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
c.set(Calendar.HOUR, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
public static Date latestOfDate(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
c.set(Calendar.HOUR, 23);
|
||||
c.set(Calendar.MINUTE, 59);
|
||||
c.set(Calendar.SECOND, 59);
|
||||
c.set(Calendar.MILLISECOND, 999);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
public static int getHourOfDate(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
return c.get(Calendar.HOUR);
|
||||
}
|
||||
|
||||
public static boolean isFirstDayOfMonth(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
return c.get(Calendar.DATE) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ϊָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><EFBFBD>·ݺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
public static Date addDate(Date date, int year, int month, int day) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
c.add(Calendar.YEAR, year);
|
||||
c.add(Calendar.MONTH, month);
|
||||
c.add(Calendar.DATE, day);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ϊָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>Сʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><EFBFBD>룬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
public static Date addTime(Date date, int hour, int minute, int second,
|
||||
int millisecond) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
c.add(Calendar.HOUR_OF_DAY, hour);
|
||||
c.add(Calendar.MINUTE, minute);
|
||||
c.add(Calendar.SECOND, second);
|
||||
c.add(Calendar.MILLISECOND, millisecond);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
public static Date addDay(Date date, int days) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
c.add(Calendar.DATE, days);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
public static Date getPreviousDate(Date date) {
|
||||
|
||||
return addDay(date, -1);
|
||||
}
|
||||
|
||||
public static boolean isTheSameDay(Date date1, Date date2) {
|
||||
|
||||
String value1 = date2String(date1, DEFAULT_DATE_FORMAT);
|
||||
String value2 = date2String(date2, DEFAULT_DATE_FORMAT);
|
||||
return value1 != null && value1.equals(value2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为周末
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static boolean isWeekend(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
int day = c.get(Calendar.DAY_OF_WEEK);
|
||||
|
||||
return day == 1 || day == 7;
|
||||
}
|
||||
|
||||
public static String week(Date date) {
|
||||
|
||||
Calendar c = getCalendar(date);
|
||||
int day = c.get(Calendar.DAY_OF_WEEK);
|
||||
|
||||
String week = "";
|
||||
switch (day) {
|
||||
case 1:
|
||||
week = "周日";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
week = "周一";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
week = "周二";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
week = "周三";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
week = "周四";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
week = "周五";
|
||||
break;
|
||||
|
||||
case 7:
|
||||
week = "周六";
|
||||
break;
|
||||
}
|
||||
|
||||
return week;
|
||||
}
|
||||
|
||||
public static String getNowDateStr() {
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
int year = now.get(Calendar.YEAR);
|
||||
int month = now.get(Calendar.MONTH) + 1;
|
||||
int day = now.get(Calendar.DAY_OF_MONTH);
|
||||
String dayNames[] = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||
int dayOfWeek = now.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (dayOfWeek < 0) dayOfWeek = 0;
|
||||
String week = dayNames[dayOfWeek];
|
||||
String nowDateStr = year + "年" + month + "月" + day + "日 " + week;
|
||||
|
||||
return nowDateStr;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
DateUtil.isWeekend(new Date());
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-08", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-09", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-10", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-11", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-12", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-13", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-14", "yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package com.xhpc.evcs.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.type.CollectionType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class JSONUtil {
|
||||
|
||||
private static ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* 将一个对象转换成目标对象
|
||||
*
|
||||
* @param src
|
||||
* @param dest
|
||||
* @return
|
||||
*/
|
||||
public static <T> T copyProperties(Object src, Class<T> dest) throws Exception {
|
||||
|
||||
return JSON.parseObject(JSON.toJSONString(src), dest);
|
||||
}
|
||||
|
||||
public static <T> T copyProperties(Object src, JavaType type) throws Exception {
|
||||
|
||||
return JSON.parseObject(JSON.toJSONString(src), type);
|
||||
}
|
||||
|
||||
// 适用于简单对象,复杂对象参考下面的main方法
|
||||
public static <T> T readParams(String params, Class<T> clz) throws IOException {
|
||||
|
||||
return mapper.readValue(params, clz);
|
||||
}
|
||||
|
||||
public static <T> List<T> readParamsList(String data, Class<T> clzo) throws IOException {
|
||||
|
||||
CollectionType javaType = mapper.getTypeFactory()
|
||||
.constructCollectionType(List.class, clzo);
|
||||
return mapper.readValue(data, javaType);
|
||||
}
|
||||
|
||||
public static String toJSONString(Object o) throws JsonProcessingException {
|
||||
|
||||
return mapper.writeValueAsString(o);
|
||||
}
|
||||
|
||||
// 适用于复杂对象的例子
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
String json = "[\n" + "{\n" + " \"id\": \"123\",\n" + " \"phoneNumbers\": [1,2],\n \"gf\": {\"id\":\"1\"," +
|
||||
"\"name\":\"nana\"}\n" + "}\n" + "\n]";
|
||||
byte[] jsonData = json.getBytes();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
//read JSON like DOM Parser
|
||||
JsonNode rootNode = objectMapper.readTree(jsonData);
|
||||
JsonNode idNode = rootNode.path("id");
|
||||
System.out.println("id = " + idNode.asInt());
|
||||
|
||||
JsonNode phoneNosNode = rootNode.path("phoneNumbers");
|
||||
Iterator<JsonNode> elements = phoneNosNode.elements();
|
||||
while (elements.hasNext()) {
|
||||
JsonNode phone = elements.next();
|
||||
System.out.println("Phone No = " + phone.asLong());
|
||||
}
|
||||
JsonNode gfid = rootNode.path("gf").path("id");
|
||||
System.out.println("gf id: " + gfid.asInt());
|
||||
}
|
||||
|
||||
}
|
||||
154
evcs-modules/evcs-core/pom.xml
Normal file
154
evcs-modules/evcs-core/pom.xml
Normal file
@ -0,0 +1,154 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.xhpc</groupId>
|
||||
<artifactId>evcs-modules</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>evcs-core</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xhpc</groupId>
|
||||
<artifactId>evcs-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.9</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.14.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
<version>3.14.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-commons</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Used to support JSONPath usage in testing. -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
</dependency>
|
||||
<!-- Allow for automatic restarts when classpath contents change. -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--阿里数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.properties</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,39 @@
|
||||
package com.xhpc;
|
||||
|
||||
import com.xhpc.evcs.config.EvcsFilter;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.Filter;
|
||||
|
||||
@EntityScan("com.xhpc")
|
||||
@EnableJpaRepositories("com.xhpc")
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class EvcsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(EvcsApplication.class, args);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
@Bean //duplicated to @Component annotation, make doFilter invoke twice, nah... gone?
|
||||
public Filter getEvcsFilter() {
|
||||
|
||||
System.out.println(">>>> bean filter init <<<<");
|
||||
return new EvcsFilter();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package com.xhpc.evcs;
|
||||
|
||||
import com.xhpc.evcs.api.CoreDispatcher;
|
||||
import com.xhpc.evcs.domain.ConnectorStatusInfo;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.PoleStatusInfo;
|
||||
import com.xhpc.evcs.jpa.ConnectorStatusInfoRepository;
|
||||
import com.xhpc.evcs.utils.ChangePoleStatus;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class NotificationPoleStatus2Evshare extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private ConnectorStatusInfoRepository connectorStatusInfoRepository;
|
||||
|
||||
// @Scheduled(fixedRate = 1000 * 60)
|
||||
private void notificationConnectorStatus() throws IOException {
|
||||
|
||||
List<ConnectorStatusInfo> connectorStatusInfos = connectorStatusInfoRepository.findAll();
|
||||
Set<ConnectorStatusInfo> connectorStatusInfoSet = new HashSet<>(connectorStatusInfos.size());
|
||||
CollectionUtils.addAll(connectorStatusInfoSet, connectorStatusInfos);
|
||||
Set<ConnectorStatusInfo> changeStatus = ChangePoleStatus.getChangeStatus(connectorStatusInfoSet);
|
||||
List<PoleStatusInfo> poleStatusInfos = new ArrayList<>();
|
||||
//用于过滤掉集合里重复的充电桩编号
|
||||
Map<String, Integer> infosMap = new HashMap<>();
|
||||
for (ConnectorStatusInfo statusInfo : changeStatus) {
|
||||
String connectorNo = statusInfo.getConnectorID();
|
||||
String poleNo = connectorNo.substring(0, connectorNo.length() - 2); //截掉
|
||||
|
||||
if (statusInfo.getStatus() == 255 || statusInfo.getStatus() == 0) {
|
||||
infosMap.put(poleNo, 2);
|
||||
} else if (statusInfo.getStatus() == 1) {
|
||||
infosMap.put(poleNo, 0);
|
||||
} else {
|
||||
infosMap.put(poleNo, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> keys = infosMap.keySet();
|
||||
for (String key : keys) {
|
||||
PoleStatusInfo poleStatusInfo = new PoleStatusInfo();
|
||||
poleStatusInfo.setPoleNo(key);
|
||||
poleStatusInfo.setStatus(infosMap.get(key));
|
||||
poleStatusInfos.add(poleStatusInfo);
|
||||
}
|
||||
|
||||
if (poleStatusInfos.size() > 0) {
|
||||
notificationPoleStatus2Evshare(poleStatusInfos);
|
||||
}
|
||||
}
|
||||
|
||||
public String notificationPoleStatus2Evshare(@RequestBody List<PoleStatusInfo> poleStatusInfos) throws IOException {
|
||||
|
||||
String data = JSONUtil.toJSONString(poleStatusInfos);
|
||||
CommonRequest<List<PoleStatusInfo>> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId("MA6DFCTD5");
|
||||
commonRequest.setData(data);
|
||||
String responseBody = "";//todo ok(commonRequest, "pole/notification_pole_status");
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.evcs.domain.CDChargeOrderInfo4Bonus;
|
||||
import com.xhpc.evcs.domain.ChargeOrderInfo;
|
||||
import com.xhpc.evcs.domain.StationInfo;
|
||||
import com.xhpc.evcs.dto.ChargeOrderInfoResponse;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.encryption.EvcsConst;
|
||||
import com.xhpc.evcs.jpa.ChargeOrderInfoRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController()
|
||||
public class ChargeOrderInfoController extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private ChargeOrderInfoRepository chargeOrderInfoRepository;
|
||||
|
||||
@PostMapping("/v1/notification_charge_order_info")
|
||||
public CommonResponse notificationChargeOrderInfo(@RequestBody CommonRequest<CDChargeOrderInfo4Bonus> commonRequest) throws IOException {
|
||||
|
||||
String operatorID = commonRequest.getOperatorId();
|
||||
StationInfo stationInfo = new StationInfo();
|
||||
stationInfo.setOperatorId(operatorID);
|
||||
String data = commonRequest.getData();
|
||||
ChargeOrderInfo chargeOrderInfo = JSONUtil.readParams(data, ChargeOrderInfo.class);
|
||||
chargeOrderInfo.setInfraOperatorId("759588065"); //todo use common request operator id?
|
||||
chargeOrderInfo.setBillerOperatorId("MA6DFCTD5");
|
||||
log.info(">>notify charge order OID: " + operatorID);
|
||||
// chargeOrderInfoRepository.save(chargeOrderInfo);
|
||||
CommonResponse response = new CommonResponse();
|
||||
response.setRet(EvcsConst.RET_SUCC);
|
||||
ChargeOrderInfoResponse resp = new ChargeOrderInfoResponse();
|
||||
resp.setConfirmResult(0);
|
||||
resp.setConnectorID(chargeOrderInfo.getConnectorID());
|
||||
resp.setStartChargeSeq(chargeOrderInfo.getStartChargeSeq());
|
||||
response.setData(JSONUtil.toJSONString(resp));
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.evcs.domain.StationInfo;
|
||||
import com.xhpc.evcs.dto.*;
|
||||
import com.xhpc.evcs.encryption.EvcsConst;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController()
|
||||
public class CheckChargeOrderController extends CoreDispatcher {
|
||||
|
||||
@PostMapping("/v1/check_charge_orders")
|
||||
public CommonResponse notificationChargeOrderInfo(@RequestBody CommonRequest<CheckChargeOrderRequestData> commonRequest) throws IOException {
|
||||
|
||||
String operatorID = commonRequest.getOperatorId();
|
||||
StationInfo stationInfo = new StationInfo();
|
||||
stationInfo.setOperatorId(operatorID);
|
||||
String data = commonRequest.getData();
|
||||
CheckChargeOrderRequestData req = JSONUtil.readParams(data, CheckChargeOrderRequestData.class);
|
||||
CommonResponse response = new CommonResponse();
|
||||
response.setRet(EvcsConst.RET_SUCC);
|
||||
CheckChargeOrderResponseData resp = new CheckChargeOrderResponseData();
|
||||
resp.setCheckOrderSeq(req.getCheckOrderSeq());
|
||||
resp.setStartTime(req.getStartTime());
|
||||
resp.setEndTime(req.getEndTime());
|
||||
resp.setDisputeOrders(new DisputeOrder[]{});
|
||||
resp.setTotalDisputeMoney(0.0);
|
||||
resp.setTotalDisputeOrder(0);
|
||||
resp.setTotalDisputePower(0.0);
|
||||
response.setData(JSONUtil.toJSONString(resp));
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,158 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.DTOJsonHelper;
|
||||
import com.xhpc.evcs.dto.TokenRequest;
|
||||
import com.xhpc.evcs.dto.TokenResponse;
|
||||
import com.xhpc.evcs.http.ForbiddenException;
|
||||
import com.xhpc.evcs.http.ServerInternalException;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.jpa.OperatorInfoRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.xhpc.evcs.config.EvcsFilter.encryptReqOut;
|
||||
|
||||
@Slf4j
|
||||
public class CoreDispatcher {
|
||||
|
||||
@Resource
|
||||
OperatorInfoRepository operatorInfoRepository;
|
||||
|
||||
@Value("http://hlht.cd-test.zcsy-inc.cn/evcs/20160701")
|
||||
private String evcsSrvUrl;
|
||||
@Value("true")
|
||||
private boolean oklog = false;
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
public static final okhttp3.MediaType JSON = okhttp3.MediaType.parse("application/json; charset=utf-8");
|
||||
|
||||
@Transactional
|
||||
public String ok(Object object, String url, String operatorId3irdpty, String operatorID) {
|
||||
|
||||
okhttp3.RequestBody body = null;
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (oklog) {
|
||||
builder.addInterceptor(logging);
|
||||
}
|
||||
builder.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.SECONDS);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String bearer = null;
|
||||
AuthSecretToken authSecretTokenOut;
|
||||
try {
|
||||
if (object.getClass().getSimpleName().equals("CommonRequest")) {
|
||||
CommonRequest commonRequest = (CommonRequest) object;
|
||||
if (operatorId3irdpty == null)
|
||||
operatorId3irdpty = commonRequest.getOperatorId();
|
||||
authSecretTokenOut = getAuthSecretTokenOut(operatorId3irdpty, operatorID);
|
||||
Date tokenExpiry = authSecretTokenOut.getTokenExpiry();
|
||||
String oData = commonRequest.getData();
|
||||
String tData;
|
||||
if (tokenExpiry == null || tokenExpiry.before(cal.getTime())) {
|
||||
TokenRequest tokenRequest = new TokenRequest();
|
||||
tokenRequest.setOperatorId(operatorID);
|
||||
tokenRequest.setOperatorSecret(authSecretTokenOut.getOperatorSecret());
|
||||
commonRequest.setData(JSONUtil.toJSONString(tokenRequest));
|
||||
tData = JSONUtil.toJSONString(commonRequest);
|
||||
log.debug(tData);
|
||||
if (authSecretTokenOut.isEncrypt()) {
|
||||
tData = encryptReqOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(),
|
||||
authSecretTokenOut.getSigSecret(), commonRequest);
|
||||
}
|
||||
Request request = new Request.Builder()
|
||||
.url(evcsSrvUrl + "/query_token")
|
||||
.post(okhttp3.RequestBody.create(JSON, tData))
|
||||
.build();
|
||||
OkHttpClient client = builder.build();
|
||||
String tokenResponse = fwdToInfra(request, client);
|
||||
TokenResponse tr = DTOJsonHelper.parseResponseData(tokenResponse, TokenResponse.class, authSecretTokenOut);
|
||||
if (tr != null) {
|
||||
String token = tr.getAccessToken();
|
||||
Integer tokenAvailableTime = tr.getTokenAvailableTime();
|
||||
authSecretTokenOut.setToken(token);
|
||||
authSecretTokenOut.setTokenExpiry(DateUtil.date(Calendar.getInstance().getTimeInMillis() + (tokenAvailableTime) * 1000L - 300));
|
||||
authSecretTokenRepository.save(authSecretTokenOut);
|
||||
}
|
||||
}
|
||||
bearer = authSecretTokenOut.getToken();
|
||||
commonRequest.setData(oData);
|
||||
tData = JSONUtil.toJSONString(commonRequest);
|
||||
if (authSecretTokenOut.isEncrypt()) {
|
||||
tData = encryptReqOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(),
|
||||
authSecretTokenOut.getSigSecret(), commonRequest);
|
||||
}
|
||||
body = okhttp3.RequestBody.create(JSON, tData);
|
||||
}
|
||||
} catch (JsonProcessingException | BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg);
|
||||
throw new ServerInternalException(msg);
|
||||
}
|
||||
final Request.Builder req = new Request.Builder()
|
||||
.url(evcsSrvUrl + url)
|
||||
.header("Authorization", "Bearer " + bearer);
|
||||
Request request;
|
||||
assert body != null;
|
||||
// if (body==null) request = req.get().build();
|
||||
// else
|
||||
request = req.post(body).build();
|
||||
OkHttpClient client = builder.build();
|
||||
return fwdToInfra(request, client);
|
||||
}
|
||||
|
||||
private String fwdToInfra(Request request, OkHttpClient client) {
|
||||
|
||||
String responseBody = null;
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.isSuccessful()) {
|
||||
ResponseBody body = response.body();
|
||||
responseBody = body == null ? null : body.string();
|
||||
} else {
|
||||
int code = response.code();
|
||||
if (code == 401 || code == 403) {
|
||||
throw new ForbiddenException("Remote system returned " + code);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg);
|
||||
throw new ServerInternalException(msg);
|
||||
}
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
private AuthSecretToken getAuthSecretTokenOut(String operatorId3irdpty, String operatorID) {
|
||||
|
||||
return authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType(operatorId3irdpty, operatorID,
|
||||
AuthSecretToken.SECRET_TOKEN_TYPE_OUT).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.evcs.domain.ChargeOrderInfo;
|
||||
import com.xhpc.evcs.dto.*;
|
||||
import com.xhpc.evcs.encryption.EvcsConst;
|
||||
import com.xhpc.evcs.http.ServerInternalException;
|
||||
import com.xhpc.evcs.jpa.ChargeOrderInfoRepository;
|
||||
import com.xhpc.evcs.utils.DateUtil;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController()
|
||||
public class EquipChargeStatusController extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
ChargeOrderInfoRepository chargeOrderInfoRepository;
|
||||
|
||||
@PostMapping("/v1/query_equip_charge_status")
|
||||
public CommonResponse QueryEquipChargeStatus(@RequestBody CommonRequest<ChargeInfoRequest> commonRequest) throws IOException {
|
||||
|
||||
CDEquipChargeStatusCDInfo cdResponse = new CDEquipChargeStatusCDInfo();
|
||||
String data = commonRequest.getData();
|
||||
ChargeInfoRequest chargeInfoRequest = JSONUtil.readParams(data, ChargeInfoRequest.class);
|
||||
String responseBody = "";
|
||||
String startChargeSeq = chargeInfoRequest.getStartChargeSeq();
|
||||
//这里要做一下转换 给成都市那边的订单号是 运营商ID(9位) + 填0(4位) + 四九订单号 填充够27位
|
||||
if ("0000".equals(startChargeSeq.substring(9, 13))) {
|
||||
startChargeSeq = startChargeSeq.substring(13);
|
||||
chargeInfoRequest.setStartChargeSeq(startChargeSeq);
|
||||
}
|
||||
if (startChargeSeq.length() > 14) {
|
||||
XhpcHistoryOrder xhpcHistoryOrder = chargeOrderInfoRepository.findById(startChargeSeq).orElse(null);
|
||||
ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo(xhpcHistoryOrder);
|
||||
if (chargeOrderInfo == null) {
|
||||
throw new ServerInternalException("未查询到该订单编号数据");
|
||||
}
|
||||
cdResponse.setStartChargeSeq(chargeOrderInfo.getStartChargeSeq());
|
||||
cdResponse.setStartChargeSeqStat(chargeOrderInfo.getStartChargeSeqStat());
|
||||
cdResponse.setConnectorID(chargeOrderInfo.getConnectorID());
|
||||
cdResponse.setStartTime(chargeOrderInfo.getStartTime());
|
||||
String endTime;
|
||||
if (chargeOrderInfo.getEndTime() != null) {
|
||||
endTime = chargeOrderInfo.getEndTime();
|
||||
} else {
|
||||
endTime = DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
cdResponse.setEndTime(endTime);
|
||||
cdResponse.setTotalPower(chargeOrderInfo.getTotalPower());
|
||||
cdResponse.setElecMoney(chargeOrderInfo.getTotalElecMoney());
|
||||
cdResponse.setSeviceMoney(chargeOrderInfo.getTotalSeviceMoney());
|
||||
cdResponse.setTotalMoney(chargeOrderInfo.getTotalMoney());
|
||||
|
||||
ChargeDetails detail = new ChargeDetails();
|
||||
detail.setDetailStartTime(cdResponse.getStartTime());
|
||||
detail.setDetailEndTime(endTime);
|
||||
detail.setDetailSeviceMoney(cdResponse.getSeviceMoney());
|
||||
detail.setDetailElecMoney(cdResponse.getElecMoney());
|
||||
detail.setDetailPower(cdResponse.getTotalPower());
|
||||
ChargeDetails[] details = {detail};
|
||||
cdResponse.setChargeDetails(details);
|
||||
|
||||
} else {
|
||||
responseBody = "";//todo ok(chargeInfoRequest, "equip/query_equip_charge_status");
|
||||
cdResponse = JSONUtil.readParams(responseBody, CDEquipChargeStatusCDInfo.class);
|
||||
if (cdResponse.getStartChargeSeq() == null || "".equals(cdResponse.getStartChargeSeq())) {
|
||||
throw new ServerInternalException("未查询到该订单编号数据");
|
||||
} else {
|
||||
String seq = cdResponse.getStartChargeSeq();
|
||||
cdResponse.setStartChargeSeq("MA6DFCTD50000" + seq);
|
||||
}
|
||||
}
|
||||
|
||||
CommonResponse response = new CommonResponse();
|
||||
response.setRet(EvcsConst.RET_SUCC);
|
||||
response.setData(JSONUtil.toJSONString(cdResponse));
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.evcs.dto.*;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class QueryStationStatusController extends CoreDispatcher {
|
||||
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResponse queryStationsInfo(@RequestBody CommonRequest<StationStatusRequest> commonRequest) throws Exception {
|
||||
|
||||
StationStatusRequest stationStatusRequest = JSONUtil.readParams(commonRequest.getData(), StationStatusRequest.class);
|
||||
String stationIDs[] = stationStatusRequest.getStationIds();
|
||||
String data = "";// todo ok(stationIDs, "/weixin/queryStationStatus");
|
||||
List<StationStatusInfo> stationStatusInfo = JSONUtil.readParamsList(data, StationStatusInfo.class);
|
||||
StationStatusInfoWrapper stationStatusInfoWrappers = new StationStatusInfoWrapper();
|
||||
stationStatusInfoWrappers.setTotal(stationStatusInfo.size());
|
||||
stationStatusInfoWrappers.setStationStatusInfos(stationStatusInfo);
|
||||
CommonResponse resp = new CommonResponse();
|
||||
resp.setRet("0");
|
||||
resp.setMsg("");
|
||||
resp.setData(JSONUtil.toJSONString(stationStatusInfoWrappers));
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.xhpc.evcs.config.EvcsFilter;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.dto.TokenRequest;
|
||||
import com.xhpc.evcs.dto.TokenResponse;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@RestController()
|
||||
public class QueryTokenController extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResponse queryToken(@RequestBody TokenRequest tokenRequest) throws IOException {
|
||||
|
||||
log.info("<<query token request body: " + tokenRequest);
|
||||
CommonResponse resp = new CommonResponse();
|
||||
resp.setRet("0");
|
||||
resp.setMsg("");
|
||||
String operatorID = tokenRequest.getOperatorId();
|
||||
TokenResponse tokenResponse = new TokenResponse();
|
||||
tokenResponse.setOperatorId("MA6DFCTD5");
|
||||
tokenResponse.setSuccStat(0);
|
||||
tokenResponse.setFailReason(0);
|
||||
// if (operator == null) {
|
||||
// resp.setRet("4003");
|
||||
// resp.setMsg("Invalid OperatorID");
|
||||
// tokenResponse.setSuccStat(1);
|
||||
// tokenResponse.setFailReason(1);
|
||||
// } else {
|
||||
String data = null;
|
||||
AuthSecretToken authSecretToken = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret(
|
||||
operatorID, AuthSecretToken.SECRET_TOKEN_TYPE_IN, tokenRequest.getOperatorSecret()).orElse(null);
|
||||
if (authSecretToken == null) {
|
||||
resp.setRet("4003");
|
||||
resp.setMsg("Invalid OperatorID/Secret");
|
||||
tokenResponse.setSuccStat(1);
|
||||
tokenResponse.setFailReason(2);
|
||||
resp.setData(data);
|
||||
} else {
|
||||
String token;
|
||||
if (authSecretToken.getTokenExpiry() != null && !authSecretToken.getTokenExpiry().before(Calendar.getInstance().getTime())) {
|
||||
token = authSecretToken.getToken();
|
||||
} else {
|
||||
token = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
authSecretToken.setToken(token);
|
||||
authSecretToken.setTokenExpiry(getTokenExpiry());
|
||||
authSecretTokenRepository.save(authSecretToken);
|
||||
}
|
||||
tokenResponse.setAccessToken(token);
|
||||
tokenResponse.setTokenAvailableTime(7200);
|
||||
tokenResponse.setSuccStat(0);
|
||||
tokenResponse.setFailReason(0);
|
||||
resp.setMsg("Query token success");
|
||||
resp.setData(JSONUtil.toJSONString(tokenResponse));
|
||||
byte[] buf = JSONUtil.toJSONString(resp).getBytes(StandardCharsets.UTF_8);
|
||||
log.debug("out.plain: {}", new String(buf, StandardCharsets.UTF_8));
|
||||
final JsonNode encrypt = EvcsFilter.encryptRespOut(authSecretToken.getDataSecret(),
|
||||
authSecretToken.getDataSecretIV(), authSecretToken.getSigSecret(), buf);
|
||||
resp.setData(encrypt.get("Data"));
|
||||
resp.setSig(encrypt.get("Sig").asText());
|
||||
log.debug("out.enc: {}", resp);
|
||||
}
|
||||
// }
|
||||
return resp;
|
||||
}
|
||||
|
||||
private Date getTokenExpiry() {
|
||||
|
||||
DateTime dt = new DateTime();
|
||||
dt = dt.plusSeconds(7200);
|
||||
return dt.toDate();
|
||||
}
|
||||
|
||||
private AuthSecretToken getAuthSecretToken(String operatorID, String tokenType) {
|
||||
|
||||
return authSecretTokenRepository.findByOperatorIdAndSecretTokenType(operatorID, tokenType).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.dto.NotificationStartChargeResultRequestData;
|
||||
import com.xhpc.evcs.dto.NotificationStartStopChargeResultResponse;
|
||||
import com.xhpc.evcs.encryption.EvcsConst;
|
||||
import com.xhpc.evcs.jpa.ChargeOrderInfoRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController()
|
||||
public class StartChargeResultController extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private ChargeOrderInfoRepository chargeOrderInfoRepository;
|
||||
|
||||
@PostMapping("/v1/notification_start_charge_result")
|
||||
public CommonResponse notifyStartChargeResult(@RequestBody CommonRequest<NotificationStartChargeResultRequestData> commonRequest) throws IOException {
|
||||
|
||||
String data = commonRequest.getData();
|
||||
NotificationStartChargeResultRequestData startChargeResultRequest = JSONUtil.readParams(data,
|
||||
NotificationStartChargeResultRequestData.class);
|
||||
String startChargeSeq = startChargeResultRequest.getStartChargeSeq();
|
||||
// ChargeOrderInfo chargeOrderInfo = chargeOrderInfoRepository.findById(startChargeSeq).orElse(new ChargeOrderInfo()
|
||||
// .setStartChargeSeqAndReturn(startChargeSeq));
|
||||
// chargeOrderInfo.setStartChargeSeqStat(startChargeResultRequest.getStartChargeSeqStat());
|
||||
// chargeOrderInfo.setIdentCode(startChargeResultRequest.getIdentCode());
|
||||
// chargeOrderInfoRepository.save(chargeOrderInfo); todo
|
||||
CommonResponse response = new CommonResponse();
|
||||
response.setRet(EvcsConst.RET_SUCC);
|
||||
NotificationStartStopChargeResultResponse resp = new NotificationStartStopChargeResultResponse();
|
||||
resp.setSuccStat(0);
|
||||
resp.setFailReason(0);
|
||||
resp.setStartChargeSeq(startChargeResultRequest.getStartChargeSeq());
|
||||
response.setData(JSONUtil.toJSONString(resp));
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.evcs.domain.ConnectorStatusInfo;
|
||||
import com.xhpc.evcs.domain.StationInfo;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.dto.Status;
|
||||
import com.xhpc.evcs.encryption.EvcsConst;
|
||||
import com.xhpc.evcs.jpa.ConnectorStatusInfoRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController()
|
||||
public class StationStatusController extends CoreDispatcher {
|
||||
|
||||
@Resource
|
||||
ConnectorStatusInfoRepository connectorStatusInfoRepository;
|
||||
|
||||
@PostMapping("/v1/notification_stationStatus")
|
||||
public CommonResponse notificationStationStatus(@RequestBody CommonRequest<ConnectorStatusInfo> commonRequest) throws IOException {
|
||||
|
||||
String operatorID = commonRequest.getOperatorId();
|
||||
StationInfo stationInfo = new StationInfo();
|
||||
stationInfo.setOperatorId(operatorID);
|
||||
ConnectorStatusInfo connectorStatusInfo = commonRequest.anyDataType(ConnectorStatusInfo.class, "ConnectorStatusInfo");
|
||||
connectorStatusInfoRepository.save(connectorStatusInfo);
|
||||
CommonResponse response = new CommonResponse();
|
||||
response.setRet(EvcsConst.RET_SUCC);
|
||||
response.setData(JSONUtil.toJSONString(new Status(0)));
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,157 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.common.api.dto.ChargingStationDto;
|
||||
import com.xhpc.evcs.domain.StationInfo;
|
||||
import com.xhpc.evcs.domain.XhpcChargingPile;
|
||||
import com.xhpc.evcs.domain.XhpcChargingStation;
|
||||
import com.xhpc.evcs.dto.*;
|
||||
import com.xhpc.evcs.jpa.XhpcChargingPileRepository;
|
||||
import com.xhpc.evcs.jpa.XhpcChargingStationRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class StationsInfoController extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private XhpcChargingPileRepository xhpcChargingPileRepository;
|
||||
@Autowired
|
||||
private XhpcChargingStationRepository xhpcChargingStationRepository;
|
||||
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResponse queryStationsInfo(@RequestBody CommonRequest<PageRequest> commonRequest) throws Exception {
|
||||
|
||||
assert false;
|
||||
String operatorId = commonRequest.getOperatorId();
|
||||
final PageRequest pageRequest = commonRequest.anyDataType(PageRequest.class);
|
||||
List<StationInfo> stations = new ArrayList<>();
|
||||
int pageCount = 1;
|
||||
if (operatorId.equals("765367656")) {
|
||||
List<String> stationKeys = new ArrayList<>(REDIS.keys("station:*"));
|
||||
final Integer pageSize = pageRequest.getPageSize();
|
||||
int fullpage = stationKeys.size() == 0 ? 0 : stationKeys.size() / pageSize;
|
||||
final Integer pageNo = pageRequest.getPageNo();
|
||||
int plus = stationKeys.size() % pageSize;
|
||||
assert (pageCount >= pageNo) : "too large pageNo";
|
||||
pageCount = fullpage + (plus == 0 ? 0 : 1);
|
||||
if (pageCount >= pageNo) {
|
||||
Integer lastOne = stationKeys.size() < pageNo * pageSize ? stationKeys.size() : pageNo * pageSize;
|
||||
for (int i = ((pageNo - 1) * pageSize); i < lastOne; i++) {
|
||||
final String stationKey = stationKeys.get(i);
|
||||
ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey);
|
||||
if (chargingStationDto.getPiles() != null) {
|
||||
StationInfo station = new StationInfo();
|
||||
station.setStationStatus(50L);
|
||||
final String stationId = stationKey.replace("station:", "");
|
||||
station.setStationId(stationId);
|
||||
Double lat = chargingStationDto.getLat();
|
||||
if (lat == null) {
|
||||
XhpcChargingStation stationExample = new XhpcChargingStation();
|
||||
stationExample.setId(Long.parseLong(stationId));
|
||||
Example<XhpcChargingStation> example = Example.of(stationExample);
|
||||
XhpcChargingStation xhpcChargingStation =
|
||||
xhpcChargingStationRepository.findOne(example).orElse(null);
|
||||
if (null != xhpcChargingStation) {
|
||||
chargingStationDto.setLat(Double.valueOf(xhpcChargingStation.getLatitude()));
|
||||
chargingStationDto.setLng(Double.valueOf(xhpcChargingStation.getLongitude()));
|
||||
chargingStationDto.setType(Long.valueOf(xhpcChargingStation.getType()));
|
||||
chargingStationDto.setOperatorId(xhpcChargingStation.getOperatorIdEvcs() == null ? "MA6DFCTD5"
|
||||
: xhpcChargingStation.getOperatorIdEvcs());
|
||||
chargingStationDto.setAreaCode(xhpcChargingStation.getAreaCode().toString());
|
||||
REDIS.setCacheObject(stationKey, chargingStationDto);
|
||||
}
|
||||
}
|
||||
station.setStationLat(chargingStationDto.getLat());
|
||||
station.setStationLng(chargingStationDto.getLng());
|
||||
station.setStationType(chargingStationDto.getType());
|
||||
station.setOperatorId(chargingStationDto.getOperatorId());
|
||||
station.setEquipmentOwnerId(chargingStationDto.getOperatorId());
|
||||
station.setAreaCode(chargingStationDto.getAreaCode());
|
||||
station.setConstruction(chargingStationDto.getConstruction());
|
||||
List<EquipmentInfo> piles = getEquipmentInfos(chargingStationDto.getPiles());
|
||||
station.setEquipmentInfos(piles);
|
||||
stations.add(station);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PageStationsInfoResponse response = new PageStationsInfoResponse();
|
||||
response.setItemSize(stations.size());
|
||||
response.setPageNo(pageRequest.getPageNo());
|
||||
response.setPageCount(pageCount);
|
||||
response.setStationInfos(stations);
|
||||
CommonResponse resp = new CommonResponse();
|
||||
resp.setRet("0");
|
||||
resp.setMsg("Query station info success");
|
||||
resp.setData(JSONUtil.toJSONString(response));
|
||||
return resp;
|
||||
}
|
||||
|
||||
private List<EquipmentInfo> getEquipmentInfos(Set<String> pileNoSet) {
|
||||
|
||||
List<EquipmentInfo> equipmentInfos = new ArrayList<>();
|
||||
for (String pileNo : pileNoSet) {
|
||||
final Map<String, Object> cachePile = REDIS.getCacheMap("pile:".concat(pileNo));
|
||||
Integer connectorType = (Integer) cachePile.get("connectorType");
|
||||
if (connectorType == null) {
|
||||
XhpcChargingPile pileExample = new XhpcChargingPile();
|
||||
pileExample.setSerialNumber(pileNo);
|
||||
Example<XhpcChargingPile> example = Example.of(pileExample);
|
||||
XhpcChargingPile xhpcChargingPile = xhpcChargingPileRepository.findOne(example).orElse(null);
|
||||
if (xhpcChargingPile != null) {
|
||||
cachePile.put("connectorType", xhpcChargingPile.getType() == 1 ? Integer.valueOf(4) : Integer.valueOf(3));
|
||||
cachePile.put("voltageUpperLimits", xhpcChargingPile.getMaxVoltage().intValue());
|
||||
cachePile.put("voltageLowerLimits", xhpcChargingPile.getMinVoltage().intValue());
|
||||
cachePile.put("current", xhpcChargingPile.getCurrent());
|
||||
cachePile.put("power", xhpcChargingPile.getPower());
|
||||
cachePile.put("nationalStandard", xhpcChargingPile.getNationalStandard().equals("2011") ?
|
||||
Integer.valueOf(1) : Integer.valueOf(2));
|
||||
cachePile.put("equipmentType", xhpcChargingPile.getType());
|
||||
REDIS.setCacheMap("pile:".concat(pileNo), cachePile);
|
||||
}
|
||||
}
|
||||
EquipmentInfo equipmentInfo = new EquipmentInfo();
|
||||
equipmentInfo.setEquipmentID(pileNo);
|
||||
equipmentInfo.setEquipmentType((Integer) cachePile.get("equipmentType"));
|
||||
equipmentInfo.setPower((Double) cachePile.get("power"));
|
||||
equipmentInfo.setConnectorInfos(getConnectorInfos(pileNo, cachePile));
|
||||
equipmentInfos.add(equipmentInfo);
|
||||
}
|
||||
return equipmentInfos;
|
||||
}
|
||||
|
||||
private List<ConnectorInfo> getConnectorInfos(String pileNo, Map<String, Object> cachePile) {
|
||||
|
||||
List<ConnectorInfo> connectorInfos = new ArrayList<>();
|
||||
final Object gunNumCache = cachePile.get("gunNum");
|
||||
if (gunNumCache == null) return connectorInfos;
|
||||
int gunNum = (int) gunNumCache;
|
||||
for (int i = 1; i <= gunNum; i++) {
|
||||
String gunId = pileNo.concat(String.format("%02d", i));
|
||||
ConnectorInfo connectorInfo = new ConnectorInfo();
|
||||
connectorInfo.setConnectorID(gunId);
|
||||
connectorInfo.setConnectorType((Integer) cachePile.get("connectorType"));
|
||||
connectorInfo.setVoltageUpperLimits((Integer) cachePile.get("voltageUpperLimits"));
|
||||
connectorInfo.setVoltageLowerLimits((Integer) cachePile.get("voltageLowerLimits"));
|
||||
connectorInfo.setCurrent((Integer) cachePile.get("current"));
|
||||
connectorInfo.setPower((Double) cachePile.get("power"));
|
||||
connectorInfo.setNationalStandard((Integer) cachePile.get("nationalStandard"));
|
||||
connectorInfos.add(connectorInfo);
|
||||
}
|
||||
return connectorInfos;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.dto.NotificationStartStopChargeResultResponse;
|
||||
import com.xhpc.evcs.dto.NotificationStopChargeResultRequestData;
|
||||
import com.xhpc.evcs.encryption.EvcsConst;
|
||||
import com.xhpc.evcs.jpa.ChargeOrderInfoRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController()
|
||||
public class StopChargeResultController extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private ChargeOrderInfoRepository chargeOrderInfoRepository;
|
||||
|
||||
@PostMapping("/v1/notification_stop_charge_result")
|
||||
public CommonResponse notifyStartChargeResult(@RequestBody CommonRequest<NotificationStopChargeResultRequestData> commonRequest) throws IOException {
|
||||
|
||||
String data = commonRequest.getData();
|
||||
NotificationStopChargeResultRequestData stopChargeResultRequestData = JSONUtil.readParams(data,
|
||||
NotificationStopChargeResultRequestData.class);
|
||||
String startChargeSeq = stopChargeResultRequestData.getStartChargeSeq();
|
||||
// ChargeOrderInfo chargeOrderInfo = chargeOrderInfoRepository.findById(startChargeSeq).orElse(new ChargeOrderInfo()
|
||||
// .setStartChargeSeqAndReturn(startChargeSeq));
|
||||
// chargeOrderInfo.setStartChargeSeqStat(stopChargeResultRequestData.getStartChargeSeqStat());
|
||||
// chargeOrderInfo.setFailReason(stopChargeResultRequestData.getFailReason());
|
||||
// chargeOrderInfoRepository.save(chargeOrderInfo); todo
|
||||
CommonResponse response = new CommonResponse();
|
||||
response.setRet(EvcsConst.RET_SUCC);
|
||||
NotificationStartStopChargeResultResponse resp = new NotificationStartStopChargeResultResponse();
|
||||
resp.setSuccStat(0);
|
||||
resp.setFailReason(0);
|
||||
resp.setStartChargeSeq(stopChargeResultRequestData.getStartChargeSeq());
|
||||
response.setData(JSONUtil.toJSONString(resp));
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.xhpc.evcs.cd;
|
||||
|
||||
import com.xhpc.evcs.api.CoreDispatcher;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@Slf4j
|
||||
public abstract class CDCoreDispatcher extends CoreDispatcher {
|
||||
|
||||
@Value("${xhpc.evcs.cdevcs.srv.url}")
|
||||
public String evcsSrvUrl;
|
||||
|
||||
public String getEvcsSrvUrl() {
|
||||
|
||||
return evcsSrvUrl;
|
||||
}
|
||||
|
||||
public void setEvcsSrvUrl(String evcsSrvUrl) {
|
||||
|
||||
this.evcsSrvUrl = evcsSrvUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
package com.xhpc.evcs.cd;
|
||||
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.domain.CDChargeOrderInfo4Bonus;
|
||||
import com.xhpc.evcs.domain.EtOrderMapping;
|
||||
import com.xhpc.evcs.domain.XhpcStatisticsTimeInterval;
|
||||
import com.xhpc.evcs.dto.ChargeOrderInfoResponse;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.DTOJsonHelper;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.jpa.ChargeOrderInfoRepository;
|
||||
import com.xhpc.evcs.jpa.EtOrderMappingRepository;
|
||||
import com.xhpc.evcs.jpa.StatisticTimeIntervalRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.xhpc.evcs.cd.NotificationEquipChargeStatusTask.transferInternetOrderNo;
|
||||
import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT;
|
||||
|
||||
@Component
|
||||
public class NotificationChargeOrderInfo4BonusTask extends CDCoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private ChargeOrderInfoRepository chargeOrderInfoRepository;
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
@Autowired
|
||||
private StatisticTimeIntervalRepository statisticTimeIntervalRepository;
|
||||
@Autowired
|
||||
private EtOrderMappingRepository etOrderMappingRepository;
|
||||
private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfo4BonusTask.class);
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 60)
|
||||
public void run() throws IOException {
|
||||
|
||||
AuthSecretToken authSecretTokenOut =
|
||||
authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType(
|
||||
"765367656", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); //todo
|
||||
// maybe对接第三方
|
||||
if (authSecretTokenOut != null) {
|
||||
final List<XhpcHistoryOrder> notYetPushOrder =
|
||||
chargeOrderInfoRepository.findByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(authSecretTokenOut.getLastPushOrder(), 0);
|
||||
for (XhpcHistoryOrder xhpcHistoryOrder : notYetPushOrder) {
|
||||
List<XhpcStatisticsTimeInterval> statisticTimeIntervalList =
|
||||
statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId());
|
||||
xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList);
|
||||
notify(xhpcHistoryOrder, authSecretTokenOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void notify(XhpcHistoryOrder xhpcHistoryOrder, AuthSecretToken authSecretTokenOut) throws IOException {
|
||||
|
||||
String xhOrderNo = xhpcHistoryOrder.getSerialNumber();
|
||||
EtOrderMapping etOrderMapping = saveOrderMapping(xhOrderNo, etOrderMappingRepository);
|
||||
CDChargeOrderInfo4Bonus cdChargeOrderInfo4Bonus = new CDChargeOrderInfo4Bonus(xhpcHistoryOrder, etOrderMapping);
|
||||
String operatorIdEvcs = xhpcHistoryOrder.getOperatorIdEvcs();
|
||||
operatorIdEvcs = operatorIdEvcs == null ? "MA6DFCTD5" : operatorIdEvcs;
|
||||
String data = JSONUtil.toJSONString(cdChargeOrderInfo4Bonus);
|
||||
logger.debug(data);
|
||||
CommonRequest<CDChargeOrderInfo4Bonus> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId(operatorIdEvcs);
|
||||
commonRequest.setData(data);
|
||||
String responseBody = ok(commonRequest, "/notification_charge_order_info_for_bonus", "765367656", operatorIdEvcs);
|
||||
ChargeOrderInfoResponse chargeOrderInfoResponse = DTOJsonHelper.parseResponseData(responseBody,
|
||||
ChargeOrderInfoResponse.class, authSecretTokenOut);
|
||||
if (chargeOrderInfoResponse != null && chargeOrderInfoResponse.getConfirmResult() == 0) {
|
||||
authSecretTokenOut.setLastPushOrder(xhpcHistoryOrder.getHistoryOrderId());
|
||||
authSecretTokenRepository.save(authSecretTokenOut);
|
||||
} else {
|
||||
throw new RuntimeException(String.format("push CD notification order[%s] failed: %s",
|
||||
xhpcHistoryOrder.getSerialNumber(), responseBody));
|
||||
}
|
||||
}
|
||||
|
||||
static EtOrderMapping saveOrderMapping(String xhOrderNo, EtOrderMappingRepository etOrderMappingRepository) {
|
||||
|
||||
EtOrderMapping om = new EtOrderMapping();
|
||||
om.setXhOrderNo(xhOrderNo);
|
||||
Example<EtOrderMapping> example = Example.of(om);
|
||||
EtOrderMapping etOrderMapping = etOrderMappingRepository.findOne(example).orElse(null);
|
||||
if (etOrderMapping == null) {
|
||||
etOrderMapping = new EtOrderMapping();
|
||||
etOrderMapping.setXhOrderNo(xhOrderNo);
|
||||
etOrderMapping.setEvcsOrderNo(transferInternetOrderNo(xhOrderNo));
|
||||
etOrderMapping = etOrderMappingRepository.save(etOrderMapping);
|
||||
}
|
||||
return etOrderMapping;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,221 @@
|
||||
package com.xhpc.evcs.cd;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.xhpc.common.data.redis.CacheRateModel;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.domain.CDChargeOrderInfo4Bonus;
|
||||
import com.xhpc.evcs.dto.*;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.jpa.EtOrderMappingRepository;
|
||||
import com.xhpc.evcs.jpa.StatisticTimeIntervalRepository;
|
||||
import com.xhpc.evcs.utils.DateUtil;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||
import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT;
|
||||
import static com.xhpc.evcs.utils.DateUtil.DATE_FORMAT_DATE_TIME;
|
||||
|
||||
@Component
|
||||
public class NotificationEquipChargeStatusTask extends CDCoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
@Autowired
|
||||
private StatisticTimeIntervalRepository statisticTimeIntervalRepository;
|
||||
@Autowired
|
||||
private EtOrderMappingRepository etOrderMappingRepository;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(NotificationEquipChargeStatusTask.class);
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 50)
|
||||
public void run() throws IOException {
|
||||
|
||||
AuthSecretToken authSecretTokenOut =
|
||||
authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType(
|
||||
"765367656", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); //todo
|
||||
// maybe对接第三方
|
||||
if (authSecretTokenOut != null) {
|
||||
final Collection<String> gunkeys = REDIS.keys("gun:*");
|
||||
for (String gunkey : gunkeys) {
|
||||
if (!gunkey.endsWith(".seqdec") && !gunkey.endsWith(".seqhex") && !gunkey.endsWith(".hori")) {
|
||||
final Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||
final String status = cacheGun.get("status").toString();
|
||||
if (isInteger(status)) {
|
||||
final String orderkey = cacheGun.get("orderkey").toString();
|
||||
CDEquipChargeStatusCDInfo equipChargeStatusCD = new CDEquipChargeStatusCDInfo();
|
||||
equipChargeStatusCD.setStartChargeSeq(transferInternetOrderNo(orderkey));
|
||||
equipChargeStatusCD.setStartChargeSeqStat(2);
|
||||
equipChargeStatusCD.setConnectorID(orderkey.substring(6, 22));
|
||||
String current = REDIS.getCacheMapValue(gunkey, "current");
|
||||
equipChargeStatusCD.setCurrentA(Integer.parseInt(current == null ? "10" : current, 16) / 100.0);
|
||||
String voltage = REDIS.getCacheMapValue(gunkey, "voltage");
|
||||
equipChargeStatusCD.setVoltageA(Integer.parseInt(voltage == null ? "300" : voltage, 16) / 100.0);
|
||||
Double soc = REDIS.getCacheMapValue(gunkey, "endSoc");
|
||||
equipChargeStatusCD.setSoc(soc == null ? 0 : soc);
|
||||
equipChargeStatusCD.setStartTime(cacheGun.get("orderstarttime").toString());
|
||||
equipChargeStatusCD.setEndTime(DateUtil.date2String(Calendar.getInstance().getTime(),
|
||||
DATE_FORMAT_DATE_TIME));
|
||||
equipChargeStatusCD.setChargeModel(3);
|
||||
equipChargeStatusCD.setTotalPower(REDIS.getCacheMapValue(orderkey, "totalPower"));
|
||||
equipChargeStatusCD.setTotalMoney(REDIS.getCacheMapValue(orderkey, "totalMoney"));
|
||||
final Long rateModelId = REDIS.getCacheMapValue(gunkey.replace("gun", "pile").substring(0, 19),
|
||||
"rateModelId");
|
||||
final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
||||
calculateEm(equipChargeStatusCD, cacheRateModel);
|
||||
notify(equipChargeStatusCD, authSecretTokenOut);
|
||||
String xhOrderNo = orderkey.substring(6);
|
||||
NotificationChargeOrderInfo4BonusTask.saveOrderMapping(xhOrderNo, etOrderMappingRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String transferInternetOrderNo(String orderKeyOrNo) {
|
||||
|
||||
return "MA6DFCTD5".concat(DateUtil.getYYYY()).concat(orderKeyOrNo.replace("order:", "").substring(18));
|
||||
}
|
||||
|
||||
private void calculateEm(CDEquipChargeStatusCDInfo equipChargeStatusCD, CacheRateModel cacheRateModel) {
|
||||
|
||||
final Date endTime = DateUtil.string2Date(equipChargeStatusCD.getEndTime());
|
||||
final Date startTime = DateUtil.string2Date(equipChargeStatusCD.getStartTime());
|
||||
long totalMilSec = endTime.getTime() - startTime.getTime();
|
||||
BigDecimal hours = new BigDecimal(totalMilSec).divide(new BigDecimal(3600000), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal minutes = new BigDecimal(totalMilSec).divide(new BigDecimal(60000), 2, RoundingMode.HALF_UP);
|
||||
equipChargeStatusCD.setSumPeriod(hours.setScale(0, RoundingMode.CEILING).intValue());
|
||||
final Integer sumPeriod = equipChargeStatusCD.getSumPeriod();
|
||||
DateTime firstNDT = DateTime.of(startTime);
|
||||
List<ChargeDetails> chargeDetails = new ArrayList<>();
|
||||
Double firstNElecMoney = 0.0;
|
||||
for (int i = 0; i < sumPeriod - 1; i++) {
|
||||
ChargeDetails cd = new ChargeDetails();
|
||||
int firstSTHourOfDay = firstNDT.getField(DateField.HOUR_OF_DAY);
|
||||
int tf = (firstSTHourOfDay + i) * 2;
|
||||
final String rtf = cacheRateModel.getTfPricesSeq()[tf];
|
||||
BigDecimal timePeriodRatio = BigDecimal.valueOf(60).divide(minutes, 2, RoundingMode.HALF_UP);
|
||||
BigDecimal tpPower = BigDecimal.valueOf(equipChargeStatusCD.getTotalPower()).multiply(timePeriodRatio);
|
||||
calculateCD(equipChargeStatusCD, cacheRateModel, rtf, timePeriodRatio, tpPower, cd);
|
||||
if (i == 0) {
|
||||
cd.setDetailStartTime(equipChargeStatusCD.getStartTime());
|
||||
} else {
|
||||
if (firstSTHourOfDay == 23) {
|
||||
firstNDT.setField(DateField.DAY_OF_MONTH, firstNDT.getField(DateField.DAY_OF_MONTH) + 1);
|
||||
firstNDT.setField(DateField.HOUR_OF_DAY, 0);//todo no, there are more to considered like day of month,
|
||||
// month of year etc...
|
||||
} else {
|
||||
firstNDT.setField(DateField.HOUR_OF_DAY, firstSTHourOfDay + 1);
|
||||
}
|
||||
firstNDT.setField(DateField.MINUTE, 0);
|
||||
firstNDT.setField(DateField.SECOND, 0);
|
||||
cd.setDetailStartTime(firstNDT.toString(DATE_FORMAT_DATE_TIME));
|
||||
}
|
||||
firstNElecMoney += cd.getDetailElecMoney();
|
||||
chargeDetails.add(cd);
|
||||
}
|
||||
DateTime lastDT = DateTime.of(endTime);
|
||||
int tf = (lastDT.getField(DateField.HOUR_OF_DAY)) * 2;
|
||||
final String rtf = cacheRateModel.getTfPricesSeq()[tf];
|
||||
BigDecimal timePeriodRatio = BigDecimal.valueOf(60).divide(minutes, 2, RoundingMode.HALF_UP);
|
||||
BigDecimal tpPower = BigDecimal.valueOf(equipChargeStatusCD.getTotalPower())
|
||||
.multiply(timePeriodRatio).divide(BigDecimal.valueOf(100000), 2, RoundingMode.HALF_UP);
|
||||
ChargeDetails cd = new ChargeDetails();
|
||||
calculateCD(equipChargeStatusCD, cacheRateModel, rtf, timePeriodRatio, tpPower, cd);
|
||||
firstNElecMoney += cd.getDetailElecMoney();
|
||||
cd.setDetailStartTime(firstNDT.toString(DATE_FORMAT_DATE_TIME));
|
||||
chargeDetails.add(cd);
|
||||
ChargeDetails[] cda = new ChargeDetails[chargeDetails.size()];
|
||||
equipChargeStatusCD.setChargeDetails(chargeDetails.toArray(cda));
|
||||
equipChargeStatusCD.setSumPeriod(sumPeriod);
|
||||
equipChargeStatusCD.setElecMoney(firstNElecMoney);
|
||||
equipChargeStatusCD.setSeviceMoney(equipChargeStatusCD.getTotalMoney() - firstNElecMoney);
|
||||
}
|
||||
|
||||
private void calculateCD(CDEquipChargeStatusCDInfo equipChargeStatusCD, CacheRateModel cacheRateModel, String rtf,
|
||||
BigDecimal timePeriodRatio, BigDecimal tpPower, ChargeDetails cd) {
|
||||
|
||||
cd.setDetailPower(tpPower.multiply(timePeriodRatio).doubleValue());
|
||||
Integer powerPrice;
|
||||
Integer svcPrice;
|
||||
if ("00".equals(rtf)) {
|
||||
powerPrice = cacheRateModel.getT1Price();
|
||||
svcPrice = cacheRateModel.getT1SvcPrice();
|
||||
} else if ("01".equals(rtf)) {
|
||||
powerPrice = cacheRateModel.getT2Price();
|
||||
svcPrice = cacheRateModel.getT2SvcPrice();
|
||||
} else if ("02".equals(rtf)) {
|
||||
powerPrice = cacheRateModel.getT3Price();
|
||||
svcPrice = cacheRateModel.getT3SvcPrice();
|
||||
} else {
|
||||
powerPrice = cacheRateModel.getT4Price();
|
||||
svcPrice = cacheRateModel.getT4SvcPrice();
|
||||
}
|
||||
cd.setElecPrice((double) Math.round(powerPrice / 1000D) / 100D);
|
||||
cd.setSevicePrice((double) Math.round(svcPrice / 1000D) / 100D);
|
||||
cd.setDetailElecMoney(BigDecimal.valueOf(cd.getElecPrice()).multiply(BigDecimal.valueOf(cd.getDetailPower())).divide(BigDecimal.valueOf(10000), 2,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
cd.setDetailSeviceMoney(BigDecimal.valueOf(cd.getSevicePrice()).multiply(BigDecimal.valueOf(cd.getDetailPower())).divide(BigDecimal.valueOf(10000), 2,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
}
|
||||
|
||||
public void notify(CDEquipChargeStatusCDInfo cdEquipChargeStatusCDInfo, AuthSecretToken authSecretTokenOut) throws IOException {
|
||||
|
||||
String operatorIdEvcs = "MA6DFCTD5";
|
||||
String data = JSONUtil.toJSONString(cdEquipChargeStatusCDInfo);
|
||||
logger.debug(data);
|
||||
CommonRequest<CDChargeOrderInfo4Bonus> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId(operatorIdEvcs);
|
||||
commonRequest.setData(data);
|
||||
String responseBody = ok(commonRequest, "/notification_equip_charge_status", "765367656", operatorIdEvcs);
|
||||
CDEquipmentChargeStatusResponse cdEquipmentChargeStatusResponse = DTOJsonHelper.parseResponseData(responseBody,
|
||||
CDEquipmentChargeStatusResponse.class, authSecretTokenOut);
|
||||
if (cdEquipmentChargeStatusResponse != null && cdEquipmentChargeStatusResponse.getSuccStat() != 0) {
|
||||
throw new RuntimeException(String.format("push CD equipment order status [%s] failed: %s",
|
||||
cdEquipChargeStatusCDInfo.getStartChargeSeq(), responseBody));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInteger(String str) {
|
||||
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
int length = str.length();
|
||||
if (length == 0) {
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
if (str.charAt(0) == '-') {
|
||||
if (length == 1) {
|
||||
return false;
|
||||
}
|
||||
i = 1;
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
char c = str.charAt(i);
|
||||
if (c < '0' || c > '9') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
DateTime dt = DateTime.now();
|
||||
System.out.println((double) Math.round(100111 / 100D) / 100D);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package com.xhpc.evcs.cd;
|
||||
|
||||
import com.xhpc.common.api.dto.ChargingStationDto;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.domain.ConnectorStatusInfo;
|
||||
import com.xhpc.evcs.dto.CDConnectorStatusInfo4BonusRequest;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.DTOJsonHelper;
|
||||
import com.xhpc.evcs.dto.Status;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.utils.ChangePoleStatus;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||
import static com.xhpc.common.dto.ConnectorStatusInfo.*;
|
||||
import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT;
|
||||
|
||||
@Component
|
||||
public class NotificationStationStatusTask extends CDCoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 15)
|
||||
protected void run() throws IOException {
|
||||
|
||||
Collection<String> stationTerminalKeys = REDIS.keys("stationTerminalStatus:*");
|
||||
for (String stationTerminalKey : stationTerminalKeys) {
|
||||
ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationTerminalKey.replace("stationTerminalStatus",
|
||||
"station")); //todo OperatorID
|
||||
String operatorId = chargingStationDto.getOperatorId();
|
||||
operatorId = operatorId == null ? "MA6DFCTD5" : operatorId;
|
||||
AuthSecretToken authSecretTokenOut =
|
||||
authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType(
|
||||
"765367656", operatorId, SECRET_TOKEN_TYPE_OUT).orElse(null); //todo
|
||||
// maybe对接第三方
|
||||
if (authSecretTokenOut != null) {
|
||||
Map<String, String> terminalStatusMap = REDIS.getCacheMap(stationTerminalKey);
|
||||
Set<ConnectorStatusInfo> connectorStatusInfos = translateStatus(operatorId, terminalStatusMap);
|
||||
if (!connectorStatusInfos.isEmpty()) {
|
||||
Set<ConnectorStatusInfo> changeStatus = ChangePoleStatus.getChangeStatus(connectorStatusInfos);
|
||||
for (ConnectorStatusInfo statusInfo : changeStatus) {
|
||||
notify(statusInfo, authSecretTokenOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Set<ConnectorStatusInfo> translateStatus(String operatorId, Map<String, String> terminalStatusMap) {
|
||||
|
||||
Set<ConnectorStatusInfo> connectorStatusInfoList = new HashSet<>();
|
||||
final Set<String> connectorIds = terminalStatusMap.keySet();
|
||||
for (String gunId : connectorIds) {
|
||||
ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo();
|
||||
connectorStatusInfo.setConnectorID(gunId);
|
||||
connectorStatusInfo.setOperatorID(operatorId);
|
||||
connectorStatusInfo.setStatus(translateStatus(terminalStatusMap.get(gunId)));
|
||||
connectorStatusInfoList.add(connectorStatusInfo);
|
||||
}
|
||||
return connectorStatusInfoList;
|
||||
}
|
||||
|
||||
private Integer translateStatus(String statusStr) {
|
||||
|
||||
switch (statusStr) {
|
||||
case "空闲":
|
||||
return FREE;
|
||||
case "离线":
|
||||
return OFF_LINE;
|
||||
case "故障":
|
||||
return ERROR;
|
||||
default:
|
||||
return CHARGING;
|
||||
}
|
||||
}
|
||||
|
||||
public Status notify(ConnectorStatusInfo connectorStatusInfo, AuthSecretToken authSecretTokenOut) throws IOException {
|
||||
|
||||
CDConnectorStatusInfo4BonusRequest statusInfo2CDRequest = new CDConnectorStatusInfo4BonusRequest();
|
||||
statusInfo2CDRequest.setConnectorStatusInfo(connectorStatusInfo);
|
||||
String data = JSONUtil.toJSONString(statusInfo2CDRequest);
|
||||
CommonRequest<CDConnectorStatusInfo4BonusRequest> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId(connectorStatusInfo.getOperatorID());
|
||||
commonRequest.setData(data);
|
||||
String responseBody = ok(commonRequest, "/notification_stationStatus", "765367656",
|
||||
connectorStatusInfo.getOperatorID());
|
||||
Status status = DTOJsonHelper.parseResponseData(responseBody, Status.class, authSecretTokenOut);
|
||||
if (status == null || status.getStatus() != 0) {
|
||||
throw new RuntimeException(String.format("push CD notification connector[%s] failed: %s",
|
||||
connectorStatusInfo.getConnectorID(), responseBody));
|
||||
}
|
||||
//todo if token is invalid then retry?
|
||||
return status;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,313 @@
|
||||
package com.xhpc.evcs.config;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.encryption.Aes128Cbc;
|
||||
import com.xhpc.evcs.encryption.HMAC;
|
||||
import com.xhpc.evcs.http.HttpServletRequestRepeatReadWrapper;
|
||||
import com.xhpc.evcs.http.HttpServletRequestWritableWrapper;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.jpa.OperatorInfoRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Scanner;
|
||||
|
||||
@SuppressWarnings({"Duplicates"}) //todo
|
||||
@Slf4j
|
||||
//@Component //spring boot way, see https://www.surasint.com/spring-boot-webfilter-instead-of-component/
|
||||
//@Order(1) not supported, see https://github.com/spring-projects/spring-boot/issues/8276
|
||||
@WebFilter(urlPatterns = {"/v1/*", "/v2/*"}, filterName = "v1n2filter") //multiple filters execute by filterName order
|
||||
public class EvcsFilter extends OncePerRequestFilter {
|
||||
|
||||
@Resource
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
@Resource
|
||||
private OperatorInfoRepository operatorInfoRepository;
|
||||
@Value("${xhpc.evcs.encrypt:false}")
|
||||
private boolean encrypt = false;
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
|
||||
|
||||
if (!encrypt) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
ServletRequest requestWrapper = new HttpServletRequestRepeatReadWrapper(request);
|
||||
Scanner scanner = new Scanner(requestWrapper.getInputStream(), "UTF-8").useDelimiter("\\A");
|
||||
String bodyString = scanner.hasNext() ? scanner.next() : null;
|
||||
log.debug("in.enc: {}", bodyString);
|
||||
if (!ObjectUtils.isEmpty(bodyString)) {
|
||||
String servletPath = request.getServletPath();
|
||||
log.debug("servletPath: " + servletPath);
|
||||
CommonRequest commonRequest = JSONUtil.readParams(bodyString, CommonRequest.class);
|
||||
String operatorId = commonRequest.getOperatorId();
|
||||
String authorization = request.getHeader("Authorization");
|
||||
AuthSecretToken authSecretTokenIn;
|
||||
Date now = Calendar.getInstance().getTime();
|
||||
ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
|
||||
if (authorization != null && authorization.startsWith("Bearer ")) {
|
||||
String token = authorization.substring(7);
|
||||
authSecretTokenIn =
|
||||
authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndTokenExpiryGreaterThan(
|
||||
operatorId, AuthSecretToken.SECRET_TOKEN_TYPE_IN, now).orElse(null);
|
||||
if (authSecretTokenIn == null || !token.equals(authSecretTokenIn.getToken())) {
|
||||
CommonResponse resp = new CommonResponse();
|
||||
resp.setRet("4003");
|
||||
resp.setMsg("Invalid token");
|
||||
String data = JSONUtil.toJSONString(resp);
|
||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||
responseWrapper = new ContentCachingResponseWrapper(response);
|
||||
chain.doFilter(requestWrapper, responseWrapper);
|
||||
return;
|
||||
}
|
||||
} else if (authorization == null) { //todo giv't better arrangement
|
||||
final String encin = request.getHeader("enc.in");
|
||||
if (encin != null && encin.equals("false")) {
|
||||
chain.doFilter(requestWrapper, response);
|
||||
return;
|
||||
}
|
||||
if (servletPath.endsWith("/query_token")) {
|
||||
authSecretTokenIn = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId,
|
||||
AuthSecretToken.SECRET_TOKEN_TYPE_IN).orElse(null);
|
||||
if (authSecretTokenIn == null) {
|
||||
CommonResponse resp = new CommonResponse();
|
||||
resp.setRet("4003");
|
||||
resp.setMsg("Invalid OperatorID");
|
||||
String data = JSONUtil.toJSONString(resp);
|
||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// response.setStatus(403);
|
||||
responseWrapper = new ContentCachingResponseWrapper(response);
|
||||
chain.doFilter(requestWrapper, responseWrapper);
|
||||
return;
|
||||
} else {
|
||||
final byte[] decrypt;
|
||||
try {
|
||||
decrypt = decrypt(request, authSecretTokenIn, commonRequest, bodyString);
|
||||
} catch (BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
CommonResponse resp = new CommonResponse();
|
||||
resp.setRet("4003");
|
||||
resp.setMsg("Invalid Encryption");
|
||||
String data = JSONUtil.toJSONString(resp);
|
||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
chain.doFilter(requestWrapper, responseWrapper);
|
||||
return;
|
||||
}
|
||||
((HttpServletRequestRepeatReadWrapper) requestWrapper).setBody(decrypt);
|
||||
chain.doFilter(requestWrapper, response);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//decrypt request
|
||||
byte[] decryptedData = null;
|
||||
String erroMsg = "Decryption error";
|
||||
CommonResponse resp = new CommonResponse();
|
||||
authSecretTokenIn = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId,
|
||||
AuthSecretToken.SECRET_TOKEN_TYPE_IN).orElse(null);
|
||||
if (authSecretTokenIn != null
|
||||
&& now.before(authSecretTokenIn.getTokenExpiry())
|
||||
&& authorization != null && authorization.substring(7).equals(authSecretTokenIn.getToken())) {
|
||||
try {
|
||||
decryptedData = decrypt(request, authSecretTokenIn, commonRequest, bodyString);
|
||||
log.debug("in.dec: {}", new String(decryptedData));
|
||||
} catch (BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {
|
||||
erroMsg = e.getMessage();
|
||||
}
|
||||
} else {
|
||||
erroMsg = "Authorization error, check OperatorID or token expiry";
|
||||
}
|
||||
if (decryptedData != null && decryptedData.length > 0) {
|
||||
requestWrapper = new HttpServletRequestWritableWrapper(request, decryptedData);
|
||||
} else {
|
||||
resp.setRet("4004");
|
||||
resp.setMsg(erroMsg);
|
||||
String data = JSONUtil.toJSONString(resp);
|
||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||
chain.doFilter(requestWrapper, responseWrapper);
|
||||
return;
|
||||
}
|
||||
|
||||
//encrypt response
|
||||
final String encout = request.getHeader("enc.out");
|
||||
// if (requestWrapper == null) {
|
||||
// chain.doFilter(request, responseWrapper);
|
||||
// } else {
|
||||
chain.doFilter(requestWrapper, responseWrapper);
|
||||
// }
|
||||
byte[] buf = responseWrapper.getContentAsByteArray();
|
||||
log.debug("out.plain: {}", new String(buf, StandardCharsets.UTF_8));
|
||||
String encryptedData;
|
||||
AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId,
|
||||
AuthSecretToken.SECRET_TOKEN_TYPE_OUT).orElse(null);
|
||||
if (encout == null && authSecretTokenOut != null) {
|
||||
encryptedData = encryptRespOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(),
|
||||
authSecretTokenOut.getSigSecret(), buf).toString();
|
||||
log.debug("out.enc: {}", encryptedData);
|
||||
response.getOutputStream().write(encryptedData == null ? internalError() :
|
||||
encryptedData.getBytes(StandardCharsets.UTF_8));
|
||||
} else if ("false".equals(encout)) {
|
||||
response.getOutputStream().write(buf);
|
||||
} else {
|
||||
resp.setRet("4004");
|
||||
resp.setMsg("Encryption error");
|
||||
String data = JSONUtil.toJSONString(resp);
|
||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||
chain.doFilter(requestWrapper, responseWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] internalError() {
|
||||
|
||||
CommonResponse resp = new CommonResponse();
|
||||
resp.setData("");
|
||||
resp.setRet("1");
|
||||
resp.setMsg("Internal error.");
|
||||
return resp.toString().getBytes();
|
||||
}
|
||||
|
||||
public static String encryptReqOut(String dataSecret, String dataSecretIV, String sigSecret, CommonRequest commonRequest)
|
||||
throws BadPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException,
|
||||
IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException, JsonProcessingException {
|
||||
|
||||
String data = Aes128Cbc.encrypt(commonRequest.getData(), dataSecret, dataSecretIV);
|
||||
commonRequest.setData(data);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
DateTime dt = new DateTime(cal);
|
||||
commonRequest.setTimeStamp(dt.toString(DatePattern.PURE_DATETIME_PATTERN));
|
||||
commonRequest.setSeq(String.valueOf(DateUtil.millisecond(dt)));
|
||||
String sig =
|
||||
HMAC.hmacDigest(commonRequest.getOperatorId() + data + commonRequest.getTimeStamp() + commonRequest.getSeq(),
|
||||
sigSecret);
|
||||
commonRequest.setSig(sig);
|
||||
final String jsonString = JSONUtil.toJSONString(commonRequest);
|
||||
log.debug("enc to out:{} ", jsonString);
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
public static JsonNode encryptRespOut(String dataSecret, String dataSecretIV, String sigSecret, byte[] buf) {
|
||||
|
||||
JsonNode rootNode;
|
||||
String data = null;
|
||||
if (buf.length > 0) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
rootNode = objectMapper.readTree(buf);
|
||||
JsonNode msg = rootNode.path("Msg");
|
||||
JsonNode ret = rootNode.path("Ret");
|
||||
if (msg.toString().equals("")) {
|
||||
String retstring = ret.toString();
|
||||
if ("0".equals(retstring)) {
|
||||
((ObjectNode) rootNode).put("Msg", "Success");
|
||||
} else {
|
||||
((ObjectNode) rootNode).put("Msg", "Failure");
|
||||
}
|
||||
}
|
||||
JsonNode dataNode = rootNode.path("Data");
|
||||
String rawData = dataNode.toString();
|
||||
log.debug("out data: " + rawData);
|
||||
data = Aes128Cbc.encrypt(rawData, dataSecret, dataSecretIV);
|
||||
((ObjectNode) rootNode).put("Data", data);
|
||||
} catch (Exception e) {
|
||||
rootNode = new ObjectNode(JsonNodeFactory.instance);
|
||||
((ObjectNode) rootNode).put("Msg", e.getMessage());
|
||||
}
|
||||
} else {
|
||||
rootNode = new ObjectNode(JsonNodeFactory.instance);
|
||||
}
|
||||
String sig = HMAC.hmacDigest(rootNode.path("Ret").asText() + rootNode.path("Msg").asText() + data, sigSecret);
|
||||
((ObjectNode) rootNode).put("Sig", sig);
|
||||
log.debug("enc to out: " + rootNode);
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
private byte[] decrypt(HttpServletRequest request, AuthSecretToken authSecretToken,
|
||||
CommonRequest commonRequest, String bodyString) throws IOException, BadPaddingException,
|
||||
InvalidAlgorithmParameterException, NoSuchAlgorithmException, IllegalBlockSizeException, NoSuchPaddingException,
|
||||
InvalidKeyException {
|
||||
|
||||
byte[] buf = new byte[]{};
|
||||
if ("POST".equalsIgnoreCase(request.getMethod())) {
|
||||
if (request.getServletPath().endsWith("/query_token")) {
|
||||
String encryptedMsg = commonRequest.getData();
|
||||
String data = Aes128Cbc.decryptString(encryptedMsg, authSecretToken.getDataSecret(), authSecretToken
|
||||
.getDataSecretIV());
|
||||
commonRequest.setData(data);
|
||||
buf = data.getBytes(StandardCharsets.UTF_8);
|
||||
} else {
|
||||
String authorization = request.getHeader("Authorization");
|
||||
if (authorization != null && authorization.startsWith("Bearer ")) {
|
||||
//decrypt Data field
|
||||
buf = bodyString.getBytes(StandardCharsets.UTF_8);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode rootNode = objectMapper.readTree(buf);
|
||||
JsonNode sigNode = rootNode.path("Sig");
|
||||
JsonNode operatorIDNode = rootNode.path("OperatorID");
|
||||
JsonNode dataNode = rootNode.path("Data");
|
||||
JsonNode timestampNode = rootNode.path("TimeStamp");
|
||||
JsonNode seqNode = rootNode.path("Seq");
|
||||
String computedSig = HMAC.hmacDigest(
|
||||
operatorIDNode.asText().concat(dataNode.asText()).concat(timestampNode.asText()).concat(seqNode.asText()),
|
||||
authSecretToken.getSigSecret());
|
||||
if (!computedSig.equals(sigNode.asText())) {
|
||||
throw new InvalidAlgorithmParameterException("Illegal Sig, computed: ".concat(computedSig));
|
||||
}
|
||||
if (!dataNode.isNull()) {
|
||||
String rawData = dataNode.asText();
|
||||
if (rawData.startsWith("{")) {
|
||||
((ObjectNode) rootNode).put("Data", rawData);
|
||||
} else {
|
||||
String decryptedData = Aes128Cbc.decryptString(rawData, authSecretToken.getDataSecret(),
|
||||
authSecretToken.getDataSecretIV());
|
||||
((ObjectNode) rootNode).put("Data", decryptedData);
|
||||
}
|
||||
buf = rootNode.toString().getBytes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.xhpc.evcs.config;
|
||||
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.http.HttpServletRequestRepeatReadWrapper;
|
||||
import com.xhpc.evcs.jpa.OperatorInfoRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Scanner;
|
||||
|
||||
@SuppressWarnings({"Duplicates"})
|
||||
@Slf4j
|
||||
public class EvcsInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
OperatorInfoRepository operatorInfoRepository;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
|
||||
|
||||
HttpServletRequest requestWrapper = new HttpServletRequestRepeatReadWrapper(request);
|
||||
Scanner scanner = new Scanner(requestWrapper.getInputStream(), "UTF-8").useDelimiter("\\A");
|
||||
String bodyString = scanner.hasNext() ? scanner.next() : null;
|
||||
if (!ObjectUtils.isEmpty(bodyString)) {
|
||||
CommonRequest commonRequest = JSONUtil.readParams(bodyString, CommonRequest.class);
|
||||
if (commonRequest != null) {
|
||||
String operatorID = commonRequest.getOperatorId();
|
||||
operatorInfoRepository.findById(operatorID).orElseThrow(() -> new EntityNotFoundException("OperatorInfo" +
|
||||
"::OperatorID[" + operatorID + "] not found."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o,
|
||||
ModelAndView modelAndView) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o,
|
||||
Exception e) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.xhpc.evcs.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
//@Configuration //using filter instead todo
|
||||
public class InterceptorConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
||||
registry.addInterceptor(getEvcsInterceptor()).addPathPatterns("/v1/**");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HandlerInterceptor getEvcsInterceptor() {
|
||||
|
||||
return new EvcsInterceptor();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.xhpc.evcs.jpa;
|
||||
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface AuthSecretTokenRepository extends JpaRepository<AuthSecretToken, String>,
|
||||
QueryByExampleExecutor<AuthSecretToken>, JpaSpecificationExecutor<AuthSecretToken> {
|
||||
|
||||
|
||||
Optional<AuthSecretToken> findByOperatorIdAndSecretTokenType(String operatorId, String secretTokenType);
|
||||
|
||||
Optional<AuthSecretToken> findByOperatorId3irdptyAndSecretTokenTypeAndTokenExpiryGreaterThan(String operatorId,
|
||||
String secretTokenType,
|
||||
Date time);
|
||||
|
||||
Optional<AuthSecretToken> findByOperatorId3irdptyAndOperatorIdAndSecretTokenType(String operatorId3irdpty,
|
||||
String operatorID,
|
||||
String secretTokenTypeIn);
|
||||
|
||||
Optional<AuthSecretToken> findByOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret(String operatorID3irdpty,
|
||||
String secretTokenType,
|
||||
String operatorSecret);
|
||||
|
||||
Optional<AuthSecretToken> findByOperatorId3irdptyAndSecretTokenType(String operatorId, String secretTokenType);
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.xhpc.evcs.jpa;
|
||||
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ChargeOrderInfoRepository extends JpaRepository<XhpcHistoryOrder, String>,
|
||||
QueryByExampleExecutor<XhpcHistoryOrder>, JpaSpecificationExecutor<XhpcHistoryOrder> {
|
||||
|
||||
List<XhpcHistoryOrder> findByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(Long hisOrderId, int i);
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user