mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
同步获取响应数据
This commit is contained in:
@@ -26,6 +26,7 @@ import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class PileRemoteService {
|
||||
@@ -287,9 +288,17 @@ public class PileRemoteService {
|
||||
|
||||
/**
|
||||
* 预约充电指令/预约指令
|
||||
* @return result: 1-成功; 0-失败
|
||||
*/
|
||||
public void reservationCharging(ReservationChargingCommand command) {
|
||||
ykcPushCommandService.pushReservationChargingCommand(command);
|
||||
public String reservationCharging(ReservationChargingCommand command) {
|
||||
String result = "1";
|
||||
byte[] bytes = ykcPushCommandService.pushReservationChargingCommand(command);
|
||||
// 解析结果
|
||||
if (Objects.isNull(bytes)) {
|
||||
result = "0";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,6 +82,6 @@ public interface YKCPushCommandService {
|
||||
* 发送预约充电命令
|
||||
* @param command
|
||||
*/
|
||||
void pushReservationChargingCommand(ReservationChargingCommand command);
|
||||
byte[] pushReservationChargingCommand(ReservationChargingCommand command);
|
||||
|
||||
}
|
||||
|
||||
@@ -471,12 +471,10 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
.reservedEndTime(pileReservationInfo.getEndTime().toLocalTime())
|
||||
.amount(Constants.WHITELIST_DEFAULT_AMOUNT)
|
||||
.build();
|
||||
pileRemoteService.reservationCharging(command);
|
||||
|
||||
// 从redis中获取回复, 3秒没有获取到判为超时
|
||||
|
||||
|
||||
this.insertOrUpdateSelective(pileReservationInfo);
|
||||
String result = pileRemoteService.reservationCharging(command);
|
||||
if (StringUtils.equals(result, Constants.ONE)) {
|
||||
this.insertOrUpdateSelective(pileReservationInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -30,9 +29,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@@ -620,9 +617,10 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
* 发送预约充电命令
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void pushReservationChargingCommand(ReservationChargingCommand command) {
|
||||
public byte[] pushReservationChargingCommand(ReservationChargingCommand command) {
|
||||
// 交易流水号
|
||||
String transactionCode = command.getTransactionCode();
|
||||
byte[] transactionCodeArr = BytesUtil.str2Bcd(transactionCode);
|
||||
@@ -678,14 +676,17 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
reservationTypeByteArr, verifyIdentityByteArr, vin1ByteArr, vin2ByteArr, vin3ByteArr,
|
||||
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
||||
|
||||
byte[] response;
|
||||
try {
|
||||
this.send(msg, pileSn, YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE);
|
||||
response = this.send(msg, pileSn, YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
log.error("发送消息异常", e);
|
||||
response = null;
|
||||
}
|
||||
|
||||
log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
|
||||
transactionCode, pileSn, connectorCode, operation, verifyIdentity, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user