update 电单车

This commit is contained in:
Guoqs
2024-09-18 10:45:53 +08:00
parent 5e8a6b6605
commit 89af8426ab
10 changed files with 604 additions and 6 deletions

View File

@@ -41,25 +41,25 @@ public class ChargingOperationResponse extends AbsEBikeMessage2 {
*/
private String waitPortNumber;
public ChargingOperationResponse(byte[] dataBytes) {
super(dataBytes);
public ChargingOperationResponse(byte[] messageBytes) {
super(messageBytes);
// 读取结果
int startIndex = 12;
int length = 1;
this.result = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
this.result = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 16;
this.transactionCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
this.transactionCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 1;
this.portNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)));
this.portNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
// startIndex += length;
// length = 2;
// this.waitPortNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)));
// this.waitPortNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
}

View File

@@ -0,0 +1,81 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 刷卡操作02指令
*/
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd02 extends AbsEBikeMessage2 {
/**
* 卡片ID
*/
private String cardId;
/**
* 卡片类型
*/
private String cardType;
/**
* 端口号
*/
private String portNumber;
/**
* 余额卡内金额
*/
private String cardBalance;
/**
* 时间戳
*/
// private String timestamp;
/**
* 卡号2字节数
*/
private int card2Length;
/**
* 卡号2
*/
private String card2Code;
public Cmd02(byte[] messageBytes) {
super(messageBytes);
int startIndex = 12;
int length = 4;
this.cardId = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 1;
this.cardType = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 1;
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 2;
this.cardBalance = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
// length = 4;
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
if (messageBytes.length > startIndex) {
startIndex += length;
length = 1;
card2Length = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
this.card2Code = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
}
}
}

View File

@@ -0,0 +1,68 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.YouDianUtils;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd03 extends AbsEBikeMessage2 {
private int chargingTime; // 充电时长, 单位:"秒"
private int maxPower; // 最大功率, 单位:"0.1W"
private int consumedEnergy; // 耗电量, 单位:"0.01度"
private String portNumber; // 端口号
private int startMode; // 在线/离线启动/验证码
private int cardNumberOrVerificationCode; // 卡号/验证码
private int stopReason; // 停止原因
private String orderNumber; // 订单编号
private int secondMaxPower; // 第二最大功率
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
public Cmd03(byte[] messageBytes) {
super(messageBytes);
int startIndex = 12;
int length = 2;
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 2;
this.maxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 2;
this.consumedEnergy = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 1;
this.portNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
startIndex += length;
length = 1;
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 4;
this.cardNumberOrVerificationCode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 1;
this.stopReason = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 16;
this.orderNumber = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 2;
this.secondMaxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 31, 35)) + "";
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 35, 37)) + "";
}
}

View File

@@ -0,0 +1,61 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd04 extends AbsEBikeMessage2 {
/**
* 端口号
*/
private String portNumber;
/**
* 在线/离线启动
*/
private String startMode;
/**
* 卡片ID
*/
private String cardId;
/**
* 充电时长
*/
private String chargingTime;
/**
* 订单编号
*/
private String orderCode;
public Cmd04(byte[] messageBytes) {
super(messageBytes);
int startIndex = 12;
int length = 1;
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 1;
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 4;
this.cardId = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 2;
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 16;
this.orderCode = BytesUtil.bcd2StrLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
}
}

View File

@@ -0,0 +1,187 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.YouDianUtils;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.math.BigDecimal;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd06 extends AbsEBikeMessage2 {
/**
* 端口号当前充电的端口号。注00表示1号端口01表示2号端口; port+1为实际端口
*/
private String port;
/**
* 各端口状态: 1=充电中, 2=已扫码暂未检测到功率等待插入充电器充电柜专有如单车桩出现此值为出错值请忽略3=有充电器但未充电已充满电5=浮充,其他值=出错值请忽略
*/
private String portStatus;
/**
* 充电时长:开始充电到当前为止,已经充电多长时间
*/
private String chargingTime;
/**
* 当前订单累计电量:当前端口的订单,开始充电到当前为止,已经消耗的电量
*/
private String totalUsedElectricity;
/**
* 在线/离线启动:=0表示启动时处于离线状态 =1表示启动时处于在线状态 3=验证码启动(仅支持带按键和屏幕的机型)
*/
private String startMode;
/**
* 实时功率:心跳包发送时的当前功率
*/
private String realTimePower;
/**
* 心跳包期间最大功率:心跳包期间出现过的最大功率
*/
private String maxPower;
/**
* 心跳包期间最小功率:心跳包期间出现过的最小功率
*/
private String minPower;
/**
* 心跳包期间平均功率:心跳包期间出现过的平均功率
*/
private String avgPower;
/**
* 订单编号:当前充电的订单编号
*/
private String orderCode;
/**
* 该时间段内消耗电量此数据需除以4800后才是真实的电量该字段属于调试使用服务器无需关心此字段
*/
private String timePeriodElectricity;
/**
* 峰值功率:整个充电过程中出现过的最大功率,有些版本无此字段
*/
private String peakPower;
/**
* 设备的当前电压
*/
private String voltage;
/**
* 设备的当前电流,可以计量芯片采集也可以通过计算得出,0.001A为单位1000表示1A电流
*/
private String current;
/**
* 设备的当前环境温度,仅针对有此功能的机型
*/
private String ambientTemperature;
/**
* 端口温度,仅针对有此功能的机型
*/
private String portTemperature;
/**
* 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
*/
// private String timestamp;
/**
* 占位时长:(充电柜专用,其他设备忽略此字段)表示充满后占用设备的时长,单位为分钟
*/
private String occupancyTime;
public Cmd06(byte[] messageBytes) {
super(messageBytes);
int startIndex = 12;
int length = 1;
this.port = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
startIndex += length;
length = 1;
this.portStatus = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 2;
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 2;
this.totalUsedElectricity = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.01")).toString();
startIndex += length;
length = 1;
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 2;
this.realTimePower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 2;
this.maxPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 2;
this.minPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 2;
this.avgPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 16;
this.orderCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 2;
this.timePeriodElectricity = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 2;
this.peakPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 2;
this.voltage = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 2;
this.current = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.001")).toString();
startIndex += length;
length = 1;
this.ambientTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.subtract(new BigDecimal("65")).toString();
startIndex += length;
length = 1;
this.portTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.subtract(new BigDecimal("65")).toString();
startIndex += length;
length = 2;
this.occupancyTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
}
}

View File

@@ -0,0 +1,13 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd11 extends AbsEBikeMessage2 {
}

View File

@@ -0,0 +1,12 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd12 extends AbsEBikeMessage2 {
}

View File

@@ -0,0 +1,73 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.math.BigDecimal;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd20 extends AbsEBikeMessage2 {
/**
* 固件版本如100则表示V1.00版本
*/
private String firmwareVersion;
/**
* 端口数量 表示设备总共有多少个端口
*/
private int portNumber;
/**
* 虚拟ID需要内部组网的设备的本地地址如485、LORA系列如不需组网的设备默认为00
*/
private String virtualId;
/**
* 设备类型: 见01指令中的设备类型表
*/
private String deviceType;
/**
* 工作模式第0位0=联网1=刷卡。第1位0=RN82091=BL0939。第2位0=无短路预检1=有短路预检。第3位0=光耦检测模式1=带灯模式。
*/
private String workMode;
/**
* 电源板版本号电源板的固件版本号如没有电源板的机型则为0
*/
private String powerBoardVersion;
public Cmd20(byte[] messageBytes) {
super(messageBytes);
int startIndex = 12;
int length = 2;
this.firmwareVersion = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 1;
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 1;
this.virtualId = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 1;
this.deviceType = BytesUtil.printHexBinary(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 1;
this.workMode = BytesUtil.bcd2StrLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = 2;
this.powerBoardVersion = BytesUtil.bcd2StrLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
}
}

View File

@@ -0,0 +1,91 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.google.common.collect.Lists;
import com.jsowell.common.enums.ebike.PortStatusEnum;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.math.BigDecimal;
import java.util.List;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd21 extends AbsEBikeMessage2 {
/**
* 电压:设备的当前电压(打包发送心跳包指令时的当前时间点的实时电压)
* 2024年8月26日15点02分 已经转为标准单位V
*/
private String voltage;
/**
* 端口数量:表示设备总共有多少个端口,和后面的“端口状态”配套
*/
private int portNumber;
/**
* 注4、各端口状态一个字节表示一个端口和“端口数量”匹配
* 如端口数量是16则“各端口状态”为16字节
* 每个字节表示的意思,
* 0=空闲1=充电中2=有充电器但未充电用户未启动充电3=有充电器但未充电(已充满电) 4=该路无法计量5=浮充6=存储器损坏,
* 7插座弹片卡住故障8接触不良或保险丝烧断故障9(算法-继电器粘连)0x0A=霍尔开关损坏(即插入检测传感器)。
* 0x0B=(预检-继电器坏或保险丝断0x0D=(预检-负载短路。0x0E=(过滤性预检-继电器粘连),0x0F=(刷卡芯片损坏故障)0x10=(检测电路故障)
*/
private List<String> portStatus;
private List<String> statusDescList;
/**
* 信号强度指分机与主机之间的无线信号强度如LORA信号。00则为有线组网或无信号强度功能
*/
private String rssi;
/**
* 当前环境温度表示当前设备内的温度可能和真正的当前环境温度有一定的误差如00则表示无此功能
*/
private String temperature;
public Cmd21(byte[] messageBytes) {
super(messageBytes);
// 读取结果
int startIndex = 12;
int length = 2;
this.voltage = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
.multiply(new BigDecimal("0.1")).toString();
startIndex += length;
length = 1;
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
startIndex += length;
length = this.portNumber;
byte[] statusBytes = BytesUtil.copyBytes(messageBytes, startIndex, length);
// 解析
List<String> statusList = Lists.newArrayList();
List<String> statusDescList = Lists.newArrayList();
for (byte statusByte : statusBytes) {
int status = BytesUtil.bytesToIntLittle(new byte[]{statusByte});
statusList.add(String.valueOf(status));
statusDescList.add(PortStatusEnum.getDescriptionByValue(status));
}
this.portStatus = statusList;
this.statusDescList = statusDescList;
startIndex += length;
length = 1;
this.rssi = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
startIndex += length;
length = 1;
int i = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
if (i > 65) {
i = i - 65;
}
this.temperature = i + "";
}
}

View File

@@ -0,0 +1,12 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class Cmd22 extends AbsEBikeMessage2 {
}