修复QueryStationsInfo接口的数据来源逻辑
This commit is contained in:
parent
2280e9af5e
commit
3a38623b32
@ -0,0 +1,167 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "et_dispute_orders")
|
||||
@Entity
|
||||
public class EtDisputeOrder {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "start_charge_seq", nullable = false, length = 27)
|
||||
private String startChargeSeq;
|
||||
|
||||
@Column(name = "total_power", nullable = false)
|
||||
private Double totalPower;
|
||||
|
||||
@Column(name = "total_money", nullable = false)
|
||||
private Double totalMoney;
|
||||
|
||||
@Column(name = "dispute_reason", nullable = false)
|
||||
private Integer disputeReason;
|
||||
|
||||
@Column(name = "dispute_order_status", nullable = false)
|
||||
private Integer disputeOrderStatus;
|
||||
|
||||
@Column(name = "check_order_seq", nullable = false, length = 27)
|
||||
private String checkOrderSeq;
|
||||
|
||||
@Column(name = "start_time", nullable = false, length = 30)
|
||||
private String startTime;
|
||||
|
||||
@Column(name = "end_time", nullable = false, length = 30)
|
||||
private String endTime;
|
||||
|
||||
@Column(name = "total_dispute_order", nullable = false)
|
||||
private Integer totalDisputeOrder;
|
||||
|
||||
@Column(name = "total_dispute_power", nullable = false)
|
||||
private Double totalDisputePower;
|
||||
|
||||
@Column(name = "total_dispute_money", nullable = false)
|
||||
private Double totalDisputeMoney;
|
||||
|
||||
public Double getTotalDisputeMoney() {
|
||||
|
||||
return totalDisputeMoney;
|
||||
}
|
||||
|
||||
public void setTotalDisputeMoney(Double totalDisputeMoney) {
|
||||
|
||||
this.totalDisputeMoney = totalDisputeMoney;
|
||||
}
|
||||
|
||||
public Double getTotalDisputePower() {
|
||||
|
||||
return totalDisputePower;
|
||||
}
|
||||
|
||||
public void setTotalDisputePower(Double totalDisputePower) {
|
||||
|
||||
this.totalDisputePower = totalDisputePower;
|
||||
}
|
||||
|
||||
public Integer getTotalDisputeOrder() {
|
||||
|
||||
return totalDisputeOrder;
|
||||
}
|
||||
|
||||
public void setTotalDisputeOrder(Integer totalDisputeOrder) {
|
||||
|
||||
this.totalDisputeOrder = totalDisputeOrder;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getCheckOrderSeq() {
|
||||
|
||||
return checkOrderSeq;
|
||||
}
|
||||
|
||||
public void setCheckOrderSeq(String checkOrderSeq) {
|
||||
|
||||
this.checkOrderSeq = checkOrderSeq;
|
||||
}
|
||||
|
||||
public Integer getDisputeOrderStatus() {
|
||||
|
||||
return disputeOrderStatus;
|
||||
}
|
||||
|
||||
public void setDisputeOrderStatus(Integer disputeOrderStatus) {
|
||||
|
||||
this.disputeOrderStatus = disputeOrderStatus;
|
||||
}
|
||||
|
||||
public Integer getDisputeReason() {
|
||||
|
||||
return disputeReason;
|
||||
}
|
||||
|
||||
public void setDisputeReason(Integer disputeReason) {
|
||||
|
||||
this.disputeReason = disputeReason;
|
||||
}
|
||||
|
||||
public Double getTotalMoney() {
|
||||
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
public void setTotalMoney(Double totalMoney) {
|
||||
|
||||
this.totalMoney = totalMoney;
|
||||
}
|
||||
|
||||
public Double getTotalPower() {
|
||||
|
||||
return totalPower;
|
||||
}
|
||||
|
||||
public void setTotalPower(Double totalPower) {
|
||||
|
||||
this.totalPower = totalPower;
|
||||
}
|
||||
|
||||
public String getStartChargeSeq() {
|
||||
|
||||
return startChargeSeq;
|
||||
}
|
||||
|
||||
public void setStartChargeSeq(String startChargeSeq) {
|
||||
|
||||
this.startChargeSeq = startChargeSeq;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,195 @@
|
||||
package com.xhpc.evcs.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
|
||||
@Table(name = "xhpc_rate")
|
||||
@Entity
|
||||
public class XhpcRate {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "rate_id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "charging_station_id")
|
||||
private Long chargingStationId;
|
||||
|
||||
@Column(name = "power_fee", precision = 10, scale = 5)
|
||||
private BigDecimal powerFee;
|
||||
|
||||
@Column(name = "service_fee", precision = 10, scale = 5)
|
||||
private BigDecimal serviceFee;
|
||||
|
||||
@Column(name = "name", length = 30)
|
||||
private String name;
|
||||
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "del_flag")
|
||||
private Integer delFlag;
|
||||
|
||||
@Column(name = "create_time")
|
||||
private Instant createTime;
|
||||
|
||||
@Column(name = "create_by", length = 30)
|
||||
private String createBy;
|
||||
|
||||
@Column(name = "update_time")
|
||||
private Instant updateTime;
|
||||
|
||||
@Column(name = "update_by", length = 30)
|
||||
private String updateBy;
|
||||
|
||||
@Column(name = "remark")
|
||||
private String remark;
|
||||
|
||||
@Column(name = "rate_model_id")
|
||||
private Long rateModelId;
|
||||
|
||||
@Column(name = "rate_value", length = 20)
|
||||
private String rateValue;
|
||||
|
||||
public String getRateValue() {
|
||||
|
||||
return rateValue;
|
||||
}
|
||||
|
||||
public void setRateValue(String rateValue) {
|
||||
|
||||
this.rateValue = rateValue;
|
||||
}
|
||||
|
||||
public Long getRateModelId() {
|
||||
|
||||
return rateModelId;
|
||||
}
|
||||
|
||||
public void setRateModelId(Long rateModelId) {
|
||||
|
||||
this.rateModelId = rateModelId;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Instant getUpdateTime() {
|
||||
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Instant updateTime) {
|
||||
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Instant getCreateTime() {
|
||||
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Instant createTime) {
|
||||
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public BigDecimal getServiceFee() {
|
||||
|
||||
return serviceFee;
|
||||
}
|
||||
|
||||
public void setServiceFee(BigDecimal serviceFee) {
|
||||
|
||||
this.serviceFee = serviceFee;
|
||||
}
|
||||
|
||||
public BigDecimal getPowerFee() {
|
||||
|
||||
return powerFee;
|
||||
}
|
||||
|
||||
public void setPowerFee(BigDecimal powerFee) {
|
||||
|
||||
this.powerFee = powerFee;
|
||||
}
|
||||
|
||||
public Long getChargingStationId() {
|
||||
|
||||
return chargingStationId;
|
||||
}
|
||||
|
||||
public void setChargingStationId(Long chargingStationId) {
|
||||
|
||||
this.chargingStationId = chargingStationId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,9 +18,9 @@ public class ChargeOrder {
|
||||
@JsonProperty("StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
@JsonProperty("TotalPower")
|
||||
private Integer totalPower;
|
||||
private Double totalPower;
|
||||
@JsonProperty("TotalMoney")
|
||||
private Integer totalMoney;
|
||||
private Double totalMoney;
|
||||
@JsonIgnore
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
@ -37,25 +37,25 @@ public class ChargeOrder {
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public Integer getTotalPower() {
|
||||
public Double getTotalPower() {
|
||||
|
||||
return totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalPower")
|
||||
public void setTotalPower(Integer totalPower) {
|
||||
public void setTotalPower(Double totalPower) {
|
||||
|
||||
this.totalPower = totalPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public Integer getTotalMoney() {
|
||||
public Double getTotalMoney() {
|
||||
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalMoney")
|
||||
public void setTotalMoney(Integer totalMoney) {
|
||||
public void setTotalMoney(Double totalMoney) {
|
||||
|
||||
this.totalMoney = totalMoney;
|
||||
}
|
||||
|
||||
@ -28,9 +28,9 @@ public class CheckChargeOrderRequestData {
|
||||
@JsonProperty("OrderCount")
|
||||
private Integer orderCount;
|
||||
@JsonProperty("TotalOrderPower")
|
||||
private Integer totalOrderPower;
|
||||
private Double totalOrderPower;
|
||||
@JsonProperty("TotalOrderMoney")
|
||||
private Integer totalOrderMoney;
|
||||
private Double totalOrderMoney;
|
||||
@JsonProperty("ChargeOrders")
|
||||
private List<ChargeOrder> chargeOrders = null;
|
||||
@JsonIgnore
|
||||
@ -85,25 +85,25 @@ public class CheckChargeOrderRequestData {
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderPower")
|
||||
public Integer getTotalOrderPower() {
|
||||
public Double getTotalOrderPower() {
|
||||
|
||||
return totalOrderPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderPower")
|
||||
public void setTotalOrderPower(Integer totalOrderPower) {
|
||||
public void setTotalOrderPower(Double totalOrderPower) {
|
||||
|
||||
this.totalOrderPower = totalOrderPower;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderMoney")
|
||||
public Integer getTotalOrderMoney() {
|
||||
public Double getTotalOrderMoney() {
|
||||
|
||||
return totalOrderMoney;
|
||||
}
|
||||
|
||||
@JsonProperty("TotalOrderMoney")
|
||||
public void setTotalOrderMoney(Integer totalOrderMoney) {
|
||||
public void setTotalOrderMoney(Double totalOrderMoney) {
|
||||
|
||||
this.totalOrderMoney = totalOrderMoney;
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ public class CheckChargeOrderController {
|
||||
|
||||
@PostMapping("/v1/check_charge_orders")
|
||||
public CommonResponse check_charge_orders(@RequestBody CommonRequest<CheckChargeOrderRequestData> commonRequest) throws IOException {
|
||||
|
||||
//todo 正在开发
|
||||
String operatorID = commonRequest.getOperatorId();
|
||||
StationInfo stationInfo = new StationInfo();
|
||||
stationInfo.setOperatorId(operatorID);
|
||||
|
||||
@ -4,6 +4,7 @@ import com.xhpc.common.api.ChargingStationPushStatusService;
|
||||
import com.xhpc.common.api.dto.ChargingStationDto;
|
||||
import com.xhpc.common.data.redis.CacheRateModel;
|
||||
import com.xhpc.evcs.domain.XhpcChargingPile;
|
||||
import com.xhpc.evcs.domain.XhpcChargingStation;
|
||||
import com.xhpc.evcs.domain.XhpcStationInternetBlacklist;
|
||||
import com.xhpc.evcs.dto.*;
|
||||
import com.xhpc.evcs.jpa.XhpcChargingPileRepository;
|
||||
@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -41,7 +43,7 @@ public class QueryStationsInfoController {
|
||||
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResponse queryStationsInfo(@RequestBody(required = false) CommonRequest<PageRequest> commonRequest) throws Exception {
|
||||
// todo 电站状态更新逻辑
|
||||
// todo 电站状态更新逻辑,没必要做,全推
|
||||
// chargingStationPushStatusService.editStationStatus();
|
||||
// chargingStationPushStatusService.saveStationStatus();
|
||||
|
||||
@ -99,7 +101,43 @@ public class QueryStationsInfoController {
|
||||
}
|
||||
ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey);
|
||||
StationInfo stationInfo = new StationInfo();
|
||||
stationInfo.setStationId(String.valueOf(chargingStationDto.getStationId()));
|
||||
//站点状态
|
||||
stationInfo.setStationStatus(50);
|
||||
//充电站Id
|
||||
String stationId = stationKey.replace("station:", "");
|
||||
stationInfo.setStationId(stationId);
|
||||
Double lat = chargingStationDto.getLat();
|
||||
if (lat == null) {
|
||||
XhpcChargingStation stationExample = new XhpcChargingStation();
|
||||
stationExample.setId(Long.parseLong(stationId));
|
||||
Example<XhpcChargingStation> example = Example.of(stationExample);
|
||||
XhpcChargingStation xhpcChargingStation =
|
||||
xhpcChargingStationRepository.findOne(example).orElse(null);
|
||||
if (xhpcChargingStation != null) {
|
||||
//纬度
|
||||
chargingStationDto.setLat(new BigDecimal(xhpcChargingStation.getLatitude()).setScale(6,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
//经度
|
||||
chargingStationDto.setLng(new BigDecimal(xhpcChargingStation.getLongitude()).setScale(6,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
//站点类型
|
||||
chargingStationDto.setType(xhpcChargingStation.getType());
|
||||
//运营商id
|
||||
chargingStationDto.setOperatorId(xhpcChargingStation.getOperatorIdEvcs() == null ? "MA6DFCTD5"
|
||||
: xhpcChargingStation.getOperatorIdEvcs());
|
||||
//详细地址
|
||||
chargingStationDto.setAddress(xhpcChargingStation.getAddress());
|
||||
//充电站省直辖区编码
|
||||
chargingStationDto.setAreaCode(xhpcChargingStation.getAreaCode().toString());
|
||||
//充电站名称
|
||||
chargingStationDto.setName(xhpcChargingStation.getName());
|
||||
//服务电话
|
||||
chargingStationDto.setServiceTel(xhpcChargingStation.getServiceTel());
|
||||
//车位数量
|
||||
chargingStationDto.setParkNums(xhpcChargingStation.getParkNums());
|
||||
REDIS.setCacheObject(stationKey, chargingStationDto);
|
||||
}
|
||||
}
|
||||
stationInfo.setOperatorId(chargingStationDto.getOperatorId());
|
||||
stationInfo.setEquipmentOwnerId(chargingStationDto.getOperatorId());
|
||||
stationInfo.setStationName(chargingStationDto.getName());
|
||||
@ -108,7 +146,6 @@ public class QueryStationsInfoController {
|
||||
stationInfo.setAddress(chargingStationDto.getAddress());
|
||||
stationInfo.setServiceTel(chargingStationDto.getServiceTel());
|
||||
stationInfo.setStationType(chargingStationDto.getType());
|
||||
stationInfo.setStationStatus(50);
|
||||
stationInfo.setParkNums(chargingStationDto.getParkNums());
|
||||
stationInfo.setStationLng(chargingStationDto.getLng());
|
||||
stationInfo.setStationLat(chargingStationDto.getLat());
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package com.xhpc.evcs.jpa;
|
||||
|
||||
import com.xhpc.evcs.domain.EtDisputeOrder;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Dao of et_dispute_orders
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/11/8 15:46
|
||||
* @since version-1.0
|
||||
*/
|
||||
@Repository
|
||||
public interface EtDisputeOrdersRepository extends JpaRepository<EtDisputeOrder, Long>,
|
||||
QueryByExampleExecutor<EtDisputeOrder>, JpaSpecificationExecutor<EtDisputeOrder> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.xhpc.evcs.jpa;
|
||||
|
||||
import com.xhpc.evcs.domain.XhpcRate;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Dao of xhpc_rate
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/11/9 10:16
|
||||
* @since version-1.0
|
||||
*/
|
||||
public interface XhpcRateRepository extends JpaRepository<XhpcRate, Long>,
|
||||
QueryByExampleExecutor<XhpcRate>, JpaSpecificationExecutor<XhpcRate> {
|
||||
|
||||
/**
|
||||
* 通过费率模型id获取所有费率
|
||||
*
|
||||
* @param rateModelId
|
||||
* @return 所有费率
|
||||
*/
|
||||
List<XhpcRate> findByRateModelId(Long rateModelId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,185 @@
|
||||
package com.xhpc.evcs.notification;
|
||||
|
||||
import com.xhpc.common.data.redis.CacheOrderData;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.domain.EtDisputeOrder;
|
||||
import com.xhpc.evcs.domain.XhpcRate;
|
||||
import com.xhpc.evcs.dto.ChargeOrder;
|
||||
import com.xhpc.evcs.dto.CheckChargeOrderRequestData;
|
||||
import com.xhpc.evcs.dto.CheckChargeOrderResponseData;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.jpa.EtDisputeOrdersRepository;
|
||||
import com.xhpc.evcs.jpa.XhpcRateRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||
import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT;
|
||||
|
||||
/**
|
||||
* 推送所有充电结束后的订单进行对账
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/11/8 10:06
|
||||
* @since version-1.0
|
||||
*/
|
||||
public class CheckChargeOrders extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private XhpcRateRepository xhpcRateRepository;
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
@Autowired
|
||||
private EtDisputeOrdersRepository etDisputeOrdersRepository;
|
||||
|
||||
public void checkChargeOrder() throws Exception {
|
||||
|
||||
//获取Redis中的所有订单的状态数据
|
||||
Collection<String> pushOrders = REDIS.keys("pushOrder:*");
|
||||
|
||||
for (String pushOrderKey : pushOrders) {
|
||||
Map<String, Object> pushOrder = REDIS.getCacheMap(pushOrderKey);
|
||||
Boolean stopCommandSent = (Boolean) pushOrder.get("stopCommandSent");
|
||||
if (stopCommandSent == null) {
|
||||
continue;
|
||||
}
|
||||
String orderNo = pushOrderKey.substring(10);
|
||||
Map<String, Object> order = REDIS.getCacheMap("order:" + orderNo);
|
||||
String operatorId3rdpty = (String) order.get("operatorId3rdpty"); //todo zz
|
||||
if (operatorId3rdpty == null) {
|
||||
continue;
|
||||
}
|
||||
AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId3rdpty, SECRET_TOKEN_TYPE_OUT).orElse(null);
|
||||
if (authSecretTokenOut == null) {
|
||||
continue;
|
||||
}
|
||||
CommonRequest<CheckChargeOrderRequestData> commonRequest = new CommonRequest<>();
|
||||
//封装数据的实体类
|
||||
CheckChargeOrderRequestData checkChargeOrder = new CheckChargeOrderRequestData();
|
||||
//判断是否是结束了的充电订单
|
||||
if (stopCommandSent) {
|
||||
//订单对账流水号(内部对应的第三方充电订单号)
|
||||
CacheOrderData orderData = (CacheOrderData) order.get("orderData");
|
||||
String internetSerialNumber = (String) pushOrder.get("internetSerialNumber");
|
||||
checkChargeOrder.setCheckOrderSeq(internetSerialNumber);
|
||||
//充电订单号(内部对应的第三方充电订单号)
|
||||
ChargeOrder chargeOrder = new ChargeOrder();
|
||||
chargeOrder.setStartChargeSeq(internetSerialNumber);
|
||||
|
||||
if (orderData != null) {
|
||||
//使用指定包装类封装数据
|
||||
//账单开始时间
|
||||
checkChargeOrder.setStartTime(orderData.getStartTime());
|
||||
//账单结束时间
|
||||
checkChargeOrder.setEndTime(orderData.getEndTime());
|
||||
//订单数量
|
||||
checkChargeOrder.setOrderCount(1);
|
||||
//总电量
|
||||
checkChargeOrder.setTotalOrderPower(Double.parseDouble(orderData.getTotalPowerQuantity().toString()) / 10000);
|
||||
//累计充电量
|
||||
chargeOrder.setTotalPower(Double.parseDouble(orderData.getTotalPowerQuantity().toString()) / 10000);
|
||||
//总金额
|
||||
Map<String, Double> map = getTotalElecMoneyAndTotalServiceMoney(orderNo);
|
||||
Double totalPowerPrice = map.get("totalPowerPrice");
|
||||
Double totalServicePrice = map.get("totalServicePrice");
|
||||
Double sumMoney = totalPowerPrice + totalServicePrice;
|
||||
checkChargeOrder.setTotalOrderMoney(sumMoney);
|
||||
//累计总金额
|
||||
chargeOrder.setTotalMoney(sumMoney);
|
||||
List<ChargeOrder> orderList = new ArrayList<>();
|
||||
orderList.add(chargeOrder);
|
||||
checkChargeOrder.setChargeOrders(orderList);
|
||||
//将其转换为json
|
||||
String jsonData = JSONUtil.toJSONString(checkChargeOrder);
|
||||
commonRequest.setData(jsonData);
|
||||
|
||||
//推送并处理推送结果
|
||||
String result = ok(commonRequest, "/check_charge_orders", authSecretTokenOut, operatorId3rdpty);
|
||||
CheckChargeOrderResponseData checkChargeOrderResponseData = JSONUtil.readParams(result, CheckChargeOrderResponseData.class);
|
||||
if (checkChargeOrderResponseData.getDisputeOrders() == null) {
|
||||
//没有争议订单
|
||||
REDIS.deleteObject(pushOrderKey);
|
||||
}
|
||||
//将争议订单放入数据库
|
||||
EtDisputeOrder etDisputeOrder = JSONUtil.copyProperties(result, EtDisputeOrder.class);
|
||||
etDisputeOrder = etDisputeOrdersRepository.save(etDisputeOrder);
|
||||
if (etDisputeOrder.getId() != null) {
|
||||
REDIS.deleteObject(pushOrderKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Double> getTotalElecMoneyAndTotalServiceMoney(String orderNo) {
|
||||
|
||||
//获取结算后的订单
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("order:" + orderNo);
|
||||
CacheOrderData cacheOrderData = (CacheOrderData) cacheMap.get("orderData");
|
||||
//总金额
|
||||
BigDecimal bigDecimal = new BigDecimal(10000);
|
||||
BigDecimal money = new BigDecimal(cacheOrderData.getCost()).divide(bigDecimal);
|
||||
//00: 尖费率 01: 峰费率 02: 平费率 03: 谷费率
|
||||
BigDecimal t1powerFee = new BigDecimal(0);
|
||||
BigDecimal t2powerFee = new BigDecimal(0);
|
||||
BigDecimal t3powerFee = new BigDecimal(0);
|
||||
BigDecimal t4powerFee = new BigDecimal(0);
|
||||
//费率计费模型
|
||||
Long rateModelId = (Long) cacheMap.get("rateModelId");
|
||||
List<XhpcRate> rateModelList = xhpcRateRepository.findByRateModelId(rateModelId);
|
||||
for (XhpcRate xhpcRate : rateModelList) {
|
||||
if ("00".equals(xhpcRate.getRateValue())) {
|
||||
t1powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
if ("01".equals(xhpcRate.getRateValue())) {
|
||||
t2powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
if ("02".equals(xhpcRate.getRateValue())) {
|
||||
t3powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
if ("03".equals(xhpcRate.getRateValue())) {
|
||||
t4powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
}
|
||||
//总电费
|
||||
BigDecimal powerPrice = new BigDecimal(0);
|
||||
Integer totalPower = 0;
|
||||
if (!"0".equals(cacheOrderData.getT1PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT1PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT2PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT2PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT3PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT3PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT4PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT4PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
powerPrice = powerPrice.setScale(2, BigDecimal.ROUND_DOWN);
|
||||
//总服务费
|
||||
BigDecimal servicePrice = money.subtract(powerPrice);
|
||||
|
||||
HashMap<String, Double> data = new HashMap<>(7);
|
||||
data.put("totalPowerPrice", servicePrice.doubleValue());
|
||||
data.put("totalServicePrice", servicePrice.doubleValue());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,8 +8,6 @@ import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.DTOJsonHelper;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -30,7 +28,7 @@ public class NotificationCancelOrderTask extends CoreDispatcher {
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
|
||||
//private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 15)
|
||||
public void run() throws JsonProcessingException {
|
||||
@ -80,7 +78,7 @@ public class NotificationCancelOrderTask extends CoreDispatcher {
|
||||
|
||||
String operatorIdEvcs = "MA6DFCTD5";
|
||||
String data = JSONUtil.toJSONString(cancelOrderRequest);
|
||||
logger.debug(data);
|
||||
//logger.debug(data);
|
||||
CommonRequest<CancelOrderRequest> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId(operatorIdEvcs);
|
||||
commonRequest.setData(data);
|
||||
|
||||
@ -0,0 +1,178 @@
|
||||
package com.xhpc.evcs.notification;
|
||||
|
||||
import com.xhpc.common.data.redis.CacheOrderData;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.domain.XhpcRate;
|
||||
import com.xhpc.evcs.dto.ChargeOrderInfo;
|
||||
import com.xhpc.evcs.dto.ChargeOrderInfoResponse;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.jpa.XhpcRateRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
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 WH
|
||||
* @date 2021/11/7 14:39
|
||||
* @since version-1.0
|
||||
*/
|
||||
public class NotificationChargeOrderInfo extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
|
||||
@Autowired
|
||||
private XhpcRateRepository xhpcRateRepository;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public void pushChargeOrderInfo() throws IOException {
|
||||
|
||||
//获取Redis中的所有订单的状态数据
|
||||
Collection<String> pushOrders = REDIS.keys("pushOrder:*");
|
||||
|
||||
for (String pushOrderKey : pushOrders) {
|
||||
Map<String, Object> pushOrder = REDIS.getCacheMap(pushOrderKey);
|
||||
Boolean stopCommandSent = (Boolean) pushOrder.get("stopCommandSent");
|
||||
if (stopCommandSent == null) {
|
||||
continue;
|
||||
}
|
||||
String orderNo = pushOrderKey.substring(10);
|
||||
Map<String, Object> order = REDIS.getCacheMap("order:" + orderNo);
|
||||
String operatorId3rdpty = (String) order.get("operatorId3rdpty"); //todo zz
|
||||
if (operatorId3rdpty == null) {
|
||||
continue;
|
||||
}
|
||||
AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId3rdpty, SECRET_TOKEN_TYPE_OUT).orElse(null);
|
||||
if (authSecretTokenOut == null) {
|
||||
continue;
|
||||
}
|
||||
CommonRequest<ChargeOrderInfo> commonRequest = new CommonRequest<>();
|
||||
//封装数据的实体类
|
||||
ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo();
|
||||
//判断是否是结束了的充电订单
|
||||
if (stopCommandSent) {
|
||||
//充电订单号(内部对应的第三方充电订单号)
|
||||
CacheOrderData orderData = (CacheOrderData) order.get("orderData");
|
||||
String internetSerialNumber = (String) pushOrder.get("internetSerialNumber");
|
||||
chargeOrderInfo.setStartChargeSeq(internetSerialNumber);
|
||||
if (orderData != null) {
|
||||
//使用指定包装类封装数据
|
||||
//充电设备接口编码
|
||||
chargeOrderInfo.setConnectorID(orderData.getPileNo() + orderData.getGunId());
|
||||
//开始充电时间
|
||||
chargeOrderInfo.setStartTime(orderData.getStartTime());
|
||||
//结束充电时间
|
||||
chargeOrderInfo.setEndTime(orderData.getEndTime());
|
||||
//累计充电量
|
||||
chargeOrderInfo.setTotalPower(Double.parseDouble(orderData.getTotalPowerQuantity().toString()) / 10000);
|
||||
//总电费
|
||||
Map<String, Double> map = getTotalElecMoneyAndTotalServiceMoney(orderNo);
|
||||
Double totalPowerPrice = map.get("totalPowerPrice");
|
||||
chargeOrderInfo.setTotalPower(totalPowerPrice);
|
||||
//总服务费
|
||||
Double totalServicePrice = map.get("totalServicePrice");
|
||||
chargeOrderInfo.setTotalSeviceMoney(totalServicePrice);
|
||||
//累计总金额
|
||||
Double sumMoney = totalPowerPrice + totalServicePrice;
|
||||
chargeOrderInfo.setTotalMoney(sumMoney);
|
||||
//充电结束原因
|
||||
chargeOrderInfo.setStopReason(0);
|
||||
|
||||
//将其转换为json
|
||||
String jsonData = JSONUtil.toJSONString(chargeOrderInfo);
|
||||
commonRequest.setData(jsonData);
|
||||
String result = ok(commonRequest, "/notification_charge_order_info", authSecretTokenOut, operatorId3rdpty);
|
||||
|
||||
ChargeOrderInfoResponse chargeOrderInfoResponse = JSONUtil.readParams(result, ChargeOrderInfoResponse.class);
|
||||
Integer confirmResult = chargeOrderInfoResponse.getConfirmResult();
|
||||
//无视争议订单,对结果不进行处理,在下面的推送中在进行处理
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Double> getTotalElecMoneyAndTotalServiceMoney(String orderNo) {
|
||||
|
||||
//获取结算后的订单
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("order:" + orderNo);
|
||||
CacheOrderData cacheOrderData = (CacheOrderData) cacheMap.get("orderData");
|
||||
//总金额
|
||||
BigDecimal bigDecimal = new BigDecimal(10000);
|
||||
BigDecimal money = new BigDecimal(cacheOrderData.getCost()).divide(bigDecimal);
|
||||
//00: 尖费率 01: 峰费率 02: 平费率 03: 谷费率
|
||||
BigDecimal t1powerFee = new BigDecimal(0);
|
||||
BigDecimal t2powerFee = new BigDecimal(0);
|
||||
BigDecimal t3powerFee = new BigDecimal(0);
|
||||
BigDecimal t4powerFee = new BigDecimal(0);
|
||||
//费率计费模型
|
||||
Long rateModelId = (Long) cacheMap.get("rateModelId");
|
||||
List<XhpcRate> rateModelList = xhpcRateRepository.findByRateModelId(rateModelId);
|
||||
for (XhpcRate xhpcRate : rateModelList) {
|
||||
if ("00".equals(xhpcRate.getRateValue())) {
|
||||
t1powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
if ("01".equals(xhpcRate.getRateValue())) {
|
||||
t2powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
if ("02".equals(xhpcRate.getRateValue())) {
|
||||
t3powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
if ("03".equals(xhpcRate.getRateValue())) {
|
||||
t4powerFee = xhpcRate.getPowerFee();
|
||||
}
|
||||
}
|
||||
//总电费
|
||||
BigDecimal powerPrice = new BigDecimal(0);
|
||||
Integer totalPower = 0;
|
||||
if (!"0".equals(cacheOrderData.getT1PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT1PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT2PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT2PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT3PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT3PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT4PowerQuantity().toString())) {
|
||||
BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee);
|
||||
totalPower = totalPower + cacheOrderData.getT4PowerQuantity();
|
||||
powerPrice = powerPrice.add(multiply);
|
||||
}
|
||||
powerPrice = powerPrice.setScale(2, BigDecimal.ROUND_DOWN);
|
||||
//总服务费
|
||||
BigDecimal servicePrice = money.subtract(powerPrice);
|
||||
|
||||
HashMap<String, Double> data = new HashMap<>(7);
|
||||
data.put("totalPowerPrice", servicePrice.doubleValue());
|
||||
data.put("totalServicePrice", servicePrice.doubleValue());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,157 +1,157 @@
|
||||
package com.xhpc.evcs.notification;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.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.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
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 HongYun on 2021/11/1
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class NotificationChargeOrderInfoTask extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private XhpcHistoryOrderRepository xhpcHistoryOrderRepository;
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 60)
|
||||
public void run() throws IOException {
|
||||
|
||||
//Getting the internetSerialNumbers to load the requestData.
|
||||
Collection<String> pushOrders = REDIS.keys("pushOrder:*");
|
||||
List<String> internetSerialNumbers = new ArrayList<>();
|
||||
List<String> connectorIdMap = new ArrayList<>();
|
||||
List<String> orderNos = new ArrayList<>();
|
||||
for (String pushOrder : pushOrders) {
|
||||
Integer chargeOrderInfoNotificationStat = REDIS.getCacheMapValue(pushOrder, "chargeOrderInfoNotificationStat");
|
||||
|
||||
if (0 == chargeOrderInfoNotificationStat) {
|
||||
internetSerialNumbers.add(REDIS.getCacheMapValue(pushOrder, "internetSerialNumber"));
|
||||
connectorIdMap.add(REDIS.getCacheMapValue(pushOrder, "connectorID"));
|
||||
orderNos.add(pushOrder);
|
||||
}
|
||||
}
|
||||
|
||||
//Ensuring that the connectorId is following the handling of the data, which named interSerialNumber.
|
||||
int times = 0;
|
||||
//Loading the requestData, and also notifying.
|
||||
for (String internetSerialNumber : internetSerialNumbers) {
|
||||
String connector = connectorIdMap.get(times);
|
||||
String orderNo = orderNos.get(times);
|
||||
++times;
|
||||
String operatorId = internetSerialNumber.substring(0, 9);
|
||||
AuthSecretToken authSecretToken = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId, SECRET_TOKEN_TYPE_OUT).orElse(null);
|
||||
if (null != authSecretToken) {
|
||||
XhpcHistoryOrder xhpcHistoryOrder = xhpcHistoryOrderRepository.findByInternetSerialNumber(internetSerialNumber).orElse(null);
|
||||
if (null != xhpcHistoryOrder) {
|
||||
ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo();
|
||||
if (null != xhpcHistoryOrder.getInternetSerialNumber()) {
|
||||
chargeOrderInfo.setStartChargeSeq(xhpcHistoryOrder.getInternetSerialNumber());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
//The connector is absolutely exists.
|
||||
chargeOrderInfo.setConnectorID(connector);
|
||||
|
||||
Date startTime = xhpcHistoryOrder.getStartTime();
|
||||
if (null == startTime) {
|
||||
continue;
|
||||
}
|
||||
String formatStartTime = DateUtil.format(startTime, "yyyy-MM-dd HH: mm: ss");
|
||||
chargeOrderInfo.setStartTime(formatStartTime);
|
||||
|
||||
Date endTime = xhpcHistoryOrder.getEndTime();
|
||||
if (null == endTime) continue;
|
||||
String formatEndTime = DateUtil.format(endTime, "yyyy-MM-dd HH: mm: ss");
|
||||
chargeOrderInfo.setEndTime(formatEndTime);
|
||||
|
||||
if (null != xhpcHistoryOrder.getTotalPower()) {
|
||||
chargeOrderInfo.setTotalPower(xhpcHistoryOrder.getTotalPower());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null != xhpcHistoryOrder.getActPowerPrice()) {
|
||||
chargeOrderInfo.setTotalElecMoney(xhpcHistoryOrder.getActPowerPrice().doubleValue());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null != xhpcHistoryOrder.getServicePriceTotal()) {
|
||||
chargeOrderInfo.setTotalSeviceMoney(xhpcHistoryOrder.getServicePriceTotal().doubleValue());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null != xhpcHistoryOrder.getTotalPrice()) {
|
||||
chargeOrderInfo.setTotalMoney(xhpcHistoryOrder.getTotalPrice().doubleValue());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null != xhpcHistoryOrder.getStopReasonEvcs()) {
|
||||
chargeOrderInfo.setStopReason(xhpcHistoryOrder.getStopReasonEvcs());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
notify(chargeOrderInfo, authSecretToken, orderNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void notify(ChargeOrderInfo chargeOrderInfo, AuthSecretToken authSecretTokenOut, String orderNo) throws JsonProcessingException {
|
||||
|
||||
String operatorIdEvcs = "MA6DFCTD5";
|
||||
String data = JSONUtil.toJSONString(chargeOrderInfo);
|
||||
logger.debug(data);
|
||||
CommonRequest<ChargeOrderInfo> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId(operatorIdEvcs);
|
||||
commonRequest.setData(data);
|
||||
String responseBody = ok(commonRequest, "/notification_charge_order_info", authSecretTokenOut, operatorIdEvcs);
|
||||
ChargeOrderInfoResponse chargeOrderInfoResponse = DTOJsonHelper.parseResponseData(responseBody,
|
||||
ChargeOrderInfoResponse.class, authSecretTokenOut);
|
||||
if (null != chargeOrderInfoResponse) {
|
||||
Integer confirmResult = chargeOrderInfoResponse.getConfirmResult();
|
||||
XhpcHistoryOrder horder = xhpcHistoryOrderRepository.findByInternetSerialNumber(chargeOrderInfo.getStartChargeSeq()).orElse(null);
|
||||
if (horder != null) {
|
||||
horder.setConfirmResult(confirmResult);
|
||||
xhpcHistoryOrderRepository.save(horder);
|
||||
}
|
||||
//O means that the response is success.
|
||||
if (confirmResult == 0) {
|
||||
REDIS.setCacheMapValue(orderNo, "chargeOrderInfoNotificationStat", -1);
|
||||
} else {
|
||||
throw new RuntimeException(String.format("push CD start order status [%s] failed: %s",
|
||||
chargeOrderInfoResponse.getStartChargeSeq(), responseBody));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.xhpc.evcs.notification;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//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.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.io.IOException;
|
||||
//import java.util.ArrayList;
|
||||
//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 HongYun on 2021/11/1
|
||||
// */
|
||||
//
|
||||
//@Component
|
||||
//public class NotificationChargeOrderInfoTask extends CoreDispatcher {
|
||||
//
|
||||
// @Autowired
|
||||
// private XhpcHistoryOrderRepository xhpcHistoryOrderRepository;
|
||||
// @Autowired
|
||||
// private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
//
|
||||
// private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
|
||||
//
|
||||
// @Scheduled(fixedRate = 1000 * 60)
|
||||
// public void run() throws IOException {
|
||||
//
|
||||
// //Getting the internetSerialNumbers to load the requestData.
|
||||
// Collection<String> pushOrders = REDIS.keys("pushOrder:*");
|
||||
// List<String> internetSerialNumbers = new ArrayList<>();
|
||||
// List<String> connectorIdMap = new ArrayList<>();
|
||||
// List<String> orderNos = new ArrayList<>();
|
||||
// for (String pushOrder : pushOrders) {
|
||||
// Integer chargeOrderInfoNotificationStat = REDIS.getCacheMapValue(pushOrder, "chargeOrderInfoNotificationStat");
|
||||
//
|
||||
// if (0 == chargeOrderInfoNotificationStat) {
|
||||
// internetSerialNumbers.add(REDIS.getCacheMapValue(pushOrder, "internetSerialNumber"));
|
||||
// connectorIdMap.add(REDIS.getCacheMapValue(pushOrder, "connectorID"));
|
||||
// orderNos.add(pushOrder);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //Ensuring that the connectorId is following the handling of the data, which named interSerialNumber.
|
||||
// int times = 0;
|
||||
// //Loading the requestData, and also notifying.
|
||||
// for (String internetSerialNumber : internetSerialNumbers) {
|
||||
// String connector = connectorIdMap.get(times);
|
||||
// String orderNo = orderNos.get(times);
|
||||
// ++times;
|
||||
// String operatorId = internetSerialNumber.substring(0, 9);
|
||||
// AuthSecretToken authSecretToken = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId, SECRET_TOKEN_TYPE_OUT).orElse(null);
|
||||
// if (null != authSecretToken) {
|
||||
// XhpcHistoryOrder xhpcHistoryOrder = xhpcHistoryOrderRepository.findByInternetSerialNumber(internetSerialNumber).orElse(null);
|
||||
// if (null != xhpcHistoryOrder) {
|
||||
// ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo();
|
||||
// if (null != xhpcHistoryOrder.getInternetSerialNumber()) {
|
||||
// chargeOrderInfo.setStartChargeSeq(xhpcHistoryOrder.getInternetSerialNumber());
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// //The connector is absolutely exists.
|
||||
// chargeOrderInfo.setConnectorID(connector);
|
||||
//
|
||||
// Date startTime = xhpcHistoryOrder.getStartTime();
|
||||
// if (null == startTime) {
|
||||
// continue;
|
||||
// }
|
||||
// String formatStartTime = DateUtil.format(startTime, "yyyy-MM-dd HH: mm: ss");
|
||||
// chargeOrderInfo.setStartTime(formatStartTime);
|
||||
//
|
||||
// Date endTime = xhpcHistoryOrder.getEndTime();
|
||||
// if (null == endTime) continue;
|
||||
// String formatEndTime = DateUtil.format(endTime, "yyyy-MM-dd HH: mm: ss");
|
||||
// chargeOrderInfo.setEndTime(formatEndTime);
|
||||
//
|
||||
// if (null != xhpcHistoryOrder.getTotalPower()) {
|
||||
// chargeOrderInfo.setTotalPower(xhpcHistoryOrder.getTotalPower());
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (null != xhpcHistoryOrder.getActPowerPrice()) {
|
||||
// chargeOrderInfo.setTotalElecMoney(xhpcHistoryOrder.getActPowerPrice().doubleValue());
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (null != xhpcHistoryOrder.getServicePriceTotal()) {
|
||||
// chargeOrderInfo.setTotalSeviceMoney(xhpcHistoryOrder.getServicePriceTotal().doubleValue());
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (null != xhpcHistoryOrder.getTotalPrice()) {
|
||||
// chargeOrderInfo.setTotalMoney(xhpcHistoryOrder.getTotalPrice().doubleValue());
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (null != xhpcHistoryOrder.getStopReasonEvcs()) {
|
||||
// chargeOrderInfo.setStopReason(xhpcHistoryOrder.getStopReasonEvcs());
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
// notify(chargeOrderInfo, authSecretToken, orderNo);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void notify(ChargeOrderInfo chargeOrderInfo, AuthSecretToken authSecretTokenOut, String orderNo) throws JsonProcessingException {
|
||||
//
|
||||
// String operatorIdEvcs = "MA6DFCTD5";
|
||||
// String data = JSONUtil.toJSONString(chargeOrderInfo);
|
||||
// logger.debug(data);
|
||||
// CommonRequest<ChargeOrderInfo> commonRequest = new CommonRequest<>();
|
||||
// commonRequest.setOperatorId(operatorIdEvcs);
|
||||
// commonRequest.setData(data);
|
||||
// String responseBody = ok(commonRequest, "/notification_charge_order_info", authSecretTokenOut, operatorIdEvcs);
|
||||
// ChargeOrderInfoResponse chargeOrderInfoResponse = DTOJsonHelper.parseResponseData(responseBody,
|
||||
// ChargeOrderInfoResponse.class, authSecretTokenOut);
|
||||
// if (null != chargeOrderInfoResponse) {
|
||||
// Integer confirmResult = chargeOrderInfoResponse.getConfirmResult();
|
||||
// XhpcHistoryOrder horder = xhpcHistoryOrderRepository.findByInternetSerialNumber(chargeOrderInfo.getStartChargeSeq()).orElse(null);
|
||||
// if (horder != null) {
|
||||
// horder.setConfirmResult(confirmResult);
|
||||
// xhpcHistoryOrderRepository.save(horder);
|
||||
// }
|
||||
// //O means that the response is success.
|
||||
// if (confirmResult == 0) {
|
||||
// REDIS.setCacheMapValue(orderNo, "chargeOrderInfoNotificationStat", -1);
|
||||
// } else {
|
||||
// throw new RuntimeException(String.format("push CD start order status [%s] failed: %s",
|
||||
// chargeOrderInfoResponse.getStartChargeSeq(), responseBody));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user