update 电单车

This commit is contained in:
Guoqs
2024-09-13 09:33:23 +08:00
parent e154b0c0dc
commit decd185c79
3 changed files with 21 additions and 4 deletions

View File

@@ -133,4 +133,18 @@ public class YouDianUtils {
// 转换为字节数组 // 转换为字节数组
return BytesUtil.intToBytesLittle(hexValue, 1); return BytesUtil.intToBytesLittle(hexValue, 1);
} }
/**
* 端口号从0开始
* @param portNumber
* @return
*/
public static String convertPortNumberToString(int portNumber) {
if (portNumber < 0 || portNumber > 15) {
throw new IllegalArgumentException("Port number must be between 0 and 15.");
}
// 转换为字节数组
return String.format("%02d", portNumber + 1);
}
} }

View File

@@ -1,5 +1,6 @@
package com.jsowell.pile.domain.ebike.deviceupload; package com.jsowell.pile.domain.ebike.deviceupload;
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.AbsEBikeMessage;
import lombok.Getter; import lombok.Getter;
@@ -42,7 +43,7 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
@Setter @Setter
public static class PowerHeartbeat { public static class PowerHeartbeat {
/** /**
* 端口号当前充电的端口号。注00表示1号端口01表示2号端口 * 端口号当前充电的端口号。注00表示1号端口01表示2号端口; port+1为实际端口
*/ */
private String port; private String port;
@@ -135,7 +136,8 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
public PowerHeartbeat(byte[] dataBytes) { public PowerHeartbeat(byte[] dataBytes) {
int startIndex = 0; int startIndex = 0;
int length = 1; int length = 1;
this.port = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + ""; int i = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
this.port = i + YouDianUtils.convertPortNumberToString(i);
length = 1; length = 1;
this.portStatus = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + ""; this.portStatus = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";

View File

@@ -1954,12 +1954,13 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode; String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode;
// 拿到所有数据 // 拿到所有数据
Map<Object, Object> map = redisCache.hmget(redisKey); Map<Object, Object> map = redisCache.hmget(redisKey);
logger.info("查redis中的实时数据, pileConnectorCode:{}, transactionCode:{}, map:{}", pileConnectorCode, transactionCode, map);
if (map == null) { if (map == null || map.isEmpty()) {
// 按照电单车重新查 // 按照电单车重新查
pileConnectorCode = transactionCode.substring(0, 10); // 电单车车桩 pileConnectorCode = transactionCode.substring(0, 10); // 电单车车桩
redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode; redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode;
map = redisCache.hmget(redisKey); map = redisCache.hmget(redisKey);
logger.info("按照电单车重新查, pileConnectorCode:{}, transactionCode:{}, map:{}", pileConnectorCode, transactionCode, map);
} }
if (map != null && !map.isEmpty()) { if (map != null && !map.isEmpty()) {