fix(watch-job):

空值报错处理: 在SyncUserStatJob中添加空值检查
数据库规范: "limit 1"替换为"FETCH FIRST 1 ROWS ONLY"
This commit is contained in:
hejiayang
2026-03-18 13:49:08 +08:00
parent 7d3ee66a4b
commit 961dc7c104
2 changed files with 9 additions and 7 deletions
@@ -613,7 +613,7 @@ public class AsyncImportService {
queryWrapper.eq(WatchBindHis::getWatchNo,device.getWatchNo());
queryWrapper.isNull(WatchBindHis::getBindEndDate);
queryWrapper.orderByDesc(WatchBindHis::getCreateDate);
queryWrapper.last("limit 1");
queryWrapper.last("FETCH FIRST 1 ROWS ONLY");
//解绑
WatchBindHis updateHis = watchBindHisMapper.selectOne(queryWrapper);
//修改绑定用户
@@ -251,7 +251,7 @@ public class SyncUserStatJob {
.isNotNull(WatchDataStepsHf::getStepCount)
.gt(WatchDataStepsHf::getStepCount, 0)
.orderByDesc(WatchDataStepsHf::getStepCount)
.last("limit 1");
.last("FETCH FIRST 1 ROWS ONLY");
WatchDataStepsHf latest = watchDataStepsHfServiceService.getOne(queryWrapper);
if (ObjectUtil.isNull(latest)) {
return;
@@ -306,21 +306,21 @@ public class SyncUserStatJob {
queryWrapper.isNotNull(WatchDataSteps::getDataValue);
queryWrapper.gt(WatchDataSteps::getDataValue, 0);
queryWrapper.orderByDesc(WatchDataSteps::getMaxId);
queryWrapper.last("limit 1");
queryWrapper.last("FETCH FIRST 1 ROWS ONLY");
WatchDataSteps list = watchDataStepsService.getOne(queryWrapper);
LambdaQueryWrapper<WatchDataDistance> watchDataDistanceQueryWrapper = getQueryWrapper(userId, dateStr);
watchDataDistanceQueryWrapper.gt(WatchDataDistance::getDataValue, 0);
watchDataDistanceQueryWrapper.isNotNull(WatchDataDistance::getDataValue);
watchDataDistanceQueryWrapper.orderByDesc(WatchDataDistance::getMaxId);
watchDataDistanceQueryWrapper.last("limit 1");
watchDataDistanceQueryWrapper.last("FETCH FIRST 1 ROWS ONLY");
WatchDataDistance watchDataDistanceList = watchDataDistanceService.getOne(watchDataDistanceQueryWrapper);
LambdaQueryWrapper<WatchDataCalorie> watchDataCalorieQueryWrapper = getQueryWrapper(userId, dateStr);
watchDataCalorieQueryWrapper.gt(WatchDataCalorie::getDataValue, 0);
watchDataCalorieQueryWrapper.isNotNull(WatchDataCalorie::getDataValue);
watchDataCalorieQueryWrapper.orderByDesc(WatchDataCalorie::getMaxId);
watchDataCalorieQueryWrapper.last("limit 1");
watchDataCalorieQueryWrapper.last("FETCH FIRST 1 ROWS ONLY");
WatchDataCalorie watchDataCalorieList = watchDataCalorieService.getOne(watchDataCalorieQueryWrapper);
if (ObjectUtil.isNull(list) && ObjectUtil.isNull(watchDataDistanceList) && ObjectUtil.isNull(watchDataCalorieList)) {
@@ -833,7 +833,9 @@ public class SyncUserStatJob {
rate.setSilenceMinValue((int) silenceMin);
rate.setSilenceAvgValue((int) silenceSize);
rate.setNewValue(currentDataValue.intValue());
rate.setSilenceNewValue(watchDataHeartRate.getSilenceValue().intValue());
if(watchDataHeartRate.getSilenceValue() != null){
rate.setSilenceNewValue(watchDataHeartRate.getSilenceValue().intValue());
}
rate.setLastUploadTime(watchDataHeartRate.getTimeStamp());
SyncUserStatJob bean = SpringContextUtils.getBean(SyncUserStatJob.class);
@@ -928,7 +930,7 @@ public class SyncUserStatJob {
LambdaQueryWrapper<WatchDevice> deviceWrapper = new LambdaQueryWrapper<>();
deviceWrapper.eq(WatchDevice::getBindUserId, user.getId());
deviceWrapper.orderByDesc(WatchDevice::getBindDate);
deviceWrapper.last("limit 1");
deviceWrapper.last("FETCH FIRST 1 ROWS ONLY");
WatchDevice watchDevice = watchDeviceMapper.selectOne(deviceWrapper);
if (watchDevice != null) {
watchData.setWatchNo(watchDevice.getWatchNo());