fix:设备信息展示

This commit is contained in:
waner 2026-04-16 10:18:17 +08:00
parent 312391052f
commit 1f9b7297a2

View File

@ -44,7 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor(onConstructor_ = @Autowired) @RequiredArgsConstructor
public class InitServiceImpl implements InitService { public class InitServiceImpl implements InitService {
private static final String TASK_TYPE_INIT = "INIT"; private static final String TASK_TYPE_INIT = "INIT";
@ -64,35 +64,14 @@ public class InitServiceImpl implements InitService {
private final InitStepExecutor initStepExecutor; private final InitStepExecutor initStepExecutor;
private final InitCommandProfileService initCommandProfileService; private final InitCommandProfileService initCommandProfileService;
private final InitExecutorProperties initExecutorProperties; private final InitExecutorProperties initExecutorProperties;
private Executor backgroundExecutor = Executors.newCachedThreadPool(); private final Executor backgroundExecutor = Executors.newCachedThreadPool();
private ConcurrentMap<String, CompletableFuture<Void>> activeExecutions = new ConcurrentHashMap<>(); private final ConcurrentMap<String, CompletableFuture<Void>> activeExecutions = new ConcurrentHashMap<>();
InitServiceImpl(
InitTaskRepository initTaskRepository,
InitTaskStepRepository initTaskStepRepository,
CisdPresetProperties cisdPresetProperties,
ObjectMapper objectMapper,
InitStepExecutor initStepExecutor,
InitCommandProfileService initCommandProfileService,
InitExecutorProperties initExecutorProperties,
Executor backgroundExecutor,
ConcurrentMap<String, CompletableFuture<Void>> activeExecutions
) {
this.initTaskRepository = initTaskRepository;
this.initTaskStepRepository = initTaskStepRepository;
this.cisdPresetProperties = cisdPresetProperties;
this.objectMapper = objectMapper;
this.initStepExecutor = initStepExecutor;
this.initCommandProfileService = initCommandProfileService;
this.initExecutorProperties = initExecutorProperties;
this.backgroundExecutor = backgroundExecutor;
this.activeExecutions = activeExecutions;
}
/** /**
* 读取后端预制产品类型和版本 * 读取后端预制产品类型和版本
* 该接口是前端动态渲染企业/间参/直参初始化页的入口 * 该接口是前端动态渲染企业/间参/直参初始化页的入口
*/ */
@Override
public InitPlanTemplateResponse loadTemplate(String ignoredVersion) { public InitPlanTemplateResponse loadTemplate(String ignoredVersion) {
String productType = resolvePresetProductType(); String productType = resolvePresetProductType();
@ -104,6 +83,7 @@ public class InitServiceImpl implements InitService {
return response; return response;
} }
@Override
public InitPreviewResponse preview(InitPreviewRequest request) { public InitPreviewResponse preview(InitPreviewRequest request) {
if (request == null) { if (request == null) {
throw new IllegalArgumentException("request must not be null"); throw new IllegalArgumentException("request must not be null");
@ -124,6 +104,7 @@ public class InitServiceImpl implements InitService {
return response; return response;
} }
@Override
public ResetPreviewResponse previewReset() { public ResetPreviewResponse previewReset() {
ResolvedResetContext context = resolveCurrentResetContext(); ResolvedResetContext context = resolveCurrentResetContext();
String productType = context.productType(); String productType = context.productType();
@ -136,6 +117,7 @@ public class InitServiceImpl implements InitService {
return response; return response;
} }
@Override
public InitCreateTaskResponse createTask(InitPreviewRequest request) { public InitCreateTaskResponse createTask(InitPreviewRequest request) {
if (request == null) { if (request == null) {
throw new IllegalArgumentException("request must not be null"); throw new IllegalArgumentException("request must not be null");
@ -197,6 +179,7 @@ public class InitServiceImpl implements InitService {
return response; return response;
} }
@Override
public ResetCreateTaskResponse createResetTask() { public ResetCreateTaskResponse createResetTask() {
ResolvedResetContext context = resolveCurrentResetContext(); ResolvedResetContext context = resolveCurrentResetContext();
String productType = context.productType(); String productType = context.productType();
@ -244,6 +227,7 @@ public class InitServiceImpl implements InitService {
return response; return response;
} }
@Override
public DeviceInitStateSnapshot getDeviceInitStateSnapshot() { public DeviceInitStateSnapshot getDeviceInitStateSnapshot() {
Optional<InitTaskEntity> running = initTaskRepository.findLatestByStatus("RUNNING"); Optional<InitTaskEntity> running = initTaskRepository.findLatestByStatus("RUNNING");
if (running.isPresent()) { if (running.isPresent()) {
@ -268,6 +252,7 @@ public class InitServiceImpl implements InitService {
return new DeviceInitStateSnapshot("INITIALIZED", TASK_TYPE_INIT, latestInit.get().getStatus(), context.orgCode(), context.mqType()); return new DeviceInitStateSnapshot("INITIALIZED", TASK_TYPE_INIT, latestInit.get().getStatus(), context.orgCode(), context.mqType());
} }
@Override
public CurrentInitConfigResponse loadCurrentInitConfig() { public CurrentInitConfigResponse loadCurrentInitConfig() {
Optional<InitTaskEntity> latestInit = initTaskRepository.findLatestByTaskTypeAndStatus(TASK_TYPE_INIT, "SUCCESS"); Optional<InitTaskEntity> latestInit = initTaskRepository.findLatestByTaskTypeAndStatus(TASK_TYPE_INIT, "SUCCESS");
if (latestInit.isEmpty()) { if (latestInit.isEmpty()) {
@ -276,6 +261,7 @@ public class InitServiceImpl implements InitService {
return resolveCurrentInitConfigFromTask(latestInit.get()); return resolveCurrentInitConfigFromTask(latestInit.get());
} }
@Override
public InitTaskDetailResponse getTask(String taskId) { public InitTaskDetailResponse getTask(String taskId) {
InitTaskEntity entity = requireTask(taskId); InitTaskEntity entity = requireTask(taskId);
@ -292,6 +278,7 @@ public class InitServiceImpl implements InitService {
return response; return response;
} }
@Override
public List<InitTaskStepResponse> getTaskSteps(String taskId) { public List<InitTaskStepResponse> getTaskSteps(String taskId) {
requireTask(taskId); requireTask(taskId);
@ -308,6 +295,7 @@ public class InitServiceImpl implements InitService {
}).toList(); }).toList();
} }
@Override
public InitTaskStepLogResponse getTaskStepLog(String taskId, int stepNo) { public InitTaskStepLogResponse getTaskStepLog(String taskId, int stepNo) {
if (stepNo <= 0) { if (stepNo <= 0) {
throw new IllegalArgumentException("stepNo must be > 0"); throw new IllegalArgumentException("stepNo must be > 0");
@ -343,10 +331,12 @@ public class InitServiceImpl implements InitService {
} }
} }
@Override
public InitTaskExecuteResponse executeTask(String taskId) { public InitTaskExecuteResponse executeTask(String taskId) {
return executeTaskInternal(taskId); return executeTaskInternal(taskId);
} }
@Override
public InitTaskExecuteResponse executeResetTask(String taskId) { public InitTaskExecuteResponse executeResetTask(String taskId) {
InitTaskEntity task = requireTask(taskId); InitTaskEntity task = requireTask(taskId);
String taskType = normalize(task.getTaskType()); String taskType = normalize(task.getTaskType());