WIP:三方对接逻辑
This commit is contained in:
parent
69c0825b7b
commit
21ffb9ffee
@ -89,7 +89,7 @@ public class CDChargeOrderInfo4BonusReq {
|
|||||||
|
|
||||||
this.startChargeSeq = etOrderMapping.getEvcsOrderNo();
|
this.startChargeSeq = etOrderMapping.getEvcsOrderNo();
|
||||||
this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16);
|
this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16);
|
||||||
this.endTime = DateUtil.date2String(xhpcHistoryOrder.getCreateTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
this.endTime = DateUtil.date2String(xhpcHistoryOrder.getEndTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
||||||
this.startTime = DateUtil.date2String(xhpcHistoryOrder.getStartTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
this.startTime = DateUtil.date2String(xhpcHistoryOrder.getStartTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
||||||
this.chargeModel = xhpcHistoryOrder.getChargeModelEvcs();
|
this.chargeModel = xhpcHistoryOrder.getChargeModelEvcs();
|
||||||
this.totalPower = xhpcHistoryOrder.getTotalPower();
|
this.totalPower = xhpcHistoryOrder.getTotalPower();
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package com.xhpc.evcs.dto;
|
package com.xhpc.evcs.dto;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import com.xhpc.evcs.domain.XhpcStatisticsTimeInterval;
|
||||||
|
import com.xhpc.evcs.utils.DateUtil;
|
||||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -9,8 +11,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
//@JsonInclude(JsonInclude.Include.NON_NULL)
|
//@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@JsonPropertyOrder({
|
@JsonPropertyOrder({
|
||||||
@ -23,7 +24,8 @@ import java.util.Map;
|
|||||||
"TotalSeviceMoney",
|
"TotalSeviceMoney",
|
||||||
"TotalMoney",
|
"TotalMoney",
|
||||||
"StopReason",
|
"StopReason",
|
||||||
"SumPeriod"
|
"SumPeriod",
|
||||||
|
"ChargeDetails"
|
||||||
})
|
})
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@ -77,7 +79,37 @@ public class ChargeOrderInfo {
|
|||||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||||
|
|
||||||
public ChargeOrderInfo(XhpcHistoryOrder xhpcHistoryOrder) {
|
public ChargeOrderInfo(XhpcHistoryOrder xhpcHistoryOrder) {
|
||||||
// this.connectorID = xhpcHistoryOrder.getTerminalId()
|
|
||||||
|
this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16);
|
||||||
|
this.startChargeSeq = xhpcHistoryOrder.getInternetSerialNumber();
|
||||||
|
this.endTime = DateUtil.date2StringDt(xhpcHistoryOrder.getEndTime());
|
||||||
|
this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16);
|
||||||
|
this.endTime = DateUtil.date2String(xhpcHistoryOrder.getEndTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
||||||
|
this.startTime = DateUtil.date2String(xhpcHistoryOrder.getStartTime(), DateUtil.DATE_FORMAT_DATE_TIME);
|
||||||
|
this.chargeModel = xhpcHistoryOrder.getChargeModelEvcs();
|
||||||
|
this.totalPower = xhpcHistoryOrder.getTotalPower();
|
||||||
|
this.totalElecMoney = xhpcHistoryOrder.getTotalPrice().doubleValue();
|
||||||
|
this.totalSeviceMoney = xhpcHistoryOrder.getServicePriceTotal().doubleValue();
|
||||||
|
this.totalMoney = xhpcHistoryOrder.getTotalPrice().doubleValue();
|
||||||
|
this.stopReason = xhpcHistoryOrder.getStopReasonEvcs();
|
||||||
|
this.sumPeriod = xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList().size();
|
||||||
|
this.chargeDetails = translate(xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList());
|
||||||
|
Date starttime = xhpcHistoryOrder.getStartTime();
|
||||||
|
Date endtime = xhpcHistoryOrder.getEndTime();
|
||||||
|
int cl = 0;
|
||||||
|
if (starttime != null && endtime != null) {
|
||||||
|
cl = Math.toIntExact((endtime.getTime() - starttime.getTime()) / 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChargeDetails[] translate(List<XhpcStatisticsTimeInterval> xhpcStatisticsTimeIntervalList) {
|
||||||
|
|
||||||
|
List<ChargeDetails> details = new LinkedList<>();
|
||||||
|
for (XhpcStatisticsTimeInterval statistics : xhpcStatisticsTimeIntervalList) {
|
||||||
|
details.add(new ChargeDetails(statistics));
|
||||||
|
}
|
||||||
|
ChargeDetails[] a = new ChargeDetails[details.size()];
|
||||||
|
return details.toArray(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChargeOrderInfo() {
|
public ChargeOrderInfo() {
|
||||||
|
|||||||
@ -76,6 +76,11 @@ public class DateUtil {
|
|||||||
return date2String(date, DEFAULT_DATE_FORMAT);
|
return date2String(date, DEFAULT_DATE_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String date2StringDt(Date date) {
|
||||||
|
|
||||||
|
return date2String(date, DATE_FORMAT_DATE_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert date to string, and the format is same to SimpleDateFormat for
|
* convert date to string, and the format is same to SimpleDateFormat for
|
||||||
* example "yyyyMMdd" "yyyy-MM-dd HH:mm" etc please see
|
* example "yyyyMMdd" "yyyy-MM-dd HH:mm" etc please see
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface XhpcHistoryOrderRepository extends JpaRepository<XhpcHistoryOrder, Long>,
|
public interface XhpcHistoryOrderRepository extends JpaRepository<XhpcHistoryOrder, Long>,
|
||||||
@ -15,5 +14,6 @@ public interface XhpcHistoryOrderRepository extends JpaRepository<XhpcHistoryOrd
|
|||||||
|
|
||||||
List<XhpcHistoryOrder> findByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(Long hisOrderId, int i);
|
List<XhpcHistoryOrder> findByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(Long hisOrderId, int i);
|
||||||
|
|
||||||
Optional<XhpcHistoryOrder> findByInternetSerialNumber(String startChargeSeq);
|
List<XhpcHistoryOrder> findByConfirmResultNotAndOperatorId3rdptyEvcsIsNotNull(int succCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import static com.xhpc.evcs.config.EvcsFilter.encryptReqOut;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class CoreDispatcher {
|
public class CoreDispatcher {
|
||||||
|
|
||||||
@Value("${xhpc.evcs.oklog:true}")
|
@Value("${xhpc.evcs.oklog:false}")
|
||||||
private boolean oklog;
|
private boolean oklog;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||||
@ -46,6 +46,10 @@ public class CoreDispatcher {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public String ok(Object object, String url, AuthSecretToken authSecretTokenOut, String operatorID) {
|
public String ok(Object object, String url, AuthSecretToken authSecretTokenOut, String operatorID) {
|
||||||
|
|
||||||
|
if (authSecretTokenOut == null) {
|
||||||
|
log.error("authSecretTokenOut is null");
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
okhttp3.RequestBody body = null;
|
okhttp3.RequestBody body = null;
|
||||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||||
if (oklog) {
|
if (oklog) {
|
||||||
@ -58,10 +62,6 @@ public class CoreDispatcher {
|
|||||||
.writeTimeout(10, TimeUnit.SECONDS);
|
.writeTimeout(10, TimeUnit.SECONDS);
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
String bearerToken = null;
|
String bearerToken = null;
|
||||||
if (authSecretTokenOut == null) {
|
|
||||||
String error = String.format("secret/token not found for [%s/%s](opId3pt/opId)", authSecretTokenOut.getOperatorId3irdpty(), operatorID);
|
|
||||||
throw new RuntimeException(error);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
if (object.getClass().getSimpleName().equals("CommonRequest")) {
|
if (object.getClass().getSimpleName().equals("CommonRequest")) {
|
||||||
CommonRequest commonRequest = (CommonRequest) object;
|
CommonRequest commonRequest = (CommonRequest) object;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
|
|||||||
private XhpcChargingStationRepository chargingStationRepo;
|
private XhpcChargingStationRepository chargingStationRepo;
|
||||||
private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfo4BonusTask.class);
|
private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfo4BonusTask.class);
|
||||||
|
|
||||||
@Scheduled(fixedRate = 1000 * 60)
|
@Scheduled(fixedDelay = 1000 * 60)
|
||||||
public void run() throws IOException {
|
public void run() throws IOException {
|
||||||
|
|
||||||
AuthSecretToken authSecretTokenOut =
|
AuthSecretToken authSecretTokenOut =
|
||||||
|
|||||||
@ -1,157 +1,66 @@
|
|||||||
//package com.xhpc.evcs.notification;
|
package com.xhpc.evcs.notification;
|
||||||
//
|
|
||||||
//import cn.hutool.core.date.DateUtil;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
//import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||||
//import com.xhpc.evcs.domain.AuthSecretToken;
|
import com.xhpc.evcs.dto.ChargeOrderInfo;
|
||||||
//import com.xhpc.evcs.dto.ChargeOrderInfo;
|
import com.xhpc.evcs.dto.ChargeOrderInfoResponse;
|
||||||
//import com.xhpc.evcs.dto.ChargeOrderInfoResponse;
|
import com.xhpc.evcs.dto.CommonRequest;
|
||||||
//import com.xhpc.evcs.dto.CommonRequest;
|
import com.xhpc.evcs.dto.DTOJsonHelper;
|
||||||
//import com.xhpc.evcs.dto.DTOJsonHelper;
|
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||||
//import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository;
|
||||||
//import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository;
|
import com.xhpc.evcs.utils.JSONUtil;
|
||||||
//import com.xhpc.evcs.utils.JSONUtil;
|
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||||
//import com.xhpc.order.domain.XhpcHistoryOrder;
|
import org.slf4j.Logger;
|
||||||
//import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
||||||
//import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
//import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
import java.util.List;
|
||||||
//import java.io.IOException;
|
|
||||||
//import java.util.ArrayList;
|
/**
|
||||||
//import java.util.Collection;
|
* @Author HongYun on 2021/11/1
|
||||||
//import java.util.Date;
|
*/
|
||||||
//import java.util.List;
|
@Component
|
||||||
//
|
public class NotificationChargeOrderInfoTask extends CoreDispatcher {
|
||||||
//import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
|
||||||
//import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT;
|
@Autowired
|
||||||
//
|
private XhpcHistoryOrderRepository xhpcHistoryOrderRepository;
|
||||||
///**
|
@Autowired
|
||||||
// * @Author HongYun on 2021/11/1
|
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||||
// */
|
|
||||||
//
|
private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
|
||||||
//@Component
|
|
||||||
//public class NotificationChargeOrderInfoTask extends CoreDispatcher {
|
@Scheduled(fixedRate = 1000 * 15)
|
||||||
//
|
public void run() throws JsonProcessingException {
|
||||||
// @Autowired
|
|
||||||
// private XhpcHistoryOrderRepository xhpcHistoryOrderRepository;
|
List<AuthSecretToken> authSecretTokenList = authSecretTokenRepository.findAll();
|
||||||
// @Autowired
|
List<XhpcHistoryOrder> xhpcHistoryOrderList =
|
||||||
// private AuthSecretTokenRepository authSecretTokenRepository;
|
xhpcHistoryOrderRepository.findByConfirmResultNotAndOperatorId3rdptyEvcsIsNotNull(0);
|
||||||
//
|
for (XhpcHistoryOrder horder : xhpcHistoryOrderList) {
|
||||||
// private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
|
|
||||||
//
|
for (AuthSecretToken authSecretToken : authSecretTokenList) {
|
||||||
// @Scheduled(fixedRate = 1000 * 60)
|
if (authSecretToken.getOperatorId3irdpty().equals(horder.getOperatorId3rdptyEvcs())) {
|
||||||
// public void run() throws IOException {
|
ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo(horder);
|
||||||
//
|
final ChargeOrderInfoResponse pushResp = notify(chargeOrderInfo, authSecretToken);
|
||||||
// //Getting the internetSerialNumbers to load the requestData.
|
horder.setConfirmResult(pushResp.getConfirmResult());
|
||||||
// Collection<String> pushOrders = REDIS.keys("pushOrder:*");
|
logger.info("3rd part order {} push result: {}", horder.getSerialNumber(), pushResp.getConfirmResult());
|
||||||
// List<String> internetSerialNumbers = new ArrayList<>();
|
// xhpcHistoryOrderRepository.save(horder);
|
||||||
// List<String> connectorIdMap = new ArrayList<>();
|
}
|
||||||
// List<String> orderNos = new ArrayList<>();
|
}
|
||||||
// for (String pushOrder : pushOrders) {
|
}
|
||||||
// Integer chargeOrderInfoNotificationStat = REDIS.getCacheMapValue(pushOrder, "chargeOrderInfoNotificationStat");
|
}
|
||||||
//
|
|
||||||
// if (0 == chargeOrderInfoNotificationStat) {
|
public ChargeOrderInfoResponse notify(ChargeOrderInfo chargeOrderInfo, AuthSecretToken authSecretTokenOut) throws JsonProcessingException {
|
||||||
// internetSerialNumbers.add(REDIS.getCacheMapValue(pushOrder, "internetSerialNumber"));
|
|
||||||
// connectorIdMap.add(REDIS.getCacheMapValue(pushOrder, "connectorID"));
|
String operatorIdEvcs = "MA6DFCTD5";
|
||||||
// orderNos.add(pushOrder);
|
String data = JSONUtil.toJSONString(chargeOrderInfo);
|
||||||
// }
|
CommonRequest<ChargeOrderInfo> commonRequest = new CommonRequest<>();
|
||||||
// }
|
commonRequest.setOperatorId(operatorIdEvcs);
|
||||||
//
|
commonRequest.setData(data);
|
||||||
// //Ensuring that the connectorId is following the handling of the data, which named interSerialNumber.
|
String responseBody = ok(commonRequest, "/notification_charge_order_info", authSecretTokenOut, operatorIdEvcs);
|
||||||
// int times = 0;
|
return DTOJsonHelper.parseResponseData(responseBody,
|
||||||
// //Loading the requestData, and also notifying.
|
ChargeOrderInfoResponse.class, authSecretTokenOut);
|
||||||
// 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));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@ -174,7 +174,7 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
|
|||||||
EquipChargeStatusRes equipChargeStatusRes = DTOJsonHelper.parseResponseData(responseBody,
|
EquipChargeStatusRes equipChargeStatusRes = DTOJsonHelper.parseResponseData(responseBody,
|
||||||
EquipChargeStatusRes.class, authSecretTokenOut);
|
EquipChargeStatusRes.class, authSecretTokenOut);
|
||||||
if (equipChargeStatusRes != null && equipChargeStatusRes.getSuccStat() != 0) {
|
if (equipChargeStatusRes != null && equipChargeStatusRes.getSuccStat() != 0) {
|
||||||
throw new RuntimeException(String.format("push CD equipment order status [%s] failed: %s",
|
throw new RuntimeException(String.format("push equipment order status [%s] failed: %s",
|
||||||
equipChargeStatus.getStartChargeSeq(), responseBody));
|
equipChargeStatus.getStartChargeSeq(), responseBody));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -24,10 +23,10 @@ public class NotificationStopChargeResultTask extends CoreDispatcher {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||||
|
|
||||||
@Scheduled(fixedRate = 1000 * 20)
|
@Scheduled(fixedRate = 1000 * 5)
|
||||||
public void run() throws IOException {
|
public void run() throws Exception {
|
||||||
|
|
||||||
//notifyService();
|
notifyService();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,15 +52,15 @@ public class NotificationStopChargeResultTask extends CoreDispatcher {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String orderNo = pushOrderKey.substring(10);
|
String orderNo = pushOrderKey.substring(10);
|
||||||
Map<String, Object> order = REDIS.getCacheMap("order:" + orderNo);
|
Map<String, Object> cacheOrder = REDIS.getCacheMap("order:" + orderNo);
|
||||||
|
final Object stopResult = cacheOrder.get("stopResult");
|
||||||
|
if (stopResult == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String operatorId3rdpty = (String) pushOrder.get("operatorId3rdpty");
|
String operatorId3rdpty = (String) pushOrder.get("operatorId3rdpty");
|
||||||
if (operatorId3rdpty == null) {
|
AuthSecretToken authSecretTokenOut =
|
||||||
continue;
|
authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId3rdpty,
|
||||||
}
|
SECRET_TOKEN_TYPE_OUT).orElse(null);
|
||||||
AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId3rdpty, SECRET_TOKEN_TYPE_OUT).orElse(null);
|
|
||||||
if (authSecretTokenOut == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
CommonRequest<ChargeResultRequest> chargeResultRequestCommonRequest = new CommonRequest<>();
|
CommonRequest<ChargeResultRequest> chargeResultRequestCommonRequest = new CommonRequest<>();
|
||||||
ChargeResultRequest chargeResultRequest = new ChargeResultRequest();
|
ChargeResultRequest chargeResultRequest = new ChargeResultRequest();
|
||||||
if (stopCommandSent) {
|
if (stopCommandSent) {
|
||||||
@ -69,7 +68,7 @@ public class NotificationStopChargeResultTask extends CoreDispatcher {
|
|||||||
//通过充电订单号,获取指定的订单
|
//通过充电订单号,获取指定的订单
|
||||||
//判断订单充电状态
|
//判断订单充电状态
|
||||||
//获取指定的订单的数据
|
//获取指定的订单的数据
|
||||||
CacheOrderData orderData = (CacheOrderData) order.get("orderData");
|
CacheOrderData orderData = (CacheOrderData) cacheOrder.get("orderData");
|
||||||
String internetSerialNumber = (String) pushOrder.get("internetSerialNumber");
|
String internetSerialNumber = (String) pushOrder.get("internetSerialNumber");
|
||||||
chargeResultRequest.setStartChargeSeq(internetSerialNumber);
|
chargeResultRequest.setStartChargeSeq(internetSerialNumber);
|
||||||
if (orderData != null) {
|
if (orderData != null) {
|
||||||
@ -85,24 +84,25 @@ public class NotificationStopChargeResultTask extends CoreDispatcher {
|
|||||||
chargeResultRequestCommonRequest.setOperatorId(operatorId3rdpty);
|
chargeResultRequestCommonRequest.setOperatorId(operatorId3rdpty);
|
||||||
String jsonData = JSONUtil.toJSONString(chargeResultRequest);
|
String jsonData = JSONUtil.toJSONString(chargeResultRequest);
|
||||||
chargeResultRequestCommonRequest.setData(jsonData);
|
chargeResultRequestCommonRequest.setData(jsonData);
|
||||||
String result = ok(chargeResultRequestCommonRequest, "/notification_stop_charge_result", authSecretTokenOut, operatorId3rdpty);
|
String result = ok(chargeResultRequestCommonRequest, "/notification_stop_charge_result",
|
||||||
|
authSecretTokenOut, operatorId3rdpty);
|
||||||
|
|
||||||
ChargeResultResponse chargeResultResponse = JSONUtil.readParams(result, ChargeResultResponse.class);
|
ChargeResultResponse chargeResultResponse = JSONUtil.readParams(result, ChargeResultResponse.class);
|
||||||
succStat = chargeResultResponse.getSuccStat();
|
succStat = chargeResultResponse.getSuccStat();
|
||||||
//推送成功则排除这个已推送的订单,否则则继续推送该订单 // 用于测试暂时注释
|
//推送成功则排除这个已推送的订单,否则则继续推送该订单 // 用于测试暂时注释
|
||||||
// if (succStat==0){
|
if (succStat == 0) {
|
||||||
// REDIS.deleteObject(pushOrderKey);
|
REDIS.deleteObject(pushOrderKey);
|
||||||
// }
|
}
|
||||||
|
// pushOrder.put("stopCommandSent", false);
|
||||||
|
// REDIS.setCacheMap(pushOrderKey, pushOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//推送充电订单信息
|
//推送充电订单信息
|
||||||
new NotificationChargeOrderInfo().pushChargeOrderInfo();
|
// new NotificationChargeOrderInfo().pushChargeOrderInfo();
|
||||||
|
//
|
||||||
//进行账单对账
|
// //进行账单对账
|
||||||
new CheckChargeOrders().checkChargeOrder();
|
// new CheckChargeOrders().checkChargeOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user