升级固件

This commit is contained in:
waner
2026-04-10 10:31:04 +08:00
parent 463d2ce897
commit faf88b1bfe
3 changed files with 44 additions and 12 deletions
@@ -98,16 +98,8 @@ public class UpgradeTaskRunner {
return;
}
// 只有 execute 和 verify 都成功后,才认为升级成功并回写设备软件版本表。
DeviceSoftwareVersionEntity versionEntity = new DeviceSoftwareVersionEntity();
String componentCode = componentCode(task.getTaskType());
versionEntity.setComponentCode(componentCode);
versionEntity.setComponentName(componentName(componentCode));
versionEntity.setCurrentVersion(task.getTargetVersion());
versionEntity.setSourceType("UPGRADE");
versionEntity.setDetectedAt(LocalDateTime.now());
versionEntity.setRemarks("updated by offline upgrade task " + task.getTaskId());
deviceSoftwareVersionRepository.saveOrUpdate(versionEntity);
// 只有软件类升级才回写设备软件版本表;固件版本第一版暂不在该表维护。
updateSoftwareVersionIfRequired(task);
upgradeTaskRepository.updateStatus(
task.getTaskId(),
@@ -221,6 +213,21 @@ public class UpgradeTaskRunner {
};
}
private void updateSoftwareVersionIfRequired(UpgradeTaskEntity task) {
String componentCode = componentCode(task.getTaskType());
if (!"TMS".equals(componentCode) && !"RECEIVER".equals(componentCode)) {
return;
}
DeviceSoftwareVersionEntity versionEntity = new DeviceSoftwareVersionEntity();
versionEntity.setComponentCode(componentCode);
versionEntity.setComponentName(componentName(componentCode));
versionEntity.setCurrentVersion(task.getTargetVersion());
versionEntity.setSourceType("UPGRADE");
versionEntity.setDetectedAt(LocalDateTime.now());
versionEntity.setRemarks("updated by offline upgrade task " + task.getTaskId());
deviceSoftwareVersionRepository.saveOrUpdate(versionEntity);
}
private String componentCode(String taskType) {
return trim(taskType);
}