update 电单车

This commit is contained in:
Guoqs
2024-09-14 15:21:05 +08:00
parent 9cab295b83
commit bcf90e0668
2 changed files with 39 additions and 15 deletions

View File

@@ -1,11 +1,10 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.YouDianUtils;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import lombok.Data;
import java.util.Arrays;
/**
* 结算消费信息上传03指令
*/
@@ -37,7 +36,7 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage {
private int chargingTime; // 充电时长, 单位:"秒"
private int maxPower; // 最大功率, 单位:"0.1W"
private int consumedEnergy; // 耗电量, 单位:"0.01度"
private int portNumber; // 端口号
private String portNumber; // 端口号
private int startMode; // 在线/离线启动/验证码
private int cardNumberOrVerificationCode; // 卡号/验证码
private int stopReason; // 停止原因
@@ -47,16 +46,42 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage {
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
public SettlementInfo(byte[] dataBytes) {
this.chargingTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2));
this.maxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 4));
this.consumedEnergy = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 4, 6));
this.portNumber = BytesUtil.bytesToIntLittle(new byte[]{dataBytes[6]});
this.startMode = BytesUtil.bytesToIntLittle(new byte[]{dataBytes[7]});
this.cardNumberOrVerificationCode = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 8, 12));
this.stopReason = BytesUtil.bytesToIntLittle(new byte[]{dataBytes[12]});
// this.orderNumber = BytesUtil.bcd2Str(Arrays.copyOfRange(dataBytes, 13, 29));
this.orderNumber = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, 13, 16));
this.secondMaxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 29, 31));
int startIndex = 0;
int length = 2;
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
startIndex += length;
length = 2;
this.maxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
startIndex += length;
length = 2;
this.consumedEnergy = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
startIndex += length;
length = 1;
this.portNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)));
startIndex += length;
length = 1;
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
startIndex += length;
length = 4;
this.cardNumberOrVerificationCode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
startIndex += length;
length = 1;
this.stopReason = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
startIndex += length;
length = 16;
this.orderNumber = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
startIndex += length;
length = 2;
this.secondMaxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 31, 35)) + "";
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 35, 37)) + "";
}

View File

@@ -136,8 +136,7 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
public PowerHeartbeat(byte[] dataBytes) {
int startIndex = 0;
int length = 1;
int i = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
this.port = YouDianUtils.convertPortNumberToString(i);
this.port = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)));
startIndex += length;
length = 1;