This commit is contained in:
Lemon
2024-08-28 16:19:30 +08:00
18 changed files with 132 additions and 9 deletions

View File

@@ -52,7 +52,6 @@ public abstract class AbsEBikeMessage {
}
}
public static AbsEBikeMessage parseMessage(byte[] messageBytes) {
if (messageBytes == null || messageBytes.length < 14 || messageBytes.length > 256) {
throw new IllegalArgumentException("Invalid message bytes");
@@ -101,6 +100,8 @@ public abstract class AbsEBikeMessage {
}
}
public abstract byte[] getMessageBytes();
public static void main(String[] args) {
String s = "44 4e 59 00 0d 3b 37 ab 04 b9 00 22 54 33 cc 66 03 7b".replace(" ", "");
byte[] messageBytes = BytesUtil.hexStringToByteArray(s);

View File

@@ -26,6 +26,11 @@ public class EBikeMessageCmd02 extends AbsEBikeMessage {
this.creditCardInfo = new CreditCardInfo(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return null;
}
public CreditCardInfo getCreditCardInfo() {
return creditCardInfo;
}

View File

@@ -6,6 +6,9 @@ import lombok.Data;
import java.util.Arrays;
/**
* 结算消费信息上传03指令
*/
public class EBikeMessageCmd03 extends AbsEBikeMessage {
private SettlementInfo settlementInfo;
@@ -20,6 +23,11 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage {
this.settlementInfo = new SettlementInfo(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public SettlementInfo getSettlementInfo() {
return settlementInfo;
}

View File

@@ -24,6 +24,11 @@ public class EBikeMessageCmd04 extends AbsEBikeMessage {
this.confirmOrder = new ConfirmOrder(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public ConfirmOrder getSettlementInfo() {
return confirmOrder;
}

View File

@@ -26,6 +26,11 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
this.powerHeartbeat = new PowerHeartbeat(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public PowerHeartbeat getPowerHeartbeat() {
return powerHeartbeat;
}

View File

@@ -23,6 +23,11 @@ public class EBikeMessageCmd20 extends AbsEBikeMessage {
this.deviceRegister = new DeviceRegister(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public DeviceRegister getDeviceRegister() {
return deviceRegister;
}

View File

@@ -29,6 +29,11 @@ public class EBikeMessageCmd21 extends AbsEBikeMessage {
this.deviceHeartbeat = new DeviceHeartbeat(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
/**
* 此为心跳包间隔时间默认为3分钟方便服务器管理SocketIP
* 设备如2次收不到服务器应答则进入离线状态

View File

@@ -1,5 +1,6 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.util.bean.SerializationUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import lombok.Getter;
import lombok.Setter;
@@ -22,4 +23,10 @@ public class EBikeMessageCmd22 extends AbsEBikeMessage {
}
@Override
public byte[] getMessageBytes() {
byte[] serialize = SerializationUtil.serialize(this);
return serialize;
}
}

View File

@@ -18,4 +18,9 @@ public class EBikeMessageCmd81 extends AbsEBikeMessage {
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
}

View File

@@ -24,6 +24,11 @@ public class EBikeMessageCmd82 extends AbsEBikeMessage {
this.specificData = new SpecificData(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public SpecificData getSpecificData() {
return specificData;
}

View File

@@ -340,7 +340,7 @@ public class PileRemoteService {
String failedReason = BytesUtil.bcd2Str(failedReasonByteArr);
String failedReasonMsg = ChargingFailedReasonEnum.getMsgByCode(Integer.parseInt(failedReason, 16));
log.info("0x59预约充电响应sync, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果:{}, 失败原因:{}",
log.info("0x59预约充电响应sync, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果(00-失败; 01成功):{}, 失败原因:{}",
transactionCode, pileSn, connectorCode, resultCode, failedReasonMsg);
}

View File

@@ -0,0 +1,34 @@
package com.jsowell.pile.service.impl;
import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 电单车发送指令service
*/
@Slf4j
@Service
public class EBikeSendCommandService {
/**
* 公共方法发送指令
* @param pileSn 装编号
* @param msg 消息
* @param timeout 超时时间
* @param unit 时间单位
*/
private void sendCommand(String pileSn, Class<? extends AbsEBikeMessage> msg, long timeout, TimeUnit unit) {
// 通过桩编号获取channel
ChannelHandlerContext ctx = PileChannelEntity.getChannelByPileSn(pileSn);
if (Objects.isNull(ctx)) {
log.error("push命令[{}]失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", "value", pileSn);
throw new NullPointerException("channel");
}
}
}

View File

@@ -3826,8 +3826,36 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.reason(chargingStartupResult.getFailReason())
.build();
BigDecimal sharpElectricityPrice = BigDecimal.ZERO;
BigDecimal sharpServicePrice = BigDecimal.ZERO;
BigDecimal sharpPrice = BigDecimal.ZERO;
BigDecimal peakElectricityPrice = BigDecimal.ZERO;
BigDecimal peakServicePrice = BigDecimal.ZERO;
BigDecimal peakPrice = BigDecimal.ZERO;
BigDecimal flatElectricityPrice = BigDecimal.ZERO;
BigDecimal flatServicePrice = BigDecimal.ZERO;
BigDecimal flatPrice = BigDecimal.ZERO;
BigDecimal valleyElectricityPrice = BigDecimal.ZERO;
BigDecimal valleyServicePrice = BigDecimal.ZERO;
BigDecimal valleyPrice = BigDecimal.ZERO;
OrderDetail orderDetail = OrderDetail.builder()
.orderCode(orderCode)
.sharpElectricityPrice(sharpElectricityPrice)
.sharpServicePrice(sharpServicePrice)
.sharpPrice(sharpPrice)
.peakElectricityPrice(peakElectricityPrice)
.peakServicePrice(peakServicePrice)
.peakPrice(peakPrice)
.flatElectricityPrice(flatElectricityPrice)
.flatServicePrice(flatServicePrice)
.flatPrice(flatPrice)
.valleyElectricityPrice(valleyElectricityPrice)
.valleyServicePrice(valleyServicePrice)
.valleyPrice(valleyPrice)
.delFlag(DelFlagEnum.NORMAL.getValue())
.build();

View File

@@ -688,7 +688,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
response = null;
}
log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作(01-启动; 02-取消; 03-修改):{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
transactionCode, pileSn, connectorCode, operation, verifyIdentity, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount);
return response;
}