Browse Source

fix:修改状态的时候直接本地化

master
白凤吉 4 days ago
parent
commit
d0142739cb
  1. 3
      src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java
  2. 3
      src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java
  3. 4
      src/main/java/com/iflytop/handacid/app/service/DeviceService.java
  4. 8
      src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java

3
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
}

3
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完毕");
}

4
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());

8
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<SystemConfigMapper, SystemConfig> {
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);

Loading…
Cancel
Save