diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDChargeFeeDetail.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDChargeFeeDetail.java new file mode 100644 index 00000000..0eafd71e --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDChargeFeeDetail.java @@ -0,0 +1,34 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import javax.persistence.Column; + +/** + * @author yuyang + * @date 2023-09-20 14:13 + */ +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +@Data +public class CDChargeFeeDetail { + + @JsonProperty("EquipmentType") + Integer equipmentType; + + @JsonProperty("StartTime") + String startTime; + + @JsonProperty("EndTime") + String endTime; + + @Column(columnDefinition = "Decimal(10,2)") + @JsonProperty("ElectricityFee") + Double electricityFee; + + @Column(columnDefinition = "Decimal(10,2)") + @JsonProperty("serviceFee") + Double serviceFee; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorChargeStatusInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorChargeStatusInfo.java index f249276e..57259b25 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorChargeStatusInfo.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorChargeStatusInfo.java @@ -6,6 +6,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import lombok.Data; +import javax.persistence.Column; + /** * @author yuyang * @date 2023-09-07 15:16 @@ -15,13 +17,9 @@ import lombok.Data; "StartChargeSeq", "ConnectorID", "ConnectorStatus", - "Vin", + "OrderStatus", "CurrentA", - "CurrentB", - "CurrentC", "VoltageA", - "VoltageB", - "VoltageC", "Soc", "StartTime", "EndTime", @@ -30,7 +28,11 @@ import lombok.Data; "TotalPower", "ElecMoney", "SeviceMoney", - "TotalMoney" + "TotalMoney", + "OperatorID", + "EquipmentOwnerID", + "StationID", + "EquipmentID" }) @Data public class CDConnectorChargeStatusInfo { @@ -50,44 +52,52 @@ public class CDConnectorChargeStatusInfo { @JsonProperty("ConnectorStatus") public Integer connectorStatus; /** - * 车辆识别码 - */ - @JsonProperty("Vin") - public String vin; + * 充电订单状态 + * */ + @JsonProperty("OrderStatus") + public Integer orderStatus; + + +// /** +// * 车辆识别码 +// */ +// @JsonProperty("Vin") +// public String vin; /** * A 相电流 */ @JsonProperty("CurrentA") public Double currentA; - /** - * B 相电流 - */ - @JsonProperty("CurrentB") - public Double currentB; - /** - * C 相电流 - */ - @JsonProperty("CurrentC") - public Double currentC; +// /** +// * B 相电流 +// */ +// @JsonProperty("CurrentB") +// public Double currentB; +// /** +// * C 相电流 +// */ +// @JsonProperty("CurrentC") +// public Double currentC; /** * A 相电压 */ @JsonProperty("VoltageA") public Double voltageA; - /** - * B 相电压 - */ - @JsonProperty("VoltageB") - public Double voltageB; - /** - * C 相电压 - */ - @JsonProperty("VoltageC") - public Double voltageC; +// /** +// * B 相电压 +// */ +// @JsonProperty("VoltageB") +// public Double voltageB; +// /** +// * C 相电压 +// */ +// @JsonProperty("VoltageC") +// public Double voltageC; /** * 电池剩余电量 */ @JsonProperty("Soc") + @Column(columnDefinition = "Decimal(10,1)") public Double soc; /** * 开始充电时间 @@ -113,21 +123,44 @@ public class CDConnectorChargeStatusInfo { * 累计充电量 */ @JsonProperty("TotalPower") + @Column(columnDefinition = "Decimal(10,2)") public Double totalPower; /** * 累计电费 */ @JsonProperty("ElecMoney") + @Column(columnDefinition = "Decimal(10,2)") public Double elecMoney; /** * 累计服务费 */ @JsonProperty("SeviceMoney") + @Column(columnDefinition = "Decimal(10,2)") public Double seviceMoney; /** * 累计总金额 */ @JsonProperty("TotalMoney") + @Column(columnDefinition = "Decimal(10,2)") public Double totalMoney; - + /** + * 运营平台 ID + */ + @JsonProperty("OperatorID") + public String operatorID; + /** + * 产权所属单位ID + */ + @JsonProperty("EquipmentOwnerID") + public String equipmentOwnerID; + /** + * 充电站ID + */ + @JsonProperty("StationID") + public String stationID; + /** + * 充电设备编码 + */ + @JsonProperty("EquipmentID") + public String equipmentID; } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorInfo.java new file mode 100644 index 00000000..85cb2f69 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorInfo.java @@ -0,0 +1,81 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Transient; + +/** + * @author yuyang + * @date 2023-09-27 17:35 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "ConnectorID", + "ConnectorName", + "ConnectorType", + "VoltageUpperLimits", + "VoltageLowerLimits", + "Current", + "Power", + "NationalStandard", + "EquipmentClassification", + "AuxPower", + "OpreateStatus" +}) +@Data +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDConnectorInfo { + + @JsonProperty("ConnectorID") + public String connectorID; + @JsonProperty("ConnectorName") + public String connectorName; + // 1:家用插座(模式 2) + // 2:交流接口插座(模式 3, 连接方式 B ) + // 3:交流接口插头(带枪线, 模式 3,连接方式 C) + // 4:直流接口枪头(带枪线, 模式 4) + // 5:无线充电座 + // 6:其他 + @JsonProperty("ConnectorType") + public Integer connectorType; + @JsonProperty("VoltageUpperLimits") + public Integer voltageUpperLimits; + @JsonProperty("VoltageLowerLimits") + public Integer voltageLowerLimits; + @JsonProperty("Current") + public Integer current; + + @Column(columnDefinition = "Decimal(10,1)") + @JsonProperty("Power") + public Double power; +// @JsonProperty("ParkNo") +// public String ParkNo; + @JsonProperty("NationalStandard") + public Integer nationalStandard; + /** + * 设备接口分类 + */ + @Transient + @JsonProperty("EquipmentClassification") + public Integer equipmentClassification; + /** + * 辅助电源 + */ + @Transient + @JsonProperty("AuxPower") + public Integer auxPower; + /** + * 运营状态 + */ + @Transient + @JsonProperty("OpreateStatus") + public Integer opreateStatus; + + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorStatusInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorStatusInfo.java new file mode 100644 index 00000000..6610c3e9 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorStatusInfo.java @@ -0,0 +1,67 @@ +package com.xhpc.evcs.cdjgpc.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; + +/** + * @author yuyang + * @date 2023-09-28 9:51 + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "OperatorID", + "EquipmentOwnerID", + "StationID", + "EquipmentID", + "EquipmentClassification", + "ConnectorID", + "Status" +}) +@Setter +@Getter +public class CDConnectorStatusInfo { + + /** + * 运营平台 ID + */ + @JsonProperty("OperatorID") + public String operatorID; + /** + * 产权所属单位ID + */ + @JsonProperty("EquipmentOwnerID") + public String equipmentOwnerID; + /** + * 充电站 ID + */ + @JsonProperty("StationID") + public String stationID; + /** + * 充电设备编码 + */ + @JsonProperty("EquipmentID") + public String equipmentID; + /** + * 设备接口分类 + */ + @JsonProperty("EquipmentClassification") + public Integer equipmentClassification; + /** + * 充电设备接口编码 + */ + @JsonProperty("ConnectorID") + public String connectorID; + /** + * 充电设备接口状态 + */ + @JsonProperty("Status") + public Integer status; + + + + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorStatusInfoReq.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorStatusInfoReq.java new file mode 100644 index 00000000..aba4cb49 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDConnectorStatusInfoReq.java @@ -0,0 +1,44 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author yuyang + * @date 2023-10-08 15:18 + */ +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDConnectorStatusInfoReq { + @JsonProperty("ConnectorStatusInfo") + private CDConnectorStatusInfo connectorStatusInfo; + + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("ConnectorStatusInfo") + public CDConnectorStatusInfo getConnectorStatusInfo() { + + return connectorStatusInfo; + } + + @JsonProperty("ConnectorStatusInfo") + public void setConnectorStatusInfo(CDConnectorStatusInfo connectorStatusInfo) { + + this.connectorStatusInfo = connectorStatusInfo; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + + this.additionalProperties.put(name, value); + } +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDEquipAuthRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDEquipAuthRequest.java new file mode 100644 index 00000000..8097609b --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDEquipAuthRequest.java @@ -0,0 +1,24 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * @author yuyang + * @date 2023-09-20 15:24 + */ +@Getter +@Setter +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDEquipAuthRequest { + + @JsonProperty("EquipAuthSeq") + String equipAuthSeq; + @JsonProperty("ConnectorID") + String connectorId; + @JsonProperty("QRCode") + String qRCode; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDEquipmentInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDEquipmentInfo.java index 68971d0d..12a66585 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDEquipmentInfo.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDEquipmentInfo.java @@ -29,7 +29,8 @@ import java.util.List; "EquipmentPower", "NewNationalStandard", "ConnectorInfos", - "VinFlag" + "VinFlag", + "EquipmentClassificatlon" }) @Data @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, @@ -111,7 +112,7 @@ public class CDEquipmentInfo { * 充电设备 接口列表 */ @JsonProperty("ConnectorInfos") - public List connectorInfos; + public List connectorInfos; /** * 充 电 设 备 经度 */ @@ -127,4 +128,9 @@ public class CDEquipmentInfo { */ @JsonProperty("VinFlag") public Integer vinFlag; + /** + * 设备分类 + */ + @JsonProperty("EquipmentClassificatlon") + public Integer equipmentClassificatlon; } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDNotificationOrderSettlementInfoRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDNotificationOrderSettlementInfoRequest.java new file mode 100644 index 00000000..2d687f35 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDNotificationOrderSettlementInfoRequest.java @@ -0,0 +1,75 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +import javax.persistence.Column; + +/** + * @author yuyang + * @date 2023-09-27 10:41 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "StartChargeSeq", + "ConnectorID", + "TotalPower", + "TotalMoney", + "TaxiOrder", + "SubsidyMoney", + "SettlementMoney" +}) +@Data +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDNotificationOrderSettlementInfoRequest { + + /** + * 充电订单号 + */ + @JsonProperty("StartChargeSeq") + public String startChargeSeq; + + /** + * 充电设备接口 编码 + */ + @JsonProperty("ConnectorID") + public String connectorID; + + /** + * 累计充电量 + */ + @JsonProperty("TotalPower") + @Column(columnDefinition = "Decimal(10,2)") + public Double totalPower; + + /** + * 累计总金额 + */ + @JsonProperty("TotalMoney") + @Column(columnDefinition = "Decimal(10,2)") + public Double totalMoney; + + /** + * 是否出租车订单 + */ + @JsonProperty("TaxiOrder") + public Integer taxiOrder; + + /** + * 补贴金额 + */ + @JsonProperty("SubsidyMoney") + @Column(columnDefinition = "Decimal(10,2)") + public Double subsidyMoney; + + /** + * 结算金额 + */ + @JsonProperty("SettlementMoney") + @Column(columnDefinition = "Decimal(10,2)") + public Double settlementMoney; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDOrderInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDOrderInfo.java index 4421a6bf..daee1920 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDOrderInfo.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDOrderInfo.java @@ -3,9 +3,17 @@ package com.xhpc.evcs.cdjgpc.dto; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.xhpc.evcs.dto.ConnectorInfo; +import com.xhpc.evcs.domain.EtOrderMapping; +import com.xhpc.evcs.domain.XhpcStatisticsTimeInterval; +import com.xhpc.evcs.dto.ChargeDetails; +import com.xhpc.evcs.utils.DateUtil; +import com.xhpc.order.domain.XhpcHistoryOrder; import lombok.Data; +import javax.persistence.Column; +import java.text.DecimalFormat; +import java.util.Date; +import java.util.LinkedList; import java.util.List; /** @@ -19,15 +27,16 @@ import java.util.List; "StationID", "EquipmentID", "ConnectorID", + "EquipmentClassification", "StartChargeSeq", "UserChargeType", - "MobileNumber", "Money", "ElectMoney", "ServiceMoney", "Elect", "StartTime", "EndTime", + "SwapOrderID", "PaymentAmount", "PayTime", "PayChannel", @@ -38,7 +47,8 @@ import java.util.List; "ChargeLast", "MeterValueStart", "MeterValueEnd", - "ChargeDetails" + "ChargeDetails", + "PushTimeStamp" }) @Data public class CDOrderInfo { @@ -67,6 +77,11 @@ public class CDOrderInfo { */ @JsonProperty("ConnectorID") public String connectorID; + /** + * 设备接口分类 + */ + @JsonProperty("EquipmentClassification") + public Integer equipmentClassification; /** * 充电订单号 */ @@ -80,27 +95,31 @@ public class CDOrderInfo { /** * 用户手机号 */ - @JsonProperty("MobileNumber") - public String mobileNumber; +// @JsonProperty("MobileNumber") +// public String mobileNumber; /** * 本次充电消费总金额 */ @JsonProperty("Money") + @Column(columnDefinition = "Decimal(10,2)") public Double money; /** * 本本次充电电费总金额 */ @JsonProperty("ElectMoney") + @Column(columnDefinition = "Decimal(10,2)") public Double electMoney; /** * 本次充电 服务费金额 */ @JsonProperty("ServiceMoney") + @Column(columnDefinition = "Decimal(10,2)") public Double serviceMoney; /** * 本次充电电量 */ @JsonProperty("Elect") + @Column(columnDefinition = "Decimal(10,2)") public Double elect; /** * 本次充电开始时间 @@ -112,10 +131,16 @@ public class CDOrderInfo { */ @JsonProperty("EndTime") public String endTime; + /** + * 换电订单编号 + */ + @JsonProperty("SwapOrderID") + public String swapOrderID; /** * 支付金额 */ @JsonProperty("PaymentAmount") + @Column(columnDefinition = "Decimal(10,2)") public Double paymentAmount; /** * 支付时 @@ -147,6 +172,7 @@ public class CDOrderInfo { * 接口额定功 率 */ @JsonProperty("Power") + @Column(columnDefinition = "Decimal(10,1)") public Double power; /** * 充电时长 @@ -157,18 +183,110 @@ public class CDOrderInfo { * 电表总起值 */ @JsonProperty("MeterValueStart") + @Column(columnDefinition = "Decimal(10,3)") public Double meterValueStart; /** * 电表总止值 */ @JsonProperty("MeterValueEnd") + @Column(columnDefinition = "Decimal(10,3)") public Double meterValueEnd; /** * 充电明细信息 */ @JsonProperty("ChargeDetails") - public List chargeDetails; + public ChargeDetails[] chargeDetails; + /** + * 推送时间 + */ + @JsonProperty("PushTimeStamp") + public String pushTimeStamp; + public CDOrderInfo(XhpcHistoryOrder xhpcHistoryOrder, EtOrderMapping etOrderMapping) { + this.operatorID =xhpcHistoryOrder.getOperatorIdEvcs(); + //this.operatorID = xhpcHistoryOrder.getOperatorId3rdptyEvcs(); + this.stationID =xhpcHistoryOrder.getChargingStationId().toString(); + this.equipmentID = xhpcHistoryOrder.getSerialNumber().substring(0, 14); + this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16); + this.startChargeSeq = etOrderMapping.getEvcsOrderNo(); + this.equipmentClassification =1; + this.userChargeType ="1"; + this.money = xhpcHistoryOrder.getTotalPrice().doubleValue(); + this.electMoney =xhpcHistoryOrder.getTotalPrice().doubleValue(); + this.serviceMoney = xhpcHistoryOrder.getServicePriceTotal().doubleValue(); + this.elect = xhpcHistoryOrder.getTotalPower(); + this.endTime = DateUtil.date2String(xhpcHistoryOrder.getEndTime(), DateUtil.DATE_FORMAT_DATE_TIME); + this.startTime = DateUtil.date2String(xhpcHistoryOrder.getStartTime(), DateUtil.DATE_FORMAT_DATE_TIME); + this.pushTimeStamp = DateUtil.date2String(new Date(), DateUtil.DATE_FORMAT_DATE_TIME); + this.paymentAmount = xhpcHistoryOrder.getActPrice().doubleValue(); + if(xhpcHistoryOrder.getTotalPrice().compareTo(xhpcHistoryOrder.getActPrice())!=0){ + this.discountInfo ="优惠金额:"+xhpcHistoryOrder.getPromotionDiscount(); + } + this.payTime =DateUtil.date2String(xhpcHistoryOrder.getEndTime(), DateUtil.DATE_FORMAT_DATE_TIME); + if("支付宝".equals(xhpcHistoryOrder.getChargingMode())){ + this.payChannel =1; + }else if("微信".equals(xhpcHistoryOrder.getChargingMode())){ + this.payChannel =2; + }else{ + this.payChannel =6; + } + if(xhpcHistoryOrder.getStopReasonEvcs() !=null){ + String stopReasonEvcs = xhpcHistoryOrder.getStopReasonEvcs(); + if("40".equals(stopReasonEvcs)||"0".equals(stopReasonEvcs)||"00".equals(stopReasonEvcs)||"45".equals(stopReasonEvcs)||"APP 远程停止".equals(stopReasonEvcs) + ||"72".equals(stopReasonEvcs)){ + this.stopReason =0; + }else if("41".equals(stopReasonEvcs) ||"42".equals(stopReasonEvcs)||"43".equals(stopReasonEvcs)||"44".equals(stopReasonEvcs)||"4E".equals(stopReasonEvcs)||"平台停止".equals(stopReasonEvcs)){ + this.stopReason =1; + }else if("4A".equals(stopReasonEvcs) ||"4B".equals(stopReasonEvcs)||"4C".equals(stopReasonEvcs)||"4D".equals(stopReasonEvcs)||"4F".equals(stopReasonEvcs) || + "55".equals(stopReasonEvcs)||"57".equals(stopReasonEvcs)||"62".equals(stopReasonEvcs)||"63".equals(stopReasonEvcs)||"74".equals(stopReasonEvcs)||"75".equals(stopReasonEvcs) + ||"78".equals(stopReasonEvcs)||"79".equals(stopReasonEvcs)||"7A".equals(stopReasonEvcs)||"7B".equals(stopReasonEvcs)||"7C".equals(stopReasonEvcs)||"7D".equals(stopReasonEvcs) + ||"7E".equals(stopReasonEvcs)||"7F".equals(stopReasonEvcs)||"83".equals(stopReasonEvcs)){ + this.stopReason =3; + }else if("5A".equals(stopReasonEvcs)||"82".equals(stopReasonEvcs)){ + this.stopReason =2; + }else if("6B".equals(stopReasonEvcs) ||"6D".equals(stopReasonEvcs)||"5E".equals(stopReasonEvcs)){ + this.stopReason =4; + }else{ + this.stopReason =0; + } + }else{ + this.stopReason =0; + } + this.power = xhpcHistoryOrder.getConnectorPowerEvcs(); + Date starttime = xhpcHistoryOrder.getStartTime(); + Date endtime = xhpcHistoryOrder.getEndTime(); + int cl = 0; + if (starttime != null && endtime != null) { + cl = Math.toIntExact((endtime.getTime() - starttime.getTime()) / 1000); + } + this.chargeLast = Math.abs(cl); + if(xhpcHistoryOrder.getMeterValueStartEvcs() !=null && xhpcHistoryOrder.getMeterValueStartEvcs()>0){ + double v = xhpcHistoryOrder.getMeterValueStartEvcs() / 10000; + DecimalFormat df = new DecimalFormat("#.000"); + this.meterValueStart =Double.parseDouble(df.format(v)); + }else{ + this.meterValueStart = xhpcHistoryOrder.getMeterValueStartEvcs(); + } + if(xhpcHistoryOrder.getMeterValueEndEvcs() !=null && xhpcHistoryOrder.getMeterValueEndEvcs()>0){ + double v = xhpcHistoryOrder.getMeterValueEndEvcs() / 10000; + DecimalFormat df = new DecimalFormat("#.000"); + this.meterValueEnd =Double.parseDouble(df.format(v)); + } else{ + this.meterValueEnd = xhpcHistoryOrder.getMeterValueEndEvcs(); + } + final List xhpcStatisticsTimeIntervalList = + xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList(); + this.sumPeriod = xhpcStatisticsTimeIntervalList == null ? 0 : xhpcStatisticsTimeIntervalList.size(); + this.chargeDetails = translate(xhpcStatisticsTimeIntervalList); + } + private ChargeDetails[] translate(List< XhpcStatisticsTimeInterval > xhpcStatisticsTimeIntervalList) { + List details = new LinkedList<>(); + for (XhpcStatisticsTimeInterval statistics : xhpcStatisticsTimeIntervalList) { + details.add(new ChargeDetails(statistics)); + } + ChargeDetails[] a = new ChargeDetails[details.size()]; + return details.toArray(a); + } } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDPageRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDPageRequest.java new file mode 100644 index 00000000..0afa044a --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDPageRequest.java @@ -0,0 +1,32 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author yuyang + * @date 2023-10-11 19:38 + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +@Getter +@Setter +public class CDPageRequest { + @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; + @JsonIgnore + private Map additionalProperties = new HashMap(); +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDPageStationsInfoResponse.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDPageStationsInfoResponse.java new file mode 100644 index 00000000..3701547e --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDPageStationsInfoResponse.java @@ -0,0 +1,29 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.xhpc.evcs.dto.StationInfo; +import lombok.Getter; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yuyang + * @date 2023-09-16 18:10 + */ +@Getter +@Setter +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDPageStationsInfoResponse { + @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 stationInfos = new ArrayList<>(); +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDQuerySupEquipmentStatsInfoRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDQuerySupEquipmentStatsInfoRequest.java new file mode 100644 index 00000000..1a132d06 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDQuerySupEquipmentStatsInfoRequest.java @@ -0,0 +1,30 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @author yuyang + * @date 2023-10-07 10:40 + */ +@Getter +@Setter +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDQuerySupEquipmentStatsInfoRequest { + + @JsonProperty("StationID") + String stationID; + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonProperty("StartTime") + String startTime; + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonProperty("EndTime") + String endTime; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationFee.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationFee.java new file mode 100644 index 00000000..426604b2 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationFee.java @@ -0,0 +1,27 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author yuyang + * @date 2023-09-20 14:09 + */ +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +@Data +public class CDStationFee { + + @JsonProperty("OperatorID") + String operatorID; + + @JsonProperty("StationID") + String stationID; + + @JsonProperty("ChargeFeeDetail") + List chargeFeeDetails; + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationFeeRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationFeeRequest.java new file mode 100644 index 00000000..11233dc6 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationFeeRequest.java @@ -0,0 +1,15 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author yuyang + * @date 2023-09-20 14:57 + */ +@Data +public class CDStationFeeRequest { + + @JsonProperty("StationIDs") + String [] stationIDs; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationInfo.java index b4377b8f..4c65aeaf 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationInfo.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationInfo.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.xhpc.evcs.dto.CommonStationInfo; import lombok.Data; +import javax.persistence.Column; import javax.persistence.Transient; import java.util.Arrays; import java.util.List; @@ -26,6 +27,7 @@ import java.util.List; "Capacity", "CountryCode", "AreaCode", + "AreaCodeCountryside", "Address", "StationTel", "ServiceTel", @@ -36,7 +38,9 @@ import java.util.List; "StationLng", "StationLat", "Construction", + "SwapMatchCars", "OpenAllDay", + "ElectricityFee", "ServiceFee", "ParkFree", "ParkFee", @@ -52,7 +56,18 @@ import java.util.List; "ParkingLockFlag", "IsDemandResponse", "IsSupportOrderlyCharging", - "ISEnergystorage" + "IsEnergyStorage", + "stationClassification", + "GeneralApplicationType", + "RoundTheClock", + "ParkType", + "ElectncityType", + "BusinessExpandType", + "RatedPower", + "PeriodFee", + "OfficialRunTime", + "VideoMonitor", + "SwapEquipmentlnfos" }) @Data @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, @@ -77,12 +92,22 @@ public class CDStationInfo extends CommonStationInfo { @Transient @JsonProperty("Capacity") public Double capacity; + + @Transient + @JsonProperty("CountryCode") + public String countryCcode; /** * 充电站省市辖区编码 */ @Transient @JsonProperty("AreaCode") public String areaCode; + /** + * 充电站省市辖区编码 + */ + @Transient + @JsonProperty("AreaCodeCountryside") + public String areaCodeCountryside; /** * 详情地址 */ @@ -161,6 +186,16 @@ public class CDStationInfo extends CommonStationInfo { // @Transient // @JsonProperty("MatchCars") // public String matchCars; + /** + * 服务车型描述 + */ + @Transient + @JsonProperty("SwapMatchCars") + public String[] swapMatchCars; + + public String swapMatchCarsName; + + /** * 车位楼层及数量描述 */ @@ -194,9 +229,9 @@ public class CDStationInfo extends CommonStationInfo { /** * 充 电 电 费 率 */ -// @Transient -// @JsonProperty("ElectricityFee") -// public String electricityFee; + @Transient + @JsonProperty("ElectricityFee") + public String electricityFee; /** * 服务费率 */ @@ -303,7 +338,71 @@ public class CDStationInfo extends CommonStationInfo { * 有是否有储能设备 */ @Transient - @JsonProperty("ISEnergystorage") - public Integer iSEnergystorage; + @JsonProperty("IsEnergyStorage") + public Integer isEnergyStorage; + /** + * 站点分类 + */ + @Transient + @JsonProperty("StationClassification") + public Integer stationClassification; + /** + * 通用类型 + */ + @Transient + @JsonProperty("GeneralApplicationType") + public Integer generalApplicationType; + /** + * 7*24小时营业 + */ + @Transient + @JsonProperty("RoundTheClock") + public Integer roundTheClock; + /** + * 停车费类型 + */ + @Transient + @JsonProperty("ParkType") + public Integer parkType; + /** + * 电费类型 + */ + @Transient + @JsonProperty("ElectncityType") + public Integer electncityType; + /** + * 报装类型 + */ + @Transient + @JsonProperty("BusinessExpandType") + public Integer businessExpandType; + /** + * 站点额定总功率 + */ + @Transient + @JsonProperty("RatedPower") + @Column(columnDefinition = "Decimal(10,1)") + public Double ratedPower; + /** + * 峰谷分时 + */ + @Transient + @JsonProperty("PeriodFee") + public Integer periodFee; + /** + * 正式投运时间 + */ + @Transient + @JsonProperty("OfficialRunTime") + public String officialRunTime; + /** + * 视频监控配套情况 + */ + @Transient + @JsonProperty("VideoMonitor") + public Integer videoMonitor; + @Transient + @JsonProperty("SwapEquipmentlnfos") + public List swapEquipmentlnfos = null; } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatslnfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatslnfo.java new file mode 100644 index 00000000..ab7db153 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatslnfo.java @@ -0,0 +1,93 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.xhpc.evcs.dto.EquipmentStatsInfo; +import lombok.Data; + +import javax.persistence.Column; +import java.util.List; + +/** + * @author yuyang + * @date 2023-09-28 10:18 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "StationID", + "StartTime", + "EndTime", + "StationElectricity", + "EquipmentStatsInfos", + "StationClassification", + "OperatorID", + "EquipmentOnwerID", + "StationTotalChargeTime", + "StationTotalChargeNum", + "StationTotalWarningNum" +}) +@Data +public class CDStationStatslnfo { + + /** + * 充电设ID + */ + @JsonProperty("StationID") + public String stationID; + /** + * 统计的开始时间 + */ + @JsonProperty("StartTime") + public String startTime; + /** + * 统计结束时间 + */ + @JsonProperty("EndTime") + public String endTime; + /** + * 充电站累计电量 + */ + @Column(columnDefinition = "Decimal(10,1)") + @JsonProperty("StationElectricity") + public Double stationElectricity; + /** + * 充电设备统计信息列表 + */ + @JsonProperty("EquipmentStatsInfos") + List equipmentStatsInfo; + /** + * 站点分类 + */ + @JsonProperty("StationClassification") + public Integer stationClassification; + /** + * 运营平台ID + */ + @JsonProperty("OperatorID") + public String operatorID; + /** + * 产权所属单位ID + */ + @JsonProperty("EquipmentOnwerID") + public String equipmentOnwerID; + + /** + * 充电站累计用电时长 + */ + @Column(columnDefinition = "Decimal(10,2)") + @JsonProperty("StationTotalChargeTime") + public Double stationTotalChargeTime; + /** + * 充电站累计充电次数 + */ + @JsonProperty("StationTotalChargeNum") + public Integer stationTotalChargeNum; + /** + * 充电站累计告警数量 + */ + @JsonProperty("StationTotalWarningNum") + public Integer stationTotalWarningNum; + +} + diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatusInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatusInfo.java new file mode 100644 index 00000000..d75a4a2d --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatusInfo.java @@ -0,0 +1,44 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +import java.util.List; + +/** + * @author yuyang + * @date 2023-09-28 10:09 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "OperatorID", + "EquipmentOnwerID", + "StatlonID", + "ConnectorStatusInfos" +}) +@Data +public class CDStationStatusInfo { + /** + * 运营平台ID + */ + @JsonProperty("OperatorID") + public String operatorID; + /** + * 产权所属单位 + */ + @JsonProperty("EquipmentOnwerID") + public String equipmentOnwerID; + /** + * 充电设ID + */ + @JsonProperty("StationID") + public String stationID; + + /** + * 充电设备接口状态列表 + */ + @JsonProperty("ConnectorStatusInfos") + public List connectorStatusInfos; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatusInfoWrapper.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatusInfoWrapper.java new file mode 100644 index 00000000..7f7957f6 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDStationStatusInfoWrapper.java @@ -0,0 +1,69 @@ +package com.xhpc.evcs.cdjgpc.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; + +/** + * @author yuyang + * @date 2023-10-08 15:52 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "Total", + "StationStatusInfos" +}) +public class CDStationStatusInfoWrapper { + @JsonProperty("Total") + private Integer total; + @JsonProperty("StationStatusInfos") + private List stationStatusInfos = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("Total") + public Integer getTotal() { + + return total; + } + + @JsonProperty("Total") + public void setTotal(Integer total) { + + this.total = total; + } + + @JsonProperty("StationStatusInfos") + public List getStationStatusInfos() { + + return stationStatusInfos; + } + + @JsonProperty("StationStatusInfos") + public void setStationStatusInfos(List stationStatusInfos) { + + this.stationStatusInfos = stationStatusInfos; + } + + @JsonAnyGetter + public Map 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(); + } +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupConnectorPowerInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupConnectorPowerInfo.java new file mode 100644 index 00000000..f6390a97 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupConnectorPowerInfo.java @@ -0,0 +1,52 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.persistence.Column; + +/** + * @author yuyang + * @date 2023-09-28 10:51 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "ConnectorID", + "EquipmentClassification", + "DataTime", + "ConnectorRealTimePower" +}) +@Data +public class CDSupConnectorPowerInfo { + + /** + * 充电设备接口编码 + */ + @JsonProperty("ConnectorID") + public String connectorID; + /** + * 设备分类 + */ + @JsonProperty("EquipmentClassification") + public Integer equipmentClassification; + /** + * 统计时间 + */ + @JsonProperty("DataTime") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + public String dataTime; + /** + * 充电设备接口实时功率 + */ + @Column(columnDefinition = "Decimal(10,1)") + @JsonProperty("ConnectorRealTimePower") + public Double connectorRealTimePower; + + + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupConnectorStatslnfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupConnectorStatslnfo.java new file mode 100644 index 00000000..3e3018db --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupConnectorStatslnfo.java @@ -0,0 +1,61 @@ +package com.xhpc.evcs.cdjgpc.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; + +import javax.persistence.Column; + +/** + * @author yuyang + * @date 2023-09-28 10:37 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "ConnectorID", + "ConnectorElectricity", + "EquipmentClassification", + "ConnectorTotalChargeTime", + "ConnectorTotalChargeNum", + "ConnectorTotalWarningNum" +}) +@Setter +@Getter +public class CDSupConnectorStatslnfo { + + /** + * 充电设备接口编码 + */ + @JsonProperty("ConnectorID") + public String connectorID; + /** + * 充电设备接口累计电量 + */ + @Column(columnDefinition = "Decimal(10,2)") + @JsonProperty("ConnectorElectricity") + public Double connectorElectricity; + /** + * 设备分类 + */ + @JsonProperty("EquipmentClassification") + public Integer equipmentClassification; + /** + * 充电设备接口累计充电时长 + */ + @JsonProperty("ConnectorTotalChargeTime") + public Integer connectorTotalChargeTime; + /** + * 充电设备接口累计充电次数 + */ + @JsonProperty("ConnectorTotalChargeNum") + public Integer connectorTotalChargeNum; + /** + * 充电设备接口累计告警 + */ + @JsonProperty("ConnectorTotalWarningNum") + public Integer connectorTotalWarningNum; + + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentAccidentInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentAccidentInfo.java new file mode 100644 index 00000000..a56f8ac9 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentAccidentInfo.java @@ -0,0 +1,83 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +/** + * @author yuyang + * @date 2023-09-28 11:03 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "AreaCode", + "Address", + "AccidentEntity", + "Type", + "AccidentReason", + "Level", + "AccidentTime", + "Description", + "Pictures", + "AnalysisReport" +}) +@Data +public class CDSupEquipmentAccidentInfo { + + /** + * 区域代码 + */ + @JsonProperty("AreaCode") + public String areaCode; + /** + * 事故地点 + */ + @JsonProperty("Address") + public String address; + /** + * 事故主体 + */ + @JsonProperty("AccidentEntity") + public Integer accidentEntity; + /** + * 事故类型 + */ + @JsonProperty("Type") + public Integer type; + /** + * 事故原因 + */ + @JsonProperty("AccidentReason") + public String accidentReason; + /** + * 事故分级 + */ + @JsonProperty("Level") + public Integer level; + /** + * 发生时间 + */ + @JsonProperty("AccidentTime") + public String accidentTime; + /** + * 事故文字描述 + */ + @JsonProperty("Description") + public String description; + /** + * 现场图片 + */ + @JsonProperty("Pictures") + public String [] pictures; + + public String picturesName; + + /** + * 事故分析报 + */ + @JsonProperty("AnalysisReport") + public String [] analysisReport; + + public String analysisReportName; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentAccidentInfoResponse.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentAccidentInfoResponse.java new file mode 100644 index 00000000..9ea4fec7 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentAccidentInfoResponse.java @@ -0,0 +1,29 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yuyang + * @date 2023-10-09 19:20 + */ +@Getter +@Setter +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) + +public class CDSupEquipmentAccidentInfoResponse { + @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("EquipmentAccidentInfos") + List supEquipmentAccidentInfos = new ArrayList<>(); +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentPowerInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentPowerInfo.java new file mode 100644 index 00000000..fba944c0 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupEquipmentPowerInfo.java @@ -0,0 +1,54 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +import javax.persistence.Column; +import java.util.List; + +/** + * @author yuyang + * @date 2023-09-28 10:47 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "EquipmentID", + "EquipmentClassification", + "DataTime", + "EquipRealTimePower", + "ConnectorPowerInfos" +}) +@Data +public class CDSupEquipmentPowerInfo { + + public String pileID; + /** + * 充电设备编码 + */ + @JsonProperty("EquipmentID") + public String equipmentID; + /** + * 设备分类 + */ + @JsonProperty("EquipmentClassification") + public Integer equipmentClassification; + /** + * 统计时间 + */ + @JsonProperty("DataTime") + public String dataTime; + /** + * 统计时间 + */ + @Column(columnDefinition = "Decimal(10,1)") + @JsonProperty("EquipRealTimePower") + public Double equipRealTimePower; + /** + * 充电设备接口功率信息列表 + */ + @JsonProperty("ConnectorPowerInfos") + List connectorPowerInfos; + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupStationPowerInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupStationPowerInfo.java new file mode 100644 index 00000000..aee6046f --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSupStationPowerInfo.java @@ -0,0 +1,63 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +import javax.persistence.Column; +import java.util.List; + +/** + * @author yuyang + * @date 2023-09-28 10:44 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "OperatorlD", + "EquipmentOnwerID", + "StationID", + "StationClassification", + "DataTime", + "StationRealTimePower", + "EquipmentPowerInfos" +}) +@Data +public class CDSupStationPowerInfo { + /** + * 充电设备接口编码 + */ + @JsonProperty("OperatorlD") + public String operatorlD; + /** + * 产权所属单位ID + */ + @JsonProperty("EquipmentOnwerID") + public String equipmentOnwerID; + /** + * 充电站 + */ + @JsonProperty("StationID") + public String stationID; + /** + * 站点分类 + */ + @JsonProperty("StationClassification") + public Integer stationClassification; + /** + * 统计时间 + */ + @JsonProperty("DataTime") + public String dataTime; + /** + * 充电站实时功率 + */ + @Column(columnDefinition = "Decimal(10,1)") + @JsonProperty("StationRealTimePower") + public Double stationRealTimePower; + /** + * 充电设备功率信息列表 + */ + @JsonProperty("EquipmentPowerInfos") + List equipmentPowerInfos; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuperviseQueryEquipmentPowerInfoRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuperviseQueryEquipmentPowerInfoRequest.java new file mode 100644 index 00000000..5e1aacfd --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuperviseQueryEquipmentPowerInfoRequest.java @@ -0,0 +1,23 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * @author yuyang + * @date 2023-10-07 10:52 + */ +@Getter +@Setter +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDSuperviseQueryEquipmentPowerInfoRequest { + + @JsonProperty("StationID") + String stationID; + + @JsonProperty("DataTime") + String dataTime; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuperviseQueryStationPowerInfoRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuperviseQueryStationPowerInfoRequest.java new file mode 100644 index 00000000..4c67e335 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuperviseQueryStationPowerInfoRequest.java @@ -0,0 +1,27 @@ +package com.xhpc.evcs.cdjgpc.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @author yuyang + * @date 2023-10-07 10:48 + */ +@Getter +@Setter +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class CDSuperviseQueryStationPowerInfoRequest { + + @JsonProperty("StationIDs") + String [] stationIDs; + + @JsonProperty("DataTime") + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + String dataTime; +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuqEquipmentStatslnfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuqEquipmentStatslnfo.java new file mode 100644 index 00000000..7f86f808 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSuqEquipmentStatslnfo.java @@ -0,0 +1,67 @@ +package com.xhpc.evcs.cdjgpc.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; + +import javax.persistence.Column; +import java.util.List; + +/** + * @author yuyang + * @date 2023-09-28 10:32 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "EquipmentID", + "EquipmentClassification", + "EquipmentElectncity", + "EquipmentTotalChargeTime", + "EquipmentTotalChargeNum", + "EquipmentTotalWarningNum", + "ConnectorStatsInfos" +}) +@Setter +@Getter +public class CDSuqEquipmentStatslnfo { + + /** + * 充电设备编码 + */ + @JsonProperty("EquipmentID") + public String equipmentID; + /** + * 设备分类 + */ + @JsonProperty("EquipmentClassification") + public Integer equipmentClassification; + /** + * 充电设备累计电量 + */ + @Column(columnDefinition = "Decimal(10,2)") + @JsonProperty("EquipmentElectncity") + public Double equipmentElectncity; + /** + * 充电设备累计充电时长 + */ + @JsonProperty("EquipmentTotalChargeTime") + public Integer equipmentTotalChargeTime; + /** + * 充电累计充电次数 + */ + @JsonProperty("EquipmentTotalChargeNum") + public Integer equipmentTotalChargeNum; + /** + * 充电设备累计告警数量 + */ + @JsonProperty("EquipmentTotalWarningNum") + public Integer equipmentTotalWarningNum; + /** + * 充电设备接口运行统计列表 + */ + @JsonProperty("ConnectorStatsInfos") + List connectorStatsInfos; + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSwapEquipmentlnfos.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSwapEquipmentlnfos.java new file mode 100644 index 00000000..52cb074a --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/cdjgpc/dto/CDSwapEquipmentlnfos.java @@ -0,0 +1,9 @@ +package com.xhpc.evcs.cdjgpc.dto; + +/** + * @author yuyang + * @date 2023-09-27 17:25 + */ +public class CDSwapEquipmentlnfos { + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingPile.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingPile.java index a658f152..fddc00eb 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingPile.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingPile.java @@ -130,6 +130,13 @@ public class XhpcChargingPile extends BaseEntity { @Column(name = "manufacturer_id") private String manufacturerId; + @Column(name = "equipment_classificatlon") + private Integer equipmentClassificatlon; + + @Column(name = "aux_power") + private Integer auxPower; + + private String constructionTime; public Integer getEquipmentType() { @@ -486,6 +493,22 @@ public class XhpcChargingPile extends BaseEntity { this.constructionTime = constructionTime; } + public Integer getEquipmentClassificatlon() { + return equipmentClassificatlon; + } + + public void setEquipmentClassificatlon(Integer equipmentClassificatlon) { + this.equipmentClassificatlon = equipmentClassificatlon; + } + + public Integer getAuxPower() { + return auxPower; + } + + public void setAuxPower(Integer auxPower) { + this.auxPower = auxPower; + } + @Override public String toString() { return "XhpcChargingPile{" + @@ -525,6 +548,7 @@ public class XhpcChargingPile extends BaseEntity { ", equipmentStatus=" + equipmentStatus + ", equipmentPurpose=" + equipmentPurpose + ", manufacturerId='" + manufacturerId + '\'' + + ", equipmentClassificatlon='" + equipmentClassificatlon + '\'' + ", constructionTime='" + constructionTime + '\'' + '}'; } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java index 0acf8f36..f56a5d13 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java @@ -27,4 +27,8 @@ public class EquipAuthResponse { @JsonProperty("FailReason") Integer failReason; + + @JsonProperty("FailReasonMsg") + String failReasonMsg; + } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/NotificationStartChargeResultRequestData.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/NotificationStartChargeResultRequestData.java index 6243dded..f33e9de6 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/NotificationStartChargeResultRequestData.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/NotificationStartChargeResultRequestData.java @@ -27,6 +27,9 @@ public class NotificationStartChargeResultRequestData { @JsonProperty("IdentCode") private String identCode; + @JsonProperty("FailReasonMsg") + private String failReasonMsg; + @JsonProperty("StartChargeSeq") public String getStartChargeSeq() { @@ -87,6 +90,15 @@ public class NotificationStartChargeResultRequestData { this.identCode = identCode; } + @JsonProperty("FailReasonMsg") + public String getFailReasonMsg() { + return failReasonMsg; + } + + @JsonProperty("FailReasonMsg") + public void setFailReasonMsg(String failReasonMsg) { + this.failReasonMsg = failReasonMsg; + } @JsonIgnore private Map additionalProperties = new HashMap(); @@ -103,6 +115,8 @@ public class NotificationStartChargeResultRequestData { this.additionalProperties.put(name, value); } + + @Override public String toString() { diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/QueryStopChargeResponse.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/QueryStopChargeResponse.java index df7e06d0..396506e6 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/QueryStopChargeResponse.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/QueryStopChargeResponse.java @@ -16,6 +16,7 @@ import lombok.Setter; "StartChargeSeqStat", "SuccStat", "FailReason", + "FailReasonMsg", }) public class QueryStopChargeResponse { @@ -27,5 +28,6 @@ public class QueryStopChargeResponse { int succStat; @JsonProperty("FailReason") int failReason; - + @JsonProperty("FailReasonMsg") + String failReasonMsg; } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeRequest.java index 04ca8bde..d007d057 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeRequest.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeRequest.java @@ -18,6 +18,9 @@ public class StartChargeRequest { @JsonProperty("QRCode") String qRCode; + @JsonProperty("PhoneNum") + String PhoneNum; + @JsonProperty("PlateNum") String plateNum; @@ -33,6 +36,9 @@ public class StartChargeRequest { @JsonProperty("UserId") String userId3rdpty; + @JsonProperty("FailReasonMsg") + String failReasonMsg; + @JsonIgnore private Map additionalProperties = new HashMap(); @@ -84,6 +90,16 @@ public class StartChargeRequest { this.qRCode = qRCode; } + @JsonProperty("PhoneNum") + public String getPhoneNum() { + return PhoneNum; + } + + @JsonProperty("PhoneNum") + public void setPhoneNum(String phoneNum) { + PhoneNum = phoneNum; + } + @JsonProperty("PlateNum") public String getPlateNum() { @@ -144,4 +160,13 @@ public class StartChargeRequest { this.userId3rdpty = userId3rdpty; } + @JsonProperty("FailReasonMsg") + public String getFailReasonMsg() { + return failReasonMsg; + } + + @JsonProperty("FailReasonMsg") + public void setFailReasonMsg(String failReasonMsg) { + this.failReasonMsg = failReasonMsg; + } } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeResponse.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeResponse.java index ecc35369..373e4ac6 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeResponse.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeResponse.java @@ -26,4 +26,7 @@ public class StartChargeResponse { @JsonProperty("FailReason") Integer failReason; + + @JsonProperty("FailReasonMsg") + String failReasonMsg; } diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationStatsRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationStatsRequest.java index 8abb4246..70b08601 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationStatsRequest.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationStatsRequest.java @@ -1,6 +1,7 @@ package com.xhpc.evcs.dto; import com.fasterxml.jackson.annotation.*; +import lombok.Data; import java.util.HashMap; import java.util.Map; @@ -11,10 +12,11 @@ import java.util.Map; "StartTime", "EndTime" }) +@Data public class StationStatsRequest { @JsonProperty("StationID") - private Integer stationID; + private String stationID; @JsonProperty("StartTime") private String startTime; @JsonProperty("EndTime") @@ -34,4 +36,16 @@ public class StationStatsRequest { this.additionalProperties.put(name, value); } + public String getStationID() { + return stationID; + } + + public String getStartTime() { + return startTime; + } + + public String getEndTime() { + return endTime; + } + } diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryTokenController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryTokenController.java index e40c63dc..3596e506 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryTokenController.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryTokenController.java @@ -113,4 +113,62 @@ public class QueryTokenController { } } + + + @PostMapping("/v10/query_token") + public CommonResponse queryTokenV10(@RequestHeader(value = "enc.out", defaultValue = "true") String encout, + @RequestBody TokenRequest tokenRequest) throws IOException { + log.debug("< 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 && check NPE + chargeOrderInfo.setBillerOperatorId("MA6DFCTD5"); + // log.info(">>notify charge order OID: " + operatorID); +// chargeOrderInfoRepository.save(chargeOrderInfo); + CommonResponse response = new CommonResponse(); + response.setRet(EvcsConst.RET_SUCC); + CDChargeOrder4BonusInfoRes resp = new CDChargeOrder4BonusInfoRes(); + resp.setConfirmResult(0); + resp.setConnectorID(chargeOrderInfo.getConnectorID()); + resp.setStartChargeSeq(chargeOrderInfo.getStartChargeSeq()); + response.setData(JSONUtil.toJSONString(resp)); + return response; + } + +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDNotificationStationInfoController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDNotificationStationInfoController.java index 47026034..bb91b2ae 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDNotificationStationInfoController.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDNotificationStationInfoController.java @@ -1,27 +1,38 @@ package com.xhpc.evcs.cdjgpc.api; +import cn.hutool.core.date.DateUtil; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.xhpc.common.api.PowerPileService; import com.xhpc.common.api.dto.ChargingStationDto; import com.xhpc.common.core.domain.R; -import com.xhpc.common.redis.service.RedisService; -import com.xhpc.evcs.cdjgpc.dto.CDEquipmentInfo; -import com.xhpc.evcs.cdjgpc.dto.CDStationInfo; -import com.xhpc.evcs.cdjgpc.dto.CDStationInfoResponse; +import com.xhpc.common.data.redis.CacheRateModel; +import com.xhpc.common.data.redis.CacheRealtimeData; +import com.xhpc.common.domain.XhpcTerminal; +import com.xhpc.evcs.cdjgpc.dto.*; import com.xhpc.evcs.domain.AuthSecretToken; +import com.xhpc.evcs.domain.XhpcInternetUser; +import com.xhpc.evcs.domain.XhpcStationInternetBlacklist; import com.xhpc.evcs.dto.*; +import com.xhpc.evcs.encryption.EvcsConst; import com.xhpc.evcs.jpa.AuthSecretTokenRepository; +import com.xhpc.evcs.jpa.XhpcInternetUserRepository; +import com.xhpc.evcs.jpa.XhpcStationInternetBlacklistRepository; +import com.xhpc.evcs.jpa.XhpcTerminalRepository; import com.xhpc.evcs.notification.CoreDispatcher; import com.xhpc.evcs.utils.JSONUtil; import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import static cn.hutool.core.util.NumberUtil.isInteger; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.Instant; import java.util.*; - +import java.util.stream.Collectors; +import static com.xhpc.evcs.config.EvcsFilter.encryptReqOut; +import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_IN; import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT; /** @@ -34,31 +45,55 @@ public class CDNotificationStationInfoController extends CoreDispatcher { @Resource - private AuthSecretTokenRepository authSecretTokenRepository; + AuthSecretTokenRepository authSecretTokenRepository; + @Resource + XhpcInternetUserRepository xhpcInternetUserRepository; + @Resource + XhpcStationInternetBlacklistRepository xhpcStationInternetBlacklistRepo; + @Resource + XhpcTerminalRepository terminalRepository; + @Resource + PowerPileService powerPileService; - //充电站信息变化推送 + //充电站信息变化推送(我们平台推送成都市平台) --已推送 @PostMapping("/v10/getNotificationStationInfo") public R getNotificationStationInfo(@RequestBody Map map){ try{ String chargingStationId = map.get("chargingStationId").toString(); AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType( - "765367656", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); //todo + "MA6CC2LK7", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); //todo // maybe对接第三方 if (authSecretTokenOut != null) { //获取场站信息 String key = "cdjgpc:station:".concat(chargingStationId)+".notification"; - CDStationInfo cdStationInfo =REDIS.getCacheObject(key); + cdStationInfo.setEquipmentInfos(new ArrayList<>()); + //查询场站是桩是否对应上 + ChargingStationDto stationDto = REDIS.getCacheObject("station:"+chargingStationId); + Set pks = stationDto.getPiles(); + if (pks != null) { + List cdEquipmentInfos = new ArrayList<>(); + for (String pileNo : pks) { + String pk = "pile:".concat(pileNo); + String skey = "cdjgpc:".concat(pk)+".notification"; + CDEquipmentInfo cdEquipmentInfo = REDIS.getCacheObject(skey); + if(cdEquipmentInfo==null || "".equals(cdEquipmentInfo.getEquipmentID())){ + log.info("该场站下面:"+pileNo+"桩未录入"); + }else{ + cdEquipmentInfos.add(cdEquipmentInfo); + } + } + cdStationInfo.setEquipmentInfos(cdEquipmentInfos); + } + cdStationInfo.setSwapMatchCarsName(null); CommonRequest commonRequest = new CommonRequest<>(); Map mapStationInfo =new HashMap<>(); mapStationInfo.put("StationInfo",cdStationInfo); String data =JSONUtil.toJSONString(mapStationInfo); commonRequest.setData(data); - String result =ok(commonRequest,"/notification_stationInfo",authSecretTokenOut,"MA6DFCTD5"); - System.out.println("=======responseBody========"+result); - CDStationInfoResponse cdStationInfoResponse = DTOJsonHelper.parseResponseData(result, CDStationInfoResponse.class, authSecretTokenOut); - System.out.println("=======cdStationInfoResponse========"+cdStationInfoResponse.getStatus()); + String result =ok(commonRequest,"/notification_stationInfo",authSecretTokenOut); + System.out.println("=======result========"+result); } }catch (Exception e){ e.printStackTrace(); @@ -66,35 +101,725 @@ public class CDNotificationStationInfoController extends CoreDispatcher { return R.ok(); } - @PostMapping("/v10/getNotificationStationStatus") - public R getNotificationStationStatus(@RequestBody Map map){ + /** + * 查询充电站信息(成都市平台调用我们平台) --已推送 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/query_stations_info") + public CommonResponse queryStationsInfo(@RequestBody(required = false) CommonRequest commonRequest) { + + System.out.println("================查询充电站信息======================="); + CommonResponse resp = new CommonResponse(); + try{ + //当前页数 + PageRequest pageRequest = commonRequest.transformDataType(PageRequest.class); + Integer pageNo = pageRequest.getPageNo(); + CDPageStationsInfoResponse response = new CDPageStationsInfoResponse(); + response.setPageNo(pageNo); + //页码总数 + String operatorId = commonRequest.getOperatorId(); + Instant now = Instant.now(); + XhpcInternetUser xhpcInternetUser = + xhpcInternetUserRepository + .findByOperatorIdEvcsLikeAndCooperationStartTimeBeforeAndCooperationEndTimeAfter(operatorId, now, now); + Long internetUserId = xhpcInternetUser.getInternetUserId(); + List xhpcStationInternetBlacklist = + xhpcStationInternetBlacklistRepo.findByInternetUserId(internetUserId); + List stationKeys = new ArrayList<>(REDIS.keys("station:*")); + List validStationKeys = new ArrayList<>(); + for (String stationKey : stationKeys) { + boolean isValid = true; + //查询不合作的电桩 + for (XhpcStationInternetBlacklist xhpcStationInternetBlack : xhpcStationInternetBlacklist) { + if (stationKey.substring(8).equals(xhpcStationInternetBlack.getChargingStationId().toString())) { + isValid = false; + } + } + ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey); + if (chargingStationDto.getPiles() != null) { + if (isValid) { + validStationKeys.add(stationKey); + } + } + } + if (validStationKeys.size() > 0) { + Integer pageSize = pageRequest.getPageSize(); + int totalPage = validStationKeys.size() % pageSize == 0 ? validStationKeys.size() / pageSize : + (validStationKeys.size() / pageSize) + 1; + response.setPageCount(totalPage); + } + //总记录条数 + response.setItemSize(validStationKeys.size()); + + //充电站信息列表 + List stationInfos = new ArrayList<>(); + //计算每页开始索引 + int startIndex = -1; + int endIndex = -1; + if (pageNo == 1 && validStationKeys.size() <= 10) { + startIndex = 0; + endIndex = validStationKeys.size() - 1; + } else { + Integer pageSize = pageRequest.getPageSize(); + startIndex = (pageNo - 1) * pageSize; + endIndex = startIndex + (pageSize - 1); + } + for (int i = startIndex; i <= endIndex; i++) { + String stationKey = null; + try { + stationKey = validStationKeys.get(i); + } catch (Exception e) { + continue; + } + String stationId = stationKey.replace("station:", ""); + stationInfos.add(getNotificationStationInfo(stationId)); + } + response.setStationInfos(stationInfos); + resp.setRet("0"); + resp.setMsg("Query station info success"); + resp.setData(JSONUtil.toJSONString(response)); + + }catch (Exception e){ + e.printStackTrace(); + } + + return resp; + } + + + /** + * 设备充电中状态变化推送(我们平台推送成都市平台) --已推送 + * 实时数据没15秒一帧 + */ + @PostMapping("/v10/getNotificationConnectorChargeStatus") + public void getNotificationConnectorChargeStatus(@RequestBody Map orderMap){ + //先查订单号 在查实时数据 最后计算金额 try { - AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType("765367656", SECRET_TOKEN_TYPE_OUT).orElse(null); - log.debug("nss pushing to: {}", authSecretTokenOut.getOperatorId3irdpty()); - if (authSecretTokenOut != null) { - ConnectorStatusInfoReq connectorStatusInfoReq = new ConnectorStatusInfoReq(); - ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo(); - connectorStatusInfo.setConnectorID(map.get("connectorID").toString()); - connectorStatusInfo.setStatus(ConnectorStatusInfo.FREE); - connectorStatusInfoReq.setConnectorStatusInfo(connectorStatusInfo); - String data = JSONUtil.toJSONString(connectorStatusInfoReq); - log.info("===============data=================="+data); + String orderNo = orderMap.get("orderNo").toString(); + CacheRealtimeData lord = REDIS.getCacheObject("order:"+orderNo+".lord"); + String formatTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + Map cacheMap =REDIS.getCacheMap("order:"+orderNo+".notification"); + if(cacheMap==null || cacheMap.get("startTime")==null || "".equals(cacheMap.get("startTime"))){ + cacheMap.put("lastPushTime", formatTime); + }else{ + cacheMap.put("lastPushTime", cacheMap.get("pushTime")); + } + cacheMap.put("pushTime", formatTime); + CDConnectorChargeStatusInfo cdConnectorChargeStatusInfo = new CDConnectorChargeStatusInfo(); + Map cacheMapOrder = REDIS.getCacheMap("order:"+orderNo); + if(cacheMap.get("startTime")==null ){ + if(cacheMapOrder !=null && cacheMapOrder.get("startTime")!=null){ + cdConnectorChargeStatusInfo.setStartTime(cacheMapOrder.get("startTime").toString()); + cacheMap.put("startTime", cacheMapOrder.get("startTime").toString()); + } + }else{ + cdConnectorChargeStatusInfo.setStartTime(cacheMap.get("startTime").toString()); + } + if(cacheMapOrder !=null && cacheMapOrder.get("status")!=null){ + if("已结束".equals(cacheMapOrder.get("status").toString())){ + cdConnectorChargeStatusInfo.setConnectorStatus(1); + cdConnectorChargeStatusInfo.setOrderStatus(4); + }else{ + cdConnectorChargeStatusInfo.setConnectorStatus(3); + cdConnectorChargeStatusInfo.setOrderStatus(2); + } + } + REDIS.setCacheMap("order:"+orderNo+".notification",cacheMap); + cdConnectorChargeStatusInfo.setStartChargeSeq(lord.getOrderNo()); + cdConnectorChargeStatusInfo.setConnectorID(lord.getPileNo()+lord.getGunId()); + cdConnectorChargeStatusInfo.setCurrentA((double)(lord.getWorkingCurrent()/10)); + cdConnectorChargeStatusInfo.setVoltageA((double)(lord.getWorkingVoltage()/10)); + cdConnectorChargeStatusInfo.setSoc((double)lord.getSoc()); + cdConnectorChargeStatusInfo.setEndTime(formatTime); + cdConnectorChargeStatusInfo.setPushTime(formatTime); + cdConnectorChargeStatusInfo.setLastPushTime(cacheMap.get("lastPushTime").toString()); + BigDecimal chargingDegree = new BigDecimal(lord.getChargingDegree()).divide(new BigDecimal(10000).setScale(2, BigDecimal.ROUND_UP)); + BigDecimal amountCharged = new BigDecimal(lord.getAmountCharged()).divide(new BigDecimal(10000).setScale(2, BigDecimal.ROUND_UP)); + cdConnectorChargeStatusInfo.setTotalPower(chargingDegree.doubleValue()); + cdConnectorChargeStatusInfo.setTotalMoney(amountCharged.doubleValue()); + + String key = "pile:"+orderNo.substring(0,14); + Map cachePile = REDIS.getCacheMap(key); + String stationId = cachePile.get("stationId").toString(); + cdConnectorChargeStatusInfo.setEquipmentID(orderNo.substring(0,14)); + cdConnectorChargeStatusInfo.setStationID(stationId); + + String stationSey = "cdjgpc:station:".concat(stationId)+".notification"; + CDStationInfo cdStationInfo =REDIS.getCacheObject(stationSey); + cdConnectorChargeStatusInfo.setOperatorID(cdStationInfo.getOperatorId()); + cdConnectorChargeStatusInfo.setEquipmentOwnerID(cdStationInfo.getEquipmentOwnerId()); + + + Map cacheOrder = REDIS.getCacheMap("order:" + orderNo); + + if(cacheOrder !=null && cacheOrder.get("rateModelId") !=null){ + CacheRateModel rateModel = REDIS.getCacheObject("rateModel:" + cacheOrder.get("rateModelId").toString()); + if(rateModel.getT1SvcPrice().equals(rateModel.getT2SvcPrice()) && rateModel.getT3SvcPrice().equals(rateModel.getT4SvcPrice()) && + rateModel.getT1SvcPrice().equals(rateModel.getT3SvcPrice())){ + + BigDecimal divide = new BigDecimal(rateModel.getT1SvcPrice()).divide(new BigDecimal(100000)).setScale(2, BigDecimal.ROUND_UP); + + BigDecimal bigDecimal = chargingDegree.multiply(divide).setScale(2, BigDecimal.ROUND_UP); + cdConnectorChargeStatusInfo.setSeviceMoney(bigDecimal.doubleValue()); + BigDecimal subtract = amountCharged.subtract(bigDecimal); + cdConnectorChargeStatusInfo.setElecMoney(subtract.doubleValue()); + }else{ + //暂时不考虑不同服务费 默认为0.2 + BigDecimal multiply = chargingDegree.multiply(new BigDecimal(0.2)).setScale(2, BigDecimal.ROUND_UP);; + cdConnectorChargeStatusInfo.setSeviceMoney(multiply.doubleValue()); + BigDecimal subtract = amountCharged.subtract(multiply); + cdConnectorChargeStatusInfo.setElecMoney(subtract.doubleValue()); + } + AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType("MA6CC2LK7", SECRET_TOKEN_TYPE_OUT).orElse(null); + Map map =new HashMap<>(); + map.put("ConnectorChargeStatusInfo",cdConnectorChargeStatusInfo); + String data = JSONUtil.toJSONString(map); CommonRequest commonRequest = new CommonRequest<>(); commonRequest.setData(data); - String ok = ok(commonRequest, "/notification_stationStatus", authSecretTokenOut); - log.info("===============3333=================="+ok); + String result = ok(commonRequest, "/notification_connector_charge_status", authSecretTokenOut); + System.out.println("=======result========"+result); } - }catch (Exception e){ - log.info("===============eeee=================="); + } catch (JsonProcessingException e) { e.printStackTrace(); } - - - return R.ok(); } + /** + * 设备接口状态查询(成都市平台调用我们平台) --已调用 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/query_station_status") + public CommonResponse queryStationsStatus(@RequestBody CommonRequest commonRequest) throws Exception { + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + StationStatusRequest stationStatusRequest = JSONUtil.readParams(commonRequest.getData(), StationStatusRequest.class); + if (stationStatusRequest == null) { + resp.setMsg("Request or token params validation failed"); + } else { + String[] stationIDs = stationStatusRequest.getStationIds(); + List cdStationStatusInfos = new ArrayList<>(); + //Loading data through redis at first. + Collection guns = REDIS.keys("gun:*"); + List gunsNewList = new ArrayList<>(); + for (String value : guns) { + gunsNewList.add(value.substring(4)); + } + List gunsIds = new ArrayList<>(); + for (String value : gunsNewList) { + if (value.length() == 16) { + gunsIds.add(value); + } + } + Map statusMap = new HashMap<>(); + String[] keys = {"离线", "空闲", "故障"}; + Integer[] values = {0, 1, 255}; + for (int i = 0; i < keys.length; i++) { + statusMap.put(keys[i], values[i]); + } + + List terminalList = terminalRepository.selectStatusBySql(); + Map terminalDBMap = terminalList.stream().collect(Collectors.toMap(XhpcTerminal::getSerialNumber,XhpcTerminal::getStatus)); + + for (String stationID : stationIDs) { + ChargingStationDto chargingStationDto = REDIS.getCacheObject("station:" + stationID); + CDStationInfo cdStationInfo =REDIS.getCacheObject("cdjgpc:station:"+stationID+".notification"); + + Set pileIds = new HashSet<>(); + if (null != chargingStationDto) { + pileIds = chargingStationDto.getPiles(); + } + boolean existsGun = false; + List connectorStatusInfos = new ArrayList<>(); + for (String pileId : pileIds) { + for (String value : gunsIds) { + if (pileId.equals(value.substring(0, 14))) { + existsGun = true; + CDConnectorStatusInfo cdConnectorStatusInfo = new CDConnectorStatusInfo(); + Integer gunStatus = terminalDBMap.get(value); + if (gunStatus == null){ + existsGun = false; + } else { + if (gunStatus == 0){ + Object status = REDIS.getCacheMapValue("gun:" + value, "status"); + if (isInteger(status.toString())) { + cdConnectorStatusInfo.setStatus(3); + } else { + cdConnectorStatusInfo.setStatus(statusMap.get(status)); + } + } else { + cdConnectorStatusInfo.setStatus(0); + } + cdConnectorStatusInfo.setConnectorID(value); + cdConnectorStatusInfo.setEquipmentClassification(1); + cdConnectorStatusInfo.setOperatorID(cdStationInfo.getOperatorId()); + cdConnectorStatusInfo.setEquipmentOwnerID(cdStationInfo.getEquipmentOwnerId()); + cdConnectorStatusInfo.setStationID(cdStationInfo.getStationId()); + cdConnectorStatusInfo.setEquipmentID(cdStationInfo.getOperatorId()); + connectorStatusInfos.add(cdConnectorStatusInfo); + } + } + } + } + if (existsGun) { + CDStationStatusInfo cdStationStatusInfo = new CDStationStatusInfo(); + cdStationStatusInfo.setStationID(stationID); + cdStationStatusInfo.setConnectorStatusInfos(connectorStatusInfos); + cdStationStatusInfo.setOperatorID(cdStationInfo.getOperatorId()); + cdStationStatusInfo.setEquipmentOnwerID(cdStationInfo.getEquipmentOwnerId()); + cdStationStatusInfos.add(cdStationStatusInfo); + } + } + CDStationStatusInfoWrapper stationStatusInfoWrappers = new CDStationStatusInfoWrapper(); + stationStatusInfoWrappers.setTotal(cdStationStatusInfos.size()); + if (cdStationStatusInfos.size() != 0) { + stationStatusInfoWrappers.setStationStatusInfos(cdStationStatusInfos); + } + resp.setRet("0"); + resp.setMsg("Query station status success"); + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("StationStats",stationStatusInfoWrappers); + resp.setData(JSONUtil.toJSONString(mapStationInfo)); + } + return resp; + } + + + /** + * 查询统计信息(成都市平台调用我们平台) --已调用 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/query_station_stats") + public CommonResponse queryStationsStats(@RequestBody CommonRequest commonRequest) throws Exception{ + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + StationStatsRequest stationStatsRequest = JSONUtil.readParams(commonRequest.getData(), StationStatsRequest.class); + if (stationStatsRequest == null) { + resp.setMsg("Request or token params validation failed"); + resp.setRet("4002"); + } else { + R r = powerPileService.queryStationStats(Long.valueOf(stationStatsRequest.getStationID()), stationStatsRequest.getStartTime(), stationStatsRequest.getEndTime()); + if(r.getCode() !=200){ + resp.setRet("-1"); + resp.setMsg("系统繁忙,此时请求方稍后重试"); + return resp; + } + String key ="cdjgpc:station:"+stationStatsRequest.getStationID()+".queryStationStats"; + CDStationStatslnfo stationStatsInfo =REDIS.getCacheObject(key); + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("StationStats",stationStatsInfo); + resp.setRet("0"); + resp.setData(JSONUtil.toJSONString(mapStationInfo)); + resp.setMsg("Query station info success"); + REDIS.deleteObject(key); + } + return resp; + } + + + /** + * 站点费率变化tuisong(我们平台调用成都市平台) --已推送 + * @return + * @throws Exception + */ + @PostMapping("/v10/getNotificationStationFee") + public void getNotificationStationFee() throws Exception { + AuthSecretToken authSecretTokenOut = + authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType( + "MA6CC2LK7", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); + // maybe对接第三方 + if (authSecretTokenOut != null) { + List stationKeys = new ArrayList<>(REDIS.keys("cdjgpc:stationFee:*")); + for (String stationKey : stationKeys) { + CDStationFee cdStationFeeRequest = REDIS.getCacheObject(stationKey); + Map map =new HashMap<>(); + map.put("StationFee",cdStationFeeRequest); + String data = JSONUtil.toJSONString(map); + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setData(data); + String ok = ok(commonRequest, "/notification_stationFee", authSecretTokenOut); + log.info("===============notification_stationFee=================="+ok); + REDIS.deleteObject(stationKey); + } + } + } + + /** + * 查询站点费率(成都市平台调用我们平台) + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/query_station_fee") + public CommonResponse queryStationFee(@RequestBody CommonRequest commonRequest) throws Exception{ + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + CDStationFeeRequest stationFeeRequest = JSONUtil.readParams(commonRequest.getData(), CDStationFeeRequest.class); + if (stationFeeRequest == null) { + resp.setMsg("Request or token params validation failed"); + resp.setRet("4002"); + } else { + String[] stationIDs = stationFeeRequest.getStationIDs(); + if(stationIDs !=null && stationIDs.length>0){ + List cdStationFeeList =new ArrayList<>(); + for (int i = 0; i < stationIDs.length; i++) { + String stationID = stationIDs[i]; + String skey = "cdjgpc:stationFeeRequest:".concat(stationID); + CDStationFee cdStationFeeRequest = REDIS.getCacheObject(skey); + cdStationFeeList.add(cdStationFeeRequest); + } + resp.setData(JSONUtil.toJSONString(cdStationFeeList)); + resp.setRet("0"); + }else{ + resp.setRet("-1"); + resp.setMsg("系统繁忙,此时请求方稍后重试"); + } + } + return resp; + } + + + /** + * 查询站点费率(成都市平台调用我们平台) + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/notification_order_settlement_info") + public CommonResponse notificationOrderSettlementInfo(@RequestBody CommonRequest commonRequest) throws Exception{ + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + CDNotificationOrderSettlementInfoRequest stationFeeRequest = JSONUtil.readParams(commonRequest.getData(), CDNotificationOrderSettlementInfoRequest.class); + if (stationFeeRequest == null) { + resp.setMsg("Request or token params validation failed"); + resp.setRet("4002"); + } else { + //查询订单 + + + + + + } + return resp; + } + + + /** + * 查询充电设备运行统计计信息 --已调用 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/query_SupEquipment_stats_info") + public CommonResponse querySupEquipmentStatsInfo(@RequestBody CommonRequest commonRequest)throws Exception{ + + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + StationStatsRequest stationStatsRequest = JSONUtil.readParams(commonRequest.getData(), StationStatsRequest.class); + if (stationStatsRequest == null) { + resp.setMsg("Request or token params validation failed"); + resp.setRet("4002"); + } else { + R r = powerPileService.querySupEquipmentStatsInfo(Long.valueOf(stationStatsRequest.getStationID()), stationStatsRequest.getStartTime(), stationStatsRequest.getEndTime()); + if(r.getCode() !=200){ + resp.setRet("-1"); + resp.setMsg("系统繁忙,此时请求方稍后重试"); + return resp; + } + String key ="cdjgpc:station:"+stationStatsRequest.getStationID()+".querySupEquipmentStatsInfo"; + List cdSuqEquipmentStatslnfos =REDIS.getCacheObject(key); + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("EquipmentStatsInfos",cdSuqEquipmentStatslnfos); + resp.setRet("0"); + resp.setData(JSONUtil.toJSONString(mapStationInfo)); + resp.setMsg("Query station info success"); + REDIS.deleteObject(key); + } + return resp; + } + + /** + * 查询充电设备接口运行统计计信息 --已调用 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/query_connector_stats_info") + public CommonResponse queryConnectorStatsInfo(@RequestBody CommonRequest commonRequest)throws Exception{ + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + CDQuerySupEquipmentStatsInfoRequest stationStatsRequest = JSONUtil.readParams(commonRequest.getData(), CDQuerySupEquipmentStatsInfoRequest.class); + if (stationStatsRequest == null) { + resp.setMsg("Request or token params validation failed"); + resp.setRet("4002"); + } else { + R r = powerPileService.queryConnectorStatsInfo(Long.valueOf(stationStatsRequest.getStationID()), stationStatsRequest.getStartTime(), stationStatsRequest.getEndTime()); + if(r.getCode() !=200){ + resp.setRet("-1"); + resp.setMsg("系统繁忙,此时请求方稍后重试"); + return resp; + } + String key ="cdjgpc:station:"+stationStatsRequest.getStationID()+".queryConnectorStatsInfo"; + List cdSuqEquipmentStatslnfos =REDIS.getCacheObject(key); + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("ConnectorStatsInfos",cdSuqEquipmentStatslnfos); + resp.setRet("0"); + resp.setData(JSONUtil.toJSONString(mapStationInfo)); + resp.setMsg("Query station info success"); + REDIS.deleteObject(key); + } + return resp; + } + + /** + * 查询充电站功率统计信息 --已调用 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/supervise_query_station_power_info") + public CommonResponse superviseQueryStationPowerInfo(@RequestBody CommonRequest commonRequest)throws Exception{ + + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + CDSuperviseQueryStationPowerInfoRequest stationStatsRequest = JSONUtil.readParams(commonRequest.getData(), CDSuperviseQueryStationPowerInfoRequest.class); + if (stationStatsRequest == null) { + resp.setMsg("Request or token params validation failed"); + resp.setRet("4002"); + } else { + String replace = UUID.randomUUID().toString().replace("-", ""); + + R r = powerPileService.getSuperviseQueryStationPowerInfo(stationStatsRequest.getStationIDs(), stationStatsRequest.getDataTime(),replace); + if(r.getCode() !=200){ + resp.setRet("-1"); + resp.setMsg("系统繁忙,此时请求方稍后重试"); + return resp; + } + String key ="cdjgpc:station:"+replace+".getSuperviseQueryStationPowerInfo"; + List cdSuqEquipmentStatslnfos =REDIS.getCacheObject(key); + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("StationPowerInfos",cdSuqEquipmentStatslnfos); + resp.setRet("0"); + resp.setData(JSONUtil.toJSONString(mapStationInfo)); + resp.setMsg("Query station info success"); + REDIS.deleteObject(key); + } + return resp; + } + + /** + * 查询充电设备功率统计信息---一调用 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/supervise_query_equipment_power_info") + public CommonResponse superviseQueryEquipmentPowerInfo(@RequestBody CommonRequest commonRequest)throws Exception{ + + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + CDSuperviseQueryEquipmentPowerInfoRequest stationStatsRequest = JSONUtil.readParams(commonRequest.getData(), CDSuperviseQueryEquipmentPowerInfoRequest.class); + if (stationStatsRequest == null) { + resp.setMsg("Request or token params validation failed"); + resp.setRet("4002"); + } else { + String replace = UUID.randomUUID().toString().replace("-", ""); + R r = powerPileService.getSuperviseQueryEquipmentPowerInfo(stationStatsRequest.getStationID(), stationStatsRequest.getDataTime(),replace); + if(r.getCode() !=200){ + resp.setRet("-1"); + resp.setMsg("系统繁忙,此时请求方稍后重试"); + return resp; + } + + String key ="cdjgpc:station:"+replace+".getSuperviseQueryEquipmentPowerInfo"; + List cdSuqEquipmentStatslnfos =REDIS.getCacheObject(key); + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("EquipmentPowerInfos",cdSuqEquipmentStatslnfos); + resp.setRet("0"); + resp.setData(JSONUtil.toJSONString(mapStationInfo)); + resp.setMsg("Query station info success"); + REDIS.deleteObject(key); + } + return resp; + } + + /** + * 查询充电事故 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping("/v10/supervise_query_accident_info") + public CommonResponse superviseQueryAccidentInfo(@RequestBody(required = false) CommonRequest commonRequest)throws Exception { + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + + //当前页数 + PageRequest pageRequest = commonRequest.transformDataType(PageRequest.class); + Integer pageNo = pageRequest.getPageNo(); + CDSupEquipmentAccidentInfoResponse response = new CDSupEquipmentAccidentInfoResponse(); + response.setPageNo(pageNo); + //页码总数 + Instant now = Instant.now(); + String replace = UUID.randomUUID().toString().replace("-", ""); + //获取事故数据 + R r = powerPileService.getSuperviseQueryAccidentInfo(pageRequest.getLastQueryTime(),replace); + if(r.getCode() !=200){ + resp.setRet("-1"); + resp.setMsg("系统繁忙,此时请求方稍后重试"); + return resp; + } + String key ="cdjgpc:station:"+replace+".getSuperviseQueryAccidentInfo"; + List cdSupEquipmentAccidentInfos =REDIS.getCacheObject(key); + + List equipmentAccidentInfoList =new ArrayList<>(); + + if (cdSupEquipmentAccidentInfos.size() > 0) { + Integer pageSize = pageRequest.getPageSize(); + int totalPage = cdSupEquipmentAccidentInfos.size() % pageSize == 0 ? cdSupEquipmentAccidentInfos.size() / pageSize : + (cdSupEquipmentAccidentInfos.size() / pageSize) + 1; + response.setPageCount(totalPage); + } + //总记录条数 + response.setItemSize(cdSupEquipmentAccidentInfos.size()); + + //计算每页开始索引 + int startIndex = -1; + int endIndex = -1; + if (pageNo == 1 && cdSupEquipmentAccidentInfos.size() <= 10) { + startIndex = 0; + endIndex = cdSupEquipmentAccidentInfos.size() - 1; + } else { + Integer pageSize = pageRequest.getPageSize(); + startIndex = (pageNo - 1) * pageSize; + endIndex = startIndex + (pageSize - 1); + } + for (int i = startIndex; i <= endIndex; i++) { + CDSupEquipmentAccidentInfo cdSupEquipmentAccidentInfo = cdSupEquipmentAccidentInfos.get(i); + String[] split = cdSupEquipmentAccidentInfo.getPicturesName().split(","); + cdSupEquipmentAccidentInfo.setPictures(split); + String[] split1 = cdSupEquipmentAccidentInfo.getAnalysisReportName().split(","); + cdSupEquipmentAccidentInfo.setAnalysisReport(split1); + equipmentAccidentInfoList.add(cdSupEquipmentAccidentInfo); + } + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("EquipmentAccidentInfos",equipmentAccidentInfoList); + resp.setRet("0"); + resp.setData(JSONUtil.toJSONString(mapStationInfo)); + resp.setMsg("Query station info success"); + REDIS.deleteObject(key); + return resp; + } + + + //组合场站数据 + public CDStationInfo getNotificationStationInfo(String stationId){ + + String key = "cdjgpc:station:".concat(stationId)+".notification"; + CDStationInfo cdStationInfo = REDIS.getCacheObject(key); + cdStationInfo.setEquipmentInfos(new ArrayList<>()); + //查询场站是桩是否对应上 + ChargingStationDto stationDto = REDIS.getCacheObject("station:"+stationId); + Set pks = stationDto.getPiles(); + if (pks != null) { + List cdEquipmentInfos = new ArrayList<>(); + for (String pileNo : pks) { + String pk = "pile:".concat(pileNo); + String skey = "cdjgpc:".concat(pk) + ".notification"; + CDEquipmentInfo cdEquipmentInfo = REDIS.getCacheObject(skey); + cdEquipmentInfos.add(cdEquipmentInfo); + } + cdStationInfo.setEquipmentInfos(cdEquipmentInfos); + REDIS.setCacheObject(key, cdStationInfo); + } + return cdStationInfo; + } + + + //数据加密处理 + @PostMapping("/v10/getEncrytReqout") + public R getEncrytReqout(){ + try{ + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setOperatorId("MA6CC2LK7"); +// StationStatsRequest stationStatsRequest = new StationStatsRequest(); +// stationStatsRequest.setStationID("20"); +// stationStatsRequest.setStartTime("2023-10-01"); +// stationStatsRequest.setEndTime("2023-10-12"); +// StationStatusRequest stationStatsRequest =new StationStatusRequest(); +// String [] st ={"20"}; +// stationStatsRequest.setStationIds(st); + +// CDQuerySupEquipmentStatsInfoRequest cdQuerySupEquipmentStatsInfoRequest = new CDQuerySupEquipmentStatsInfoRequest(); +// cdQuerySupEquipmentStatsInfoRequest.setStationID("20"); +// cdQuerySupEquipmentStatsInfoRequest.setStartTime("2023-10-01"); +// cdQuerySupEquipmentStatsInfoRequest.setEndTime("2023-10-13"); + +// CDSuperviseQueryStationPowerInfoRequest cdSuperviseQueryStationPowerInfoRequest = new CDSuperviseQueryStationPowerInfoRequest(); +// String [] st ={"20"}; +// cdSuperviseQueryStationPowerInfoRequest.setStationIDs(st); +// cdSuperviseQueryStationPowerInfoRequest.setDataTime("2023-10-13"); + +// CDSuperviseQueryEquipmentPowerInfoRequest cdSuperviseQueryEquipmentPowerInfoRequest = new CDSuperviseQueryEquipmentPowerInfoRequest(); +// cdSuperviseQueryEquipmentPowerInfoRequest.setStationID("20"); +// cdSuperviseQueryEquipmentPowerInfoRequest.setDataTime("2023-10-13"); + CDEquipAuthRequest equipAuthRequest = new CDEquipAuthRequest(); + equipAuthRequest.setEquipAuthSeq("MA6DFCTD5202310161544441234"); + equipAuthRequest.setConnectorId("8083600020000101"); + equipAuthRequest.setQRCode("12312312312323"); + String data = JSONUtil.toJSONString(equipAuthRequest); + System.out.println("===data==="+data); + commonRequest.setData(data); + AuthSecretToken authSecretTokenOut =authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType( + "MA6CC2LK7", "MA6DFCTD5", SECRET_TOKEN_TYPE_IN).orElse(null); + String tData = encryptReqOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(), + authSecretTokenOut.getSigSecret(), commonRequest); + System.out.println("===tData==="+tData); +// String bearerToken = authSecretTokenOut.getToken(); +// okhttp3.RequestBody body = okhttp3.RequestBody.create(JSON, tData); +// final Request.Builder req = new Request.Builder() +// .url("http://localhost:9009/v10" + "/query_station_stats") +// .header("Authorization", "Bearer " + bearerToken); +// Request request; +// request = req.post(body).build(); +// OkHttpClient.Builder builder = new OkHttpClient.Builder(); +// builder.connectTimeout(10, TimeUnit.SECONDS) +// .readTimeout(10, TimeUnit.SECONDS) +// .writeTimeout(10, TimeUnit.SECONDS); +// OkHttpClient client = builder.build(); +// +// String responseBody = null; +// try { +// Response response = client.newCall(request).execute(); +// if (response.isSuccessful()) { +// okhttp3.ResponseBody body1 = response.body(); +// responseBody = body1 == null ? null : body1.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); +// } +// System.out.println("=============responseBody=============="+responseBody); + return R.ok(null); + }catch (Exception e){ + e.printStackTrace(); + } + return R.fail(); + } } diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDNotificationStopChargeResultController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDNotificationStopChargeResultController.java new file mode 100644 index 00000000..120103c6 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDNotificationStopChargeResultController.java @@ -0,0 +1,55 @@ +package com.xhpc.evcs.cdjgpc.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.XhpcHistoryOrderRepository; +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; + +/** + * @author yuyang + * @date 2023-09-24 19:13 + */ +@Slf4j +@RestController() +public class CDNotificationStopChargeResultController { + @Autowired + private XhpcHistoryOrderRepository xhpcHistoryOrderRepository; + + /** + * 推送停止充电结果 + * @param commonRequest + * @return + * @throws IOException + */ + @PostMapping("/v10/notification_stop_charge_result") + public CommonResponse notifyStartChargeResult(@RequestBody CommonRequest 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; + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryEquipAuthController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryEquipAuthController.java new file mode 100644 index 00000000..81c3cbce --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryEquipAuthController.java @@ -0,0 +1,103 @@ +package com.xhpc.evcs.cdjgpc.api; + +import com.xhpc.evcs.cdjgpc.dto.CDEquipAuthRequest; +import com.xhpc.evcs.domain.XhpcInternetUser; +import com.xhpc.evcs.domain.XhpcStationInternetBlacklist; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.dto.CommonResponse; +import com.xhpc.evcs.dto.EquipAuthRequest; +import com.xhpc.evcs.dto.EquipAuthResponse; +import com.xhpc.evcs.encryption.EvcsConst; +import com.xhpc.evcs.jpa.XhpcInternetUserRepository; +import com.xhpc.evcs.jpa.XhpcStationInternetBlacklistRepository; +import com.xhpc.evcs.utils.JSONUtil; +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.time.Instant; +import java.util.Map; + +import static cn.hutool.core.util.NumberUtil.isInteger; +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; + +/** + * @author yuyang + * @date 2023-09-20 15:36 + */ +@RestController +public class CDQueryEquipAuthController { + @Autowired + private XhpcStationInternetBlacklistRepository xhpcStationInternetBlacklistRepo; + @Autowired + private XhpcInternetUserRepository xhpcInternetUserRepository; + + /** + * 请求设备认证 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping(value = "/v10/query_equip_auth") + public CommonResponse queryEquipAuth(@RequestBody CommonRequest commonRequest) throws Exception { + + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_SUCC); + CDEquipAuthRequest equipAuthRequest = JSONUtil.readParams(commonRequest.getData(), CDEquipAuthRequest.class); + if (equipAuthRequest == null) { + resp.setRet(EvcsConst.RET_FAIL); + resp.setMsg("Request or token params validation failed"); + } else { + EquipAuthResponse equipAuthResponse = new EquipAuthResponse(); + String equipAuthSeq = equipAuthRequest.getEquipAuthSeq(); + String connectorId = equipAuthRequest.getConnectorId(); + equipAuthResponse.setEquipAuthSeq(equipAuthSeq); + equipAuthResponse.setConnectorId(connectorId); + String pileId = connectorId.substring(0, connectorId.length() - 2); + Map pileDataModel = REDIS.getCacheMap("pile:" + pileId); + Long stationId = Long.parseLong(pileDataModel.get("stationId").toString()); + Instant now = Instant.now(); + XhpcInternetUser xhpcInternetUser = xhpcInternetUserRepository + .findByOperatorIdEvcsLikeAndCooperationStartTimeBeforeAndCooperationEndTimeAfter(commonRequest.getOperatorId(), now, now); + if (xhpcInternetUser == null) { + equipAuthResponse.setSuccStat(1); + equipAuthResponse.setFailReason(2); + equipAuthResponse.setFailReasonMsg("身份验证失败"); + resp.setMsg("auth denied"); + } else { + Long internetUserId = xhpcInternetUser.getInternetUserId(); + XhpcStationInternetBlacklist xhpcStationInternetBlacklist = + xhpcStationInternetBlacklistRepo.findByChargingStationIdAndInternetUserId(stationId, internetUserId).orElse(null); + if (null != xhpcStationInternetBlacklist) { + equipAuthResponse.setSuccStat(1); + equipAuthResponse.setFailReason(2); + equipAuthResponse.setFailReasonMsg("身份验证失败"); + resp.setMsg("auth denied"); + } else { + Map cacheGun = REDIS.getCacheMap("gun:".concat(connectorId)); + String terminalStatus = (String) cacheGun.get("vehicleGunStatus"); + String status = (String) cacheGun.get("status"); + if (!"空闲".equals(status)) { + resp.setMsg("终端不在空闲状态:[".concat(status == null ? "未注册" : isInteger(status) ? "充电中" : status).concat( + "]")); + equipAuthResponse.setSuccStat(1); + equipAuthResponse.setFailReason(1); + } else if ("否".equals(terminalStatus)) { + resp.setMsg("未插枪"); + equipAuthResponse.setSuccStat(1); + equipAuthResponse.setFailReason(1); + } else { + resp.setRet("0"); + resp.setMsg("success"); + equipAuthResponse.setSuccStat(0); + equipAuthResponse.setFailReason(0); + } + + } + } + resp.setData(JSONUtil.toJSONString(equipAuthResponse)); + } + return resp; + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryEquipChargeStatusController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryEquipChargeStatusController.java new file mode 100644 index 00000000..5965f2b2 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryEquipChargeStatusController.java @@ -0,0 +1,154 @@ +package com.xhpc.evcs.cdjgpc.api; + +import com.xhpc.common.data.redis.CacheRateModel; +import com.xhpc.common.data.redis.CacheRealtimeData; +import com.xhpc.evcs.domain.EtOrderMapping; +import com.xhpc.evcs.dto.ChargeInfoRequest; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.dto.CommonResponse; +import com.xhpc.evcs.dto.EquipChargeStatus; +import com.xhpc.evcs.encryption.EvcsConst; +import com.xhpc.evcs.jpa.OrderMappingRepository; +import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository; +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; +import java.util.Map; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; +import static com.xhpc.evcs.notification.NotificationEquipChargeStatusTask.calculateEm; +import static com.xhpc.evcs.utils.DateUtil.orderNo2DateStr; + +/** + * @author yuyang + * @date 2023-09-20 16:38 + */ +@Slf4j +@RestController() +public class CDQueryEquipChargeStatusController { + @Autowired + XhpcHistoryOrderRepository xhpcHistoryOrderRepository; + @Autowired + OrderMappingRepository orderMappingRepository; + + /** + * 查询充电状态 + * @param commonRequest + * @return + * @throws IOException + */ + @PostMapping("/v10/query_equip_charge_status") + public CommonResponse queryEquipChargeStatus(@RequestBody CommonRequest commonRequest) throws IOException { + //创建数据实体类 + EquipChargeStatus equipChargeStatus = new EquipChargeStatus(); + //充电订单号 三方传进来都是27位 + String data = commonRequest.getData(); + ChargeInfoRequest chargeInfoRequest = JSONUtil.readParams(data, ChargeInfoRequest.class); + CommonResponse response = new CommonResponse(); + if (chargeInfoRequest == null) { + response.setRet(EvcsConst.RET_FAIL); + response.setMsg("Request or token params validation failed"); + } else { + String startChargeSeq = chargeInfoRequest.getStartChargeSeq(); + equipChargeStatus.setStartChargeSeq(startChargeSeq); + //充电订单状态 + EtOrderMapping etOrderMapping = orderMappingRepository.findByEvcsOrderNo(startChargeSeq).orElse(null); + if (etOrderMapping == null) { + response.setRet(EvcsConst.RET_FAIL); + response.setMsg("Order not found/started"); + log.error("3rdpty order[{}] not found", startChargeSeq); + return response; + } + String internalOrderNum = etOrderMapping.getXhOrderNo(); + Map cacheOrder = REDIS.getCacheMap("order:" + internalOrderNum); + if (cacheOrder == null) { + response.setRet(EvcsConst.RET_FAIL); + response.setMsg("Order cache data not found"); + } else { + String orderStatus = (String) cacheOrder.get("status"); + int startChargeSeqStat; + if (orderStatus == null) { + startChargeSeqStat = 5; + } else switch (orderStatus) { + case "启动中": + startChargeSeqStat = 1; + break; + case "充电中": + startChargeSeqStat = 2; + break; + case "停止中": + startChargeSeqStat = 3; + break; + case "已结束": + startChargeSeqStat = 4; + break; + default: + startChargeSeqStat = 5; + break; + } + equipChargeStatus.setStartChargeSeqStat(startChargeSeqStat); + //充电设备接口编码 + String connectorId = internalOrderNum.substring(0, 16); + equipChargeStatus.setConnectorID(connectorId); + //充电设备接口状态 + Map cacheGunData = REDIS.getCacheMap("gun:" + connectorId); + String gunStatus = (String) cacheGunData.get("status"); + int connectorStatus = 0; + switch (gunStatus) { + case "空闲": + connectorStatus = 1; + break; + case "离线": + connectorStatus = 2; + break; + case "故障": + connectorStatus = 255; + break; + default: + connectorStatus = 3; + break; + } + equipChargeStatus.setConnectorStatus(connectorStatus); + //A相电流 + Double current = (Double) cacheGunData.get("current"); + equipChargeStatus.setCurrentA(current); + //A相电压 + Double voltage = (Double) cacheGunData.get("voltage"); + equipChargeStatus.setVoltageA(voltage); + //电池剩余电量 + Integer endSoc = (Integer) cacheOrder.get("endSoc"); + Double soc = Double.valueOf(endSoc == null ? 0 : endSoc); + equipChargeStatus.setSoc(soc); + //开始充电时间 + String startTime = (String) cacheOrder.get("startTime"); + if (startTime == null) startTime = orderNo2DateStr(internalOrderNum); + equipChargeStatus.setStartTime(startTime); + //本次采样时间 直接new一个当前时间的Date就可以了 + CacheRealtimeData lord = REDIS.getCacheObject("order:" + internalOrderNum + ".lord"); + if (lord != null) { + equipChargeStatus.setEndTime(lord.getCreateTime()); + equipChargeStatus.setTotalMoney(lord.getAmountCharged() / 10000.0); + equipChargeStatus.setTotalPower(lord.getChargingDegree() / 10000.0); + } else { + equipChargeStatus.setEndTime(equipChargeStatus.getStartTime()); + equipChargeStatus.setTotalMoney(0.0); + equipChargeStatus.setTotalPower(0.0); + } + Integer chargeModel = (Integer) cacheOrder.get("chargeModel"); + equipChargeStatus.setChargeModel(chargeModel == null ? 0 : chargeModel); + final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId"); + final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId); + calculateEm(equipChargeStatus, cacheRateModel); + response.setRet(EvcsConst.RET_SUCC); + response.setData(JSONUtil.toJSONString(equipChargeStatus)); + response.setMsg("success"); + } + } + return response; + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryStartChargeController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryStartChargeController.java new file mode 100644 index 00000000..c0a2827b --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryStartChargeController.java @@ -0,0 +1,163 @@ +package com.xhpc.evcs.cdjgpc.api; + +import com.xhpc.common.api.PileOrderService; +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.utils.DateUtils; +import com.xhpc.evcs.domain.EtOrderMapping; +import com.xhpc.evcs.domain.XhpcChargingStation; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.dto.CommonResponse; +import com.xhpc.evcs.dto.StartChargeRequest; +import com.xhpc.evcs.dto.StartChargeResponse; +import com.xhpc.evcs.encryption.EvcsConst; +import com.xhpc.evcs.jpa.*; +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 java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; +import static com.xhpc.common.data.redis.StaticBeanUtil.genOrder; + +/** + * @author yuyang + * @date 2023-09-20 15:38 + */ +public class CDQueryStartChargeController { + + @Autowired + AuthSecretTokenRepository authSecretTokenRepository; + @Autowired + private OrderMappingRepository etOrderMappingRepo; + @Autowired + private XhpcHistoryOrderRepository xhpcHistoryOrderRepository; + @Autowired + private XhpcTerminalRepository xhpcTerminalRepository; + @Autowired + private PileOrderService pileOrderService; + @Autowired + private XhpcInternetUserRepository xhpcInternetUserRepository; + @Autowired + private XhpcChargingStationRepository xhpcChargingStationRepository; + + /** + * 请求启动充电 + * @param commonRequest + * @return + * @throws Exception + */ + @PostMapping(value = "/v10/query_start_charge") + public CommonResponse queryStartCharge(@RequestBody CommonRequest commonRequest) throws Exception { + + CommonResponse resp = new CommonResponse(); + resp.setRet(EvcsConst.RET_FAIL); + StartChargeRequest startChargeRequest = JSONUtil.readParams(commonRequest.getData(), StartChargeRequest.class); + if (startChargeRequest == null) { + resp.setMsg("Request or token params validation failed"); + } else { + String startChargeSeq = startChargeRequest.getStartChargeSeq(); + EtOrderMapping orderMapping = etOrderMappingRepo.findByEvcsOrderNo(startChargeSeq).orElse(null); + if (orderMapping != null) { + resp.setMsg("Duplicated StartChargeSeq"); + } else { + StartChargeResponse startChargeResponse = new StartChargeResponse(); + startChargeResponse.setFailReason(0); + startChargeResponse.setSuccStat(1); + startChargeResponse.setStartChargeSeqStat(4); + String connectorId = startChargeRequest.getConnectorId(); + Map cacheGun = REDIS.getCacheMap("gun:".concat(connectorId)); + String terminalStatus = (String) cacheGun.get("vehicleGunStatus"); + String status = (String) cacheGun.get("status"); + EtOrderMapping etOrderMapping = new EtOrderMapping(); + Date now = DateUtils.getNowDate(); + etOrderMapping.setCreateTime(now); + etOrderMapping.setEvcsOrderNo(startChargeSeq); + if (!"空闲".equals(status)) { + resp.setMsg("终端状态异常:[".concat(status == null ? "未注册" : status).concat("]")); + emptyHorder(startChargeSeq, connectorId, etOrderMapping); + } else if ("否".equals(terminalStatus)) { + resp.setMsg("未插枪"); + emptyHorder(startChargeSeq, connectorId, etOrderMapping); + } else { + String plateNum = startChargeRequest.getPlateNum(); + plateNum = plateNum == null ? startChargeRequest.getPlateNum2() : plateNum; + R res = pileOrderService.pileStartUpBy3rd(startChargeSeq, startChargeRequest.getDriverId(), + startChargeRequest.getChargingAmt(), plateNum, -1, connectorId); + startChargeResponse.setStartChargeSeq(startChargeSeq); + startChargeResponse.setConnectorID(connectorId); + resp.setMsg(res.getMsg()); + if (res.getCode() != 200) { + if (res.getCode() != 500) { + startChargeResponse.setFailReason(res.getCode()); + } else { + startChargeResponse.setFailReason(3); + } + startChargeResponse.setFailReasonMsg(res.getMsg()); + startChargeResponse.setSuccStat(1); + startChargeResponse.setStartChargeSeqStat(4); + emptyHorder(startChargeSeq, connectorId, etOrderMapping); + } else { + Map etOrderData = (Map) res.getData(); + if (etOrderData != null) { + resp.setRet(EvcsConst.RET_SUCC); + startChargeResponse.setStartChargeSeqStat(1); + startChargeResponse.setSuccStat(0); + startChargeResponse.setFailReason(0); + Map pushOrder = new HashMap<>(); + pushOrder.put("startChargeSeqStat", 1); + pushOrder.put("internetSerialNumber", startChargeRequest.getStartChargeSeq()); + pushOrder.put("connectorID", connectorId); + pushOrder.put("startChargeNotificationStat", 0); + pushOrder.put("chargeOrderInfoNotificationStat", 0); + pushOrder.put("operatorId3rdpty", startChargeSeq.substring(0, 9)); + pushOrder.put("startTime", etOrderData.get("startTime")); + String orderNo = (String) etOrderData.get("orderNo"); + etOrderMapping.setXhOrderNo(orderNo); + REDIS.setCacheMap("pushOrder:".concat(orderNo), pushOrder); + } else { + emptyHorder(startChargeSeq, connectorId, etOrderMapping); + } + } + } + etOrderMappingRepo.save(etOrderMapping); + resp.setData(JSONUtil.toJSONString(startChargeResponse)); + } + } + return resp; + } + + private void emptyHorder(String startChargeSeq, String connectorId, EtOrderMapping etOrderMapping) { + + final Long stationId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "stationId"); + XhpcChargingStation xhpcChargingStation = xhpcChargingStationRepository.findById(stationId).orElse(null); + if (xhpcChargingStation != null) { + XhpcHistoryOrder emptyHorder = new XhpcHistoryOrder(); + emptyHorder.setTenantId(xhpcChargingStation.getTenantId()); + Date now = DateUtils.getNowDate(); + emptyHorder.setStartTime(now); + emptyHorder.setEndTime(now); + emptyHorder.setCreateTime(now); + emptyHorder.setUpdateTime(now); + emptyHorder.setStopReasonEvcs("平台停止"); + String sn = genOrder(connectorId); + etOrderMapping.setXhOrderNo(sn); + emptyHorder.setSerialNumber(sn); + emptyHorder.setInternetSerialNumber(startChargeSeq); + String operatorId3rdpty = startChargeSeq.substring(0, 9); + emptyHorder.setOperatorId3rdptyEvcs(operatorId3rdpty); + emptyHorder.setUserId(xhpcInternetUserRepository.queryDbId(operatorId3rdpty)); + emptyHorder.setType(1); + emptyHorder.setSource(1); + emptyHorder.setState(-1); + emptyHorder.setChargingStationId(stationId); + emptyHorder.setTerminalId(xhpcTerminalRepository.queryDbId(connectorId)); + emptyHorder.setConfirmResult(-1); + xhpcHistoryOrderRepository.save(emptyHorder); + } + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryStopChargeController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryStopChargeController.java new file mode 100644 index 00000000..53f0cb00 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/api/CDQueryStopChargeController.java @@ -0,0 +1,149 @@ +package com.xhpc.evcs.cdjgpc.api; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.core.domain.R; +import com.xhpc.evcs.domain.EtOrderMapping; +import com.xhpc.evcs.domain.XhpcChargingPile; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.dto.CommonResponse; +import com.xhpc.evcs.dto.QueryStopChargeRequest; +import com.xhpc.evcs.dto.QueryStopChargeResponse; +import com.xhpc.evcs.encryption.EvcsConst; +import com.xhpc.evcs.jpa.OrderMappingRepository; +import com.xhpc.evcs.jpa.XhpcChargingPileRepository; +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; +import java.util.Map; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; + +/** + * @author yuyang + * @date 2023-09-24 19:04 + */ +@Slf4j +@RestController +public class CDQueryStopChargeController { + + @Autowired + PowerPileService powerPileService; + //三方订单与redis内部订单映射表 + @Autowired + private OrderMappingRepository etOrderMappingRepo; + + @Autowired + private com.xhpc.evcs.jpa.XhpcChargingPileRepository XhpcChargingPileRepository; + + /** + * 请求停止充电 + * @param commonRequest + * @return + * @throws IOException + */ + @PostMapping("/v10/query_stop_charge") + public CommonResponse queryStopCharge(@RequestBody CommonRequest commonRequest) throws IOException { + + CommonResponse commonResponse = new CommonResponse(); + commonResponse.setRet(EvcsConst.RET_FAIL); + QueryStopChargeRequest queryStopChargeRequest = JSONUtil.readParams(commonRequest.getData(), + QueryStopChargeRequest.class); + if (queryStopChargeRequest == null) { + commonResponse.setMsg("Request or token params validation failed"); + } else { + // evcs电订单号(27位) + String startChargeSeq = queryStopChargeRequest.getStartChargeSeq(); + QueryStopChargeResponse queryStopChargeResponse = new QueryStopChargeResponse(); + queryStopChargeResponse.setStartChargeSeq(startChargeSeq); + //判断三方的订单号是否存在 + EtOrderMapping etOrderMapping = etOrderMappingRepo.findByEvcsOrderNo(startChargeSeq).orElse(null); + if (etOrderMapping == null) { + return failCommonResponse(queryStopChargeResponse, "错误的充电订单号"); + } + String xhOrderNo = etOrderMapping.getXhOrderNo(); + String pushOrderkey = "pushOrder:".concat(xhOrderNo); + Map pushOrder = REDIS.getCacheMap(pushOrderkey); + if (pushOrder == null || (pushOrder.get("isStopNotified") != null && (Boolean) pushOrder.get("isStopNotified"))) { + return failCommonResponse(queryStopChargeResponse, "已下发停止充电指令"); + } + //充电设备接口编码(枪编码) + String connectorId = queryStopChargeRequest.getConnectorId(); + String pileNum = connectorId.substring(0, connectorId.length() - 2); + //从数据库中查询对应的桩的版本信息 + XhpcChargingPile pileInfo = XhpcChargingPileRepository.findBySerialNumber(pileNum).orElse(null); + String versionNum = pileInfo.getCommunicationProtocolVersion() != null ? + pileInfo.getCommunicationProtocolVersion() : + "0A"; + //给对应的枪发送停止充电指令 + R r = powerPileService.stopCharging(xhOrderNo, pileNum, connectorId, versionNum); + // 判断停止指令发送是否成功 + if (r.getCode() != 200) { + //向redis中放入停止充电指令没有下发成功的标识 + REDIS.setCacheMap(pushOrderkey, pushOrder); + //充电订单状态 + queryStopChargeResponse.setStartChargeSeqStat(5); + //操作结果 + queryStopChargeResponse.setSuccStat(1); + //失败原因 + String errorMsg = r.getMsg(); + if (errorMsg.contains("未注册")) { + queryStopChargeResponse.setFailReasonMsg("此设备不存在"); + queryStopChargeResponse.setFailReason(1); + } + if (errorMsg.contains("离线")) { + queryStopChargeResponse.setFailReasonMsg("此设备离线"); + queryStopChargeResponse.setFailReason(2); + } + if (errorMsg.contains("订单号")) { + //4 means error orderNumber + queryStopChargeResponse.setFailReasonMsg("订单号不正确"); + queryStopChargeResponse.setFailReason(4); + } + if (errorMsg.contains("端口")) { + //5 means port is not charging + queryStopChargeResponse.setFailReasonMsg("端口不在充电中"); + queryStopChargeResponse.setFailReason(5); + } + queryStopChargeResponse.setStartChargeSeqStat(4); + queryStopChargeResponse.setSuccStat(1); + String data = JSONUtil.toJSONString(queryStopChargeResponse); + commonResponse.setMsg("请求停止充电失败"); + commonResponse.setData(data); + return commonResponse; + } + //设置该订单已经被停止的标识 + Map order = REDIS.getCacheMap("order:" + xhOrderNo); + order.replace("status", "已结束"); + REDIS.setCacheMap("order:".concat(xhOrderNo), order); + REDIS.setCacheMap(pushOrderkey, pushOrder); + queryStopChargeResponse.setStartChargeSeqStat(3); + queryStopChargeResponse.setSuccStat(0); + queryStopChargeResponse.setFailReason(0); + String data = JSONUtil.toJSONString(queryStopChargeResponse); + commonResponse.setRet("0"); + commonResponse.setMsg("请求停止充电成功"); + commonResponse.setData(data); + } + return commonResponse; + } + + private CommonResponse failCommonResponse(QueryStopChargeResponse queryStopChargeResponse, String msg) throws JsonProcessingException { + + queryStopChargeResponse.setStartChargeSeqStat(5); + queryStopChargeResponse.setSuccStat(1); + queryStopChargeResponse.setFailReason(0); + String data = JSONUtil.toJSONString(queryStopChargeResponse); + CommonResponse commonResponse = new CommonResponse(); + commonResponse.setRet("500"); + commonResponse.setMsg(msg); + commonResponse.setData(data); + return commonResponse; + } + +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationChargeOrderInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationChargeOrderInfoTask.java new file mode 100644 index 00000000..a384e161 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationChargeOrderInfoTask.java @@ -0,0 +1,111 @@ +package com.xhpc.evcs.cdjgpc.notification; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.xhpc.evcs.domain.AuthSecretToken; +import com.xhpc.evcs.dto.ChargeOrderInfo; +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.XhpcHistoryOrderRepository; +import com.xhpc.evcs.notification.CoreDispatcher; +import com.xhpc.evcs.notification.NotificationChargeOrderInfoTask; +import com.xhpc.evcs.utils.DateUtil; +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.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.time.Duration; +import java.time.Instant; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; +import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT; + +/** + * @author yuyang + * @date 2023-09-24 19:27 + */ +@Component +public class CDNotificationChargeOrderInfoTask extends CoreDispatcher { + @Autowired + private XhpcHistoryOrderRepository xhpcHistoryOrderRepository; + @Autowired + private AuthSecretTokenRepository authSecretTokenRepository; + + private final Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class); + + //@Scheduled(fixedRate = 1000 * 15) + public void run() throws JsonProcessingException { + + Collection orderKeys = REDIS.keys("order:*"); + Instant now = Instant.now(); + for (String okey : orderKeys) { + String orderNo = okey.substring(6); + if(orderNo.length() < 32){ + logger.error("orderNo[{}] is error", orderNo); + continue; + } + + Date otime = DateUtil.orderNo2Date(orderNo); + if (Duration.between(otime.toInstant(), now).toHours() > 24 * 3) { + REDIS.deleteObject(okey); + REDIS.deleteObject(okey.replace("order", "pushOrder")); + logger.info("clear cache..{}", okey); + } + } + List authSecretTokenList = authSecretTokenRepository.findBySecretTokenType(SECRET_TOKEN_TYPE_OUT); + List xhpcHistoryOrderList = + xhpcHistoryOrderRepository.findByConfirmResultNotAndSource(0, 1); + for (XhpcHistoryOrder horder : xhpcHistoryOrderList) { + for (AuthSecretToken authSecretToken : authSecretTokenList) { + if(!"765367656".equals(horder.getInternetSerialNumber().substring(0, 9))){ + continue; + } + String operatorId3rdptyEvcs = horder.getOperatorId3rdptyEvcs(); + if (operatorId3rdptyEvcs == null) { + if (horder.getInternetSerialNumber() != null) { + operatorId3rdptyEvcs = horder.getInternetSerialNumber().substring(0, 9); + horder.setOperatorId3rdptyEvcs(operatorId3rdptyEvcs); + xhpcHistoryOrderRepository.save(horder); // mending + } + } + if (authSecretToken.getOperatorId3irdpty().equals(operatorId3rdptyEvcs)) { +// final List statisticsTimeIntervals = +// xhpcStatisticsTimeIntervalRepository.findAllByHistoryOrderId(horder.getHistoryOrderId()); +// horder.setXhpcStatisticsTimeIntervalList(statisticsTimeIntervals); //似乎并不需要 + ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo(horder); + chargeOrderInfo.setChargeModel(null); + final ChargeOrderInfoResponse pushResp = notify(chargeOrderInfo, authSecretToken); + if (pushResp != null) { + horder.setConfirmResult(pushResp.getConfirmResult()); + logger.debug("3rd part order {} push result: {}", horder.getSerialNumber(), + pushResp.getConfirmResult()); + //logger.info("==============推送返回值================="+pushResp.toString()); + xhpcHistoryOrderRepository.save(horder); + REDIS.setCacheMapValue("pushOrder:".concat(horder.getSerialNumber()), "horderpushed", true); + } else { + logger.error("3dp[{}] order[{}/{}] push fail", operatorId3rdptyEvcs, + horder.getSerialNumber(), horder.getInternetSerialNumber()); + } + } + } + } + } + + public ChargeOrderInfoResponse notify(ChargeOrderInfo chargeOrderInfo, AuthSecretToken authSecretTokenOut) throws JsonProcessingException { + + String data = JSONUtil.toJSONString(chargeOrderInfo); + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setData(data); + String responseBody = ok(commonRequest, "/notification_charge_order_info", authSecretTokenOut); + return DTOJsonHelper.parseResponseData(responseBody, + ChargeOrderInfoResponse.class, authSecretTokenOut); + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationOrderInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationOrderInfoTask.java new file mode 100644 index 00000000..178c7c9f --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationOrderInfoTask.java @@ -0,0 +1,191 @@ +package com.xhpc.evcs.cdjgpc.notification; + +import com.xhpc.evcs.cdjgpc.dto.CDOrderInfo; +import com.xhpc.evcs.cdjgpc.dto.CDStationInfo; +import com.xhpc.evcs.domain.*; +import com.xhpc.evcs.dto.CDChargeOrder4BonusInfoRes; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.dto.DTOJsonHelper; +import com.xhpc.evcs.jpa.*; +import com.xhpc.evcs.notification.CoreDispatcher; +import com.xhpc.evcs.notification.NotificationChargeOrderInfo4BonusTask; +import com.xhpc.evcs.utils.DateUtil; +import com.xhpc.evcs.utils.JSONUtil; +import com.xhpc.order.domain.XhpcHistoryOrder; +import lombok.extern.slf4j.Slf4j; +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.HashMap; +import java.util.List; +import java.util.Map; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; +import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT; + +/** + * 订单信息推送 + * @author yuyang + * @date 2023-09-20 9:34 + */ +@Component +@Slf4j +public class CDNotificationOrderInfoTask extends CoreDispatcher { + @Autowired + private XhpcHistoryOrderRepository xhpcHistoryOrderRepository; + @Autowired + private EtPushFailedOrderRepository etPushFailedOrderRepository; + @Autowired + private AuthSecretTokenRepository authSecretTokenRepository; + @Autowired + private StatisticTimeIntervalRepository statisticTimeIntervalRepository; + @Autowired + private OrderMappingRepository orderMappingRepository; + @Autowired + private XhpcChargingStationRepository chargingStationRepo; + private final Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfo4BonusTask.class); + + /** + *订单信息推送 ---已推送 + * @throws IOException + */ + //@Scheduled(fixedDelay = 1000 * 60) + public void run() throws IOException { + AuthSecretToken authSecretTokenOut = + authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType( + "MA6CC2LK7", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); //todo + // maybe对接第三方 + if (authSecretTokenOut != null) { + final List notYetPushOrder = + xhpcHistoryOrderRepository.findTop100ByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(authSecretTokenOut.getLastPushOrder(), 0); + for (XhpcHistoryOrder xhpcHistoryOrder : notYetPushOrder) { + List statisticTimeIntervalList = + statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId()); + xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList); + notify(xhpcHistoryOrder, authSecretTokenOut, false); + } + final List pushFailedOrders = + xhpcHistoryOrderRepository.findTop10JoinPushFailedOrders(authSecretTokenOut.getOperatorId3irdpty()); + for (XhpcHistoryOrder xhpcHistoryOrder : pushFailedOrders) { + List statisticTimeIntervalList = + statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId()); + xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList); + final boolean notify = notify(xhpcHistoryOrder, authSecretTokenOut, true); + if (notify) { + etPushFailedOrderRepository.deleteById(xhpcHistoryOrder.getHistoryOrderId()); + } + } + } + } + + public boolean notify(XhpcHistoryOrder xhpcHistoryOrder, AuthSecretToken authSecretTokenOut, boolean isRepush) throws IOException { + String operatorIdEvcs = xhpcHistoryOrder.getOperatorIdEvcs(); + if (operatorIdEvcs == null) { + Long chargingStationId = xhpcHistoryOrder.getChargingStationId(); + XhpcChargingStation station = chargingStationRepo.findById(chargingStationId).orElse(null); + if(station == null){ + logger.error("station[{}] is not exits", chargingStationId); + return false; + } + + String stationOperatorIdEvcs = station.getOperatorIdEvcs(); + if (stationOperatorIdEvcs == null) { + logger.error("station[{}] operator id evcs not set", chargingStationId); + return false; + } + if (stationOperatorIdEvcs.length() == 18) { + operatorIdEvcs = stationOperatorIdEvcs.substring(8, 17); + } else { + operatorIdEvcs = stationOperatorIdEvcs; + } + } + Long chargingStationId = xhpcHistoryOrder.getChargingStationId(); + String key = "cdjgpc:station:".concat(chargingStationId.toString())+".notification"; + CDStationInfo cdStationInfo =REDIS.getCacheObject(key); + + EtOrderMapping etOrderMapping = saveOrderMapping(xhpcHistoryOrder, orderMappingRepository, operatorIdEvcs); + CDOrderInfo cdChargeOrderInfo4BonusReq = new CDOrderInfo(xhpcHistoryOrder,etOrderMapping); + if(cdStationInfo !=null && cdStationInfo.getOperatorId() !=null){ + cdChargeOrderInfo4BonusReq.setOperatorID(cdStationInfo.getOperatorId()); + cdChargeOrderInfo4BonusReq.setEquipmentOwnerID(cdStationInfo.getEquipmentOwnerId()); + } + operatorIdEvcs = operatorIdEvcs == null ? "MA6DFCTD5" : operatorIdEvcs; + Map mapStationInfo =new HashMap<>(); + mapStationInfo.put("OrderInfo",cdChargeOrderInfo4BonusReq); + String data = JSONUtil.toJSONString(mapStationInfo); + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setData(data); + String responseBody = ok(commonRequest, "/notification_orderInfo", authSecretTokenOut); + CDChargeOrder4BonusInfoRes cdChargeOrder4BonusInfoRes = DTOJsonHelper.parseResponseData(responseBody, + CDChargeOrder4BonusInfoRes.class, authSecretTokenOut); + if (!isRepush) { + authSecretTokenOut.setLastPushOrder(xhpcHistoryOrder.getHistoryOrderId()); + authSecretTokenRepository.save(authSecretTokenOut); + } + if (cdChargeOrder4BonusInfoRes != null && cdChargeOrder4BonusInfoRes.getConfirmResult() == 0) { + return true; + } else { + if (!isRepush) { + EtPushFailedOrder etPushFailedOrder = new EtPushFailedOrder(); + etPushFailedOrder.setId(xhpcHistoryOrder.getHistoryOrderId()); + etPushFailedOrder.setOperatorId3rdpty(authSecretTokenOut.getOperatorId3irdpty()); + etPushFailedOrderRepository.save(etPushFailedOrder); + } + logger.error(String.format("push CD notification order[%s] failed: %s", xhpcHistoryOrder.getSerialNumber(), + responseBody)); + return false; + } + } + + private EtOrderMapping saveOrderMapping(XhpcHistoryOrder xhpcHistoryOrder, + OrderMappingRepository orderMappingRepository, String operatorId) { + + String internetSerialNumber = xhpcHistoryOrder.getInternetSerialNumber(); + String xhOrderNo = xhpcHistoryOrder.getSerialNumber(); + return saveOrderMapping(xhOrderNo, internetSerialNumber, orderMappingRepository, operatorId); + } + + public static String transferInternetOrderNo(String orderKeyOrNo, String operatorId) { + //80836000010001012110191723410021 + //MA6DFCTD5202201111742100140 + String orderNo = orderKeyOrNo.replace("order:", ""); + if (operatorId.length() > 9) { + operatorId = operatorId.substring(0, 9); + } + return operatorId.concat(DateUtil.getYYYY()).concat(orderNo.substring(18)); + } + + public static EtOrderMapping saveOrderMapping(String xhOrderNo, String internetSerialNumber, + OrderMappingRepository orderMappingRepository, String operatorId) { + + EtOrderMapping etOrderMapping; + EtOrderMapping om; + if (internetSerialNumber != null) { + om = new EtOrderMapping(); + om.setEvcsOrderNo(internetSerialNumber); + Example example = Example.of(om); + etOrderMapping = orderMappingRepository.findOne(example).orElse(null); + if (etOrderMapping == null) { + om.setXhOrderNo(xhOrderNo); + etOrderMapping = orderMappingRepository.save(om); + } + } else { + om = new EtOrderMapping(); + om.setXhOrderNo(xhOrderNo); + Example example = Example.of(om); + etOrderMapping = orderMappingRepository.findOne(example).orElse(null); + if (etOrderMapping == null) { + etOrderMapping = new EtOrderMapping(); + etOrderMapping.setXhOrderNo(xhOrderNo); + etOrderMapping.setEvcsOrderNo(transferInternetOrderNo(xhOrderNo, operatorId)); + etOrderMapping = orderMappingRepository.save(etOrderMapping); + } + } + return etOrderMapping; + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationStationStatusTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationStationStatusTask.java new file mode 100644 index 00000000..8dd7cb00 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDNotificationStationStatusTask.java @@ -0,0 +1,155 @@ +package com.xhpc.evcs.cdjgpc.notification; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.xhpc.common.api.dto.ChargingStationDto; +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.utils.HttpUtils; +import com.xhpc.common.domain.XhpcTerminal; +import com.xhpc.evcs.cdjgpc.dto.CDConnectorStatusInfo; +import com.xhpc.evcs.cdjgpc.dto.CDConnectorStatusInfoReq; +import com.xhpc.evcs.cdjgpc.dto.CDStationFee; +import com.xhpc.evcs.cdjgpc.dto.CDStationInfo; +import com.xhpc.evcs.domain.AuthSecretToken; +import com.xhpc.evcs.domain.XhpcInternetUser; +import com.xhpc.evcs.domain.XhpcStationInternetBlacklist; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.dto.ConnectorStatusInfo; +import com.xhpc.evcs.dto.ConnectorStatusInfoReq; +import com.xhpc.evcs.dto.PageRequest; +import com.xhpc.evcs.jpa.AuthSecretTokenRepository; +import com.xhpc.evcs.jpa.XhpcInternetUserRepository; +import com.xhpc.evcs.jpa.XhpcStationInternetBlacklistRepository; +import com.xhpc.evcs.jpa.XhpcTerminalRepository; +import com.xhpc.evcs.notification.CoreDispatcher; +import com.xhpc.evcs.utils.ChangePoleStatus; +import com.xhpc.evcs.utils.JSONUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.io.IOException; +import java.time.Instant; +import java.util.*; +import java.util.stream.Collectors; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; +import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_IN; +import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT; +import static com.xhpc.evcs.dto.ConnectorStatusInfo.*; +import static com.xhpc.evcs.dto.ConnectorStatusInfo.CHARGING; + +/** + * 设备状态变化推送 --已推送 + * @author yuyang + * @date 2023-10-07 10:32 + */ +@Component +@Slf4j +public class CDNotificationStationStatusTask extends CoreDispatcher { + @Autowired + private AuthSecretTokenRepository authSecretTokenRepository; + @Autowired + private XhpcInternetUserRepository xhpcInternetUserRepository; + @Autowired + private XhpcStationInternetBlacklistRepository xhpcStationInternetBlacklistRepo; + @Resource + private XhpcTerminalRepository terminalRepository; + + //@Scheduled(fixedRate = 1000 * 45) + protected void run() throws IOException { + + Collection stationTerminalKeys = REDIS.keys("stationTerminalStatus:*"); + + List terminalList = terminalRepository.selectStatusBySql(); + Map terminalDBMap = terminalList.stream().collect(Collectors.toMap(XhpcTerminal::getSerialNumber,XhpcTerminal::getStatus)); + + Instant now = Instant.now(); + + XhpcInternetUser xhpcInternetUser = + xhpcInternetUserRepository.findByOperatorIdEvcsLikeAndCooperationStartTimeBeforeAndCooperationEndTimeAfter("MA6CC2LK7", Instant.now(), Instant.now()); + + for (String stationTerminalKey : stationTerminalKeys) { + ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationTerminalKey.replace("stationTerminalStatus", + "station")); + String operatorId = chargingStationDto.getOperatorId(); + Map terminalStatusMap = REDIS.getCacheMap(stationTerminalKey); + Set connectorStatusInfos = translateStatus(operatorId, terminalStatusMap, terminalDBMap); + Set changeStatus = ChangePoleStatus.getChangeStatus(connectorStatusInfos); + if (!changeStatus.isEmpty()) { + XhpcStationInternetBlacklist xhpcStationInternetBlacklist = + xhpcStationInternetBlacklistRepo.findByChargingStationIdAndInternetUserId(Long.valueOf(stationTerminalKey.split(":")[1]), + xhpcInternetUser.getInternetUserId()).orElse(null); + if (xhpcStationInternetBlacklist != null) continue; + AuthSecretToken authSecretTokenOut = + authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType("MA6CC2LK7", SECRET_TOKEN_TYPE_OUT).orElse(null); + log.debug("nss pushing to: {}", "MA6CC2LK7"); + if (authSecretTokenOut != null) { + for (ConnectorStatusInfo statusInfo : changeStatus) { + notify(stationTerminalKey,statusInfo, authSecretTokenOut); + } + } + } + } + } + + private Set translateStatus(String operatorId, Map terminalStatusMap, Map terminalDBMap) { + + Set connectorStatusInfoList = new HashSet<>(); + final Set connectorIds = terminalStatusMap.keySet(); + for (String gunId : connectorIds) { + ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(gunId); + connectorStatusInfo.setOperatorID(operatorId); + Integer dbStatus = terminalDBMap.get(gunId); + if(dbStatus !=null && dbStatus == 0){ + connectorStatusInfo.setStatus(translateStatus(terminalStatusMap.get(gunId))); + } else { + connectorStatusInfo.setStatus(0); + } + 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 void notify(String stationTerminalKey,ConnectorStatusInfo connectorStatusInfo, AuthSecretToken authSecretTokenOut) throws IOException { + + CDConnectorStatusInfoReq connectorStatusInfoReq = new CDConnectorStatusInfoReq(); + + CDStationInfo cdStationInfo =REDIS.getCacheObject(stationTerminalKey.replace("stationTerminalStatus","cdjgpc:station")+".notification"); + CDConnectorStatusInfo cdConnectorStatusInfo =new CDConnectorStatusInfo(); + cdConnectorStatusInfo.setOperatorID(cdStationInfo.getOperatorId()); + cdConnectorStatusInfo.setEquipmentOwnerID(cdStationInfo.getEquipmentOwnerId()); + cdConnectorStatusInfo.setStationID(cdStationInfo.getStationId()); + cdConnectorStatusInfo.setEquipmentID(connectorStatusInfo.getConnectorID().substring(0,14)); + cdConnectorStatusInfo.setEquipmentClassification(1); + cdConnectorStatusInfo.setConnectorID(connectorStatusInfo.getConnectorID()); + cdConnectorStatusInfo.setStatus(connectorStatusInfo.getStatus()); + + connectorStatusInfoReq.setConnectorStatusInfo(cdConnectorStatusInfo); + String data = JSONUtil.toJSONString(connectorStatusInfoReq); + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setData(data); + String result = ok(commonRequest, "/notification_stationStatus", authSecretTokenOut); + + System.out.println("=======result========"+result); + + } + +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseNotificationOperationStatusInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseNotificationOperationStatusInfoTask.java new file mode 100644 index 00000000..1594ae2d --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseNotificationOperationStatusInfoTask.java @@ -0,0 +1,67 @@ +package com.xhpc.evcs.cdjgpc.notification; + +import cn.hutool.core.date.DateUtil; +import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.core.domain.R; +import com.xhpc.evcs.cdjgpc.dto.CDStationStatslnfo; +import com.xhpc.evcs.domain.AuthSecretToken; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.jpa.AuthSecretTokenRepository; +import com.xhpc.evcs.notification.CoreDispatcher; +import com.xhpc.evcs.utils.JSONUtil; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; +import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT; + +/** + * 推送充电站用能统计信息 ---推送失败 + * @author yuyang + * @date 2023-10-07 11:00 + */ +@Component +@Slf4j +public class CDSuperviseNotificationOperationStatusInfoTask extends CoreDispatcher { + + @Resource + AuthSecretTokenRepository authSecretTokenRepository; + @Resource + PowerPileService powerPileService; + + private final Logger logger = LoggerFactory.getLogger(CDSuperviseNotificationOperationStatusInfoTask.class); + //@Scheduled(cron = "0 0 0 * * ? ") + //@Scheduled(fixedRate = 1000 * 45) + protected void run() throws IOException { + String replace = UUID.randomUUID().toString().replace("-", ""); + + R r = powerPileService.getSuperviseNotificationOperationStatusInfo(replace); + if(r.getCode() !=200){ + logger.info("========推送充电站用能统计信息失败,时间:"+ DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")); + } + String key ="cdjgpc:station:"+replace+".getSuperviseNotificationOperationStatusInfo"; + List stationStatsInfoList =REDIS.getCacheObject(key); + AuthSecretToken authSecretTokenOut = + authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType( + "MA6CC2LK7", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); + Map map =new HashMap<>(); + map.put("StationStatsInfos",stationStatsInfoList); + String data = JSONUtil.toJSONString(map); + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setData(data); + String ok = ok(commonRequest, "/supervise_notification_operation_status_info", authSecretTokenOut); + System.out.println("=====ok======"+ok); + logger.info("========推送充电站用能统计信息成功,时间:========="+DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")); + REDIS.deleteObject(key); + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseNotificationRealtimePowerInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseNotificationRealtimePowerInfoTask.java new file mode 100644 index 00000000..13451ed9 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseNotificationRealtimePowerInfoTask.java @@ -0,0 +1,69 @@ +package com.xhpc.evcs.cdjgpc.notification; + +import cn.hutool.core.date.DateUtil; +import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.core.domain.R; +import com.xhpc.evcs.cdjgpc.dto.CDStationStatslnfo; +import com.xhpc.evcs.cdjgpc.dto.CDSupStationPowerInfo; +import com.xhpc.evcs.domain.AuthSecretToken; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.jpa.AuthSecretTokenRepository; +import com.xhpc.evcs.notification.CoreDispatcher; +import com.xhpc.evcs.utils.JSONUtil; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; +import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT; + +/** + * 推送充电站实时功率 + * @author yuyang + * @date 2023-10-07 11:04 + */ +@Component +@Slf4j +public class CDSuperviseNotificationRealtimePowerInfoTask extends CoreDispatcher { + + @Resource + AuthSecretTokenRepository authSecretTokenRepository; + @Resource + PowerPileService powerPileService; + + private final Logger logger = LoggerFactory.getLogger(CDSuperviseNotificationOperationStatusInfoTask.class); + //@Scheduled(cron = "0 0 0 * * ? ") + //@Scheduled(fixedRate = 1000 * 45) + protected void run() throws IOException { + String replace = UUID.randomUUID().toString().replace("-", ""); + AuthSecretToken authSecretTokenOut = + authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType( + "MA6CC2LK7", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); + + R r = powerPileService.getSuperviseNotificationRealtimePowerInfo(authSecretTokenOut.getOperatorId3irdpty(),replace); + if(r.getCode() !=200){ + logger.info("========推送充电站实时功率失败,时间:"+ DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")); + } + String key ="cdjgpc:station:"+replace+".getSuperviseNotificationRealtimePowerInfo"; + List supStationPowerInfos =REDIS.getCacheObject(key); + + Map map =new HashMap<>(); + map.put("SupStationPowerInfos",supStationPowerInfos); + String data = JSONUtil.toJSONString(map); + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setData(data); + String ok = ok(commonRequest, "/supervise_notification_realtime_power_info", authSecretTokenOut); + System.out.println("=====ok======"+ok); + logger.info("========推送充电站实时功率成功,时间:========="+DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")); + REDIS.deleteObject(key); + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseQueryAccidentInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseQueryAccidentInfoTask.java new file mode 100644 index 00000000..ea089099 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/cdjgpc/notification/CDSuperviseQueryAccidentInfoTask.java @@ -0,0 +1,17 @@ +package com.xhpc.evcs.cdjgpc.notification; + +import com.xhpc.evcs.notification.CoreDispatcher; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 查询充电事故 + * @author yuyang + * @date 2023-10-07 11:05 + */ +@Component +@Slf4j +public class CDSuperviseQueryAccidentInfoTask extends CoreDispatcher { + + //"/supervise_query_accident_info" +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java index bbbf444c..7d6d4d8f 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java @@ -48,7 +48,7 @@ import java.util.Scanner; //@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 //成都市监管平台v10 恒大v20 新电途 v30 快电 v40 小桔v50 -@WebFilter(urlPatterns = {"/v1/*", "/v2/*", "/v10/*"}, filterName = "v1n2filter") //multiple filters execute by filterName order +@WebFilter(urlPatterns = {"/v1/*", "/v2/*", "/v10/*"}, filterName = "v1n10filter") //multiple filters execute by filterName order public class EvcsFilter extends OncePerRequestFilter { @Resource @@ -64,7 +64,7 @@ public class EvcsFilter extends OncePerRequestFilter { return; } ServletRequest requestWrapper = new HttpServletRequestRepeatReadWrapper(request); - final String encin = request.getHeader("enc.in"); +// final String encin = request.getHeader("enc.in"); // if (encin != null && encin.equals("false")) { //todo comment out in prd env // chain.doFilter(requestWrapper, response); // return; diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/CoreDispatcher.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/CoreDispatcher.java index 2aaa97f9..f48d456d 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/CoreDispatcher.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/CoreDispatcher.java @@ -134,6 +134,7 @@ public class CoreDispatcher { assert body != null; // if (body==null) request = req.get().build(); // else + logger.info("==============body================="+body.toString()); request = req.post(body).build(); OkHttpClient client = builder.build(); return fwdToInfra(request, client); @@ -167,4 +168,98 @@ public class CoreDispatcher { AuthSecretToken.SECRET_TOKEN_TYPE_OUT).orElse(null); } + public String ceshiOk(Object object, String url, AuthSecretToken authSecretTokenOut) { + + return ceshiOk(object, url, authSecretTokenOut, null); + } + + @Transactional + public String ceshiOk(Object object, String url, AuthSecretToken authSecretTokenOut, String stationOperatorId) { + if (authSecretTokenOut == null) { + log.error("authSecretTokenOut is null"); + throw new RuntimeException(); + } + okhttp3.RequestBody body = null; + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + if (oklog2) { + HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); + logging.setLevel(HttpLoggingInterceptor.Level.BODY); + builder.addInterceptor(logging); + } + builder.connectTimeout(10, TimeUnit.SECONDS) + .readTimeout(10, TimeUnit.SECONDS) + .writeTimeout(10, TimeUnit.SECONDS); + Calendar cal = Calendar.getInstance(); + String bearerToken = null; + try { + if (object.getClass().getSimpleName().equals("CommonRequest")) { + CommonRequest commonRequest = (CommonRequest) object; + if (stationOperatorId != null) { + commonRequest.setOperatorId(stationOperatorId); + } else { + commonRequest.setOperatorId(authSecretTokenOut.getOperatorId()); + } + Date tokenExpiry = authSecretTokenOut.getTokenExpiry(); + String originalData = commonRequest.getData(); + String tData; + if (tokenExpiry == null || tokenExpiry.before(cal.getTime())) { + log.debug("query notify token opid3rdpt [{}]", authSecretTokenOut.getOperatorId3irdpty()); + TokenRequest tokenRequest = new TokenRequest(); + tokenRequest.setOperatorId(authSecretTokenOut.getOperatorId()); + tokenRequest.setOperatorSecret(authSecretTokenOut.getOperatorSecret()); + commonRequest.setData(JSONUtil.toJSONString(tokenRequest)); + tData = JSONUtil.toJSONString(commonRequest); + if (authSecretTokenOut.isEncrypt()) { + tData = encryptReqOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(), + authSecretTokenOut.getSigSecret(), commonRequest); + } + Request request = new Request.Builder() + .url(authSecretTokenOut.getUrlPrefix() + "/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); + } + } + bearerToken = authSecretTokenOut.getToken(); + commonRequest.setData(originalData); + tData = JSONUtil.toJSONString(commonRequest); + log.debug("to [{}] {} out plain data:\n{}", authSecretTokenOut.getOperatorId3irdpty(), url, tData); + if (authSecretTokenOut.isEncrypt()) { + tData = encryptReqOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(), + authSecretTokenOut.getSigSecret(), commonRequest); +// log.debug("notify out encrypt data:\n{}", tData); + } + body = okhttp3.RequestBody.create(JSON, tData); +// logger.info("==============平台推送值================="+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(authSecretTokenOut.getUrlPrefix() + url) + .header("Authorization", "Bearer " + bearerToken); + Request request; + assert body != null; +// if (body==null) request = req.get().build(); +// else + logger.info("==============body================="+body.toString()); + request = req.post(body).build(); + OkHttpClient client = builder.build(); + return fwdToInfra(request, client); + } + + + } diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java index c7fc8d0d..969aa20c 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java @@ -39,7 +39,7 @@ public class NotificationChargeOrderInfoTask extends CoreDispatcher { private final Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class); - //@Scheduled(fixedRate = 1000 * 15) + //111@Scheduled(fixedRate = 1000 * 15) public void run() throws JsonProcessingException { Collection orderKeys = REDIS.keys("order:*"); @@ -62,6 +62,10 @@ public class NotificationChargeOrderInfoTask extends CoreDispatcher { List xhpcHistoryOrderList = xhpcHistoryOrderRepository.findByConfirmResultNotAndSource(0, 1); for (XhpcHistoryOrder horder : xhpcHistoryOrderList) { + + if("765367656".equals(horder.getInternetSerialNumber().substring(0, 9))){ + continue; + } for (AuthSecretToken authSecretToken : authSecretTokenList) { String operatorId3rdptyEvcs = horder.getOperatorId3rdptyEvcs(); if (operatorId3rdptyEvcs == null) { diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java index e969469e..93d1da03 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java @@ -48,7 +48,7 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher { * 推送充电状态 * @throws IOException */ - //@Scheduled(fixedRate = 1000 * 50) + //111@Scheduled(fixedRate = 1000 * 50) public void run() throws IOException { List authSecretTokenOutList = authSecretTokenRepository.findBySecretTokenType(SECRET_TOKEN_TYPE_OUT); @@ -211,10 +211,14 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher { public void notify(EquipChargeStatus equipChargeStatus, AuthSecretToken authSecretTokenOut) throws IOException { - String data = JSONUtil.toJSONString(equipChargeStatus); - CommonRequest commonRequest = new CommonRequest<>(); final String operatorId = authSecretTokenOut.getOperatorId3irdpty().equals("765367656") ? authSecretTokenOut.getOperatorId() : "MA6DFCTD5"; + if(operatorId.equals("765367656")){ + equipChargeStatus.setChargeModel(null); + } + String data = JSONUtil.toJSONString(equipChargeStatus); + CommonRequest commonRequest = new CommonRequest<>(); + commonRequest.setData(data); String responseBody = ok(commonRequest, "/notification_equip_charge_status", authSecretTokenOut); EquipChargeStatusRes equipChargeStatusRes = DTOJsonHelper.parseResponseData(responseBody, @@ -224,11 +228,4 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher { } } - public static void main(String[] args) { - - DateTime dt = DateTime.now(); - System.out.println((double) Math.round(100111 / 100D) / 100D); - - } - } diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStartChargeResultTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStartChargeResultTask.java index b47f1a31..3bdb3013 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStartChargeResultTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStartChargeResultTask.java @@ -33,7 +33,7 @@ public class NotificationStartChargeResultTask extends CoreDispatcher { /** * Judging the 3rd whether it has got the start charging task. */ - //@Scheduled(fixedRate = 1000 * 3) + //111@Scheduled(fixedRate = 1000 * 3) public void run() throws IOException { //Getting the charge orders which from 3rd. @@ -54,6 +54,12 @@ public class NotificationStartChargeResultTask extends CoreDispatcher { notificationStartChargeResultRequestData.setStartTime((String) pushOrder.get("startTime")); notificationStartChargeResultRequestData.setStartChargeSeq(startChargeSeq); notificationStartChargeResultRequestData.setConnectorId((String) pushOrder.get("connectorID")); + if("765367656".equals(operatorId)){ + Integer startChargeSeqStat = (Integer) pushOrder.get("startChargeSeqStat"); + if(startChargeSeqStat !=1){ + notificationStartChargeResultRequestData.setFailReasonMsg("平台停止"); + } + } notificationStartChargeResultRequestData.setStartChargeSeqStat((Integer) pushOrder.get( "startChargeSeqStat")); notify(notificationStartChargeResultRequestData, authSecretToken.get(), pushOrderKey.substring(10)); diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java index a24d2890..75b8fadb 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java @@ -49,7 +49,7 @@ public class NotificationStationStatusTask extends CoreDispatcher { @Resource private XhpcTerminalRepository terminalRepository; - //@Scheduled(fixedRate = 1000 * 45) + //111@Scheduled(fixedRate = 1000 * 45) protected void run() throws IOException { Collection stationTerminalKeys = REDIS.keys("stationTerminalStatus:*"); diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java index a7d67af8..447d2edc 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java @@ -26,7 +26,7 @@ public class NotificationStopChargeResultTask extends CoreDispatcher { @Autowired private AuthSecretTokenRepository authSecretTokenRepository; - //@Scheduled(fixedRate = 1000 * 3) + //111@Scheduled(fixedRate = 1000 * 3) public void run() throws Exception { notifyService(); diff --git a/sql/v2.2.sql b/sql/v2.2.sql index 1cefde0a..40098fa3 100644 --- a/sql/v2.2.sql +++ b/sql/v2.2.sql @@ -21,12 +21,24 @@ ALTER TABLE `xhpc_charging_station` ADD COLUMN `station_status` INT(4) NULL DEFAULT NULL COMMENT '场站建设状态' AFTER `construction_time`, ADD COLUMN `open_all_day` INT(4) NULL DEFAULT NULL COMMENT '是否全天开放(0 否 1是,为零时营业时间必填)' AFTER `station_status`, ADD COLUMN `busine_hours` VARCHAR(100) NULL DEFAULT NULL COMMENT '推荐格 式:周一 至周日 00:00-24:00' AFTER `open_all_day`, - ADD COLUMN `service_fee` VARCHAR(100) NULL DEFAULT NULL COMMENT '服务费率' AFTER `busine_hours`, + ADD COLUMN `electricity_fee` VARCHAR(100) NULL DEFAULT NULL COMMENT '充电费描述' AFTER `busine_hours`, + ADD COLUMN `service_fee` VARCHAR(100) NULL DEFAULT NULL COMMENT '服务费率' AFTER `electricity_fee`, ADD COLUMN `park_free` INT(4) NULL DEFAULT NULL COMMENT '是否免费停车(0 否 1是)' AFTER `service_fee`, ADD COLUMN `park_fee` VARCHAR(100) NULL DEFAULT NULL COMMENT '停车费描述' AFTER `park_free`, ADD COLUMN `payment` VARCHAR(100) NULL DEFAULT NULL COMMENT '支付方式:刷卡、线上、现金 电子钱包:微信/支付宝 ' AFTER `park_fee`; - - + ADD COLUMN `equipment_type` VARCHAR(100) NULL DEFAULT 1 COMMENT '设备类型:1:直流设备 2:交流设备 3:交直流一体设备' AFTER `payment`; + ADD COLUMN `area_code_countryside` VARCHAR(10) NULL DEFAULT NULL COMMENT '充电站省市辖区编码' AFTER `equipment_type`, + ADD COLUMN `swap_match_cars_name` VARCHAR(100) NULL DEFAULT NULL COMMENT '服务车型描述' AFTER `area_code_countryside`, + ADD COLUMN `station_classification` INT(4) NULL DEFAULT NULL COMMENT '站点分类' AFTER `swap_match_cars`, + ADD COLUMN `general_application_type` INT(4) NULL DEFAULT NULL COMMENT '通用类型' AFTER `station_classification`, + ADD COLUMN `round_the_clock` INT(4) NULL DEFAULT NULL COMMENT '7*24小时营业' AFTER `general_application_type`, + ADD COLUMN `park_type` INT(4) NULL DEFAULT NULL COMMENT '停车费类型' AFTER `round_the_clock`, + ADD COLUMN `electncity_type` INT(4) NULL DEFAULT NULL COMMENT '电费类型' AFTER `park_type`, + ADD COLUMN `business_expand_type` INT(4) NULL DEFAULT NULL COMMENT '报装类型' AFTER `electncity_type`, + ADD COLUMN `rated_power` DOUBLE(10,4) NULL DEFAULT NULL COMMENT '站点额定总功率' AFTER `business_expand_type`, + ADD COLUMN `period_fee` INT(4) NULL DEFAULT NULL COMMENT '峰谷分时' AFTER `rated_power`, + ADD COLUMN `official_run_time` VARCHAR(50) NULL DEFAULT NULL COMMENT '正式投运时间' AFTER `period_fee`, + ADD COLUMN `video_monitor` INT(4) NULL DEFAULT NULL COMMENT '视频监控配套情况' AFTER `official_run_time`; ALTER TABLE `xhpc_charging_pile` @@ -39,7 +51,37 @@ ALTER TABLE `xhpc_charging_pile` ADD COLUMN `manufacturer_id` VARCHAR(50) NULL DEFAULT NULL COMMENT '设备生产商组织机构代码' AFTER `equipment_purpose`; +ALTER TABLE `xhpc_charge_order` + ADD COLUMN `station_total_warning_num` INT(4) NULL DEFAULT NULL COMMENT '充电站累计告警数量' AFTER `vin_normal`; + + UPDATE `rycloud`.`xhpc_area` SET `code`='510156' WHERE `code`=510186; INSERT INTO `rycloud`.`xhpc_area` (`code`, `pcode`, `name`, `short_name`, `merger_name`, `province`, `city`, `level`, `lng`, `lat`, `letter`, `pinyin`, `first_char`, `status`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `is_deleted`, `tenant_id`) VALUES ('510102', '510100', '高新区', '高新区', '四川省/成都市/高新区', '四川省', '成都市', '3', '104.08347', '30.65614', 'JXQ', 'gaoxingqu', 'C', '0', NULL, NULL, '2019-12-19 11:44:50', NULL, '2019-12-19 11:44:50', '0', '000000'); + +CREATE TABLE `xhpc_equipment_accident` ( + `equipment_accident_id` bigint(20) NOT NULL AUTO_INCREMENT, + `area_code` varchar(6) DEFAULT NULL COMMENT '区域代码', + `address` varchar(255) DEFAULT NULL COMMENT '事故地点', + `accident_entity` int(4) DEFAULT NULL COMMENT '事故主题 1.运营商 2车企 3.设备制造商', + `type` int(4) DEFAULT NULL COMMENT '事故类型 1.充电设备质量问题 2.电动车电池问题 3.电网故障 4.充电站管路 99.其他', + `accident_reason` text COMMENT '事故原因', + `level` int(4) DEFAULT NULL COMMENT '事故分级 1.造成经济损失且有人员伤亡 2.造成人员伤亡 3.造成经济损失但未造成人员伤亡 4.未造成经济损失且无人员伤亡', + `accident_time` datetime DEFAULT NULL COMMENT '发生时间', + `description` text COMMENT '事故文字描述', + `pictures` text COMMENT '现场图片', + `analysis_report` text COMMENT '事故分析报告', + `del_flag` int(2) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `create_by` varchar(30) CHARACTER SET utf8 DEFAULT '' COMMENT '创建者', + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `update_by` varchar(30) CHARACTER SET utf8 DEFAULT NULL COMMENT '更新者', + `remark` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户id', + PRIMARY KEY (`equipment_accident_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='充电事故信息'; + + +ALTER TABLE `xhpc_charging_station_power` + ADD COLUMN `type` int(4) NULL DEFAULT '0' COMMENT '是否推送 0 未推送 1已推送' AFTER `installed_total_power`; diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/AutoProcessOrderTask.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/AutoProcessOrderTask.java index 970bbca3..cf5a7a10 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/AutoProcessOrderTask.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/AutoProcessOrderTask.java @@ -27,7 +27,7 @@ public class AutoProcessOrderTask { @Resource PowerPileService powerPileService; - @Scheduled(fixedRate = 60000) + //111@Scheduled(fixedRate = 60000) protected void run() { List orderList = workOrderMapper.selectByAutoRun(); diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkHistoryOrderMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkHistoryOrderMapper.xml index 30dfb142..50bb1ec7 100644 --- a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkHistoryOrderMapper.xml @@ -76,7 +76,7 @@ diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index cd288e7f..6d74470a 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -1705,4 +1705,22 @@ UPDATE et_auth_sec_token set last_push_order =#{historyOrderId} where id=2 + + + diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml index 82d898a5..10df4179 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml @@ -704,9 +704,6 @@ where co.charge_order_id=#{chargeOrderId} - - - select - format(ifnull(sum(charging_degree),0), 4) chargingDegree, + ifnull(sum(charging_degree),0) chargingDegree, format(ifnull(sum(charging_time),0), 2) chargingTime, ifnull(sum(charging_number),0) chargingNumber, - format(ifnull(sum(power_price),0), 2) powerPrice, - format(ifnull(sum(service_price),0), 2) servicePrice, - format(ifnull(sum(total_price),0), 2) totalPrice, - format(ifnull(sum(activity_power_price_total),0), 2) activityPowerPriceTotal, - format(ifnull(sum(activity_service_price_total),0), 2) activityServicePriceTotal, - format(ifnull(sum(activity_total_price),0), 2) activityTotalPrice, - format(ifnull(sum(act_price),0), 2) actPrice, - format(ifnull(sum(act_power_price),0), 2) actPowerPrice, - format(ifnull(sum(act_service_price),0), 2) actServicePrice, - format(ifnull(sum(promotion_discount),0), 2) promotionDiscount, - format(ifnull(sum(internet_commission),0), 2) internetCommission, - format(ifnull(sum(internet_svc_commission),0), 2) internetSvcCommission, - format(ifnull(sum(internet_degree_commission),0), 2) internetDegreeCommission, - format(ifnull(sum(platform_commission),0), 2) platformCommission, - format(ifnull(sum(platform_svc_commisssion),0), 2) platformSvcCommisssion, - format(ifnull(sum(operation_commission),0), 2) operationCommission, - format(ifnull(sum(operation_svc_commission),0), 2) operationSvcCommission, - format(ifnull(sum(act_power_price + act_service_price),0), 2) actTotalPrice, + ifnull(sum(power_price),0) powerPrice, + ifnull(sum(service_price),0) servicePrice, + ifnull(sum(total_price),0) totalPrice, + ifnull(sum(activity_power_price_total),0) activityPowerPriceTotal, + ifnull(sum(activity_service_price_total),0) activityServicePriceTotal, + ifnull(sum(activity_total_price),0) activityTotalPrice, + ifnull(sum(act_price),0) actPrice, + ifnull(sum(act_power_price),0) actPowerPrice, + ifnull(sum(act_service_price),0) actServicePrice, + ifnull(sum(promotion_discount),0) promotionDiscount, + ifnull(sum(internet_commission),0) internetCommission, + ifnull(sum(internet_svc_commission),0) internetSvcCommission, + ifnull(sum(internet_degree_commission),0) internetDegreeCommission, + ifnull(sum(platform_commission),0) platformCommission, + ifnull(sum(platform_svc_commisssion),0) platformSvcCommisssion, + ifnull(sum(operation_commission),0) operationCommission, + ifnull(sum(operation_svc_commission),0) operationSvcCommission, + ifnull(sum(act_power_price + act_service_price),0) actTotalPrice, DATE_FORMAT(create_time,'%Y-%m-%d') createTime from xhpc_statistics_station where del_flag=0 and type=1 and total_price >=0 @@ -1723,4 +1723,42 @@ and tenant_id=#{tenantId} + + + + diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java index 9ad64037..c7802ff6 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java @@ -230,7 +230,7 @@ public class AlipayPaymentController { } } } - Thread.sleep(1000); + Thread.sleep(500); return "failure"; }catch (Exception e){ e.printStackTrace(); diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java index f5dc28fb..ff86d191 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java @@ -309,6 +309,11 @@ public class WxPaymentController { " " + trade_type + "\n" + " " + sign + "\n" + " "; + + System.out.println("============weixin==xmlString================"); + System.out.println("============weixin==xmlString================"+xmlString); + System.out.println("============weixin==xmlString================"); + return xmlString; } @@ -452,6 +457,7 @@ public class WxPaymentController { @RequestMapping("/paymentCallback") public Object payNotify(HttpServletRequest request, HttpServletResponse response) { try{ + System.out.println("============weixin==回调Api======开始=========="); readWriteLock.writeLock().lock();//取 try { ServletInputStream in = null; @@ -506,7 +512,7 @@ public class WxPaymentController { } catch (IOException e) { e.printStackTrace(); } - Thread.sleep(1000); + Thread.sleep(500); }catch (Exception e){ e.printStackTrace(); }finally { diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRechargeOrderController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRechargeOrderController.java index 7930c59e..055b4287 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRechargeOrderController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRechargeOrderController.java @@ -95,7 +95,7 @@ public class XhpcRechargeOrderController extends BaseController { /** * 每隔30分钟,清理一次未支付的订单 */ - @Scheduled(cron = "0 0/30 * * * ?") + //@Scheduled(cron = "0 0/30 * * * ?") @GetMapping("/test1") public void test1(){ iXhpcRechargeOrderService.updateRechargeOrderStatus(); diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOriginalOrderController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOriginalOrderController.java index ec5a5d4d..6af41a0e 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOriginalOrderController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOriginalOrderController.java @@ -28,6 +28,7 @@ import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.*; @@ -43,6 +44,7 @@ import java.io.PrintWriter; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -75,14 +77,14 @@ public class XhpcRefundOriginalOrderController extends BaseController { @NoRepeatSubmit(lockTime = 3) @GetMapping("/refundOrder") - @ApiOperation(value = "支付宝支付") + @ApiOperation(value = "支付宝退款") public R refundOrder(Long refundOrderId) throws Exception { return xhpcRefundOriginalOrderService.zhbRefundOriginalOrder(refundOrderId); } @NoRepeatSubmit(lockTime = 3) @GetMapping("/refundWxOrder") - @ApiOperation(value = "微信支付") + @ApiOperation(value = "微信退款") public R refundWxOrder(Long refundOrderId) throws Exception { return xhpcRefundOriginalOrderService.wxRefundOriginalOrder(refundOrderId); } @@ -167,7 +169,7 @@ public class XhpcRefundOriginalOrderController extends BaseController { if(xhpcRefundAudit.getStatus()==2){ xhpcRefundOriginalOrderService.updateXhpcRefundOrder(xhpcRefundOrder,null,2,3); xhpcRefundOrder.setRemark("订单已取消审核"); - return R.ok("订单已取消审核"); + return R.ok(null,"订单已取消审核"); } if (!StatusConstants.REFUND_ORDER_STATUS_WAIT.equals(xhpcRefundOrder.getStatus())) { xhpcRefundOriginalOrderService.updateXhpcRefundOrder(xhpcRefundOrder,null,2,2); @@ -184,7 +186,7 @@ public class XhpcRefundOriginalOrderController extends BaseController { int refundApplication = xhpcUserAccountStatementMapper.updateAppUserRefundApplication(xhpcAppUser); if (refundApplication == 0) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return R.fail("修改用户信息失败"); + return R.fail(HttpStatus.ERROR_STATUS,"修改用户信息失败"); } Map appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(userId); BigDecimal amount = new BigDecimal(appUserInfo.get("balance").toString()); @@ -192,13 +194,13 @@ public class XhpcRefundOriginalOrderController extends BaseController { xhpcRefundOrder.setStatus(2); xhpcRefundOrder.setRemark("订单金额出错"); xhpcRefundOriginalOrderService.updateXhpcRefundOrder(xhpcRefundOrder,null,4,2); - return R.fail("订单金额出错"); + return R.fail(HttpStatus.ERROR_STATUS,"订单金额出错"); } }else if(UserTypeUtil.COMMUNIT_TYPE.equals(source)){ int i = iXhpcRefundAuditService.updateCommunityPersonnelMoney(userId, null, 0); if (i == 0) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return R.fail("获取社区用户失败"); + return R.fail(HttpStatus.ERROR_STATUS,"获取社区用户失败"); } Map communityPersonnel = iXhpcRefundAuditService.getCommunityPersonnelById(userId, xhpcRefundOrder.getTenantId()); BigDecimal amount = new BigDecimal(communityPersonnel.get("balance").toString()); @@ -206,7 +208,7 @@ public class XhpcRefundOriginalOrderController extends BaseController { xhpcRefundOrder.setStatus(2); xhpcRefundOrder.setRemark("订单金额出错"); xhpcRefundOriginalOrderService.updateXhpcRefundOrder(xhpcRefundOrder,null,4,2); - return R.fail("订单金额出错"); + return R.fail(HttpStatus.ERROR_STATUS,"订单金额出错"); } }else{ AjaxResult.error(HttpStatus.DATA_ERROR, "该用户不能退款"); @@ -222,7 +224,7 @@ public class XhpcRefundOriginalOrderController extends BaseController { xhpcRefundOrder.setStatus(2); xhpcRefundOrder.setRemark("订单金额出错"); xhpcRefundOriginalOrderService.updateXhpcRefundOrder(xhpcRefundOrder,null,4,2); - return R.fail(r.getMsg()); + return R.fail(HttpStatus.ERROR_STATUS,r.getMsg()); } } catch (Exception e) { e.printStackTrace(); @@ -237,7 +239,7 @@ public class XhpcRefundOriginalOrderController extends BaseController { xhpcRefundOrder.setStatus(2); xhpcRefundOrder.setRemark("订单金额出错"); xhpcRefundOriginalOrderService.updateXhpcRefundOrder(xhpcRefundOrder,null,4,2); - return R.fail(r.getMsg()); + return R.fail(HttpStatus.ERROR_STATUS,r.getMsg()); } } catch (Exception e) { e.printStackTrace(); @@ -356,6 +358,39 @@ public class XhpcRefundOriginalOrderController extends BaseController { return R.ok(null,"申请退款成功"); } + //@Scheduled(cron = "0/30 * * * * ? ") + @GetMapping("/moneyPage") + public void moneyPage(){ + logger.info("++++++++++++每30秒,扫描一次,退款订单金额小于200,自动审核通过++++++++++++++++"); + try { + List list = iXhpcRefundOrderService.moneyPage(1); + logger.info("++++++++++++有自动退款订单+++++list+++++++++++"+list.size()); + if(list !=null && list.size()>0){ + for (int i = 0; i > getRefundOriginalOrderList(@Param("refundOrderId")Long refundOrderId); + } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOriginalOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOriginalOrderService.java index 9cb0f3dc..7e90ed8c 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOriginalOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOriginalOrderService.java @@ -28,4 +28,6 @@ public interface IXhpcRefundOriginalOrderService { void addXhpcRefundOrder(XhpcRefundOrder xhpcRefundOrder); void getTestSms(String number); + + R getRefundOriginalOrderList(Long refundOrderId); } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOriginalOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOriginalOrderServiceImpl.java index 77bb07bf..b6dc63d9 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOriginalOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOriginalOrderServiceImpl.java @@ -714,7 +714,7 @@ public class XhpcRefundOriginalOrderServiceImpl implements IXhpcRefundOriginalOr } catch (Exception e) { e.printStackTrace(); } - Thread.sleep(1000); + Thread.sleep(500); if (fals) { return R.ok(); } @@ -913,7 +913,7 @@ public class XhpcRefundOriginalOrderServiceImpl implements IXhpcRefundOriginalOr } } - Thread.sleep(1000); + Thread.sleep(500); }catch (Exception e){ e.printStackTrace(); }finally { @@ -1444,7 +1444,11 @@ public class XhpcRefundOriginalOrderServiceImpl implements IXhpcRefundOriginalOr smsService.sendNotice(paramMap); } - + @Override + public R getRefundOriginalOrderList(Long refundOrderId) { + List> refundOriginalOrderList = xhpcRefundOriginalOrderMapper.getRefundOriginalOrderList(refundOrderId); + return R.ok(refundOriginalOrderList,"查询成功"); + } public static void main(String[] args) throws AlipayApiException { diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOriginalOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOriginalOrderMapper.xml index 121024e3..a6fe5de1 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOriginalOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOriginalOrderMapper.xml @@ -553,4 +553,25 @@ update xhpc_recharge_order set refund_status=2 where user_id=#{userId} and source =#{source} and (refund_status=0 or refund_status =1) + + + + diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java index 4641f37a..aefb7c11 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java @@ -397,43 +397,46 @@ public class ChargingController { public static void main(String[] args) { - Integer F401 = HexUtils.reverseHexInt("F401"); + Integer F401 = HexUtils.reverseHexInt("8E200100"); System.out.println("F401 转化成="+F401); - Integer D007 = HexUtils.reverseHexInt("D007"); - System.out.println("D007 转化成="+D007); + Integer F402 = HexUtils.reverseHexInt("8E200100"); + System.out.println("F402 转化成="+F402); - Integer F620 = HexUtils.reverseHexInt("F620"); - System.out.println("F620 转化成="+F620); - - Integer F03 = HexUtils.reverseHexInt("03"); - System.out.println("F03 转化成="+F03); - - Integer D3C0F = HexUtils.reverseHexInt("3C0F"); - System.out.println("3C0F 转化成="+D3C0F); - - Integer f4C1D = HexUtils.reverseHexInt("4C1D"); - System.out.println("f4C1D 转化成="+f4C1D); - - Integer DC05 = HexUtils.reverseHexInt("DC05"); - System.out.println("DC05 转化成="+DC05); - - Integer A00F = HexUtils.reverseHexInt("A00F"); - System.out.println("A00F 转化成="+A00F); - - Integer FCF3 = HexUtils.reverseHexInt("FCF3"); - System.out.println("FCF3 转化成="+FCF3); - - - - Integer f70C0001 = HexUtils.reverseHexInt("D8B68A0400"); - System.out.println("f70C0001 转化成="+f70C0001); - - Integer f70C0002 = HexUtils.reverseHexInt("C2E00200"); - System.out.println("f70C0002 转化成="+f70C0002); - - String s = HexUtils.reverseHex("38C7280A1D0817"); - System.out.println("s 转化成="+s); +// Integer D007 = HexUtils.reverseHexInt("D007"); +// System.out.println("D007 转化成="+D007); +// +// Integer F620 = HexUtils.reverseHexInt("F620"); +// System.out.println("F620 转化成="+F620); +// +// Integer F03 = HexUtils.reverseHexInt("03"); +// System.out.println("F03 转化成="+F03); +// +// Integer D3C0F = HexUtils.reverseHexInt("3C0F"); +// System.out.println("3C0F 转化成="+D3C0F); +// +// Integer f4C1D = HexUtils.reverseHexInt("4C1D"); +// System.out.println("f4C1D 转化成="+f4C1D); +// +// Integer DC05 = HexUtils.reverseHexInt("DC05"); +// System.out.println("DC05 转化成="+DC05); +// +// Integer A00F = HexUtils.reverseHexInt("A00F"); +// System.out.println("A00F 转化成="+A00F); +// +// Integer FCF3 = HexUtils.reverseHexInt("FCF3"); +// System.out.println("FCF3 转化成="+FCF3); +// +// +// +// Integer f70C0001 = HexUtils.reverseHexInt("D8B68A0400"); +// System.out.println("f70C0001 转化成="+f70C0001); +// +// Integer f70C0002 = HexUtils.reverseHexInt("C2E00200"); +// System.out.println("f70C0002 转化成="+f70C0002); +// +// String s = HexUtils.reverseHex("38C7280A1D0817"); +// System.out.println("s 转化成="+s); // String s = toHexInt(3532); // System.out.println("3532 转化成BIN码="+s); // byte[] bytes = HexUtils.toBytes("80836000150001022305301518050003"); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java index ec2d6a02..d876cc80 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java @@ -5,6 +5,7 @@ import com.xhpc.common.api.dto.ChargingStationDto; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.HttpUtils; import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.evcs.cdjgpc.dto.CDConnectorInfo; import com.xhpc.evcs.cdjgpc.dto.CDEquipmentInfo; import com.xhpc.evcs.domain.XhpcChargingPile; import com.xhpc.evcs.dto.ConnectorInfo; @@ -444,19 +445,20 @@ public class PileController { cdEquipmentInfo.setNewNationalStandard(xhpcChargingPile.getNewNationalStandard()); cdEquipmentInfo.setVinFlag(xhpcChargingPile.getVinFlag()); cdEquipmentInfo.setConnectorInfos(getConnectorInfos(serialNumber,xhpcChargingPile)); + cdEquipmentInfo.setEquipmentClassificatlon(xhpcChargingPile.getEquipmentClassificatlon()); REDIS.setCacheObject(skey, cdEquipmentInfo); } - private List getConnectorInfos(String pileNo,XhpcChargingPile xhpcChargingPile) { + private List getConnectorInfos(String pileNo, XhpcChargingPile xhpcChargingPile) { final Map cachePile = REDIS.getCacheMap("pile:".concat(pileNo)); - List connectorInfoList = new ArrayList<>(); + List connectorInfoList = new ArrayList<>(); Integer gunNumCache = (Integer) cachePile.get("gunNum"); gunNumCache = gunNumCache == null ? 2 : gunNumCache; for (int i = 1; i <= gunNumCache; i++) { String gunId = pileNo.concat(String.format("%02d", i)); - ConnectorInfo connectorInfo = new ConnectorInfo(); + CDConnectorInfo connectorInfo = new CDConnectorInfo(); connectorInfo.setConnectorID(gunId); String connectorName = REDIS.getCacheMapValue("gun:".concat(gunId), "terminalName"); //todo set them in redis! connectorInfo.setConnectorName(connectorName == null ? @@ -474,6 +476,9 @@ public class PileController { connectorInfo.setPower(power == null ? 120.0 : power); Integer nationalStandard = (Integer) cachePile.get("nationalStandard"); connectorInfo.setNationalStandard(nationalStandard == null ? 2 : nationalStandard); + connectorInfo.setEquipmentClassification(xhpcChargingPile.getEquipmentClassificatlon()); + connectorInfo.setOpreateStatus(50); + connectorInfo.setAuxPower(xhpcChargingPile.getAuxPower()); connectorInfoList.add(connectorInfo); } return connectorInfoList; diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java index 6cd474a0..2ec3ae22 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java @@ -1,20 +1,18 @@ package com.xhpc.pp.controller; -import com.xhpc.common.api.ChargingStationService; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; import com.xhpc.common.api.dto.ChargingStationDto; import com.xhpc.common.core.domain.R; import com.xhpc.common.data.redis.CacheRateModel; -import com.xhpc.evcs.cdjgpc.dto.CDEquipmentInfo; -import com.xhpc.evcs.cdjgpc.dto.CDStationInfo; +import com.xhpc.evcs.cdjgpc.dto.*; import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import java.util.concurrent.TimeUnit; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; @@ -34,30 +32,35 @@ public class StationController { REDIS.setCacheObject(skey, cacheStation); String rkey = "rateModel:".concat(rateModelId.toString()); REDIS.setCacheObject(rkey, rateModel); - addNotificationStationInfo(stationId); return R.ok(); } - //组装场站信息 - public void addNotificationStationInfo(Long stationId){ + //生成场站推送数据信息 + @GetMapping("station/addNotificationStationInfo") + public void addNotificationStationInfo(@RequestParam("stationId")Long stationId){ CDStationInfo xhpcChargingStation = deviceMessageMapper.getXhpcChargingStation(stationId); if(xhpcChargingStation !=null){ //场站信息入缓存 String skey = "cdjgpc:station:".concat(stationId.toString())+".notification"; REDIS.deleteObject(skey); + + if(xhpcChargingStation.getSwapMatchCarsName() !=null){ + String[] split = xhpcChargingStation.getSwapMatchCarsName().split(","); + xhpcChargingStation.setSwapMatchCars(split); + } xhpcChargingStation.setEquipmentInfos(new ArrayList<>()); REDIS.setCacheObject(skey, xhpcChargingStation); } } //组合场站数据 - @GetMapping("station/getNotificationStationInfo/{stationId}") - public R getNotificationStationInfo(Long chargingStationId){ - String key = "cdjgpc:station:".concat(chargingStationId.toString())+".notification"; + @GetMapping("station/getNotificationStationInfo") + public R getNotificationStationInfo(@RequestParam("stationId") Long stationId){ + String key = "cdjgpc:station:".concat(stationId.toString())+".notification"; CDStationInfo cdStationInfo = REDIS.getCacheObject(key); cdStationInfo.setEquipmentInfos(new ArrayList<>()); //查询场站是桩是否对应上 - ChargingStationDto stationDto = REDIS.getCacheObject("station:"+chargingStationId); + ChargingStationDto stationDto = REDIS.getCacheObject("station:"+stationId); Set pks = stationDto.getPiles(); if (pks != null) { List cdEquipmentInfos = new ArrayList<>(); @@ -77,7 +80,257 @@ public class StationController { return R.fail("场站未查询到充电桩信息"); } + //查询站点统计信息 + @GetMapping("station/queryStationStats") + public R queryStationStats(@RequestParam("stationId") Long stationId,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime){ + //获取场站 + CDStationStatslnfo stationStatsInfo = deviceMessageMapper.getStationEquipmentElectricity(stationId, startTime, endTime); + stationStatsInfo.setStartTime(startTime); + stationStatsInfo.setEndTime(endTime); + //获取桩 + List chargingPileIds = deviceMessageMapper.getchargingPileId(stationId); + List equipmentStatsInfos =new ArrayList<>(); + for (int i = 0; i < chargingPileIds.size(); i++) { + Long chargingPileId = chargingPileIds.get(i); + CDSuqEquipmentStatslnfo equipmentStatsInfo = deviceMessageMapper.getSupEquipmentStatsInfo(stationId, chargingPileId, startTime, endTime); + List supConnectorStatslnfo = deviceMessageMapper.getSupConnectorStatslnfo(stationId, null, startTime, endTime); + equipmentStatsInfo.setConnectorStatsInfos(supConnectorStatslnfo); + equipmentStatsInfos.add(equipmentStatsInfo); + } + stationStatsInfo.setEquipmentStatsInfo(equipmentStatsInfos); + String key ="cdjgpc:station:"+stationId+".queryStationStats"; + REDIS.setCacheObject(key, stationStatsInfo,30L, TimeUnit.MINUTES); + return R.ok(stationStatsInfo); + } + + + @GetMapping("station/getNotificationStationFee") + public R getNotificationStationFee(@RequestParam("stationId") Long stationId){ + List notificationStationFee = deviceMessageMapper.getNotificationStationFee(stationId); + String skey = "cdjgpc:stationFee:".concat(stationId.toString()); + CDStationFee cdStationFeeRequest =new CDStationFee(); + cdStationFeeRequest.setOperatorID("MA6DFCTD5"); + cdStationFeeRequest.setStationID(stationId.toString()); + cdStationFeeRequest.setChargeFeeDetails(notificationStationFee); + REDIS.setCacheObject(skey, cdStationFeeRequest); + String ske = "cdjgpc:stationFeeRequest:".concat(stationId.toString()); + REDIS.deleteObject(ske); + REDIS.setCacheObject(ske, cdStationFeeRequest,30L, TimeUnit.MINUTES); + return R.ok(); + } + + + //查询充电设备运行统计信息 + @GetMapping("station/querySupEquipmentStatsInfo") + public R querySupEquipmentStatsInfo(@RequestParam("stationId") Long stationId,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime){ + //获取场站 + List cdSuqEquipmentStatslnfos =new ArrayList<>(); + List chargingPileIds = deviceMessageMapper.getchargingPileId(stationId); + for (int i = 0; i < chargingPileIds.size(); i++) { + CDSuqEquipmentStatslnfo supEquipmentStatsInfo = deviceMessageMapper.getSupEquipmentStatsInfo(stationId,chargingPileIds.get(i), startTime, endTime); + //获取枪信息 + List supConnectorStatslnfo = deviceMessageMapper.getSupConnectorStatslnfo(stationId, chargingPileIds.get(i), startTime, endTime); + supEquipmentStatsInfo.setConnectorStatsInfos(supConnectorStatslnfo); + + cdSuqEquipmentStatslnfos.add(supEquipmentStatsInfo); + } + String key ="cdjgpc:station:"+stationId+".querySupEquipmentStatsInfo"; + REDIS.setCacheObject(key, cdSuqEquipmentStatslnfos,30L, TimeUnit.MINUTES); + return R.ok(cdSuqEquipmentStatslnfos); + } + + //查询充电设备运行统计信息 + @GetMapping("station/queryConnectorStatsInfo") + public R queryConnectorStatsInfo(@RequestParam("stationId") Long stationId,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime){ + //获取枪信息 + List supConnectorStatslnfo = deviceMessageMapper.getSupConnectorStatslnfo(stationId, null, startTime, endTime); + String key ="cdjgpc:station:"+stationId+".queryConnectorStatsInfo"; + REDIS.setCacheObject(key, supConnectorStatslnfo,30L, TimeUnit.MINUTES); + return R.ok(supConnectorStatslnfo); + } + + //查询充电站功率统信息 + @GetMapping("station/getSuperviseQueryStationPowerInfo") + public R getSuperviseQueryStationPowerInfo(@RequestParam("stationIDs") String [] stationIDs,@RequestParam("dataTime") String dataTime,@RequestParam("replace")String replace){ + System.out.println("stationIDs===="+stationIDs.toString()); + List list = Arrays.asList(stationIDs); + List longList =new ArrayList<>(); + for (int i = 0; i superviseQueryStationPowerInfoList = deviceMessageMapper.getSuperviseQueryStationPowerInfo(longList, dataTime, numbrt); + + for (int i = 0; i < superviseQueryStationPowerInfoList.size(); i++) { + //获取充电桩实时功率 + CDSupStationPowerInfo cdSupStationPowerInfo = superviseQueryStationPowerInfoList.get(i); + + List pileSuperviseQueryStationPowerInfoList = deviceMessageMapper.getPileSuperviseQueryStationPowerInfo(Long.valueOf(cdSupStationPowerInfo.getStationID()), dataTime, numbrt); + for (int j = 0; j terminalSuperviseQueryStationPowerInfo = deviceMessageMapper.getTerminalSuperviseQueryStationPowerInfo(Long.valueOf(cdSupEquipmentPowerlnfo.getPileID()), dataTime, numbrt); + cdSupEquipmentPowerlnfo.setConnectorPowerInfos(terminalSuperviseQueryStationPowerInfo); + } + cdSupStationPowerInfo.setEquipmentPowerInfos(pileSuperviseQueryStationPowerInfoList); + } + String key ="cdjgpc:station:"+replace+".getSuperviseQueryStationPowerInfo"; + REDIS.setCacheObject(key, superviseQueryStationPowerInfoList,30L, TimeUnit.MINUTES); + + return R.ok(superviseQueryStationPowerInfoList); + } + + //查询充电站功率统信息 + @GetMapping("station/getSuperviseQueryEquipmentPowerInfo") + public R getSuperviseQueryEquipmentPowerInfo(@RequestParam("stationID") String stationID,@RequestParam("dataTime") String dataTime,@RequestParam("replace")String replace){ + //获取时间 + String now = DateUtil.now(); + int hh = Integer.parseInt(now.substring(11,13)); + int mm = Integer.parseInt(now.substring(14,16)); + int dd = Integer.parseInt(now.substring(17,19)); + int numbrt =0; + if(mm<15){ + numbrt = hh*4; + }else if(mm<30){ + numbrt = hh*4+1; + }else if(mm<45){ + numbrt = hh*4+2; + }else{ + numbrt = hh*4+3; + } + + List pileSuperviseQueryStationPowerInfoList = deviceMessageMapper.getPileSuperviseQueryStationPowerInfo(Long.valueOf(stationID), dataTime, numbrt); + for (int j = 0; j terminalSuperviseQueryStationPowerInfo = deviceMessageMapper.getTerminalSuperviseQueryStationPowerInfo(Long.valueOf(cdSupEquipmentPowerlnfo.getPileID()), dataTime, numbrt); + cdSupEquipmentPowerlnfo.setConnectorPowerInfos(terminalSuperviseQueryStationPowerInfo); + } + String key ="cdjgpc:station:"+replace+".getSuperviseQueryEquipmentPowerInfo"; + REDIS.setCacheObject(key, pileSuperviseQueryStationPowerInfoList,30L, TimeUnit.MINUTES); + return R.ok(pileSuperviseQueryStationPowerInfoList); + } + + + //查充电事故 + @GetMapping("station/getSuperviseQueryAccidentInfo") + public R getSuperviseQueryAccidentInfo(@RequestParam("lastQueryTime") String lastQueryTime,@RequestParam("replace") String replace){ + List list = deviceMessageMapper.getSuperviseQueryAccidentInfo(); + + for (int i = 0; i stationStatsInfoList = deviceMessageMapper.getCDStationStatslnfoList(startTime, endTime); + + for (int k = 0; k chargingPileIds = deviceMessageMapper.getchargingPileId(stationId); + List equipmentStatsInfos =new ArrayList<>(); + for (int i = 0; i < chargingPileIds.size(); i++) { + Long chargingPileId = chargingPileIds.get(i); + CDSuqEquipmentStatslnfo equipmentStatsInfo = deviceMessageMapper.getSupEquipmentStatsInfo(stationId, chargingPileId, startTime, endTime); + List supConnectorStatslnfo = deviceMessageMapper.getSupConnectorStatslnfo(stationId, null, startTime, endTime); + equipmentStatsInfo.setConnectorStatsInfos(supConnectorStatslnfo); + equipmentStatsInfos.add(equipmentStatsInfo); + } + cdStationStatslnfo.setEquipmentStatsInfo(equipmentStatsInfos); + } + + String key ="cdjgpc:station:"+replace+".getSuperviseNotificationOperationStatusInfo"; + REDIS.setCacheObject(key, stationStatsInfoList,30L, TimeUnit.MINUTES); + return R.ok(stationStatsInfoList); + } + + + //推送充电站实时功率 + @GetMapping("station/getSuperviseNotificationRealtimePowerInfo") + public R getSuperviseNotificationRealtimePowerInfo(@RequestParam("operatorIdEvcs")String operatorIdEvcs,@RequestParam("replace")String replace){ + + List stationId = deviceMessageMapper.getStationId(); + //获取时间 + String now = DateUtil.now(); + String dataTime = now.substring(0,10); + int hh = Integer.parseInt(now.substring(11,13)); + int mm = Integer.parseInt(now.substring(14,16)); + int numbrt =0; + if(mm<15){ + numbrt = hh*4; + }else if(mm<30){ + numbrt = hh*4+1; + }else if(mm<45){ + numbrt = hh*4+2; + }else{ + numbrt = hh*4+3; + } + List superviseQueryStationPowerInfoList = deviceMessageMapper.getSuperviseQueryStationPowerInfo(stationId, dataTime, numbrt); + for (int i = 0; i < superviseQueryStationPowerInfoList.size(); i++) { + //获取充电桩实时功率 + CDSupStationPowerInfo cdSupStationPowerInfo = superviseQueryStationPowerInfoList.get(i); + + List pileSuperviseQueryStationPowerInfoList = deviceMessageMapper.getPileSuperviseQueryStationPowerInfo(Long.valueOf(cdSupStationPowerInfo.getStationID()), dataTime, numbrt); + for (int j = 0; j terminalSuperviseQueryStationPowerInfo = deviceMessageMapper.getTerminalSuperviseQueryStationPowerInfo(Long.valueOf(cdSupEquipmentPowerlnfo.getPileID()), dataTime, numbrt); + cdSupEquipmentPowerlnfo.setConnectorPowerInfos(terminalSuperviseQueryStationPowerInfo); + } + cdSupStationPowerInfo.setEquipmentPowerInfos(pileSuperviseQueryStationPowerInfoList); + } + String key ="cdjgpc:station:"+replace+".getSuperviseNotificationRealtimePowerInfo"; + REDIS.setCacheObject(key, superviseQueryStationPowerInfoList,30L, TimeUnit.MINUTES); + + return R.ok(superviseQueryStationPowerInfoList); + + } } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java index 53c0e3f0..39ee0b04 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java @@ -25,10 +25,10 @@ public class BmsChargingCompletedDataLogic implements ServiceLogic { @Override public ServiceResult service(ServiceParameter sp) throws Exception { - log.error("====0X19======getServiceName================"+sp.getServiceName()); - log.error("====0X19======getPileNo================"+sp.getPileNo()); - log.error("====0X19======getParameters================"+sp.getParameters()); - log.error("====0X19======getVersion================"+sp.getVersion()); +// log.error("====0X19======getServiceName================"+sp.getServiceName()); +// log.error("====0X19======getPileNo================"+sp.getPileNo()); +// log.error("====0X19======getParameters================"+sp.getParameters()); +// log.error("====0X19======getVersion================"+sp.getVersion()); String remark = "充电桩与 BMS 充电结束阶段报文"; Map req = sp.getParameters(); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java index 067bfb48..b05e7899 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java @@ -3,6 +3,7 @@ package com.xhpc.pp.logic; import cn.hutool.core.date.DateUtil; import cn.hutool.json.JSONUtil; import com.fasterxml.jackson.databind.ObjectMapper; +import com.xhpc.common.api.EvcsService; import com.xhpc.common.api.PileOrderService; import com.xhpc.common.api.SmsService; import com.xhpc.common.core.domain.R; @@ -31,6 +32,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; @@ -52,6 +55,8 @@ public class RealtimeDataLogic implements ServiceLogic { private ChargingController chargingController; @Resource XhpcDeviceMessageMapper deviceMessageMapper; + @Resource + EvcsService evcsService; private static final Logger log = LoggerFactory.getLogger(RealtimeDataLogic.class); @@ -60,6 +65,7 @@ public class RealtimeDataLogic implements ServiceLogic { private static final String[] hftable = {"急停按钮动作故障", "无可用整流模块", "出风口温度过高", "交流防雷故障", "交直流模块DC20通信中断", "绝缘检测模块FC08通信中断", "电度表通信中断", "读卡器通信中断", "RC10通信中断", "风扇调速板故障", "直流熔断器故障", "高压接触器故障", "门打开"}; + private final ExecutorService executorService = Executors.newFixedThreadPool(40); @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -281,6 +287,12 @@ public class RealtimeDataLogic implements ServiceLogic { deviceMessage.setContent((String) req.get("hex")); deviceMessage.setChargeOrderNo((String) req.get("orderNo")); deviceMessageMapper.insertByDomain(deviceMessage); +// executorService.execute(new Runnable() { +// @Override +// public void run() { +// evcsService.getNotificationConnectorChargeStatus(orderNo); +// } +// }); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java index 572329f6..30de201f 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java @@ -29,10 +29,10 @@ public class RemoteStopReplyDataLogic implements ServiceLogic { @Override public ServiceResult service(ServiceParameter sp) throws Exception { - log.error("=====0X35=====getServiceName================"+sp.getServiceName()); - log.error("=====0X35=====getPileNo================"+sp.getPileNo()); - log.error("=====0X35=====getParameters================"+sp.getParameters()); - log.error("=====0X35=====getVersion================"+sp.getVersion()); +// log.error("=====0X35=====getServiceName================"+sp.getServiceName()); +// log.error("=====0X35=====getPileNo================"+sp.getPileNo()); +// log.error("=====0X35=====getParameters================"+sp.getParameters()); +// log.error("=====0X35=====getVersion================"+sp.getVersion()); Map req = sp.getParameters(); ObjectMapper objectMapper = new ObjectMapper(); RemoteStopReplyData remoteStopReplyData = objectMapper.convertValue(req, RemoteStopReplyData.class); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/ServiceMainLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/ServiceMainLogic.java index f72ae17d..b0f1d130 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/ServiceMainLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/ServiceMainLogic.java @@ -21,10 +21,10 @@ public class ServiceMainLogic { private Map serviceLogics; public ServiceResult process(ServiceParameter sp) { - log.error("==========getServiceName================"+sp.getServiceName()); - log.error("==========getPileNo================"+sp.getPileNo()); - log.error("==========getParameters================"+sp.getParameters()); - log.error("==========getVersion================"+sp.getVersion()); +// log.error("==========getServiceName================"+sp.getServiceName()); +// log.error("==========getPileNo================"+sp.getPileNo()); +// log.error("==========getParameters================"+sp.getParameters()); +// log.error("==========getVersion================"+sp.getVersion()); ServiceResult result; try { ServiceLogic logic = getServiceLogic(sp.getServiceName()); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/mapper/XhpcDeviceMessageMapper.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/mapper/XhpcDeviceMessageMapper.java index be064d3a..0cb15ed0 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/mapper/XhpcDeviceMessageMapper.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/mapper/XhpcDeviceMessageMapper.java @@ -1,12 +1,14 @@ package com.xhpc.pp.mapper; -import com.xhpc.evcs.cdjgpc.dto.CDStationInfo; +import com.xhpc.evcs.cdjgpc.dto.*; import com.xhpc.evcs.domain.XhpcChargingPile; import com.xhpc.pp.domain.XhpcDeviceMessage; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + @Mapper public interface XhpcDeviceMessageMapper { @@ -18,4 +20,45 @@ public interface XhpcDeviceMessageMapper { XhpcChargingPile getXhpcChargingPile(@Param("pileNo") String pileNo); CDStationInfo getXhpcChargingStation(@Param("chargingStationId") Long chargingStationId); + + //统计电站--枪电量 + double getConnectorEquipmentElectricity(@Param("stationId")Long stationId,@Param("chargingPileId")Long chargingPileId,@Param("terminalId")Long terminalId,@Param("startTime")String startTime,@Param("endTime")String endTime); + //统计电站--桩电量 + double getEquipmentEquipmentElectricity(@Param("stationId")Long stationId,@Param("chargingPileId")Long chargingPileId,@Param("startTime")String startTime,@Param("endTime")String endTime); + //查询站点统计信息 + CDStationStatslnfo getStationEquipmentElectricity(@Param("stationId")Long stationId, @Param("startTime")String startTime, @Param("endTime")String endTime); + + //查询充电设备运行统计信息 + CDSuqEquipmentStatslnfo getSupEquipmentStatsInfo(@Param("stationId")Long stationId, @Param("chargingPileId")Long chargingPileId, @Param("startTime")String startTime, @Param("endTime")String endTime); + + + List getSupConnectorStatslnfo(@Param("stationId")Long stationId, @Param("chargingPileId")Long chargingPileId, @Param("startTime")String startTime, @Param("endTime")String endTime); + + + List getStationId(); + + //获取桩id + List getchargingPileId(@Param("stationId")Long stationId); + + //获取枪 + List getterminalId(@Param("stationId")Long stationId,@Param("chargingPileId")Long chargingPileId); + + //查询电站费率变化 + List getNotificationStationFee(@Param("stationId")Long stationId); + + //获取场站当前时间实时功率 + List getSuperviseQueryStationPowerInfo(@Param("stationIds")List stationIds,@Param("subTime")String subTime,@Param("number")Integer number); + + //获取桩当前时间实时功率 + List getPileSuperviseQueryStationPowerInfo(@Param("chargingStationId")Long chargingStationId, @Param("subTime")String subTime, @Param("number")Integer number); + + //获取枪当前时间实时功率 + List getTerminalSuperviseQueryStationPowerInfo(@Param("chargingPileId")Long chargingPileId,@Param("subTime")String subTime,@Param("number")Integer number); + + //获取充电事故 + List getSuperviseQueryAccidentInfo(); + + //充电站统计信息 + List getCDStationStatslnfoList(@Param("startTime")String startTime,@Param("endTime")String endTime); + } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java index cd2e7725..96d7d894 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java @@ -78,7 +78,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler { log.error("incorrect input data |{}| len[{}]", dataStr, d.length); } String crc = calcCrc(d); - log.info("====111=====crc==================="+crc+"==========dataStr==============="+dataStr); + //log.info("====111=====crc==================="+crc+"==========dataStr==============="+dataStr); if (!dataStr.endsWith(crc)) { log.error("incorrect input data crc {}", crc); continue; @@ -94,13 +94,13 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler { InterruptedException { String serviceName = toHex(data, 5, 6); - log.error("==========ChargingPileBinaryHandler================"+serviceName); + //log.error("==========ChargingPileBinaryHandler================"+serviceName); String version = ChargingPileServer.getVersion(handler.getName()); Map req = analysis(data, serviceName, version); int seq = HexUtils.toInteger(data, 2, 4); req.put("seqint", seq); String pileNo = (String) req.get("pileNo"); - log.error("==========ChargingPileBinaryHandler====="+serviceName+"======req====="+req.toString()); + //log.error("==========ChargingPileBinaryHandler====="+serviceName+"======req====="+req.toString()); ServiceParameter sp = new ServiceParameter(serviceName, pileNo, req); ServiceResult result = servicemainLogic.process(sp); String resultCode = result.getCode(); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java index 119307f9..66540370 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java @@ -23,7 +23,7 @@ public class HBCheckTask { @Resource XhpcDeviceMessageMapper deviceMessageMapper; - @Scheduled(fixedRate = 10000) + //111@Scheduled(fixedRate = 10000) protected void run() { String svcSrvKey = "svcSrvGuns:".concat(getLocalIPAndPort()); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/RateModelTask.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/RateModelTask.java index a213eb98..17e91fa8 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/RateModelTask.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/RateModelTask.java @@ -20,7 +20,7 @@ import static com.xhpc.pp.server.ChargingPileServer.getHandler; @Component public class RateModelTask { - @Scheduled(fixedRate = 10000) + //111@Scheduled(fixedRate = 10000) protected void run() { Collection stationKeys = REDIS.keys("station:*"); diff --git a/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcDeviceMessageMapper.xml b/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcDeviceMessageMapper.xml index 4f1ad811..6f2970f1 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcDeviceMessageMapper.xml +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcDeviceMessageMapper.xml @@ -130,6 +130,8 @@ xcp.equipment_status equipmentStatus, xcp.equipment_purpose equipmentPurpose, xcp.manufacturer_id manufacturerId, + xcp.equipment_classificatlon equipmentClassificatlon, + xcp.aux_power auxPower, date_format(xcs.construction_time,'%Y-%m-%d') as constructionTime from xhpc_charging_pile xcp left join xhpc_charging_station xcs on xcs.charging_station_id = xcp.charging_station_id @@ -147,18 +149,20 @@ ct.capacity as capacity, ct.country_code as countryCcode, CAST(ct.area_code AS CHAR(10)) as areaCode, + ct.area_code_countryside as areaCodeCountryside, ct.address as address, ct.service_tel as serviceTel, ct.station_type as stationType, ct.is_open as isOpen, - ct.country_code as countryCode, ct.station_status as stationStatus, ct.park_nums as parkNums, ROUND(ct.longitude,6) as stationLng, ROUND(ct.latitude,6) as stationLat, ct.construction_site as construction, + ct.swap_match_cars_name as swapMatchCarsName, ct.open_all_day as openAllDay, ct.busine_hours as busineHours, + ct.electricity_fee as electricityFee, ct.service_fee as serviceFee, ct.park_free as parkFree, ct.park_fee as parkFee, @@ -173,9 +177,227 @@ ct.parking_lock_flag as parkingLockFlag, ct.is_demand_response as isDemandResponse, ct.is_support_orderly_charging as isSupportOrderlyCharging, - ct.is_energystorage as isEnergystorage + ct.is_energy_storage as isEnergyStorage, + ct.station_classification as stationClassification, + ct.general_application_type as generalApplicationType, + ct.round_the_clock as roundTheClock, + ct.park_type as parkType, + ct.electncity_type as electncityType, + ct.business_expand_type as businessExpandType, + ct.rated_power as ratedPower, + ct.period_fee as periodFee, + ct.official_run_time as officialRunTime, + ct.video_monitor as videoMonitor from xhpc_charging_station as ct where ct.charging_station_id = #{chargingStationId} and ct.del_flag = 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java index f266520a..bc8c3473 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java @@ -192,11 +192,11 @@ public class XhpcAppUserController extends BaseController { String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + mapConfig.get("wxAppId").toString() + "&secret=" + mapConfig.get("wxAppSecret").toString() + "&js_code=" + jsCode + "&grant_type=authorization_code"; String result = HttpUtils.get(url); JSONObject json = JSON.parseObject(result); - logger.info("========222===========sessionKey:============222==============="); + //logger.info("========222===========sessionKey:============222==============="); if (null != json) { String openid = json.getString("openid"); String sessionKey = json.getString("session_key"); - logger.info("========333===========sessionKey:============333==============="); + //logger.info("========333===========sessionKey:============333==============="); if (StringUtils.isEmpty(openid)) { return R.fail(HttpStatus.ERROR_STATUS, "openid获取失败"); } @@ -243,18 +243,18 @@ public class XhpcAppUserController extends BaseController { } R r = settingConfigService.settingConfig(1, tenantId); if (r != null && r.getCode() == 200) { - System.out.println("========444===========sessionKey:============444==============="); + // System.out.println("========444===========sessionKey:============444==============="); Map mapConfig = (Map) r.getData(); String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + mapConfig.get("wxAppId").toString() + "&secret=" + mapConfig.get("wxAppSecret").toString() + "&js_code=" + jsCode + "&grant_type=authorization_code"; String result = HttpUtils.get(url); JSONObject json = JSON.parseObject(result); - logger.info("========555===========sessionKey:============5555==============="); + //logger.info("========555===========sessionKey:============5555==============="); if (null != json) { String openid = json.getString("openid"); redisService.setCacheObject("WXToken:" + openid, openid, 115L, TimeUnit.MINUTES); String sessionKey = json.getString("session_key"); - logger.info("========666===========sessionKey:============666==============="+sessionKey); - logger.info("========666===========sessionKey:============666==============="); + //logger.info("========666===========sessionKey:============666==============="+sessionKey); + //logger.info("========666===========sessionKey:============666==============="); if (StringUtils.isEmpty(openid)) { return R.fail(HttpStatus.ERROR_STATUS, "openid获取失败"); } @@ -309,13 +309,13 @@ public class XhpcAppUserController extends BaseController { @ApiOperation("小程序获取手机号") @GetMapping("/getPhoneCode") public String getPhoneCode(String code, String token) { - System.out.println("========888===========sessionKey:============888==============="); + //System.out.println("========888===========sessionKey:============888==============="); String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + token; Map map = new HashMap<>(); map.put("code", code); JSONObject json = new JSONObject(map); String result = HttpUtils.post(url, json); - System.out.println("========999===========sessionKey:============999==============="); + //System.out.println("========999===========sessionKey:============999==============="); JSONObject jsonObject = JSON.parseObject(result); String errmsg = jsonObject.getString("errmsg"); if ("ok".equals(errmsg)) {