mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-29 19:47:56 +08:00
update 电单车协议
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
package com.jsowell.netty.decoder;
|
|
||||||
|
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class MessageDecode extends ByteToMessageDecoder {
|
|
||||||
@Override
|
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
|
||||||
// 检查是否有足够的字节可以读取
|
|
||||||
if (in.readableBytes() < 14) { // 最小长度(包头3 + 长度2 + 物理ID4 + 消息ID2 + 命令1 + 校验2)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 读取所有可读字节
|
|
||||||
byte[] bytes = new byte[in.readableBytes()];
|
|
||||||
in.readBytes(bytes);
|
|
||||||
|
|
||||||
// 解析字节数组
|
|
||||||
AbsEBikeMessage message = AbsEBikeMessage.parseMessage(bytes);
|
|
||||||
out.add(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -129,6 +129,8 @@ public class StartAndLengthFieldFrameDecoder extends ByteToMessageDecoder {
|
|||||||
// 读取 data 数据
|
// 读取 data 数据
|
||||||
ByteBuf frame = buffer.retainedSlice(beginReader, HEADER_LENGTH_DNY + length + 2);
|
ByteBuf frame = buffer.retainedSlice(beginReader, HEADER_LENGTH_DNY + length + 2);
|
||||||
buffer.readerIndex(beginReader + HEADER_LENGTH_DNY + length + 2);
|
buffer.readerIndex(beginReader + HEADER_LENGTH_DNY + length + 2);
|
||||||
|
|
||||||
|
|
||||||
out.add(frame);
|
out.add(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
|
|||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.common.util.YKCUtils;
|
import com.jsowell.common.util.YKCUtils;
|
||||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd22;
|
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd22;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@@ -36,10 +35,10 @@ public class DeviceGetServerTimeHandler extends AbstractEBikeHandler {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
||||||
// 解析字节数组
|
// 解析字节数组
|
||||||
EBikeMessageCmd22 message = (EBikeMessageCmd22) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
|
EBikeMessageCmd22 eBikeMessageCmd22 = new EBikeMessageCmd22(dataProtocol.getBytes());
|
||||||
log.info("设备 获取服务器时间:{}", JSON.toJSONString(message));
|
log.info("设备 获取服务器时间:{}", JSON.toJSONString(eBikeMessageCmd22));
|
||||||
// 保存时间
|
// 保存时间
|
||||||
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
saveLastTimeAndCheckChannel(eBikeMessageCmd22.getPhysicalId() + "", ctx);
|
||||||
|
|
||||||
// 获取当前服务器10位时间戳
|
// 获取当前服务器10位时间戳
|
||||||
byte[] timeBytes = BytesUtil.getIntBytes((int) (System.currentTimeMillis() / 1000));
|
byte[] timeBytes = BytesUtil.getIntBytes((int) (System.currentTimeMillis() / 1000));
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
|
|||||||
import com.jsowell.common.enums.ebike.PortStatusEnum;
|
import com.jsowell.common.enums.ebike.PortStatusEnum;
|
||||||
import com.jsowell.common.util.YKCUtils;
|
import com.jsowell.common.util.YKCUtils;
|
||||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd21;
|
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd21;
|
||||||
import com.jsowell.pile.service.PileBasicInfoService;
|
import com.jsowell.pile.service.PileBasicInfoService;
|
||||||
@@ -47,15 +46,12 @@ public class HeartbeatHandler extends AbstractEBikeHandler {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
||||||
// 解析字节数组
|
// 解析字节数组
|
||||||
EBikeMessageCmd21 message = (EBikeMessageCmd21) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
|
EBikeMessageCmd21 eBikeMessageCmd21 = new EBikeMessageCmd21(dataProtocol.getBytes());
|
||||||
// 保存时间
|
// 保存时间
|
||||||
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
saveLastTimeAndCheckChannel(eBikeMessageCmd21.getPhysicalId() + "", ctx);
|
||||||
|
log.info("设备心跳包:{}", JSON.toJSONString(eBikeMessageCmd21));
|
||||||
EBikeMessageCmd21.DeviceHeartbeat deviceHeartbeat = message.getDeviceHeartbeat();
|
// 更新充电桩状态
|
||||||
log.info("设备心跳包:{}", JSON.toJSONString(message));
|
updatePileStatus(eBikeMessageCmd21);
|
||||||
|
|
||||||
updatePileStatus(message);
|
|
||||||
|
|
||||||
return getResult(dataProtocol, Constants.zeroByteArray);
|
return getResult(dataProtocol, Constants.zeroByteArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,9 +61,8 @@ public class HeartbeatHandler extends AbstractEBikeHandler {
|
|||||||
*/
|
*/
|
||||||
private void updatePileStatus(EBikeMessageCmd21 message) {
|
private void updatePileStatus(EBikeMessageCmd21 message) {
|
||||||
String pileSn = message.getPhysicalId() + "";
|
String pileSn = message.getPhysicalId() + "";
|
||||||
EBikeMessageCmd21.DeviceHeartbeat deviceHeartbeat = message.getDeviceHeartbeat();
|
int portNumber = message.getPortNumber();
|
||||||
int portNumber = deviceHeartbeat.getPortNumber();
|
List<String> portStatus = message.getPortStatus();
|
||||||
List<String> portStatus = deviceHeartbeat.getPortStatus();
|
|
||||||
for (int i = 0; i < portNumber; i++) {
|
for (int i = 0; i < portNumber; i++) {
|
||||||
// 组装pile_connector_info表数据
|
// 组装pile_connector_info表数据
|
||||||
String connectorCode = String.format("%1$02d", i + 1);
|
String connectorCode = String.format("%1$02d", i + 1);
|
||||||
@@ -77,5 +72,4 @@ public class HeartbeatHandler extends AbstractEBikeHandler {
|
|||||||
pileConnectorInfoService.updateConnectorStatus(pileConnectorCode, PortStatusEnum.eBikeStatusTransformDBStatus(eBikeStatus));
|
pileConnectorInfoService.updateConnectorStatus(pileConnectorCode, PortStatusEnum.eBikeStatusTransformDBStatus(eBikeStatus));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
|
|||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.common.util.YKCUtils;
|
import com.jsowell.common.util.YKCUtils;
|
||||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd12;
|
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd12;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@@ -36,7 +35,7 @@ public class HostGetServerTimeHandler extends AbstractEBikeHandler {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
||||||
// 解析字节数组
|
// 解析字节数组
|
||||||
EBikeMessageCmd12 message = (EBikeMessageCmd12) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
|
EBikeMessageCmd12 message = new EBikeMessageCmd12(dataProtocol.getBytes());
|
||||||
log.info("主机 获取服务器时间:{}", JSON.toJSONString(message));
|
log.info("主机 获取服务器时间:{}", JSON.toJSONString(message));
|
||||||
// 保存时间
|
// 保存时间
|
||||||
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.jsowell.common.enums.ebike.PortStatusEnum;
|
|||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.YKCUtils;
|
import com.jsowell.common.util.YKCUtils;
|
||||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd06;
|
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd06;
|
||||||
import com.jsowell.pile.service.PileBasicInfoService;
|
import com.jsowell.pile.service.PileBasicInfoService;
|
||||||
@@ -47,19 +46,14 @@ public class PowerHeartbeatHandler extends AbstractEBikeHandler {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
||||||
// 解析字节数组
|
// 解析字节数组
|
||||||
EBikeMessageCmd06 message = (EBikeMessageCmd06) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
|
EBikeMessageCmd06 message = new EBikeMessageCmd06(dataProtocol.getBytes());
|
||||||
// 保存时间
|
// 保存时间
|
||||||
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
||||||
|
|
||||||
EBikeMessageCmd06.PowerHeartbeat powerHeartbeat = message.getPowerHeartbeat();
|
|
||||||
log.info("端口充电时功率心跳包:{}", JSON.toJSONString(message));
|
log.info("端口充电时功率心跳包:{}", JSON.toJSONString(message));
|
||||||
|
|
||||||
// 更新枪口状态
|
// 更新枪口状态
|
||||||
updatePileStatus(message);
|
updatePileStatus(message);
|
||||||
|
|
||||||
// 保存实时监控数据
|
// 保存实时监控数据
|
||||||
saveRealTimeMonitorData(message);
|
saveRealTimeMonitorData(message);
|
||||||
|
|
||||||
return getResult(dataProtocol, Constants.zeroByteArray);
|
return getResult(dataProtocol, Constants.zeroByteArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,16 +62,15 @@ public class PowerHeartbeatHandler extends AbstractEBikeHandler {
|
|||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
private void saveRealTimeMonitorData(EBikeMessageCmd06 message) {
|
private void saveRealTimeMonitorData(EBikeMessageCmd06 message) {
|
||||||
EBikeMessageCmd06.PowerHeartbeat powerHeartbeat = message.getPowerHeartbeat();
|
|
||||||
// 组装数据
|
// 组装数据
|
||||||
RealTimeMonitorData realTimeMonitorData = new RealTimeMonitorData();
|
RealTimeMonitorData realTimeMonitorData = new RealTimeMonitorData();
|
||||||
realTimeMonitorData.setPileSn(message.getPhysicalId() + "");
|
realTimeMonitorData.setPileSn(message.getPhysicalId() + "");
|
||||||
realTimeMonitorData.setConnectorCode(powerHeartbeat.getPort());
|
realTimeMonitorData.setConnectorCode(message.getPort());
|
||||||
realTimeMonitorData.setPileConnectorCode(realTimeMonitorData.getPileSn() + realTimeMonitorData.getConnectorCode());
|
realTimeMonitorData.setPileConnectorCode(realTimeMonitorData.getPileSn() + realTimeMonitorData.getConnectorCode());
|
||||||
realTimeMonitorData.setTransactionCode(powerHeartbeat.getOrderCode());
|
realTimeMonitorData.setTransactionCode(message.getOrderCode());
|
||||||
realTimeMonitorData.setConnectorStatus(powerHeartbeat.getPortStatus());
|
realTimeMonitorData.setConnectorStatus(message.getPortStatus());
|
||||||
realTimeMonitorData.setOutputVoltage(powerHeartbeat.getVoltage());
|
realTimeMonitorData.setOutputVoltage(message.getVoltage());
|
||||||
realTimeMonitorData.setOutputCurrent(powerHeartbeat.getCurrent());
|
realTimeMonitorData.setOutputCurrent(message.getCurrent());
|
||||||
// realTimeMonitorData.setOutputPower("");
|
// realTimeMonitorData.setOutputPower("");
|
||||||
realTimeMonitorData.setDateTime(DateUtils.getDateTime());
|
realTimeMonitorData.setDateTime(DateUtils.getDateTime());
|
||||||
|
|
||||||
@@ -90,9 +83,8 @@ public class PowerHeartbeatHandler extends AbstractEBikeHandler {
|
|||||||
*/
|
*/
|
||||||
private void updatePileStatus(EBikeMessageCmd06 message) {
|
private void updatePileStatus(EBikeMessageCmd06 message) {
|
||||||
String pileSn = message.getPhysicalId() + "";
|
String pileSn = message.getPhysicalId() + "";
|
||||||
EBikeMessageCmd06.PowerHeartbeat powerHeartbeat = message.getPowerHeartbeat();
|
String connectorCode = message.getPort();
|
||||||
String connectorCode = powerHeartbeat.getPort();
|
String portStatus = message.getPortStatus();
|
||||||
String portStatus = powerHeartbeat.getPortStatus();
|
|
||||||
pileConnectorInfoService.updateConnectorStatus(pileSn + connectorCode, PortStatusEnum.eBikeStatusTransformDBStatus(portStatus));
|
pileConnectorInfoService.updateConnectorStatus(pileSn + connectorCode, PortStatusEnum.eBikeStatusTransformDBStatus(portStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.jsowell.common.constant.Constants;
|
|||||||
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
|
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
|
||||||
import com.jsowell.common.util.YKCUtils;
|
import com.jsowell.common.util.YKCUtils;
|
||||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd20;
|
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd20;
|
||||||
import com.jsowell.pile.service.PileBasicInfoService;
|
import com.jsowell.pile.service.PileBasicInfoService;
|
||||||
@@ -41,10 +40,9 @@ public class RegistrationHandler extends AbstractEBikeHandler {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
||||||
// 解析字节数组
|
// 解析字节数组
|
||||||
EBikeMessageCmd20 message = (EBikeMessageCmd20) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
|
EBikeMessageCmd20 message = new EBikeMessageCmd20(dataProtocol.getBytes());
|
||||||
// 保存时间
|
// 保存时间
|
||||||
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
||||||
EBikeMessageCmd20.DeviceRegister deviceRegister = message.getDeviceRegister();
|
|
||||||
log.info("设备注册包:{}", JSON.toJSONString(message));
|
log.info("设备注册包:{}", JSON.toJSONString(message));
|
||||||
pileBasicInfoService.registrationEBikePile(message);
|
pileBasicInfoService.registrationEBikePile(message);
|
||||||
return getResult(dataProtocol, Constants.zeroByteArray);
|
return getResult(dataProtocol, Constants.zeroByteArray);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.jsowell.common.util.YKCUtils;
|
|||||||
import com.jsowell.common.util.id.IdUtils;
|
import com.jsowell.common.util.id.IdUtils;
|
||||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd03;
|
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd03;
|
||||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||||
@@ -58,13 +57,11 @@ public class SettlementUploadHandler extends AbstractEBikeHandler {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
|
||||||
// 解析字节数组
|
// 解析字节数组
|
||||||
EBikeMessageCmd03 message = (EBikeMessageCmd03) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
|
EBikeMessageCmd03 message = new EBikeMessageCmd03(dataProtocol.getBytes());
|
||||||
// 保存时间
|
// 保存时间
|
||||||
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
||||||
EBikeMessageCmd03.SettlementInfo settlementInfo = message.getSettlementInfo();
|
|
||||||
log.info("结算消费信息上传:{}", JSON.toJSONString(message));
|
log.info("结算消费信息上传:{}", JSON.toJSONString(message));
|
||||||
|
String transactionCode = message.getOrderNumber();
|
||||||
String transactionCode = settlementInfo.getOrderNumber();
|
|
||||||
// 处理订单加锁/结算电单车订单
|
// 处理订单加锁/结算电单车订单
|
||||||
String lockKey = "settle_order_" + transactionCode;
|
String lockKey = "settle_order_" + transactionCode;
|
||||||
String uuid = IdUtils.fastUUID();
|
String uuid = IdUtils.fastUUID();
|
||||||
@@ -81,7 +78,6 @@ public class SettlementUploadHandler extends AbstractEBikeHandler {
|
|||||||
redisCache.unLock(lockKey);
|
redisCache.unLock(lockKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回结果
|
// 返回结果
|
||||||
return getResult(dataProtocol, Constants.zeroByteArray);
|
return getResult(dataProtocol, Constants.zeroByteArray);
|
||||||
}
|
}
|
||||||
@@ -90,13 +86,12 @@ public class SettlementUploadHandler extends AbstractEBikeHandler {
|
|||||||
* 收到交易记录 处理订单
|
* 收到交易记录 处理订单
|
||||||
*/
|
*/
|
||||||
private void processOrder(EBikeMessageCmd03 message) {
|
private void processOrder(EBikeMessageCmd03 message) {
|
||||||
EBikeMessageCmd03.SettlementInfo settlementInfo = message.getSettlementInfo();
|
String transactionCode = message.getOrderNumber();
|
||||||
String transactionCode = settlementInfo.getOrderNumber();
|
|
||||||
// 根据交易流水号查询订单信息
|
// 根据交易流水号查询订单信息
|
||||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode);
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode);
|
||||||
if (orderBasicInfo != null) {
|
if (orderBasicInfo != null) {
|
||||||
// 平台存在订单
|
// 平台存在订单
|
||||||
int stopReason = settlementInfo.getStopReason();
|
int stopReason = message.getStopReason();
|
||||||
orderBasicInfo.setReason(EBikeChargingStopReasonEnum.getMsgByCode(stopReason));
|
orderBasicInfo.setReason(EBikeChargingStopReasonEnum.getMsgByCode(stopReason));
|
||||||
// 如果订单状态为 异常,则改为 待结算
|
// 如果订单状态为 异常,则改为 待结算
|
||||||
if (StringUtils.equals(OrderStatusEnum.ABNORMAL.getValue(), orderBasicInfo.getOrderStatus())) {
|
if (StringUtils.equals(OrderStatusEnum.ABNORMAL.getValue(), orderBasicInfo.getOrderStatus())) {
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
package com.jsowell.pile.domain.ebike;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.jsowell.common.YouDianUtils;
|
|
||||||
import com.jsowell.common.util.BytesUtil;
|
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.*;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class AbsEBikeMessage {
|
|
||||||
protected String header; // 包头 (3字节)
|
|
||||||
protected int length; // 长度 (2字节)
|
|
||||||
protected int physicalId; // 物理ID (4字节)
|
|
||||||
protected int messageId; // 消息ID (2字节)
|
|
||||||
protected String command; // 命令 (1字节)
|
|
||||||
protected Object payload; // 数据 (n字节)
|
|
||||||
protected int checksum; // 校验 (2字节)
|
|
||||||
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
private static AbsEBikeMessage createMessageInstance(String command, String header, int length, int physicalId, int messageId, int checksum, byte[] dataBytes) {
|
|
||||||
switch (command) {
|
|
||||||
case "02":
|
|
||||||
return new EBikeMessageCmd02(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd02.CreditCardInfo(dataBytes));
|
|
||||||
case "03":
|
|
||||||
return new EBikeMessageCmd03(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd03.SettlementInfo(dataBytes));
|
|
||||||
case "04":
|
|
||||||
return new EBikeMessageCmd04(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd04.ConfirmOrder(dataBytes));
|
|
||||||
case "06":
|
|
||||||
return new EBikeMessageCmd06(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd06.PowerHeartbeat(dataBytes));
|
|
||||||
case "12":
|
|
||||||
return new EBikeMessageCmd12(header, length, physicalId, messageId, command, null, checksum);
|
|
||||||
case "20":
|
|
||||||
return new EBikeMessageCmd20(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd20.DeviceRegister(dataBytes));
|
|
||||||
case "21":
|
|
||||||
return new EBikeMessageCmd21(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd21.DeviceHeartbeat(dataBytes));
|
|
||||||
case "22":
|
|
||||||
return new EBikeMessageCmd22(header, length, physicalId, messageId, command, null, checksum);
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unsupported command: " + command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AbsEBikeMessage parseMessage(byte[] messageBytes) {
|
|
||||||
if (messageBytes == null || messageBytes.length < 14 || messageBytes.length > 256) {
|
|
||||||
throw new IllegalArgumentException("Invalid message bytes");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 读取包头
|
|
||||||
byte[] headerBytes = Arrays.copyOfRange(messageBytes, 0, 3);
|
|
||||||
String header = new String(headerBytes, StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
// 读取长度
|
|
||||||
byte[] lengthBytes = Arrays.copyOfRange(messageBytes, 3, 5);
|
|
||||||
int length = BytesUtil.bytesToIntLittle(lengthBytes);
|
|
||||||
|
|
||||||
// 验证长度
|
|
||||||
if (length != (messageBytes.length - 5)) {
|
|
||||||
throw new IllegalArgumentException("Invalid message length");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 读取物理ID
|
|
||||||
byte[] physicalIdBytes = Arrays.copyOfRange(messageBytes, 5, 9);
|
|
||||||
int physicalId = YouDianUtils.convertToPhysicalId(physicalIdBytes);
|
|
||||||
|
|
||||||
// 读取消息ID
|
|
||||||
byte[] messageIdBytes = Arrays.copyOfRange(messageBytes, 9, 11);
|
|
||||||
int messageId = BytesUtil.bytesToIntLittle(messageIdBytes);
|
|
||||||
|
|
||||||
// 读取命令
|
|
||||||
byte commandByte = messageBytes[11];
|
|
||||||
String command = BytesUtil.bcd2StrLittle(new byte[]{commandByte});
|
|
||||||
|
|
||||||
// 读取数据
|
|
||||||
byte[] dataBytes = Arrays.copyOfRange(messageBytes, 12, messageBytes.length - 2);
|
|
||||||
|
|
||||||
// 读取校验
|
|
||||||
byte[] checksumBytes = Arrays.copyOfRange(messageBytes, messageBytes.length - 2, messageBytes.length);
|
|
||||||
int checksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
|
||||||
|
|
||||||
// 根据命令创建相应的子类实例
|
|
||||||
AbsEBikeMessage parsedMessage = createMessageInstance(command, header, length, physicalId, messageId, checksum, dataBytes);
|
|
||||||
parsedMessage.parsePayload(dataBytes);
|
|
||||||
|
|
||||||
return parsedMessage;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new IllegalArgumentException("Error parsing message", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String s = "444e593200198bca0782000600018e030700015a0b6b0b190b480b1327388101240913141035606593918397006e0b73083f055f002d0b";
|
|
||||||
String msg82 = "44 4E 59 26 00 3B 37 AB 04 02 00 82 00 64 01 00 00 01 01 00 00 12 34 56 78 12 34 56 78 12 34 56 78 12 34 56 78 80 70 88 13 F8 08";
|
|
||||||
s = s.replace(" ", "");
|
|
||||||
byte[] messageBytes = BytesUtil.hexStringToByteArray(s);
|
|
||||||
AbsEBikeMessage absEBikeMessage = parseMessage(messageBytes);
|
|
||||||
System.out.println(JSON.toJSONString(absEBikeMessage));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -68,4 +68,8 @@ public class AbsEBikeMessage2 {
|
|||||||
byte[] checksumBytes = Arrays.copyOfRange(messageBytes, messageBytes.length - 2, messageBytes.length);
|
byte[] checksumBytes = Arrays.copyOfRange(messageBytes, messageBytes.length - 2, messageBytes.length);
|
||||||
this.checksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
this.checksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] getMessageBytes() {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public enum EBikeCommandEnum {
|
|||||||
REMOTE_CONTROL_COMMAND(0x82, "服务器开始、停止充电操作", EBikeMessageCmd82.class),
|
REMOTE_CONTROL_COMMAND(0x82, "服务器开始、停止充电操作", EBikeMessageCmd82.class),
|
||||||
;
|
;
|
||||||
|
|
||||||
EBikeCommandEnum(int code, String desc, Class<? extends AbsEBikeMessage> msgClass) {
|
EBikeCommandEnum(int code, String desc, Class<? extends AbsEBikeMessage2> msgClass) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.msgClass = msgClass;
|
this.msgClass = msgClass;
|
||||||
@@ -32,7 +32,7 @@ public enum EBikeCommandEnum {
|
|||||||
|
|
||||||
private final int code; // 帧类型code
|
private final int code; // 帧类型code
|
||||||
private final String desc; // 帧类型名称
|
private final String desc; // 帧类型名称
|
||||||
private final Class<? extends AbsEBikeMessage> msgClass;
|
private final Class<? extends AbsEBikeMessage2> msgClass;
|
||||||
|
|
||||||
public int getCode() {
|
public int getCode() {
|
||||||
return code;
|
return code;
|
||||||
@@ -42,7 +42,7 @@ public enum EBikeCommandEnum {
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends AbsEBikeMessage> getMsgClass() {
|
public Class<? extends AbsEBikeMessage2> getMsgClass() {
|
||||||
return msgClass;
|
return msgClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
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)) + "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
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)) + "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
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)) + "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
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 {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
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 {
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
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=RN8209,1=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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
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 + "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
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 {
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
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 Cmd35 extends AbsEBikeMessage2 {
|
|
||||||
}
|
|
||||||
@@ -1,43 +1,18 @@
|
|||||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷卡操作(02指令)
|
* 刷卡操作(02指令)
|
||||||
* 特别注意:上报的端口号如果不是FF为端口请求充电,服务器需应答刷卡指令后,如果服务器需要给当前端口启动充电的,需要下发82指令来启动充电
|
|
||||||
* CreditCard
|
|
||||||
*/
|
*/
|
||||||
public class EBikeMessageCmd02 extends AbsEBikeMessage {
|
@Getter
|
||||||
|
@Setter
|
||||||
private CreditCardInfo creditCardInfo;
|
@ToString(callSuper = true)
|
||||||
|
public class EBikeMessageCmd02 extends AbsEBikeMessage2 {
|
||||||
public EBikeMessageCmd02(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum, CreditCardInfo creditCardInfo) {
|
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
|
||||||
this.creditCardInfo = creditCardInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
this.creditCardInfo = new CreditCardInfo(dataBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CreditCardInfo getCreditCardInfo() {
|
|
||||||
return creditCardInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public static class CreditCardInfo {
|
|
||||||
/**
|
/**
|
||||||
* 卡片ID
|
* 卡片ID
|
||||||
*/
|
*/
|
||||||
@@ -73,29 +48,34 @@ public class EBikeMessageCmd02 extends AbsEBikeMessage {
|
|||||||
*/
|
*/
|
||||||
private String card2Code;
|
private String card2Code;
|
||||||
|
|
||||||
public CreditCardInfo(byte[] dataBytes) {
|
public EBikeMessageCmd02(byte[] messageBytes) {
|
||||||
int startIndex = 0;
|
super(messageBytes);
|
||||||
|
|
||||||
|
int startIndex = 12;
|
||||||
int length = 4;
|
int length = 4;
|
||||||
this.cardId = BytesUtil.bcd2Str(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.cardId = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.cardType = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.cardType = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.cardBalance = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.cardBalance = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
// length = 4;
|
// length = 4;
|
||||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||||
|
|
||||||
if (dataBytes.length > startIndex) {
|
if (messageBytes.length > startIndex) {
|
||||||
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
card2Length = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
card2Length = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
this.card2Code = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, card2Length)) + "";
|
this.card2Code = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,37 +2,15 @@ package com.jsowell.pile.domain.ebike.deviceupload;
|
|||||||
|
|
||||||
import com.jsowell.common.YouDianUtils;
|
import com.jsowell.common.YouDianUtils;
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
/**
|
@Getter
|
||||||
* 结算消费信息上传(03指令)
|
@Setter
|
||||||
*/
|
@ToString(callSuper = true)
|
||||||
public class EBikeMessageCmd03 extends AbsEBikeMessage {
|
public class EBikeMessageCmd03 extends AbsEBikeMessage2 {
|
||||||
|
|
||||||
private SettlementInfo settlementInfo;
|
|
||||||
|
|
||||||
public EBikeMessageCmd03(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum, SettlementInfo settlementInfo) {
|
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
|
||||||
this.settlementInfo = settlementInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
this.settlementInfo = new SettlementInfo(dataBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public SettlementInfo getSettlementInfo() {
|
|
||||||
return settlementInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class SettlementInfo {
|
|
||||||
private int chargingTime; // 充电时长, 单位:"秒"
|
private int chargingTime; // 充电时长, 单位:"秒"
|
||||||
private int maxPower; // 最大功率, 单位:"0.1W"
|
private int maxPower; // 最大功率, 单位:"0.1W"
|
||||||
private int consumedEnergy; // 耗电量, 单位:"0.01度"
|
private int consumedEnergy; // 耗电量, 单位:"0.01度"
|
||||||
@@ -45,46 +23,46 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage {
|
|||||||
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||||
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
|
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
|
||||||
|
|
||||||
public SettlementInfo(byte[] dataBytes) {
|
public EBikeMessageCmd03(byte[] messageBytes) {
|
||||||
int startIndex = 0;
|
super(messageBytes);
|
||||||
|
|
||||||
|
int startIndex = 12;
|
||||||
int length = 2;
|
int length = 2;
|
||||||
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.maxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.maxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.consumedEnergy = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.consumedEnergy = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
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;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 4;
|
length = 4;
|
||||||
this.cardNumberOrVerificationCode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.cardNumberOrVerificationCode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.stopReason = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.stopReason = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 16;
|
length = 16;
|
||||||
this.orderNumber = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.orderNumber = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.secondMaxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.secondMaxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 31, 35)) + "";
|
|
||||||
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 35, 37)) + "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 31, 35)) + "";
|
||||||
|
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 35, 37)) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,15 @@
|
|||||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Arrays;
|
@Getter
|
||||||
|
@Setter
|
||||||
/**
|
@ToString(callSuper = true)
|
||||||
* 充电端口订单确认(04指令)
|
public class EBikeMessageCmd04 extends AbsEBikeMessage2 {
|
||||||
* 这是老版本指令,和06相对应,有06指令时无此命令(2019年6月份后生产的机型已无此指令)
|
|
||||||
*/
|
|
||||||
public class EBikeMessageCmd04 extends AbsEBikeMessage {
|
|
||||||
|
|
||||||
private ConfirmOrder confirmOrder;
|
|
||||||
|
|
||||||
public EBikeMessageCmd04(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum, ConfirmOrder confirmOrder) {
|
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
|
||||||
this.confirmOrder = confirmOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
this.confirmOrder = new ConfirmOrder(dataBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmOrder getSettlementInfo() {
|
|
||||||
return confirmOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class ConfirmOrder {
|
|
||||||
/**
|
/**
|
||||||
* 端口号
|
* 端口号
|
||||||
*/
|
*/
|
||||||
@@ -60,12 +35,27 @@ public class EBikeMessageCmd04 extends AbsEBikeMessage {
|
|||||||
*/
|
*/
|
||||||
private String orderCode;
|
private String orderCode;
|
||||||
|
|
||||||
public ConfirmOrder(byte[] dataBytes) {
|
public EBikeMessageCmd04(byte[] messageBytes) {
|
||||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 1)) + "";
|
super(messageBytes);
|
||||||
this.startMode = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 1, 2)) + "";
|
|
||||||
this.cardId = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 6)) + "";
|
int startIndex = 12;
|
||||||
this.chargingTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 6, 8)) + "";
|
int length = 1;
|
||||||
this.orderCode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 8, 24));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,46 +2,17 @@ package com.jsowell.pile.domain.ebike.deviceupload;
|
|||||||
|
|
||||||
import com.jsowell.common.YouDianUtils;
|
import com.jsowell.common.YouDianUtils;
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
@Getter
|
||||||
* 端口充电时功率心跳包(06指令)
|
@Setter
|
||||||
* 这是新版本指令,和04相对应,有04指令时无此命令
|
@ToString(callSuper = true)
|
||||||
* 此命令设备开始充电后(82命令应答后)每隔设5分钟发送1次(无重发机制), 充电结束后即停止发送
|
public class EBikeMessageCmd06 extends AbsEBikeMessage2 {
|
||||||
*/
|
|
||||||
public class EBikeMessageCmd06 extends AbsEBikeMessage {
|
|
||||||
|
|
||||||
private PowerHeartbeat powerHeartbeat;
|
|
||||||
|
|
||||||
public EBikeMessageCmd06(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum, PowerHeartbeat powerHeartbeat) {
|
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
|
||||||
this.powerHeartbeat = powerHeartbeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
this.powerHeartbeat = new PowerHeartbeat(dataBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public PowerHeartbeat getPowerHeartbeat() {
|
|
||||||
return powerHeartbeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 功率心跳包
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public static class PowerHeartbeat {
|
|
||||||
/**
|
/**
|
||||||
* 端口号:当前充电的端口号。注:00表示1号端口,01表示2号端口; port+1为实际端口
|
* 端口号:当前充电的端口号。注:00表示1号端口,01表示2号端口; port+1为实际端口
|
||||||
*/
|
*/
|
||||||
@@ -132,87 +103,85 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
|
|||||||
*/
|
*/
|
||||||
private String occupancyTime;
|
private String occupancyTime;
|
||||||
|
|
||||||
|
public EBikeMessageCmd06(byte[] messageBytes) {
|
||||||
|
super(messageBytes);
|
||||||
|
|
||||||
public PowerHeartbeat(byte[] dataBytes) {
|
int startIndex = 12;
|
||||||
int startIndex = 0;
|
|
||||||
int length = 1;
|
int length = 1;
|
||||||
this.port = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)));
|
this.port = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
// this.portStatus = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.portStatus = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
this.portStatus = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.totalUsedElectricity = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.totalUsedElectricity = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.01")).toString();
|
.multiply(new BigDecimal("0.01")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.realTimePower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.realTimePower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.1")).toString();
|
.multiply(new BigDecimal("0.1")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.maxPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.maxPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.1")).toString();
|
.multiply(new BigDecimal("0.1")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.minPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.minPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.1")).toString();
|
.multiply(new BigDecimal("0.1")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.avgPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.avgPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.1")).toString();
|
.multiply(new BigDecimal("0.1")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 16;
|
length = 16;
|
||||||
this.orderCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.orderCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.timePeriodElectricity = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
this.timePeriodElectricity = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.peakPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.peakPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.1")).toString();
|
.multiply(new BigDecimal("0.1")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.voltage = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.voltage = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.1")).toString();
|
.multiply(new BigDecimal("0.1")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.current = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.current = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.multiply(new BigDecimal("0.001")).toString();
|
.multiply(new BigDecimal("0.001")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.ambientTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.ambientTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.subtract(new BigDecimal("65")).toString();
|
.subtract(new BigDecimal("65")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.portTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
this.portTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||||
.subtract(new BigDecimal("65")).toString();
|
.subtract(new BigDecimal("65")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.occupancyTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
this.occupancyTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,16 @@
|
|||||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
public class EBikeMessageCmd11 extends AbsEBikeMessage {
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class EBikeMessageCmd11 extends AbsEBikeMessage2 {
|
||||||
|
|
||||||
|
public EBikeMessageCmd11(byte[] messageBytes) {
|
||||||
|
super(messageBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,16 @@
|
|||||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
import com.jsowell.common.util.bean.SerializationUtil;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
/**
|
|
||||||
* 主机获取服务器时间(0x12)
|
|
||||||
* 此命令主机每次上电后就会发送,直至服务器应答后就停止发送。如服务器无应答,则每隔3分钟发送一次请求
|
|
||||||
* 每12小时从服务器获取一次时间,如服务器不应答则每隔3分钟发送一次请求
|
|
||||||
* 不带RTC模块的主机不会发送此命令
|
|
||||||
* DE 5C A9 5F,转小端模式,=0x5FA95CDE=1604934878=2020-11-09 23:14:38
|
|
||||||
*/
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class EBikeMessageCmd12 extends AbsEBikeMessage {
|
@ToString(callSuper = true)
|
||||||
|
public class EBikeMessageCmd12 extends AbsEBikeMessage2 {
|
||||||
|
|
||||||
public EBikeMessageCmd12(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum) {
|
public EBikeMessageCmd12(byte[] messageBytes) {
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
super(messageBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
byte[] serialize = SerializationUtil.serialize(this);
|
|
||||||
return serialize;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,39 +1,17 @@
|
|||||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
@Getter
|
||||||
* 设备注册包(20指令)
|
@Setter
|
||||||
*/
|
@ToString(callSuper = true)
|
||||||
public class EBikeMessageCmd20 extends AbsEBikeMessage {
|
public class EBikeMessageCmd20 extends AbsEBikeMessage2 {
|
||||||
|
|
||||||
private DeviceRegister deviceRegister;
|
|
||||||
|
|
||||||
public EBikeMessageCmd20(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum, DeviceRegister deviceRegister) {
|
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
|
||||||
this.deviceRegister = deviceRegister;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
this.deviceRegister = new DeviceRegister(dataBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceRegister getDeviceRegister() {
|
|
||||||
return deviceRegister;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class DeviceRegister {
|
|
||||||
/**
|
/**
|
||||||
* 固件版本,如100则表示V1.00版本
|
* 固件版本,如100则表示V1.00版本
|
||||||
*/
|
*/
|
||||||
@@ -64,15 +42,32 @@ public class EBikeMessageCmd20 extends AbsEBikeMessage {
|
|||||||
*/
|
*/
|
||||||
private String powerBoardVersion;
|
private String powerBoardVersion;
|
||||||
|
|
||||||
public DeviceRegister(byte[] dataBytes) {
|
public EBikeMessageCmd20(byte[] messageBytes) {
|
||||||
this.firmwareVersion = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) * 0.01 + "";
|
super(messageBytes);
|
||||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 3));
|
|
||||||
this.virtualId = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 3, 4)) + "";
|
|
||||||
this.deviceType = BytesUtil.printHexBinary(Arrays.copyOfRange(dataBytes, 4, 5));
|
|
||||||
this.workMode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 5, 6));
|
|
||||||
this.powerBoardVersion = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 6, 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,44 +3,18 @@ package com.jsowell.pile.domain.ebike.deviceupload;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.jsowell.common.enums.ebike.PortStatusEnum;
|
import com.jsowell.common.enums.ebike.PortStatusEnum;
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备注册包(20指令)
|
|
||||||
*/
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class EBikeMessageCmd21 extends AbsEBikeMessage {
|
@ToString(callSuper = true)
|
||||||
|
public class EBikeMessageCmd21 extends AbsEBikeMessage2 {
|
||||||
private DeviceHeartbeat deviceHeartbeat;
|
|
||||||
|
|
||||||
public EBikeMessageCmd21(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum, DeviceHeartbeat deviceHeartbeat) {
|
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
|
||||||
this.deviceHeartbeat = deviceHeartbeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
this.deviceHeartbeat = new DeviceHeartbeat(dataBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 此为心跳包,间隔时间默认为3分钟,方便服务器管理SocketIP
|
|
||||||
* 设备如2次收不到服务器应答,则进入离线状态
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public static class DeviceHeartbeat {
|
|
||||||
/**
|
/**
|
||||||
* 电压:设备的当前电压(打包发送心跳包指令时的当前时间点的实时电压)
|
* 电压:设备的当前电压(打包发送心跳包指令时的当前时间点的实时电压)
|
||||||
* 2024年8月26日15点02分 已经转为标准单位V
|
* 2024年8月26日15点02分 已经转为标准单位V
|
||||||
@@ -75,11 +49,23 @@ public class EBikeMessageCmd21 extends AbsEBikeMessage {
|
|||||||
private String temperature;
|
private String temperature;
|
||||||
|
|
||||||
|
|
||||||
public DeviceHeartbeat(byte[] dataBytes) {
|
public EBikeMessageCmd21(byte[] messageBytes) {
|
||||||
this.voltage = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) * 0.1 + "";
|
super(messageBytes);
|
||||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 3));
|
|
||||||
|
|
||||||
byte[] statusBytes = BytesUtil.copyBytes(dataBytes, 3, this.portNumber);
|
// 读取结果
|
||||||
|
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> statusList = Lists.newArrayList();
|
||||||
List<String> statusDescList = Lists.newArrayList();
|
List<String> statusDescList = Lists.newArrayList();
|
||||||
for (byte statusByte : statusBytes) {
|
for (byte statusByte : statusBytes) {
|
||||||
@@ -89,14 +75,17 @@ public class EBikeMessageCmd21 extends AbsEBikeMessage {
|
|||||||
}
|
}
|
||||||
this.portStatus = statusList;
|
this.portStatus = statusList;
|
||||||
this.statusDescList = statusDescList;
|
this.statusDescList = statusDescList;
|
||||||
this.rssi = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, dataBytes.length - 2, dataBytes.length - 1)) + "";
|
|
||||||
//
|
startIndex += length;
|
||||||
int i = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, dataBytes.length - 1, dataBytes.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) {
|
if (i > 65) {
|
||||||
i = i - 65;
|
i = i - 65;
|
||||||
}
|
}
|
||||||
this.temperature = i + "";
|
this.temperature = i + "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,32 +1,16 @@
|
|||||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
import com.jsowell.common.util.bean.SerializationUtil;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备获取服务器时间(22指令)
|
|
||||||
* 此命令设备每次上电后就会发送,直至服务器应答后就停止发送。如服务器无应答,则每隔3分钟发送一次请求
|
|
||||||
* 每12小时从服务器获取一次时间,如服务器不应答则每隔3分钟发送一次请求
|
|
||||||
*/
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class EBikeMessageCmd22 extends AbsEBikeMessage {
|
@ToString(callSuper = true)
|
||||||
|
public class EBikeMessageCmd22 extends AbsEBikeMessage2 {
|
||||||
|
|
||||||
public EBikeMessageCmd22(String header, int length, int physicalId, int messageId, String command, Object payload, int checksum) {
|
public EBikeMessageCmd22(byte[] messageBytes) {
|
||||||
super(header, length, physicalId, messageId, command, payload, checksum);
|
super(messageBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
byte[] serialize = SerializationUtil.serialize(this);
|
|
||||||
return serialize;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,15 @@
|
|||||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
|
import lombok.Getter;
|
||||||
public class EBikeMessageCmd35 extends AbsEBikeMessage {
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class EBikeMessageCmd35 extends AbsEBikeMessage2 {
|
||||||
|
public EBikeMessageCmd35(byte[] messageBytes) {
|
||||||
|
super(messageBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,16 @@
|
|||||||
package com.jsowell.pile.domain.ebike.serversend;
|
package com.jsowell.pile.domain.ebike.serversend;
|
||||||
|
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备联网状态(81指令)
|
* 查询设备联网状态(81指令)
|
||||||
* 注1、此命令应用于注册网络后,通信过程中,服务器主动查询设备状态
|
* 注1、此命令应用于注册网络后,通信过程中,服务器主动查询设备状态
|
||||||
* 注2、此命令会触发设备发送“注册包”20、“设备心跳包”01和21指令(上发时间会因设备不同而不同)
|
* 注2、此命令会触发设备发送“注册包”20、“设备心跳包”01和21指令(上发时间会因设备不同而不同)
|
||||||
*/
|
*/
|
||||||
public class EBikeMessageCmd81 extends AbsEBikeMessage {
|
public class EBikeMessageCmd81 extends AbsEBikeMessage2 {
|
||||||
|
|
||||||
@Override
|
public EBikeMessageCmd81(byte[] messageBytes) {
|
||||||
public void parsePayload(byte[] dataBytes) {
|
super(messageBytes);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
return new byte[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,12 @@ package com.jsowell.pile.domain.ebike.serversend;
|
|||||||
|
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
import com.jsowell.common.YouDianUtils;
|
import com.jsowell.common.YouDianUtils;
|
||||||
import com.jsowell.common.constant.Constants;
|
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import lombok.*;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
import java.util.Arrays;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.avro.specific.SpecificData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器开始、停止充电操作(82指令)
|
* 服务器开始、停止充电操作(82指令)
|
||||||
@@ -15,53 +15,10 @@ import java.util.Arrays;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class EBikeMessageCmd82 extends AbsEBikeMessage {
|
public class EBikeMessageCmd82 extends AbsEBikeMessage2 {
|
||||||
|
|
||||||
private SpecificData data;
|
private SpecificData data;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parsePayload(byte[] dataBytes) {
|
|
||||||
this.data = new SpecificData(dataBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
int i = 0x82;
|
|
||||||
byte[] commandBytes = new byte[]{(byte) i};
|
|
||||||
System.out.println(BytesUtil.bcd2StrLittle(commandBytes));
|
|
||||||
int i2 = 82;
|
|
||||||
byte[] commandBytes2 = new byte[]{(byte) i2};
|
|
||||||
System.out.println(BytesUtil.bcd2StrLittle(commandBytes2));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getMessageBytes() {
|
|
||||||
// 包头
|
|
||||||
byte[] headerBytes = BytesUtil.stringToHexBytes(Constants.EBIKE_HEADER, 3);
|
|
||||||
// 物理ID
|
|
||||||
byte[] physicalIdBytes = YouDianUtils.getPhysicalIdBytes(physicalId);
|
|
||||||
// 消息ID
|
|
||||||
byte[] messageIdBytes = BytesUtil.intToBytesLittle(messageId, 2);
|
|
||||||
// 命令
|
|
||||||
byte[] commandBytes = new byte[]{(byte) 0x82};
|
|
||||||
// 数据
|
|
||||||
byte[] payloadBytes = data.getBytes();
|
|
||||||
// 长度 物理ID+消息ID+命令+数据(n) +校验(2),每包最多256字节
|
|
||||||
byte[] lengthBytes = BytesUtil.intToBytesLittle(9 + payloadBytes.length);
|
|
||||||
// 拼接
|
|
||||||
byte[] concat = Bytes.concat(headerBytes, lengthBytes, physicalIdBytes, messageIdBytes, commandBytes, payloadBytes);
|
|
||||||
// 校验和
|
|
||||||
byte[] checksumBytes = YouDianUtils.getCheckFieldBytes(concat);
|
|
||||||
return Bytes.concat(concat, checksumBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpecificData getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
public static class SpecificData {
|
|
||||||
// 费率模式:=0计时,=1包月,=2计量,=3计次。包月、计次默认充满自停,计时、计量可手动设置时长和电量
|
// 费率模式:=0计时,=1包月,=2计量,=3计次。包月、计次默认充满自停,计时、计量可手动设置时长和电量
|
||||||
private int rateMode; // 费率模式 (1字节)
|
private int rateMode; // 费率模式 (1字节)
|
||||||
|
|
||||||
@@ -98,58 +55,77 @@ public class EBikeMessageCmd82 extends AbsEBikeMessage {
|
|||||||
private int fullChargePower; // 充满功率 (1字节)
|
private int fullChargePower; // 充满功率 (1字节)
|
||||||
private int maxFullChargePowerCheckTime; // 充满功率最长判断时间 (1字节)
|
private int maxFullChargePowerCheckTime; // 充满功率最长判断时间 (1字节)
|
||||||
|
|
||||||
public SpecificData(byte[] dataBytes) {
|
|
||||||
byte rateModeBytes = dataBytes[0];
|
|
||||||
this.rateMode = BytesUtil.bytesToIntLittle(new byte[]{rateModeBytes});
|
|
||||||
|
|
||||||
byte[] balanceOrValidityBytes = Arrays.copyOfRange(dataBytes, 1, 5);
|
public EBikeMessageCmd82(byte[] messageBytes) {
|
||||||
this.balanceOrValidity = BytesUtil.bytesToIntLittle(balanceOrValidityBytes);
|
super(messageBytes);
|
||||||
|
|
||||||
byte portNumberBytes = dataBytes[5];
|
int startIndex = 12;
|
||||||
this.portNumber = BytesUtil.bytesToIntLittle(new byte[]{portNumberBytes});
|
int length = 1;
|
||||||
|
this.rateMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte chargeCommandBytes = dataBytes[6];
|
startIndex += length;
|
||||||
this.chargeCommand = BytesUtil.bytesToIntLittle(new byte[]{chargeCommandBytes});
|
length = 4;
|
||||||
|
this.balanceOrValidity = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte[] chargeDurationOrPowerBytes = Arrays.copyOfRange(dataBytes, 7, 9);
|
startIndex += length;
|
||||||
this.chargeTimeOrPower = BytesUtil.bytesToIntLittle(chargeDurationOrPowerBytes);
|
length = 1;
|
||||||
|
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte[] orderNumberBytes = Arrays.copyOfRange(dataBytes, 9, 25);
|
startIndex += length;
|
||||||
this.transactionCode = BytesUtil.bcd2StrLittle(orderNumberBytes);
|
length = 1;
|
||||||
|
this.chargeCommand = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte[] maxChargeDurationBytes = Arrays.copyOfRange(dataBytes, 25, 27);
|
startIndex += length;
|
||||||
this.maxChargeTime = BytesUtil.bytesToIntLittle(maxChargeDurationBytes);
|
length = 2;
|
||||||
|
this.chargeTimeOrPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte[] overloadPowerBytes = Arrays.copyOfRange(dataBytes, 27, 29);
|
startIndex += length;
|
||||||
this.overloadPower = BytesUtil.bytesToIntLittle(overloadPowerBytes);
|
length = 16;
|
||||||
|
this.transactionCode = BytesUtil.bcd2StrLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte qrCodeLightBytes = dataBytes[29];
|
startIndex += length;
|
||||||
this.qrCodeLight = BytesUtil.bytesToIntLittle(new byte[]{qrCodeLightBytes});
|
length = 2;
|
||||||
|
this.maxChargeTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte longChargeModeBytes = dataBytes[30];
|
startIndex += length;
|
||||||
this.longChargeMode = BytesUtil.bytesToIntLittle(new byte[]{longChargeModeBytes});
|
length = 2;
|
||||||
|
this.overloadPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte[] extraFloatChargeTimeBytes = Arrays.copyOfRange(dataBytes, 31, 33);
|
startIndex += length;
|
||||||
this.extraFloatChargeTime = BytesUtil.bytesToIntLittle(extraFloatChargeTimeBytes);
|
length = 1;
|
||||||
|
this.qrCodeLight = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte skipShortCircuitDetectionBytes = dataBytes[33];
|
startIndex += length;
|
||||||
this.skipShortCircuitDetection = BytesUtil.bytesToIntLittle(new byte[]{skipShortCircuitDetectionBytes});
|
length = 1;
|
||||||
|
this.longChargeMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte noUserPullOutCheckBytes = dataBytes[34];
|
startIndex += length;
|
||||||
this.noUserPullOutCheck = BytesUtil.bytesToIntLittle(new byte[]{noUserPullOutCheckBytes});
|
length = 2;
|
||||||
|
this.extraFloatChargeTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte forceAutoStopWhenFullByte = dataBytes[35];
|
startIndex += length;
|
||||||
this.forceAutoStopWhenFull = BytesUtil.bytesToIntLittle(new byte[]{forceAutoStopWhenFullByte});
|
length = 1;
|
||||||
|
this.skipShortCircuitDetection = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte fullChargePowerBytes = dataBytes[36];
|
startIndex += length;
|
||||||
this.fullChargePower = BytesUtil.bytesToIntLittle(new byte[]{fullChargePowerBytes});
|
length = 1;
|
||||||
|
this.noUserPullOutCheck = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
byte maxFullChargePowerCheckTimeBytes = dataBytes[37];
|
startIndex += length;
|
||||||
this.maxFullChargePowerCheckTime = BytesUtil.bytesToIntLittle(new byte[]{maxFullChargePowerCheckTimeBytes});
|
length = 1;
|
||||||
|
this.forceAutoStopWhenFull = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
this.fullChargePower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
this.maxFullChargePowerCheckTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取字节数组
|
// 获取字节数组
|
||||||
public byte[] getBytes() {
|
public byte[] getMessageBytes() {
|
||||||
// 费率模式
|
// 费率模式
|
||||||
byte[] rateModeBytes = BytesUtil.intToBytesLittle(rateMode, 1);
|
byte[] rateModeBytes = BytesUtil.intToBytesLittle(rateMode, 1);
|
||||||
// 余额/有效期
|
// 余额/有效期
|
||||||
@@ -189,5 +165,5 @@ public class EBikeMessageCmd82 extends AbsEBikeMessage {
|
|||||||
// , fullChargePowerBytes, maxFullChargePowerCheckTimeBytes
|
// , fullChargePowerBytes, maxFullChargePowerCheckTimeBytes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import com.jsowell.common.enums.ykc.PileChannelEntity;
|
|||||||
import com.jsowell.common.protocol.SyncPromise;
|
import com.jsowell.common.protocol.SyncPromise;
|
||||||
import com.jsowell.common.util.*;
|
import com.jsowell.common.util.*;
|
||||||
import com.jsowell.common.util.id.IdUtils;
|
import com.jsowell.common.util.id.IdUtils;
|
||||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.ChargingOperationResponse;
|
import com.jsowell.pile.domain.ebike.deviceupload.ChargingOperationResponse;
|
||||||
import com.jsowell.pile.domain.ebike.serversend.EBikeMessageCmd82;
|
import com.jsowell.pile.domain.ebike.serversend.EBikeMessageCmd82;
|
||||||
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
||||||
@@ -46,36 +46,34 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
|
|||||||
message.setMessageId(RandomUtil.getRandomNumber(4));
|
message.setMessageId(RandomUtil.getRandomNumber(4));
|
||||||
message.setCommand("82");
|
message.setCommand("82");
|
||||||
|
|
||||||
EBikeMessageCmd82.SpecificData data = new EBikeMessageCmd82.SpecificData();
|
|
||||||
// 充电模式
|
// 充电模式
|
||||||
data.setRateMode(3);
|
message.setRateMode(3);
|
||||||
// 余额(分)或有效期
|
// 余额(分)或有效期
|
||||||
int balance = command.getChargeAmount().multiply(new BigDecimal("100")).intValue();
|
int balance = command.getChargeAmount().multiply(new BigDecimal("100")).intValue();
|
||||||
data.setBalanceOrValidity(balance);
|
message.setBalanceOrValidity(balance);
|
||||||
// 端口号
|
// 端口号
|
||||||
data.setPortNumber(Integer.parseInt(connectorCode));
|
message.setPortNumber(Integer.parseInt(connectorCode));
|
||||||
// 充电命令
|
// 充电命令
|
||||||
data.setChargeCommand(1);
|
message.setChargeCommand(1);
|
||||||
// 充电时长/功率
|
// 充电时长/功率
|
||||||
int chargeDurationOrPower = 0;
|
int chargeDurationOrPower = 0;
|
||||||
data.setChargeTimeOrPower(chargeDurationOrPower);
|
message.setChargeTimeOrPower(chargeDurationOrPower);
|
||||||
|
|
||||||
// 订单编号
|
// 订单编号
|
||||||
data.setTransactionCode(transactionCode);
|
message.setTransactionCode(transactionCode);
|
||||||
|
|
||||||
// 最大充电时长
|
// 最大充电时长
|
||||||
data.setMaxChargeTime(0);
|
message.setMaxChargeTime(0);
|
||||||
// 过载功率
|
// 过载功率
|
||||||
data.setOverloadPower(OVER_LOAD_POWER);
|
message.setOverloadPower(OVER_LOAD_POWER);
|
||||||
data.setQrCodeLight(0);
|
message.setQrCodeLight(0);
|
||||||
data.setLongChargeMode(0);
|
message.setLongChargeMode(0);
|
||||||
data.setExtraFloatChargeTime(0);
|
message.setExtraFloatChargeTime(0);
|
||||||
data.setSkipShortCircuitDetection(0);
|
message.setSkipShortCircuitDetection(0);
|
||||||
data.setNoUserPullOutCheck(0);
|
message.setNoUserPullOutCheck(0);
|
||||||
data.setForceAutoStopWhenFull(0);
|
message.setForceAutoStopWhenFull(0);
|
||||||
data.setFullChargePower(0);
|
message.setFullChargePower(0);
|
||||||
data.setMaxFullChargePowerCheckTime(0);
|
message.setMaxFullChargePowerCheckTime(0);
|
||||||
message.setData(data);
|
|
||||||
byte[] response = this.send(message);
|
byte[] response = this.send(message);
|
||||||
log.info("电单车发送启动充电指令response:{}", BytesUtil.binary(response, 16));
|
log.info("电单车发送启动充电指令response:{}", BytesUtil.binary(response, 16));
|
||||||
return new ChargingOperationResponse(response);
|
return new ChargingOperationResponse(response);
|
||||||
@@ -97,35 +95,33 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
|
|||||||
message.setMessageId(RandomUtil.getRandomNumber(4));
|
message.setMessageId(RandomUtil.getRandomNumber(4));
|
||||||
message.setCommand("82");
|
message.setCommand("82");
|
||||||
|
|
||||||
EBikeMessageCmd82.SpecificData data = new EBikeMessageCmd82.SpecificData();
|
|
||||||
// 充电模式
|
// 充电模式
|
||||||
data.setRateMode(3);
|
message.setRateMode(3);
|
||||||
// 余额或有效期
|
// 余额或有效期
|
||||||
data.setBalanceOrValidity(1234);
|
message.setBalanceOrValidity(1234);
|
||||||
// 端口号
|
// 端口号
|
||||||
data.setPortNumber(Integer.parseInt(connectorCode));
|
message.setPortNumber(Integer.parseInt(connectorCode));
|
||||||
// 充电命令
|
// 充电命令
|
||||||
data.setChargeCommand(0);
|
message.setChargeCommand(0);
|
||||||
// 充电时长/功率
|
// 充电时长/功率
|
||||||
int chargeDurationOrPower = 0;
|
int chargeDurationOrPower = 0;
|
||||||
data.setChargeTimeOrPower(chargeDurationOrPower);
|
message.setChargeTimeOrPower(chargeDurationOrPower);
|
||||||
|
|
||||||
// 订单编号
|
// 订单编号
|
||||||
data.setTransactionCode(transactionCode);
|
message.setTransactionCode(transactionCode);
|
||||||
|
|
||||||
// 最大充电时长
|
// 最大充电时长
|
||||||
data.setMaxChargeTime(0);
|
message.setMaxChargeTime(0);
|
||||||
// 过载功率
|
// 过载功率
|
||||||
data.setOverloadPower(OVER_LOAD_POWER);
|
message.setOverloadPower(OVER_LOAD_POWER);
|
||||||
data.setQrCodeLight(0);
|
message.setQrCodeLight(0);
|
||||||
data.setLongChargeMode(0);
|
message.setLongChargeMode(0);
|
||||||
data.setExtraFloatChargeTime(0);
|
message.setExtraFloatChargeTime(0);
|
||||||
data.setSkipShortCircuitDetection(0);
|
message.setSkipShortCircuitDetection(0);
|
||||||
data.setNoUserPullOutCheck(0);
|
message.setNoUserPullOutCheck(0);
|
||||||
data.setForceAutoStopWhenFull(0);
|
message.setForceAutoStopWhenFull(0);
|
||||||
data.setFullChargePower(0);
|
message.setFullChargePower(0);
|
||||||
data.setMaxFullChargePowerCheckTime(0);
|
message.setMaxFullChargePowerCheckTime(0);
|
||||||
message.setData(data);
|
|
||||||
byte[] response = this.send(message);
|
byte[] response = this.send(message);
|
||||||
log.info("电单车发送停止充电指令response:{}", BytesUtil.binary(response, 16));
|
log.info("电单车发送停止充电指令response:{}", BytesUtil.binary(response, 16));
|
||||||
return new ChargingOperationResponse(response);
|
return new ChargingOperationResponse(response);
|
||||||
@@ -135,10 +131,10 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
|
|||||||
* 公共方法, 发送指令
|
* 公共方法, 发送指令
|
||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
private byte[] send(AbsEBikeMessage msg) throws Exception {
|
private byte[] send(AbsEBikeMessage2 msg) throws Exception {
|
||||||
return this.send(msg, 5, TimeUnit.SECONDS);
|
return this.send(msg, 5, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
private byte[] send(AbsEBikeMessage msg, long timeout, TimeUnit unit) throws Exception {
|
private byte[] send(AbsEBikeMessage2 msg, long timeout, TimeUnit unit) throws Exception {
|
||||||
String pileSn = msg.getPhysicalId() + "";
|
String pileSn = msg.getPhysicalId() + "";
|
||||||
byte[] messageBytes = msg.getMessageBytes();
|
byte[] messageBytes = msg.getMessageBytes();
|
||||||
String command = YKCUtils.frameType2Str(msg.getCommand());
|
String command = YKCUtils.frameType2Str(msg.getCommand());
|
||||||
|
|||||||
@@ -1279,8 +1279,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
basicInfo.setDelFlag(DelFlagEnum.NORMAL.getValue()); // 删除标识
|
basicInfo.setDelFlag(DelFlagEnum.NORMAL.getValue()); // 删除标识
|
||||||
basicInfoList.add(basicInfo);
|
basicInfoList.add(basicInfo);
|
||||||
|
|
||||||
EBikeMessageCmd20.DeviceRegister deviceRegister = message.getDeviceRegister();
|
int portNumber = message.getPortNumber();
|
||||||
int portNumber = deviceRegister.getPortNumber();
|
|
||||||
PileConnectorInfo connectorInfo;
|
PileConnectorInfo connectorInfo;
|
||||||
for (int i = 1; i < portNumber + 1; i++) {
|
for (int i = 1; i < portNumber + 1; i++) {
|
||||||
// 组装pile_connector_info表数据
|
// 组装pile_connector_info表数据
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import com.jsowell.common.constant.Constants;
|
|||||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
import com.jsowell.common.enums.ykc.*;
|
import com.jsowell.common.enums.ykc.CardStatusEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.OrderPayModeEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.OrderPayRecordEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.*;
|
import com.jsowell.pile.domain.*;
|
||||||
|
|||||||
Reference in New Issue
Block a user