update 电单车协议

This commit is contained in:
Guoqs
2024-09-05 09:58:21 +08:00
parent 2a6daa56df
commit b341862071
9 changed files with 107 additions and 21 deletions

View File

@@ -1,10 +1,23 @@
package com.jsowell.pile.service;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.domain.ykcCommond.StopChargingCommand;
/**
* 电单车发送命令服务
*/
public interface EBikeSendCommandService {
// void send(String pileSn, AbsEBikeMessage msg);
void startCharging(String pileSn, String connectorCode);
/**
* 启动充电
* @param command
*/
void sendStartChargingCommand(StartChargingCommand command);
/**
* 停止充电
* @param command
*/
void sendStopChargingCommand(StopChargingCommand command);
}

View File

@@ -3,9 +3,12 @@ package com.jsowell.pile.service.impl;
import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.RandomUtil;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.serversend.EBikeMessageCmd82;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.domain.ykcCommond.StopChargingCommand;
import com.jsowell.pile.service.EBikeSendCommandService;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
@@ -20,15 +23,23 @@ import java.util.Objects;
@Service
public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
// 过载功率, 单位0.1W, 2450 * 0.1 = 2450W
private final int OVER_LOAD_POWER = 2450;
/**
* 电单车发送启动充电指令
* @param pileSn 电单车桩号
* @param connectorCode 枪口号
*/
@Override
public void startCharging(String pileSn, String connectorCode) {
public void sendStartChargingCommand(StartChargingCommand command) {
String pileSn = command.getPileSn();
String connectorCode = command.getConnectorCode();
String transactionCode = command.getTransactionCode();
if (StringUtils.isBlank(transactionCode)) {
transactionCode = IdUtils.generateTransactionCode(pileSn, connectorCode);
}
// 组装参数
EBikeMessageCmd82 message = new EBikeMessageCmd82();
message.setHeader("DNY");
message.setPhysicalId(Integer.parseInt(pileSn));
message.setMessageId(RandomUtil.getRandomNumber(4));
message.setCommand("82");
@@ -44,16 +55,63 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
data.setChargeCommand(1);
// 充电时长/功率
int chargeDurationOrPower = 0;
data.setChargeDurationOrPower(chargeDurationOrPower);
data.setChargeTimeOrPower(chargeDurationOrPower);
// 订单编号
String transactionCode = IdUtils.generateTransactionCode(pileSn, connectorCode);
data.setTransactionCode(transactionCode);
// 最大充电时长
data.setMaxChargeDuration(0);
data.setMaxChargeTime(0);
// 过载功率
data.setOverloadPower(3000);
data.setOverloadPower(OVER_LOAD_POWER);
data.setQrCodeLight(0);
data.setLongChargeMode(0);
data.setExtraFloatChargeTime(0);
data.setSkipShortCircuitDetection(0);
data.setNoUserPullOutCheck(0);
data.setForceAutoStopWhenFull(0);
data.setFullChargePower(0);
data.setMaxFullChargePowerCheckTime(0);
message.setData(data);
this.send(message);
}
/**
* 发送停止充电指令
* @param command
*/
@Override
public void sendStopChargingCommand(StopChargingCommand command) {
String pileSn = command.getPileSn();
String connectorCode = command.getConnectorCode();
String transactionCode = command.getTransactionCode();
// 组装参数
EBikeMessageCmd82 message = new EBikeMessageCmd82();
message.setPhysicalId(Integer.parseInt(pileSn));
message.setMessageId(RandomUtil.getRandomNumber(4));
message.setCommand("82");
EBikeMessageCmd82.SpecificData data = new EBikeMessageCmd82.SpecificData();
// 充电模式
data.setRateMode(3);
// 余额或有效期
data.setBalanceOrValidity(1234);
// 端口号
data.setPortNumber(Integer.parseInt(connectorCode));
// 充电命令
data.setChargeCommand(0);
// 充电时长/功率
int chargeDurationOrPower = 0;
data.setChargeTimeOrPower(chargeDurationOrPower);
// 订单编号
data.setTransactionCode(transactionCode);
// 最大充电时长
data.setMaxChargeTime(0);
// 过载功率
data.setOverloadPower(OVER_LOAD_POWER);
data.setQrCodeLight(0);
data.setLongChargeMode(0);
data.setExtraFloatChargeTime(0);

View File

@@ -281,6 +281,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
} catch (Exception e) {
throw new RuntimeException(e);
}
log.info("【=====平台下发充电指令=====】:订单id:{}, 桩号:{}, 枪口号:{}, 逻辑卡号:{}, 物理卡号:{}, 账户余额:{}",
transactionCode, pileSn, BytesUtil.bcd2Str(connectorCodeByteArr), logicCardNum, physicsCardNum, chargeAmount);
}