mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 预约充电
This commit is contained in:
@@ -40,9 +40,6 @@ public class CommonController {
|
|||||||
|
|
||||||
private static final String FILE_DELIMETER = ",";
|
private static final String FILE_DELIMETER = ",";
|
||||||
|
|
||||||
@Value("${remoteUpdate.path}")
|
|
||||||
private String FIRMWARE_FILEPATH;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用下载请求
|
* 通用下载请求
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3054,7 +3054,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
} else if (StartModeEnum.VIN_CODE.getValue().equals(dto.getStartMode())) {
|
} else if (StartModeEnum.VIN_CODE.getValue().equals(dto.getStartMode())) {
|
||||||
sendStartCharging = false;
|
sendStartCharging = false;
|
||||||
} else if (StartTypeEnum.RESERVED.getValue().equals(orderInfo.getStartType())) {
|
} else if (StartTypeEnum.RESERVED.getValue().equals(orderInfo.getStartType())) {
|
||||||
sendStartCharging = false;
|
// sendStartCharging = false;
|
||||||
} else if (OrderStatusEnum.STAY_RETROACTIVE_AMOUNT.getValue().equals(orderInfo.getOrderStatus())) {
|
} else if (OrderStatusEnum.STAY_RETROACTIVE_AMOUNT.getValue().equals(orderInfo.getOrderStatus())) {
|
||||||
sendStartCharging = false;
|
sendStartCharging = false;
|
||||||
}
|
}
|
||||||
@@ -3107,6 +3107,28 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
logger.info("订单:{}支付成功, 发送启动指令", dto.getOrderCode());
|
logger.info("订单:{}支付成功, 发送启动指令", dto.getOrderCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步发送预约充电指令
|
||||||
|
*/
|
||||||
|
if (StringUtils.equals(orderInfo.getStartType(), StartTypeEnum.RESERVED.getValue())) {
|
||||||
|
ReservedChargingCommand command = ReservedChargingCommand.builder()
|
||||||
|
.transactionCode(orderInfo.getTransactionCode())
|
||||||
|
.pileSn(orderInfo.getPileSn())
|
||||||
|
.connectorCode(orderInfo.getPileConnectorCode())
|
||||||
|
.operation(BytesUtil.bcd2Str(new byte[]{0x01}))
|
||||||
|
.reservedStartTime(orderInfo.getReservedStartTime())
|
||||||
|
.reservedStartTime(orderInfo.getReservedEndTime())
|
||||||
|
.amount(new BigDecimal(Constants.FIVE_HUNDRED))
|
||||||
|
.build();
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
pileRemoteService.reservedCharging(command);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("异步发送预约充电指令, orderCode:{}", orderInfo.getOrderCode(), e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (OrderStatusEnum.STAY_RETROACTIVE_AMOUNT.getValue().equals(orderInfo.getOrderStatus())) {
|
if (OrderStatusEnum.STAY_RETROACTIVE_AMOUNT.getValue().equals(orderInfo.getOrderStatus())) {
|
||||||
// 如果订单状态是待补缴,表示已经停止充电了,需要补缴费用,补缴完成订单状态改为订单完成,设置结算时间
|
// 如果订单状态是待补缴,表示已经停止充电了,需要补缴费用,补缴完成订单状态改为订单完成,设置结算时间
|
||||||
orderInfo.setOrderStatus(OrderStatusEnum.ORDER_COMPLETE.getValue());
|
orderInfo.setOrderStatus(OrderStatusEnum.ORDER_COMPLETE.getValue());
|
||||||
@@ -3591,28 +3613,6 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
.orderDetail(orderDetail)
|
.orderDetail(orderDetail)
|
||||||
.build();
|
.build();
|
||||||
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
|
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 异步发送预约充电指令
|
|
||||||
*/
|
|
||||||
if (StringUtils.equals(dto.getStartType(), StartTypeEnum.RESERVED.getValue())) {
|
|
||||||
ReservedChargingCommand command = ReservedChargingCommand.builder()
|
|
||||||
.transactionCode(orderBasicInfo.getTransactionCode())
|
|
||||||
.pileSn(orderBasicInfo.getPileSn())
|
|
||||||
.connectorCode(orderBasicInfo.getPileConnectorCode())
|
|
||||||
.operation(BytesUtil.bcd2Str(new byte[]{0x01}))
|
|
||||||
.reservedStartTime(DateUtils.parseDate(dto.getReservedStartTime(), DateUtils.YYYY_MM_DD_HH_MM_SS))
|
|
||||||
.reservedStartTime(DateUtils.parseDate(dto.getReservedEndTime(), DateUtils.YYYY_MM_DD_HH_MM_SS))
|
|
||||||
.amount(new BigDecimal(Constants.FIVE_HUNDRED))
|
|
||||||
.build();
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
try {
|
|
||||||
pileRemoteService.reservedCharging(command);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("异步发送预约充电指令, orderCode:{}", orderBasicInfo.getOrderCode(), e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return orderBasicInfo;
|
return orderBasicInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,477 +34,489 @@ import java.util.Objects;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileBillingTemplateService pileBillingTemplateService;
|
private PileBillingTemplateService pileBillingTemplateService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileModelInfoService pileModelInfoService;
|
private PileModelInfoService pileModelInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileBasicInfoService pileBasicInfoService;
|
private PileBasicInfoService pileBasicInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileStationInfoService pileStationInfoService;
|
private PileStationInfoService pileStationInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileMsgRecordService pileMsgRecordService;
|
private PileMsgRecordService pileMsgRecordService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileConnectorInfoService pileConnectorInfoService;
|
private PileConnectorInfoService pileConnectorInfoService;
|
||||||
|
|
||||||
// 需要记录报文的数据帧类型
|
// 需要记录报文的数据帧类型
|
||||||
private final List<String> frameTypeList = Lists.newArrayList(
|
private final List<String> frameTypeList = Lists.newArrayList(
|
||||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_RESTART_CODE.getBytes()),
|
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_RESTART_CODE.getBytes()),
|
||||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_CONTROL_START_CODE.getBytes()),
|
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_CONTROL_START_CODE.getBytes()),
|
||||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_STOP_CHARGING_CODE.getBytes())
|
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_STOP_CHARGING_CODE.getBytes())
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送push消息
|
* 发送push消息
|
||||||
* @param msg
|
*
|
||||||
* @param pileSn
|
* @param msg
|
||||||
* @param frameTypeCode
|
* @param pileSn
|
||||||
* @return
|
* @param frameTypeCode
|
||||||
*/
|
* @return
|
||||||
public boolean push(byte[] msg, String pileSn, Enum<YKCFrameTypeCode> frameTypeCode) {
|
*/
|
||||||
// 通过桩编号获取channel
|
public boolean push(byte[] msg, String pileSn, Enum<YKCFrameTypeCode> frameTypeCode) {
|
||||||
Channel channel = PileChannelEntity.getChannelByPileSn(pileSn);
|
// 通过桩编号获取channel
|
||||||
String value = ((YKCFrameTypeCode) frameTypeCode).getValue();
|
Channel channel = PileChannelEntity.getChannelByPileSn(pileSn);
|
||||||
if (Objects.isNull(channel)) {
|
String value = ((YKCFrameTypeCode) frameTypeCode).getValue();
|
||||||
log.error("push命令[{}]失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", value, pileSn);
|
if (Objects.isNull(channel)) {
|
||||||
return false;
|
log.error("push命令[{}]失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", value, pileSn);
|
||||||
}
|
return false;
|
||||||
/**
|
}
|
||||||
* 拼接报文
|
/**
|
||||||
*/
|
* 拼接报文
|
||||||
// 起始标志
|
*/
|
||||||
byte[] head = new byte[]{0x68};
|
// 起始标志
|
||||||
|
byte[] head = new byte[]{0x68};
|
||||||
|
|
||||||
// 序列号域
|
// 序列号域
|
||||||
byte[] serialNumber = new byte[]{0x00, 0x00};
|
byte[] serialNumber = new byte[]{0x00, 0x00};
|
||||||
|
|
||||||
// 加密标志
|
// 加密标志
|
||||||
byte[] encryptFlag = new byte[]{0x00};
|
byte[] encryptFlag = new byte[]{0x00};
|
||||||
|
|
||||||
// 帧类型标志
|
// 帧类型标志
|
||||||
byte[] frameType = new byte[]{(byte) ((YKCFrameTypeCode) frameTypeCode).getCode()};
|
byte[] frameType = new byte[]{(byte) ((YKCFrameTypeCode) frameTypeCode).getCode()};
|
||||||
|
|
||||||
// 序列号域+加密标志+帧类型标志+消息体
|
// 序列号域+加密标志+帧类型标志+消息体
|
||||||
byte[] temp = Bytes.concat(serialNumber, encryptFlag, frameType, msg);
|
byte[] temp = Bytes.concat(serialNumber, encryptFlag, frameType, msg);
|
||||||
|
|
||||||
// 数据长度
|
// 数据长度
|
||||||
byte[] length = BytesUtil.intToBytes(temp.length, 1);
|
byte[] length = BytesUtil.intToBytes(temp.length, 1);
|
||||||
|
|
||||||
// 帧校验域
|
// 帧校验域
|
||||||
byte[] crc = BytesUtil.intToBytes(CRC16Util.calcCrc16(temp));
|
byte[] crc = BytesUtil.intToBytes(CRC16Util.calcCrc16(temp));
|
||||||
// 返回报文
|
// 返回报文
|
||||||
byte[] writeMsg = Bytes.concat(head, length, temp, crc);
|
byte[] writeMsg = Bytes.concat(head, length, temp, crc);
|
||||||
// 返回完整的报文 string类型
|
// 返回完整的报文 string类型
|
||||||
String wholeMsg= BytesUtil.binary(writeMsg, 16);
|
String wholeMsg = BytesUtil.binary(writeMsg, 16);
|
||||||
// log.info("[" + channel.remoteAddress() + "] 主动发送push请求信息:{}", wholeMsg);
|
// log.info("[" + channel.remoteAddress() + "] 主动发送push请求信息:{}", wholeMsg);
|
||||||
ByteBuf byteBuf = channel.alloc().buffer().writeBytes(writeMsg);
|
ByteBuf byteBuf = channel.alloc().buffer().writeBytes(writeMsg);
|
||||||
ChannelFuture channelFuture = channel.writeAndFlush(byteBuf);
|
ChannelFuture channelFuture = channel.writeAndFlush(byteBuf);
|
||||||
channelFuture.addListener((ChannelFutureListener) channelFutureListener -> {
|
channelFuture.addListener((ChannelFutureListener) channelFutureListener -> {
|
||||||
// 检查操作的状态
|
// 检查操作的状态
|
||||||
if (channelFutureListener.isSuccess()) {
|
if (channelFutureListener.isSuccess()) {
|
||||||
log.info("push结果【成功】, pileSn:{}, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}",
|
log.info("push结果【成功】, pileSn:{}, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}",
|
||||||
pileSn, channel.remoteAddress(), channel.id(), value, wholeMsg);
|
pileSn, channel.remoteAddress(), channel.id(), value, wholeMsg);
|
||||||
} else {
|
} else {
|
||||||
// 如果发生错误,则访问描述原因的Throwable
|
// 如果发生错误,则访问描述原因的Throwable
|
||||||
Throwable cause = channelFutureListener.cause();
|
Throwable cause = channelFutureListener.cause();
|
||||||
log.info("push结果【失败】, pileSn:{}, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}",
|
log.info("push结果【失败】, pileSn:{}, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}",
|
||||||
pileSn, channel.remoteAddress(), channel.id(), value, wholeMsg);
|
pileSn, channel.remoteAddress(), channel.id(), value, wholeMsg);
|
||||||
log.error("push发送命令失败, pileSn:{}", pileSn, cause);
|
log.error("push发送命令失败, pileSn:{}", pileSn, cause);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 保存报文
|
// 保存报文
|
||||||
String frameTypeStr = YKCUtils.frameType2Str(((YKCFrameTypeCode) frameTypeCode).getBytes());
|
String frameTypeStr = YKCUtils.frameType2Str(((YKCFrameTypeCode) frameTypeCode).getBytes());
|
||||||
if (frameTypeList.contains(frameTypeStr)) {
|
if (frameTypeList.contains(frameTypeStr)) {
|
||||||
pileMsgRecordService.save(pileSn, null, frameTypeStr, null, wholeMsg);
|
pileMsgRecordService.save(pileSn, null, frameTypeStr, null, wholeMsg);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送启动充电指令
|
* 发送启动充电指令
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void pushStartChargingCommand(StartChargingCommand command) {
|
public void pushStartChargingCommand(StartChargingCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
String pileSn = command.getPileSn();
|
||||||
String connectorCode = command.getConnectorCode();
|
String connectorCode = command.getConnectorCode();
|
||||||
String transactionCode = command.getTransactionCode();
|
String transactionCode = command.getTransactionCode();
|
||||||
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode) ) {
|
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||||
log.error("远程启动充电, 充电桩编号和枪口号不能为空");
|
log.error("远程启动充电, 充电桩编号和枪口号不能为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(transactionCode)) {
|
if (StringUtils.isEmpty(transactionCode)) {
|
||||||
log.error("远程启动充电, 交易流水号不能为空");
|
log.error("远程启动充电, 交易流水号不能为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (command.getChargeAmount() == null || BigDecimal.ZERO.equals(command.getChargeAmount())) {
|
if (command.getChargeAmount() == null || BigDecimal.ZERO.equals(command.getChargeAmount())) {
|
||||||
log.error("远程启动充电, 充电金额不能为0");
|
log.error("远程启动充电, 充电金额不能为0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 枪口号
|
// 枪口号
|
||||||
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
||||||
|
|
||||||
// 交易流水号
|
// 交易流水号
|
||||||
byte[] orderIdByteArr = BytesUtil.str2Bcd(transactionCode);
|
byte[] orderIdByteArr = BytesUtil.str2Bcd(transactionCode);
|
||||||
|
|
||||||
// 桩编号
|
// 桩编号
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
|
|
||||||
// 逻辑卡号
|
// 逻辑卡号
|
||||||
String logicCardNum = StringUtils.isBlank(command.getLogicCardNum())
|
String logicCardNum = StringUtils.isBlank(command.getLogicCardNum())
|
||||||
? Constants.ZERO
|
? Constants.ZERO
|
||||||
: command.getLogicCardNum();
|
: command.getLogicCardNum();
|
||||||
byte[] logicCardNumByteArr = BytesUtil.checkLengthAndFrontAppendZero(BytesUtil.str2Bcd(logicCardNum), 16);
|
byte[] logicCardNumByteArr = BytesUtil.checkLengthAndFrontAppendZero(BytesUtil.str2Bcd(logicCardNum), 16);
|
||||||
|
|
||||||
// 物理卡号
|
// 物理卡号
|
||||||
String physicsCardNum = StringUtils.isBlank(command.getPhysicsCardNum())
|
String physicsCardNum = StringUtils.isBlank(command.getPhysicsCardNum())
|
||||||
? Constants.ZERO
|
? Constants.ZERO
|
||||||
: command.getPhysicsCardNum();
|
: command.getPhysicsCardNum();
|
||||||
byte[] physicsCardNumByteArr = BytesUtil.checkLengthAndFrontAppendZero(BytesUtil.str2Bcd(physicsCardNum), 16);
|
byte[] physicsCardNumByteArr = BytesUtil.checkLengthAndFrontAppendZero(BytesUtil.str2Bcd(physicsCardNum), 16);
|
||||||
|
|
||||||
// 账户余额
|
// 账户余额
|
||||||
BigDecimal chargeAmount = command.getChargeAmount();
|
BigDecimal chargeAmount = command.getChargeAmount();
|
||||||
byte[] accountBalanceByteArr = YKCUtils.getPriceByte(chargeAmount.toString(), 2);
|
byte[] accountBalanceByteArr = YKCUtils.getPriceByte(chargeAmount.toString(), 2);
|
||||||
|
|
||||||
byte[] msgBody = Bytes.concat(orderIdByteArr, pileSnByteArr, connectorCodeByteArr, logicCardNumByteArr, physicsCardNumByteArr, accountBalanceByteArr);
|
byte[] msgBody = Bytes.concat(orderIdByteArr, pileSnByteArr, connectorCodeByteArr, logicCardNumByteArr, physicsCardNumByteArr, accountBalanceByteArr);
|
||||||
this.push(msgBody, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_START_CODE);
|
this.push(msgBody, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_START_CODE);
|
||||||
log.info("【=====平台下发充电指令=====】:订单id:{}, 桩号:{}, 枪口号:{}, 逻辑卡号:{}, 物理卡号:{}, 账户余额:{}",
|
log.info("【=====平台下发充电指令=====】:订单id:{}, 桩号:{}, 枪口号:{}, 逻辑卡号:{}, 物理卡号:{}, 账户余额:{}",
|
||||||
transactionCode, pileSn, BytesUtil.bcd2Str(connectorCodeByteArr), logicCardNum, physicsCardNum, chargeAmount);
|
transactionCode, pileSn, BytesUtil.bcd2Str(connectorCodeByteArr), logicCardNum, physicsCardNum, chargeAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送停止ch
|
* 发送停止ch
|
||||||
* @param command
|
*
|
||||||
*/
|
* @param command
|
||||||
@Override
|
*/
|
||||||
public void pushStopChargingCommand(StopChargingCommand command) {
|
@Override
|
||||||
String pileSn = command.getPileSn();
|
public void pushStopChargingCommand(StopChargingCommand command) {
|
||||||
String connectorCode = command.getConnectorCode();
|
String pileSn = command.getPileSn();
|
||||||
// 远程停机
|
String connectorCode = command.getConnectorCode();
|
||||||
byte[] msgBody = Bytes.concat(BytesUtil.str2Bcd(pileSn), BytesUtil.str2Bcd(connectorCode));
|
// 远程停机
|
||||||
this.push(msgBody, pileSn, YKCFrameTypeCode.REMOTE_STOP_CHARGING_CODE);
|
byte[] msgBody = Bytes.concat(BytesUtil.str2Bcd(pileSn), BytesUtil.str2Bcd(connectorCode));
|
||||||
log.info("【=====平台下发指令=====】:远程停止充电,桩号:{},枪口号:{}", pileSn, connectorCode);
|
this.push(msgBody, pileSn, YKCFrameTypeCode.REMOTE_STOP_CHARGING_CODE);
|
||||||
}
|
log.info("【=====平台下发指令=====】:远程停止充电,桩号:{},枪口号:{}", pileSn, connectorCode);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pushGetRealTimeMonitorDataCommand(GetRealTimeMonitorDataCommand command) {
|
public void pushGetRealTimeMonitorDataCommand(GetRealTimeMonitorDataCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
String pileSn = command.getPileSn();
|
||||||
String connectorCode = command.getConnectorCode();
|
String connectorCode = command.getConnectorCode();
|
||||||
byte[] msg = BytesUtil.str2Bcd(pileSn + connectorCode);
|
byte[] msg = BytesUtil.str2Bcd(pileSn + connectorCode);
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.READ_REAL_TIME_MONITOR_DATA_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.READ_REAL_TIME_MONITOR_DATA_CODE);
|
||||||
log.info("【=====平台下发指令=====】:获取充电桩:{} 的 {} 枪口实时数据信息", pileSn, connectorCode);
|
log.info("【=====平台下发指令=====】:获取充电桩:{} 的 {} 枪口实时数据信息", pileSn, connectorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pushRebootCommand(RebootCommand command) {
|
public void pushRebootCommand(RebootCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
String pileSn = command.getPileSn();
|
||||||
byte[] msg = BytesUtil.str2Bcd(pileSn + Constants.ZERO_ONE);
|
byte[] msg = BytesUtil.str2Bcd(pileSn + Constants.ZERO_ONE);
|
||||||
log.info("【=====平台下发指令=====】:重启充电桩:,{}", pileSn);
|
log.info("【=====平台下发指令=====】:重启充电桩:,{}", pileSn);
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_RESTART_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_RESTART_CODE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下发二维码
|
// 下发二维码
|
||||||
@Override
|
@Override
|
||||||
public void pushIssueQRCodeCommand(IssueQRCodeCommand command) {
|
public void pushIssueQRCodeCommand(IssueQRCodeCommand command) {
|
||||||
// log.info("异步下发二维码 thread:{}", Thread.currentThread().getName());
|
// log.info("异步下发二维码 thread:{}", Thread.currentThread().getName());
|
||||||
String pileSn = command.getPileSn();
|
String pileSn = command.getPileSn();
|
||||||
// 桩编码
|
// 桩编码
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
|
|
||||||
// 二维码格式 0x00:第一种 前缀+桩编号 0x01:第二种 前缀+桩编号+枪编号
|
// 二维码格式 0x00:第一种 前缀+桩编号 0x01:第二种 前缀+桩编号+枪编号
|
||||||
byte[] qrCodeTypeByteArr = Constants.oneByteArray;
|
byte[] qrCodeTypeByteArr = Constants.oneByteArray;
|
||||||
|
|
||||||
// 二维码前缀 如:“www.baidu.com?No=”
|
// 二维码前缀 如:“www.baidu.com?No=”
|
||||||
// String qrCodePrefix = "https://wx.charging.shbochong.cn/prepare_charge?code=";
|
// String qrCodePrefix = "https://wx.charging.shbochong.cn/prepare_charge?code=";
|
||||||
// String qrCodePrefix = pileBasicInfoService.getPileQrCodeUrl(null);
|
// String qrCodePrefix = pileBasicInfoService.getPileQrCodeUrl(null);
|
||||||
String qrCodePrefix = "";
|
String qrCodePrefix = "";
|
||||||
if (StringUtils.isNotBlank(command.getQrcodePrefix())) {
|
if (StringUtils.isNotBlank(command.getQrcodePrefix())) {
|
||||||
qrCodePrefix = command.getQrcodePrefix();
|
qrCodePrefix = command.getQrcodePrefix();
|
||||||
} else {
|
} else {
|
||||||
PileStationVO pileStationVO = pileStationInfoService.getStationInfoByPileSn(pileSn);
|
PileStationVO pileStationVO = pileStationInfoService.getStationInfoByPileSn(pileSn);
|
||||||
if (StringUtils.isNotBlank(pileStationVO.getQrcodePrefix())) {
|
if (StringUtils.isNotBlank(pileStationVO.getQrcodePrefix())) {
|
||||||
// 如果有配置二维码前缀,使用配置里的。(例如希晓)
|
// 如果有配置二维码前缀,使用配置里的。(例如希晓)
|
||||||
qrCodePrefix = pileStationVO.getQrcodePrefix();
|
qrCodePrefix = pileStationVO.getQrcodePrefix();
|
||||||
} else {
|
} else {
|
||||||
// 为空则给平台二维码前缀
|
// 为空则给平台二维码前缀
|
||||||
qrCodePrefix = pileConnectorInfoService.getPileConnectorQrCodeUrl(null);
|
qrCodePrefix = pileConnectorInfoService.getPileConnectorQrCodeUrl(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] qrCodePrefixByteArr = BytesUtil.str2Asc(qrCodePrefix);
|
byte[] qrCodePrefixByteArr = BytesUtil.str2Asc(qrCodePrefix);
|
||||||
|
|
||||||
// 二维码前缀长度 二维码前缀长度长度最大不超过200 字节
|
// 二维码前缀长度 二维码前缀长度长度最大不超过200 字节
|
||||||
int length = qrCodePrefix.length();
|
int length = qrCodePrefix.length();
|
||||||
byte[] qrCodePrefixLengthByteArr = BytesUtil.intToBytes(length, 1);
|
byte[] qrCodePrefixLengthByteArr = BytesUtil.intToBytes(length, 1);
|
||||||
|
|
||||||
// 拼接消息体
|
// 拼接消息体
|
||||||
byte[] msg = Bytes.concat(pileSnByteArr, qrCodeTypeByteArr, qrCodePrefixLengthByteArr, qrCodePrefixByteArr);
|
byte[] msg = Bytes.concat(pileSnByteArr, qrCodeTypeByteArr, qrCodePrefixLengthByteArr, qrCodePrefixByteArr);
|
||||||
|
|
||||||
// push消息
|
// push消息
|
||||||
boolean result = this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE);
|
boolean result = this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE);
|
||||||
log.info("=====平台下发指令===== pileSn:{}, 下发二维码,地址为:{}", pileSn, qrCodePrefix);
|
log.info("=====平台下发指令===== pileSn:{}, 下发二维码,地址为:{}", pileSn, qrCodePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0x56 对时设置
|
* 0x56 对时设置
|
||||||
* @param command
|
*
|
||||||
*/
|
* @param command
|
||||||
@Override
|
*/
|
||||||
public void pushProofreadTimeCommand(ProofreadTimeCommand command) {
|
@Override
|
||||||
// log.info("充电桩对时,thread:{}", Thread.currentThread().getName());
|
public void pushProofreadTimeCommand(ProofreadTimeCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
// log.info("充电桩对时,thread:{}", Thread.currentThread().getName());
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
String pileSn = command.getPileSn();
|
||||||
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
|
|
||||||
// 时间
|
// 时间
|
||||||
Date date = DateUtils.parseDate(DateUtils.getDateTime());
|
Date date = DateUtils.parseDate(DateUtils.getDateTime());
|
||||||
byte[] dateBytes = Cp56Time2aUtil.date2Hbyte(date);
|
byte[] dateBytes = Cp56Time2aUtil.date2Hbyte(date);
|
||||||
|
|
||||||
// 拼装msg
|
// 拼装msg
|
||||||
byte[] msg = Bytes.concat(pileSnByteArr, dateBytes);
|
byte[] msg = Bytes.concat(pileSnByteArr, dateBytes);
|
||||||
|
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.TIME_CHECK_SETTING_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.TIME_CHECK_SETTING_CODE);
|
||||||
log.info("[充电桩:{}对时, 时间:{}, CP56Time2a:{}]", pileSn, DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date), BytesUtil.binary(dateBytes, 16));
|
log.info("[充电桩:{}对时, 时间:{}, CP56Time2a:{}]", pileSn, DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date), BytesUtil.binary(dateBytes, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向充电桩发送计费模板
|
* 向充电桩发送计费模板
|
||||||
* @param command
|
*
|
||||||
*/
|
* @param command
|
||||||
@Override
|
*/
|
||||||
public void pushPublishPileBillingTemplate(PublishPileBillingTemplateCommand command) {
|
@Override
|
||||||
BillingTemplateVO billingTemplateVO = command.getBillingTemplateVO();
|
public void pushPublishPileBillingTemplate(PublishPileBillingTemplateCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
BillingTemplateVO billingTemplateVO = command.getBillingTemplateVO();
|
||||||
// 转换
|
String pileSn = command.getPileSn();
|
||||||
byte[] messageBody = pileBillingTemplateService.generateBillingTemplateMsgBody(pileSn, billingTemplateVO);
|
// 转换
|
||||||
// 发送
|
byte[] messageBody = pileBillingTemplateService.generateBillingTemplateMsgBody(pileSn, billingTemplateVO);
|
||||||
if (messageBody != null) {
|
// 发送
|
||||||
this.push(messageBody, pileSn, YKCFrameTypeCode.BILLING_TEMPLATE_SETTING_CODE);
|
if (messageBody != null) {
|
||||||
}
|
this.push(messageBody, pileSn, YKCFrameTypeCode.BILLING_TEMPLATE_SETTING_CODE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(Constants.updateServerPort);
|
System.out.println(Constants.updateServerPort);
|
||||||
String numHex = Integer.toHexString(21);
|
String numHex = Integer.toHexString(21);
|
||||||
byte[] bytes = BytesUtil.hexString2Bytes(numHex);
|
byte[] bytes = BytesUtil.hexString2Bytes(numHex);
|
||||||
System.out.println(bytes);
|
System.out.println(bytes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pushUpdateFileCommand(UpdateFirmwareCommand command) {
|
public void pushUpdateFileCommand(UpdateFirmwareCommand command) {
|
||||||
List<String> pileSns = command.getPileSnList();
|
List<String> pileSns = command.getPileSnList();
|
||||||
if (CollectionUtils.isEmpty(pileSns)) {
|
if (CollectionUtils.isEmpty(pileSns)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PileModelInfoVO> list = pileModelInfoService.getPileModelInfoByPileSnList(pileSns);
|
List<PileModelInfoVO> list = pileModelInfoService.getPileModelInfoByPileSnList(pileSns);
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取桩型号 01:直流 02:交流
|
// 获取桩型号 01:直流 02:交流
|
||||||
byte[] pileModelType;
|
byte[] pileModelType;
|
||||||
for (PileModelInfoVO pileModelInfoVO : list) {
|
for (PileModelInfoVO pileModelInfoVO : list) {
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileModelInfoVO.getPileSn());
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileModelInfoVO.getPileSn());
|
||||||
|
|
||||||
// 数据库 1- 快充(直流) 2-慢充(交流)
|
// 数据库 1- 快充(直流) 2-慢充(交流)
|
||||||
/*if (StringUtils.equals(pileModelInfoVO.getSpeedType(), Constants.ONE)) {
|
/*if (StringUtils.equals(pileModelInfoVO.getSpeedType(), Constants.ONE)) {
|
||||||
pileModelType = Constants.oneByteArray;
|
pileModelType = Constants.oneByteArray;
|
||||||
} else {
|
} else {
|
||||||
pileModelType = Constants.twoByteArray;
|
pileModelType = Constants.twoByteArray;
|
||||||
}*/
|
}*/
|
||||||
pileModelType = Constants.zeroByteArray;
|
pileModelType = Constants.zeroByteArray;
|
||||||
|
|
||||||
// 额定功率
|
// 额定功率
|
||||||
String ratedPower = pileModelInfoVO.getRatedPower();
|
String ratedPower = pileModelInfoVO.getRatedPower();
|
||||||
int i = Integer.parseInt(ratedPower);
|
int i = Integer.parseInt(ratedPower);
|
||||||
|
|
||||||
// byte[] ratedPowerByteArr = Base64.getDecoder().decode(ratedPower);
|
// byte[] ratedPowerByteArr = Base64.getDecoder().decode(ratedPower);
|
||||||
byte[] ratedPowerByteArr = BytesUtil.ensureLength(Constants.zeroByteArray, 2);
|
byte[] ratedPowerByteArr = BytesUtil.ensureLength(Constants.zeroByteArray, 2);
|
||||||
|
|
||||||
// 升级服务器地址
|
// 升级服务器地址
|
||||||
byte[] updateServerAddressByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getServerAddress()), 16);
|
byte[] updateServerAddressByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getServerAddress()), 16);
|
||||||
|
|
||||||
// 升级服务器端口
|
// 升级服务器端口
|
||||||
byte[] updateServerPortByteArr = BytesUtil.ensureLength(BytesUtil.hexString2Bytes(Integer.toHexString(command.getPort())), 2);
|
byte[] updateServerPortByteArr = BytesUtil.ensureLength(BytesUtil.hexString2Bytes(Integer.toHexString(command.getPort())), 2);
|
||||||
|
|
||||||
// 用户名
|
// 用户名
|
||||||
byte[] userNameByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getUsername()), 16);
|
byte[] userNameByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getUsername()), 16);
|
||||||
|
|
||||||
// 密码
|
// 密码
|
||||||
byte[] passwordByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getPassword()), 16);
|
byte[] passwordByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getPassword()), 16);
|
||||||
|
|
||||||
// 文件路径
|
// 文件路径
|
||||||
byte[] filePathByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getFilePath()), 32);
|
byte[] filePathByteArr = BytesUtil.ensureLength(BytesUtil.str2Asc(command.getFilePath()), 32);
|
||||||
|
|
||||||
// 执行控制 01:立即执行 02:空闲执行
|
// 执行控制 01:立即执行 02:空闲执行
|
||||||
byte[] performTypeByteArr = Constants.oneByteArray;
|
byte[] performTypeByteArr = Constants.oneByteArray;
|
||||||
|
|
||||||
// 下载超时时间 单位:min
|
// 下载超时时间 单位:min
|
||||||
byte[] overTimeByteArr = new byte[]{0x05};
|
byte[] overTimeByteArr = new byte[]{0x05};
|
||||||
|
|
||||||
byte[] msgBody = Bytes.concat(pileSnByteArr, pileModelType, ratedPowerByteArr, updateServerAddressByteArr,
|
byte[] msgBody = Bytes.concat(pileSnByteArr, pileModelType, ratedPowerByteArr, updateServerAddressByteArr,
|
||||||
updateServerPortByteArr, userNameByteArr, passwordByteArr, filePathByteArr, performTypeByteArr, overTimeByteArr);
|
updateServerPortByteArr, userNameByteArr, passwordByteArr, filePathByteArr, performTypeByteArr, overTimeByteArr);
|
||||||
|
|
||||||
this.push(msgBody, pileModelInfoVO.getPileSn(), YKCFrameTypeCode.REMOTE_UPDATE_CODE);
|
this.push(msgBody, pileModelInfoVO.getPileSn(), YKCFrameTypeCode.REMOTE_UPDATE_CODE);
|
||||||
log.info("【=====平台下发指令=====】:远程更新, 桩号:{}, 类型:{}, 额定功率:{}, 服务器地址:{}, 端口号:{}, 用户名:{}, 密码:{}, 文件路径:{}",
|
log.info("【=====平台下发指令=====】:远程更新, 桩号:{}, 类型:{}, 额定功率:{}, 服务器地址:{}, 端口号:{}, 用户名:{}, 密码:{}, 文件路径:{}",
|
||||||
pileModelInfoVO.getPileSn(), pileModelType, BytesUtil.bcd2Str(ratedPowerByteArr), BytesUtil.binary(updateServerAddressByteArr, 16),
|
pileModelInfoVO.getPileSn(), pileModelType, BytesUtil.bcd2Str(ratedPowerByteArr), BytesUtil.binary(updateServerAddressByteArr, 16),
|
||||||
BytesUtil.binary(updateServerPortByteArr, 16), BytesUtil.binary(userNameByteArr, 16), BytesUtil.binary(passwordByteArr, 16),
|
BytesUtil.binary(updateServerPortByteArr, 16), BytesUtil.binary(userNameByteArr, 16), BytesUtil.binary(passwordByteArr, 16),
|
||||||
BytesUtil.binary(filePathByteArr, 16));
|
BytesUtil.binary(filePathByteArr, 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pushPileSettingCommand(PileSettingCommand command) {
|
public void pushPileSettingCommand(PileSettingCommand command) {
|
||||||
|
|
||||||
// 充电桩编号
|
// 充电桩编号
|
||||||
String pileSn = command.getPileSn();
|
String pileSn = command.getPileSn();
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
|
|
||||||
// 工作状态
|
// 工作状态
|
||||||
String workingState = command.getWorkingState();
|
String workingState = command.getWorkingState();
|
||||||
byte[] workingStateByteArr;
|
byte[] workingStateByteArr;
|
||||||
if (StringUtils.equals(workingState, "0")) {
|
if (StringUtils.equals(workingState, "0")) {
|
||||||
workingStateByteArr = Constants.zeroByteArray;
|
workingStateByteArr = Constants.zeroByteArray;
|
||||||
} else {
|
} else {
|
||||||
workingStateByteArr = Constants.oneByteArray;
|
workingStateByteArr = Constants.oneByteArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最大功率
|
// 最大功率
|
||||||
Integer maxPower = command.getMaxPower();
|
Integer maxPower = command.getMaxPower();
|
||||||
byte[] maxPowerByteArr = BytesUtil.str2Bcd(maxPower.toString());
|
byte[] maxPowerByteArr = BytesUtil.str2Bcd(maxPower.toString());
|
||||||
|
|
||||||
byte[] msg = Bytes.concat(pileSnByteArr, workingStateByteArr, maxPowerByteArr);
|
byte[] msg = Bytes.concat(pileSnByteArr, workingStateByteArr, maxPowerByteArr);
|
||||||
|
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.CHARGING_PILE_WORKING_PARAMETER_SETTING_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.CHARGING_PILE_WORKING_PARAMETER_SETTING_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台査询工作参数
|
* 平台査询工作参数
|
||||||
* @param command
|
*
|
||||||
*/
|
* @param command
|
||||||
@Override
|
*/
|
||||||
public void pushQueryWorkParamsCommand(QueryWorkParamsCommand command) {
|
@Override
|
||||||
// 桩编号
|
public void pushQueryWorkParamsCommand(QueryWorkParamsCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
// 桩编号
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
String pileSn = command.getPileSn();
|
||||||
// 桩类型
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
byte[] pileType = Constants.oneByteArray;
|
// 桩类型
|
||||||
PileModelInfoVO info = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
|
byte[] pileType = Constants.oneByteArray;
|
||||||
if (info == null) {
|
PileModelInfoVO info = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
|
||||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
|
if (info == null) {
|
||||||
}
|
throw new BusinessException(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
|
||||||
String chargerPileType = info.getChargerPileType();
|
}
|
||||||
if (StringUtils.equals("1", chargerPileType)) {
|
String chargerPileType = info.getChargerPileType();
|
||||||
// 直流
|
if (StringUtils.equals("1", chargerPileType)) {
|
||||||
pileType = Constants.zeroByteArray;
|
// 直流
|
||||||
}
|
pileType = Constants.zeroByteArray;
|
||||||
// 拼装msg信息
|
}
|
||||||
byte[] msg = Bytes.concat(pileSnByteArr, pileType);
|
// 拼装msg信息
|
||||||
|
byte[] msg = Bytes.concat(pileSnByteArr, pileType);
|
||||||
|
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程账户余额更新
|
* 远程账户余额更新
|
||||||
* @param command
|
*
|
||||||
*/
|
* @param command
|
||||||
@Override
|
*/
|
||||||
public void pushAccountBalanceUpdateCommand(RemoteAccountBalanceUpdateCommand command) {
|
@Override
|
||||||
// 桩编号
|
public void pushAccountBalanceUpdateCommand(RemoteAccountBalanceUpdateCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
// 桩编号
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
String pileSn = command.getPileSn();
|
||||||
// 枪口号
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
String connectorCode = command.getConnectorCode();
|
// 枪口号
|
||||||
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
String connectorCode = command.getConnectorCode();
|
||||||
// 卡号
|
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
||||||
String logicCard = command.getLogicCard();
|
// 卡号
|
||||||
byte[] logicByteArr = BytesUtil.str2Bcd(logicCard);
|
String logicCard = command.getLogicCard();
|
||||||
logicByteArr = BytesUtil.checkLengthAndBehindAppendZero(logicByteArr, 16);
|
byte[] logicByteArr = BytesUtil.str2Bcd(logicCard);
|
||||||
// 修改后账户余额
|
logicByteArr = BytesUtil.checkLengthAndBehindAppendZero(logicByteArr, 16);
|
||||||
String accountBalance = command.getAccountBalance();
|
// 修改后账户余额
|
||||||
byte[] priceByte = YKCUtils.getPriceByte(accountBalance, 2);
|
String accountBalance = command.getAccountBalance();
|
||||||
// 拼装msg信息
|
byte[] priceByte = YKCUtils.getPriceByte(accountBalance, 2);
|
||||||
byte[] msg = Bytes.concat(pileSnByteArr, connectorCodeByteArr, logicByteArr, priceByte);
|
// 拼装msg信息
|
||||||
|
byte[] msg = Bytes.concat(pileSnByteArr, connectorCodeByteArr, logicByteArr, priceByte);
|
||||||
|
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ACCOUNT_BALANCE_UPDATE_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ACCOUNT_BALANCE_UPDATE_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 遥控地锁
|
* 遥控地锁
|
||||||
* @param command
|
*
|
||||||
*/
|
* @param command
|
||||||
@Override
|
*/
|
||||||
public void pushRemoteControlGroundLock(RemoteControlGroundLockCommand command) {
|
@Override
|
||||||
// 桩编号
|
public void pushRemoteControlGroundLock(RemoteControlGroundLockCommand command) {
|
||||||
String pileSn = command.getPileSn();
|
// 桩编号
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
String pileSn = command.getPileSn();
|
||||||
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
|
|
||||||
// 枪口号
|
// 枪口号
|
||||||
String connectorCode = command.getConnectorCode();
|
String connectorCode = command.getConnectorCode();
|
||||||
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
||||||
|
|
||||||
// 升/降地锁 BCD 码 1 升锁 0X55,降锁 0XFF
|
// 升/降地锁 BCD 码 1 升锁 0X55,降锁 0XFF
|
||||||
byte[] operateByteArr;
|
byte[] operateByteArr;
|
||||||
if (Constants.ZERO.equals(command.getOperate())) {
|
if (Constants.ZERO.equals(command.getOperate())) {
|
||||||
operateByteArr = new byte[]{(byte) 0XFF};
|
operateByteArr = new byte[]{(byte) 0XFF};
|
||||||
} else {
|
} else {
|
||||||
operateByteArr = new byte[]{0X55};
|
operateByteArr = new byte[]{0X55};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 预留位 BIN 码 4 全部置 0 (可用于多枪)
|
// 预留位 BIN 码 4 全部置 0 (可用于多枪)
|
||||||
String obligate = "0000";
|
String obligate = "0000";
|
||||||
byte[] obligateByteArr = BytesUtil.str2Bcd(obligate);
|
byte[] obligateByteArr = BytesUtil.str2Bcd(obligate);
|
||||||
|
|
||||||
// 拼装msg信息
|
// 拼装msg信息
|
||||||
byte[] msg = Bytes.concat(pileSnByteArr, connectorCodeByteArr, operateByteArr, obligateByteArr);
|
byte[] msg = Bytes.concat(pileSnByteArr, connectorCodeByteArr, operateByteArr, obligateByteArr);
|
||||||
|
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_GROUND_LOCK_LIFTING_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_GROUND_LOCK_LIFTING_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送预约充电命令
|
* 发送预约充电命令
|
||||||
* @param command
|
*
|
||||||
*/
|
* @param command
|
||||||
@Override
|
*/
|
||||||
public void pushReservedChargingCommand(ReservedChargingCommand command) {
|
@Override
|
||||||
// 交易流水号
|
public void pushReservedChargingCommand(ReservedChargingCommand command) {
|
||||||
String transactionCode = command.getTransactionCode();
|
// 交易流水号
|
||||||
byte[] transactionCodeArr = BytesUtil.str2Bcd(transactionCode);
|
String transactionCode = command.getTransactionCode();
|
||||||
|
byte[] transactionCodeArr = BytesUtil.str2Bcd(transactionCode);
|
||||||
|
|
||||||
// 桩编号
|
// 桩编号
|
||||||
String pileSn = command.getPileSn();
|
String pileSn = command.getPileSn();
|
||||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||||
|
|
||||||
// 枪口号
|
// 枪口号
|
||||||
String connectorCode = command.getConnectorCode();
|
String connectorCode = command.getConnectorCode();
|
||||||
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
||||||
|
|
||||||
// 0x01:启动 0x02:取消 0x03:修改
|
// 0x01:启动 0x02:取消 0x03:修改
|
||||||
String operation = command.getOperation();
|
String operation = command.getOperation();
|
||||||
byte[] operateByteArr = BytesUtil.str2Bcd(operation);
|
byte[] operateByteArr = BytesUtil.str2Bcd(operation);
|
||||||
|
|
||||||
// 开始时间
|
// 开始时间
|
||||||
Date reservedStartTime = command.getReservedStartTime();
|
Date reservedStartTime = command.getReservedStartTime();
|
||||||
byte[] reservedStartTimeByteArr = Cp56Time2aUtil.date2Hbyte(DateUtils.parseDate(reservedStartTime));
|
byte[] reservedStartTimeByteArr = Cp56Time2aUtil.date2Hbyte(DateUtils.parseDate(reservedStartTime));
|
||||||
|
|
||||||
// 结束时间
|
// 结束时间
|
||||||
Date reservedEndTime = command.getReservedEndTime();
|
Date reservedEndTime = command.getReservedEndTime();
|
||||||
byte[] reservedEndTimeByteArr = Cp56Time2aUtil.date2Hbyte(DateUtils.parseDate(reservedEndTime));
|
byte[] reservedEndTimeByteArr = Cp56Time2aUtil.date2Hbyte(DateUtils.parseDate(reservedEndTime));
|
||||||
|
|
||||||
// 启动金额
|
// 启动金额
|
||||||
BigDecimal amount = command.getAmount();
|
BigDecimal amount = command.getAmount();
|
||||||
byte[] amountByteArr = YKCUtils.getPriceByte(amount.toString(), 2);
|
byte[] amountByteArr = YKCUtils.getPriceByte(amount.toString(), 2);
|
||||||
|
|
||||||
// 拼装msg信息
|
// 拼装msg信息
|
||||||
byte[] msg = Bytes.concat(transactionCodeArr, pileSnByteArr, connectorCodeByteArr, operateByteArr,
|
byte[] msg = Bytes.concat(transactionCodeArr, pileSnByteArr, connectorCodeByteArr, operateByteArr,
|
||||||
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.RESERVE_CHARGING_CODE);
|
|
||||||
}
|
this.push(msg, pileSn, YKCFrameTypeCode.RESERVE_CHARGING_CODE);
|
||||||
|
|
||||||
|
log.info("=====平台下发指令=====: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
|
||||||
|
transactionCode, pileSn, connectorCode, operation, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user