diff --git a/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java b/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java index 5b5fae6..035c09c 100644 --- a/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java +++ b/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java @@ -1,5 +1,6 @@ package com.iflytop.handacid.app.common.enums; public enum SystemConfigKey { - SOLUTION_ADD_MODE + SOLUTION_ADD_MODE, + SOLUTION_ADD_DELAY } diff --git a/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java b/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java index 78247c4..7dfa835 100644 --- a/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java +++ b/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java @@ -104,7 +104,8 @@ public class DeviceInitService { } deviceState.getChannelStateMap().put(code, channelState); } - deviceState.setMode(SolutionAddMode.valueOf(systemConfigService.getValueByKey(SystemConfigKey.SOLUTION_ADD_MODE))); + deviceState.setMode(SolutionAddMode.valueOf(systemConfigService.getValueByKeyToString(SystemConfigKey.SOLUTION_ADD_MODE))); + deviceState.setDelay(systemConfigService.getValueByKeyToInteger(SystemConfigKey.SOLUTION_ADD_DELAY)); deviceState.setRemoteControlState(remoteControlStateObjectProvider.getObject()); log.info("初始化 initDeviceState完毕"); } diff --git a/src/main/java/com/iflytop/handacid/app/service/DeviceService.java b/src/main/java/com/iflytop/handacid/app/service/DeviceService.java index 6d21a5a..b381091 100644 --- a/src/main/java/com/iflytop/handacid/app/service/DeviceService.java +++ b/src/main/java/com/iflytop/handacid/app/service/DeviceService.java @@ -30,6 +30,10 @@ public class DeviceService { deviceState.setMode(syncOperationsDTO.getMode()); systemConfigService.updateValueByKey(SystemConfigKey.SOLUTION_ADD_MODE, syncOperationsDTO.getMode().toString()); } + if(syncOperationsDTO.getDelay() != null){ + deviceState.setDelay(syncOperationsDTO.getDelay()); + systemConfigService.updateValueByKey(SystemConfigKey.SOLUTION_ADD_DELAY, syncOperationsDTO.getMode().toString()); + } if(syncOperationsDTO.getChannels() != null){ for (SyncOperationsChannel syncOperationsChannel : syncOperationsDTO.getChannels()) { ChannelState channelState = deviceState.getChannelStateMap().get(syncOperationsChannel.getChannelCode()); diff --git a/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java b/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java index 0b0db11..49c664c 100644 --- a/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java +++ b/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iflytop.handacid.app.common.enums.SystemConfigKey; import com.iflytop.handacid.common.mapper.SystemConfigMapper; import com.iflytop.handacid.common.model.entity.SystemConfig; -import com.iflytop.handacid.common.model.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -17,11 +16,16 @@ import org.springframework.stereotype.Service; public class SystemConfigService extends ServiceImpl { - public String getValueByKey(SystemConfigKey key){ + public String getValueByKeyToString(SystemConfigKey key){ SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<>(SystemConfig.class).eq(SystemConfig::getKey, key)); return systemConfig != null ? systemConfig.getValue() : null; } + public Integer getValueByKeyToInteger(SystemConfigKey key){ + SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<>(SystemConfig.class).eq(SystemConfig::getKey, key)); + return systemConfig != null ? Integer.parseInt(systemConfig.getValue()) : null; + } + public boolean updateValueByKey(SystemConfigKey key, String value){ SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<>(SystemConfig.class).eq(SystemConfig::getKey, key)); systemConfig.setValue(value);