Browse Source

feat:初始化增加mode状态

master
白凤吉 5 days ago
parent
commit
837a0ee3c2
  1. 5
      src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java
  2. 6
      src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java
  3. 8
      src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java
  4. 3
      src/main/resources/sql/init.sql

5
src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java

@ -0,0 +1,5 @@
package com.iflytop.handacid.app.common.enums;
public enum SystemConfigKey {
SOLUTION_ADD_MODE
}

6
src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java

@ -2,12 +2,15 @@ package com.iflytop.handacid.app.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.iflytop.handacid.app.common.enums.ChannelCode; import com.iflytop.handacid.app.common.enums.ChannelCode;
import com.iflytop.handacid.app.common.enums.SolutionAddMode;
import com.iflytop.handacid.app.common.enums.SystemConfigKey;
import com.iflytop.handacid.app.core.state.ChannelState; import com.iflytop.handacid.app.core.state.ChannelState;
import com.iflytop.handacid.app.core.state.DeviceState; import com.iflytop.handacid.app.core.state.DeviceState;
import com.iflytop.handacid.common.model.entity.Channel; import com.iflytop.handacid.common.model.entity.Channel;
import com.iflytop.handacid.common.model.entity.Solution; import com.iflytop.handacid.common.model.entity.Solution;
import com.iflytop.handacid.common.service.ChannelService; import com.iflytop.handacid.common.service.ChannelService;
import com.iflytop.handacid.common.service.SolutionService; import com.iflytop.handacid.common.service.SolutionService;
import com.iflytop.handacid.common.service.SystemConfigService;
import com.iflytop.handacid.hardware.service.AppEventBusService; import com.iflytop.handacid.hardware.service.AppEventBusService;
import com.iflytop.handacid.hardware.type.appevent.A8kCanBusOnConnectEvent; import com.iflytop.handacid.hardware.type.appevent.A8kCanBusOnConnectEvent;
import com.iflytop.handacid.hardware.type.appevent.AppEvent; import com.iflytop.handacid.hardware.type.appevent.AppEvent;
@ -27,6 +30,7 @@ public class DeviceInitService {
private final ObjectProvider<ChannelState> channelStateObjectProvider; private final ObjectProvider<ChannelState> channelStateObjectProvider;
private final ChannelService channelService; private final ChannelService channelService;
private final SolutionService solutionService; private final SolutionService solutionService;
private final SystemConfigService systemConfigService;
@PostConstruct @PostConstruct
@ -60,6 +64,8 @@ public class DeviceInitService {
ChannelState channelState = channelStateObjectProvider.getObject(code, solution.getId(), solution.getName(), channel.getConcentration(), channel.getTargetVolume(), channel.getReceivedVolume(), channel.getCurrentVolume()); ChannelState channelState = channelStateObjectProvider.getObject(code, solution.getId(), solution.getName(), channel.getConcentration(), channel.getTargetVolume(), channel.getReceivedVolume(), channel.getCurrentVolume());
deviceState.getChannelStateMap().put(code, channelState); deviceState.getChannelStateMap().put(code, channelState);
} }
SolutionAddMode mode = SolutionAddMode.valueOf(systemConfigService.getValueByKey(SystemConfigKey.SOLUTION_ADD_MODE));
deviceState.setMode(mode);
log.info("初始化 initDeviceState完毕"); log.info("初始化 initDeviceState完毕");
} }

8
src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java

@ -1,8 +1,11 @@
package com.iflytop.handacid.common.service; package com.iflytop.handacid.common.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.mapper.SystemConfigMapper;
import com.iflytop.handacid.common.model.entity.SystemConfig; import com.iflytop.handacid.common.model.entity.SystemConfig;
import com.iflytop.handacid.common.model.entity.User;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -13,4 +16,9 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor @RequiredArgsConstructor
public class SystemConfigService extends ServiceImpl<SystemConfigMapper, SystemConfig> { public class SystemConfigService extends ServiceImpl<SystemConfigMapper, SystemConfig> {
public String getValueByKey(SystemConfigKey key){
SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<>(SystemConfig.class).eq(SystemConfig::getKey, key));
return systemConfig != null ? systemConfig.getValue() : null;
}
} }

3
src/main/resources/sql/init.sql

@ -85,6 +85,9 @@ CREATE TABLE IF NOT EXISTS system_config (
update_time TEXT DEFAULT CURRENT_TIMESTAMP update_time TEXT DEFAULT CURRENT_TIMESTAMP
); );
INSERT OR IGNORE INTO system_config (id, key, value) VALUES
(1, 'SOLUTION_ADD_MODE','AUTO');
-- 系统日志 -- 系统日志
CREATE TABLE IF NOT EXISTS system_log ( CREATE TABLE IF NOT EXISTS system_log (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,

Loading…
Cancel
Save