mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-03 05:28:03 +08:00
update 修改crc校验方法
This commit is contained in:
@@ -49,12 +49,17 @@ public class YKCUtils {
|
||||
String sourceCRC = String.format("%04x", BytesUtil.bytesToInt(crcByte, 0));
|
||||
String targetCRC = String.format("%04x", CRC16Util.calcCrc16(data));
|
||||
String oldTargetCRC = String.format("%04x", CRC16Util.calcCrc16Old(data));
|
||||
if (!sourceCRC.equalsIgnoreCase(targetCRC)) {
|
||||
log.error("CRC校验不通过, 源crc:{}, 计算得出crc:{}, 老crc计算:{}, 帧类型:{}, 报文:{}, msg:{}"
|
||||
, sourceCRC, targetCRC, oldTargetCRC, YKCUtils.frameType2Str(frameType), BytesUtil.binary(msg, 16), Arrays.toString(msg));
|
||||
return false;
|
||||
// 将高低位位置反转,得出新的crc
|
||||
String lowString = StringUtils.substring(targetCRC, 0, 2);
|
||||
String highString = StringUtils.substring(targetCRC, 2, 4);
|
||||
String crc = highString + lowString;
|
||||
// 若目标crc和高低位反转前/后的crc都不一致,则校验不通过
|
||||
if (sourceCRC.equalsIgnoreCase(targetCRC) || sourceCRC.equalsIgnoreCase(crc)) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
log.error("CRC校验不通过, 源crc:{}, 计算得出crc:{}, 老crc计算:{}, 高低位反转后crc:{}, 帧类型:{}, 报文:{}, msg:{}"
|
||||
, sourceCRC, targetCRC, oldTargetCRC, crc, YKCUtils.frameType2Str(frameType), BytesUtil.binary(msg, 16), Arrays.toString(msg));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +132,11 @@ public class YKCUtils {
|
||||
// System.out.println(binary);
|
||||
// System.out.println(aaa);
|
||||
|
||||
String targetCRC = "0abb";
|
||||
String substring = StringUtils.substring(targetCRC, 0, 2);
|
||||
String substring1 = StringUtils.substring(targetCRC, 2, 4);
|
||||
String crc = substring1 + substring;
|
||||
|
||||
String hexString = "4f";
|
||||
byte[] bytes = new byte[]{0x4f};
|
||||
|
||||
|
||||
@@ -74,20 +74,20 @@ public class PileSimInfoServiceImpl implements IPileSimInfoService {
|
||||
}
|
||||
dto.setExpiredTime(expiredTime);
|
||||
List<SimCardInfoVO> simInfoList = pileSimInfoMapper.getSimInfoList(dto);
|
||||
if (expiredTime == null) {
|
||||
// 为空说明后管查询列表页没有选择筛选条件
|
||||
List<String> iccids = simInfoList.stream()
|
||||
.map(SimCardInfoVO::getIccId)
|
||||
.collect(Collectors.toList());
|
||||
// 查出最新的卡信息
|
||||
List<SimCardVO> simCardList = simCardService.searchByLoop(iccids);
|
||||
if (CollectionUtils.isNotEmpty(simCardList)) {
|
||||
// 批量修改存库
|
||||
pileSimInfoMapper.updateSimCardInfoBatch(simCardList);
|
||||
|
||||
simInfoList = pileSimInfoMapper.getSimInfoList(dto);
|
||||
}
|
||||
}
|
||||
// if (expiredTime == null) {
|
||||
// // 为空说明后管查询列表页没有选择筛选条件
|
||||
// List<String> iccids = simInfoList.stream()
|
||||
// .map(SimCardInfoVO::getIccId)
|
||||
// .collect(Collectors.toList());
|
||||
// // 查出最新的卡信息
|
||||
// List<SimCardVO> simCardList = simCardService.searchByLoop(iccids);
|
||||
// if (CollectionUtils.isNotEmpty(simCardList)) {
|
||||
// // 批量修改存库
|
||||
// pileSimInfoMapper.updateSimCardInfoBatch(simCardList);
|
||||
//
|
||||
// simInfoList = pileSimInfoMapper.getSimInfoList(dto);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (CollectionUtils.isEmpty(simInfoList)) {
|
||||
return new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user