Compare commits

2 Commits

Author SHA1 Message Date
lzh
e4d07a5306 fix(ci): 修复多 commit 场景下服务构建检测遗漏
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
原 getChangedFiles() 只对比 HEAD~1 和 HEAD,导致一次 push 多个
commits 时只会检测最新一个 commit 的变更。

修改为使用 GIT_PREVIOUS_SUCCESSFUL_COMMIT(Jenkins 内置变量,上次
成功构建的 commit)作为基准,确保所有变更文件都能被正确检测。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 10:30:02 +08:00
lzh
4cd520ab78 fix(iot-gateway): 兼容设备端消息体长度计算不准确的问题
修改 JT808 解码器,采用更宽松的消息体长度处理策略:
- 使用实际可用的长度(expected 与 actual 取最小值)
- 将长度差异日志降为 DEBUG 级别
- 继续解析消息而不是直接丢弃

原因:部分设备端计算消息体长度时存在偏差,导致位置上报等消息被跳过。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 10:10:09 +08:00
2 changed files with 21 additions and 12 deletions

17
Jenkinsfile vendored
View File

@@ -435,12 +435,23 @@ pipeline {
// 辅助函数
// ============================================
// 获取变更的文件列表
// 获取变更的文件列表(对比上次成功构建,支持多 commit
def getChangedFiles() {
def changedFiles = sh(
script: '''
PREV=$(git rev-parse HEAD~1 2>/dev/null || echo "")
[ -z "$PREV" ] && echo "all" || git diff --name-only $PREV HEAD
# 优先使用上次成功构建的 commit
if [ -n "$GIT_PREVIOUS_SUCCESSFUL_COMMIT" ]; then
PREV="$GIT_PREVIOUS_SUCCESSFUL_COMMIT"
else
# 回退到 origin/master如果有
PREV=$(git rev-parse origin/master 2>/dev/null || git rev-parse HEAD~1 2>/dev/null || echo "")
fi
if [ -z "$PREV" ]; then
echo "all"
else
git diff --name-only $PREV HEAD
fi
''',
returnStdout: true
).trim()

View File

@@ -56,18 +56,16 @@ public class Jt808Decoder {
return ret;
}
if (expectedBodyLength > actualAvailableLength) {
log.warn("[bytes2PackageData][消息体长度不匹配: 头部声明={}, 实际可用={}, 数据总长度={}, 消息ID=0x{}]",
expectedBodyLength, actualAvailableLength, data.length,
// 使用实际可用的长度处理(兼容设备端长度计算不准确的情况)
int actualBodyLength = Math.min(expectedBodyLength, actualAvailableLength);
if (expectedBodyLength != actualAvailableLength) {
log.debug("[bytes2PackageData][消息体长度差异: 头部声明={}, 实际可用={}, 使用={}, 消息ID=0x{}]",
expectedBodyLength, actualAvailableLength, actualBodyLength,
Integer.toHexString(msgHeader.getId()));
// 使用 null 标记长度不匹配(区别于合法的空消息体如心跳)
ret.setBodyBytes(null);
ret.setCheckSum(data[data.length - 1]);
return ret;
}
byte[] bodyBytes = new byte[msgHeader.getBodyLength()];
System.arraycopy(data, msgBodyByteStartIndex, bodyBytes, 0, bodyBytes.length);
byte[] bodyBytes = new byte[actualBodyLength];
System.arraycopy(data, msgBodyByteStartIndex, bodyBytes, 0, actualBodyLength);
ret.setBodyBytes(bodyBytes);
// 3. 解析校验码