update 电单车协议

This commit is contained in:
Guoqs
2024-08-26 10:13:02 +08:00
parent f0c2869590
commit f27773ba05
12 changed files with 123 additions and 85 deletions

View File

@@ -185,7 +185,7 @@ public class OrderBasicInfoController extends BaseController {
}
/**
* 重试订单退款接口
* 重试订单退款接口/重试退款按钮
* http://localhost:8080/order/retryRefundOrder
*/
@PostMapping("/retryRefundOrder")

View File

@@ -1,41 +0,0 @@
package com.jsowell.common.core.domain.ebike;
import lombok.extern.slf4j.Slf4j;
/**
* 友电电单车协议指令
*/
@Slf4j
public enum EBikeCommandEnum {
// HEARTBEAT("01", "设备心跳包"),
REGISTRATION("20", "设备注册包"),
GET_SERVER_TIME("22", "设备获取服务器时间"),
HEARTBEAT_2("21", "设备心跳包"),
CARD_OPERATION("02", "刷卡操作"),
SETTLEMENT_UPLOAD("03", "结算消费信息上传"),
CHARGE_PORT_CONFIRMATION("04", "充电端口订单确认"),
POWER_HEARTBEAT("06", "端口充电时功率心跳包"),
CHARGER_HEARTBEAT("41", "充电柜专有心跳包"),
ALARM_PUSH("42", "报警推送指令"),
CHARGE_COMPLETE("43", "充电完成通知,但不结算"),
PORT_PUSH("44", "端口推送指令");
;
EBikeCommandEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
private final String code; // 帧类型code
private final String desc; // 帧类型名称
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
}

View File

@@ -27,24 +27,7 @@ public class SyncPromise {
this.rpcResult = rpcResult;
}
/**
* 同步等待返回结果
*/
// public RpcResponse get(long timeout, TimeUnit unit) throws InterruptedException {
// // 等待阻塞超时时间内countDownLatch减到0将提前唤醒以此作为是否超时判断
// boolean earlyWakeUp = countDownLatch.await(timeout, unit);
//
// if(earlyWakeUp) {
// // 超时时间内countDownLatch减到0提前唤醒说明已有结果
// return rpcResponse;
// } else {
// // 超时时间内countDownLatch没有减到0自动唤醒说明超时时间内没有等到结果
// isTimeout = true;
// return null;
// }
// }
public byte[] get2(long timeout, TimeUnit unit) throws InterruptedException {
public byte[] get(long timeout, TimeUnit unit) throws InterruptedException {
// 等待阻塞超时时间内countDownLatch减到0将提前唤醒以此作为是否超时判断
boolean earlyWakeUp = countDownLatch.await(timeout, unit);
@@ -61,12 +44,5 @@ public class SyncPromise {
public void wake() {
countDownLatch.countDown();
}
// public RpcResponse getRpcResponse() {
// return rpcResponse;
// }
// public void setRpcResponse(RpcResponse rpcResponse) {
// this.rpcResponse = rpcResponse;
// }
}

View File

@@ -9,6 +9,7 @@ import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.CRC16Util;
import com.jsowell.common.util.DateUtils;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import io.netty.channel.ChannelHandlerContext;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,17 +26,7 @@ public abstract class AbstractEBikeHandler implements InitializingBean {
* 执行逻辑
* 有应答
*/
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext ctx) {
throw new UnsupportedOperationException();
}
/**
* 执行逻辑
* 不需要应答
*/
// public void pushProcess() {
// throw new UnsupportedOperationException();
// }
public abstract byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx);
/**
* 组装应答的结果

View File

@@ -1,7 +1,9 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.common.core.domain.ebike.EBikeCommandEnum;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.netty.factory.EBikeOperateFactory;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -17,4 +19,16 @@ public class GetServerTimeHandler extends AbstractEBikeHandler {
public void afterPropertiesSet() throws Exception {
EBikeOperateFactory.register(type, this);
}
/**
* 执行逻辑
* 有应答
*
* @param msg
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
return new byte[0];
}
}

View File

@@ -1,7 +1,9 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.common.core.domain.ebike.EBikeCommandEnum;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.netty.factory.EBikeOperateFactory;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -17,4 +19,16 @@ public class HeartbeatHandler extends AbstractEBikeHandler {
public void afterPropertiesSet() throws Exception {
EBikeOperateFactory.register(type, this);
}
/**
* 执行逻辑
* 有应答
*
* @param msg
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
return new byte[0];
}
}

View File

@@ -1,7 +1,9 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.common.core.domain.ebike.EBikeCommandEnum;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.netty.factory.EBikeOperateFactory;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -17,4 +19,16 @@ public class RegistrationHandler extends AbstractEBikeHandler {
public void afterPropertiesSet() throws Exception {
EBikeOperateFactory.register(type, this);
}
/**
* 执行逻辑
* 有应答
*
* @param msg
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
return new byte[0];
}
}

View File

@@ -1,7 +1,9 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.common.core.domain.ebike.EBikeCommandEnum;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.netty.factory.EBikeOperateFactory;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -17,4 +19,16 @@ public class SettlementUploadHandler extends AbstractEBikeHandler {
public void afterPropertiesSet() throws Exception {
EBikeOperateFactory.register(type, this);
}
/**
* 执行逻辑
* 有应答
*
* @param msg
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
return new byte[0];
}
}

View File

@@ -0,0 +1,57 @@
package com.jsowell.pile.domain.ebike;
import com.jsowell.pile.domain.ebike.deviceupload.*;
import lombok.extern.slf4j.Slf4j;
/**
* 友电电单车协议指令
*/
@Slf4j
public enum EBikeCommandEnum {
// HEARTBEAT("01", "设备心跳包"),
REGISTRATION("20", "设备注册包", EBikeMessageCmd20.class),
GET_SERVER_TIME("22", "设备获取服务器时间", EBikeMessageCmd22.class),
HEARTBEAT_2("21", "设备心跳包", EBikeMessageCmd21.class),
CARD_OPERATION("02", "刷卡操作", EBikeMessageCmd02.class),
SETTLEMENT_UPLOAD("03", "结算消费信息上传", EBikeMessageCmd03.class),
CHARGE_PORT_CONFIRMATION("04", "充电端口订单确认", EBikeMessageCmd04.class),
POWER_HEARTBEAT("06", "端口充电时功率心跳包", EBikeMessageCmd06.class),
// CHARGER_HEARTBEAT("41", "充电柜专有心跳包", EBikeMessageCmd41.class),
// ALARM_PUSH("42", "报警推送指令", EBikeMessageCmd20.class),
// CHARGE_COMPLETE("43", "充电完成通知,但不结算", EBikeMessageCmd20.class),
// PORT_PUSH("44", "端口推送指令", EBikeMessageCmd20.class);
;
EBikeCommandEnum(String code, String desc, Class<? extends AbsEBikeMessage> msgClass) {
this.code = code;
this.desc = desc;
this.msgClass = msgClass;
}
private final String code; // 帧类型code
private final String desc; // 帧类型名称
private final Class<? extends AbsEBikeMessage> msgClass;
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
public Class<? extends AbsEBikeMessage> getMsgClass() {
return msgClass;
}
public static Class<? extends AbsEBikeMessage> getMsgClassByCode(String code) {
for (EBikeCommandEnum e : EBikeCommandEnum.values()) {
if (e.getCode().equals(code)) {
return e.getMsgClass();
}
}
return null;
}
}

View File

@@ -2121,7 +2121,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
} catch (BaseAdaPayException e) {
throw new RuntimeException(e);
}
logger.info("根据订单号:{}, 查询到支付信息:{}", orderCode, JSON.toJSONString(paymentInfoSet));
logger.info("根据订单号:{}, 查询到支付信息:{}, ", orderCode, JSON.toJSONString(paymentInfoSet));
if (CollectionUtils.isNotEmpty(paymentInfoSet)) {
for (PaymentInfo paymentInfo : paymentInfoSet) {
String paymentId = paymentInfo.getPaymentId();

View File

@@ -207,7 +207,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
});
// 等待获取结果
byte[] rpcResponse = syncPromise.get2(timeout, unit);
byte[] rpcResponse = syncPromise.get(timeout, unit);
if(rpcResponse == null) {
if(syncPromise.isTimeout()) {

View File

@@ -285,7 +285,6 @@ export default {
payDetail: [],
// 订单退款列表
orderRefundInfoList: [],
// 重试退款按钮
// retryRefundFlag: false,
userInfo: [],
obj: {},