todo: 完善监管与第三方推送逻辑
This commit is contained in:
parent
fc5a5ca894
commit
755559739a
@ -44,7 +44,7 @@ public class CoreDispatcher {
|
||||
public static final okhttp3.MediaType JSON = okhttp3.MediaType.parse("application/json; charset=utf-8");
|
||||
|
||||
@Transactional
|
||||
public String ok(Object object, String url, String operatorId3irdpty, String operatorID) {
|
||||
public String ok(Object object, String url, AuthSecretToken authSecretTokenOut, String operatorID) {
|
||||
|
||||
okhttp3.RequestBody body = null;
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
@ -58,9 +58,8 @@ public class CoreDispatcher {
|
||||
.writeTimeout(10, TimeUnit.SECONDS);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String bearerToken = null;
|
||||
AuthSecretToken authSecretTokenOut = getAuthSecretTokenOut(operatorId3irdpty, operatorID);
|
||||
if (authSecretTokenOut == null) {
|
||||
String error = String.format("secret/token not found for [%s/%s](opId3pt/opId)", operatorId3irdpty, operatorID);
|
||||
String error = String.format("secret/token not found for [%s/%s](opId3pt/opId)", authSecretTokenOut.getOperatorId3irdpty(), operatorID);
|
||||
throw new RuntimeException(error);
|
||||
}
|
||||
try {
|
||||
|
||||
@ -169,7 +169,7 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
|
||||
CommonRequest<CDChargeOrderInfo4BonusReq> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId(operatorIdEvcs);
|
||||
commonRequest.setData(data);
|
||||
String responseBody = ok(commonRequest, "/notification_equip_charge_status", "765367656", operatorIdEvcs);
|
||||
String responseBody = ok(commonRequest, "/notification_equip_charge_status", authSecretTokenOut, operatorIdEvcs);
|
||||
EquipChargeStatusRes equipChargeStatusRes = DTOJsonHelper.parseResponseData(responseBody,
|
||||
EquipChargeStatusRes.class, authSecretTokenOut);
|
||||
if (equipChargeStatusRes != null && equipChargeStatusRes.getSuccStat() != 0) {
|
||||
|
||||
@ -88,7 +88,7 @@ public class NotificationStationStatusTask extends CoreDispatcher {
|
||||
CommonRequest<ConnectorStatusInfoReq> commonRequest = new CommonRequest<>();
|
||||
commonRequest.setOperatorId(connectorStatusInfo.getOperatorID());
|
||||
commonRequest.setData(data);
|
||||
String responseBody = ok(commonRequest, "/notification_stationStatus", "765367656",
|
||||
String responseBody = ok(commonRequest, "/notification_stationStatus", authSecretTokenOut,
|
||||
connectorStatusInfo.getOperatorID());
|
||||
EvcsStatus status = DTOJsonHelper.parseResponseData(responseBody, EvcsStatus.class, authSecretTokenOut);
|
||||
if (status == null || status.getStatus() != 0) {
|
||||
|
||||
@ -2,9 +2,12 @@ package com.xhpc.evcs.notification;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.xhpc.common.data.redis.CacheOrderData;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.dto.ChargeResultRequest;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -12,9 +15,13 @@ 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;
|
||||
|
||||
public class NotificationStopChargeResultTask extends CoreDispatcher {
|
||||
|
||||
@Autowired
|
||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 20)
|
||||
public void run() throws IOException {
|
||||
|
||||
@ -36,6 +43,8 @@ public class NotificationStopChargeResultTask extends CoreDispatcher {
|
||||
*/
|
||||
public void notifyService() {
|
||||
|
||||
List<AuthSecretToken> authSecretTokenOutList = authSecretTokenRepository.findBySecretTokenType(SECRET_TOKEN_TYPE_OUT);
|
||||
for (AuthSecretToken authSecretTokenOut : authSecretTokenOutList) {
|
||||
//20秒检测一次Redis中的数据状态,并推送
|
||||
|
||||
//获取Redis中的所有订单状态数据
|
||||
@ -90,7 +99,7 @@ public class NotificationStopChargeResultTask extends CoreDispatcher {
|
||||
|
||||
//推送数据
|
||||
//operatorId第三方的 我们场站运营商的
|
||||
ok(chargeResultRequestCommonRequest, "/notification_stop_charge_result", "765367656", null);
|
||||
ok(chargeResultRequestCommonRequest, "/notification_stop_charge_result", authSecretTokenOut, null);
|
||||
|
||||
// TODO: 2021/10/21 设置该订单数据已经被推送的标识符
|
||||
orderStatus.put("isPush", true);
|
||||
@ -102,7 +111,7 @@ public class NotificationStopChargeResultTask extends CoreDispatcher {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user