同步获取响应数据

This commit is contained in:
Guoqs
2024-08-01 17:34:01 +08:00
parent e7e8848b00
commit e1b2eda757
4 changed files with 23 additions and 15 deletions

View File

@@ -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;
}
}

View File

@@ -82,6 +82,6 @@ public interface YKCPushCommandService {
* 发送预约充电命令
* @param command
*/
void pushReservationChargingCommand(ReservationChargingCommand command);
byte[] pushReservationChargingCommand(ReservationChargingCommand command);
}

View File

@@ -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);
}
}
/**

View File

@@ -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;
}
}