|
|
@ -1,12 +1,19 @@ |
|
|
|
package com.iflytop.handacid.app.service; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.iflytop.handacid.app.common.enums.ChannelCode; |
|
|
|
import com.iflytop.handacid.app.core.state.ChannelState; |
|
|
|
import com.iflytop.handacid.app.core.state.DeviceState; |
|
|
|
import com.iflytop.handacid.app.model.bo.ChannelSolution; |
|
|
|
import com.iflytop.handacid.common.model.entity.Channel; |
|
|
|
import com.iflytop.handacid.common.service.ChannelService; |
|
|
|
import com.iflytop.handacid.hardware.service.AppEventBusService; |
|
|
|
import com.iflytop.handacid.hardware.type.appevent.A8kCanBusOnConnectEvent; |
|
|
|
import com.iflytop.handacid.hardware.type.appevent.AppEvent; |
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.ObjectProvider; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@Slf4j |
|
|
@ -16,6 +23,8 @@ public class DeviceInitService { |
|
|
|
private final AppEventBusService eventBus; |
|
|
|
private boolean isLink = false; |
|
|
|
private final DeviceState deviceState; |
|
|
|
private final ObjectProvider<ChannelState> channelStateObjectProvider; |
|
|
|
private final ChannelService channelService; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void init() { |
|
|
@ -39,8 +48,16 @@ public class DeviceInitService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void initDeviceState() { |
|
|
|
log.info("初始化 initDeviceState"); |
|
|
|
for (ChannelCode code : ChannelCode.values()) { |
|
|
|
//初始化通道 |
|
|
|
Channel channel = channelService.getOne(new LambdaQueryWrapper<>(new Channel()).eq(Channel::getCode, code)); |
|
|
|
ChannelSolution channelSolution = new ChannelSolution(channel.getSolutionId(), channel.getSolutionName(), channel.getConcentration()); |
|
|
|
ChannelState channelState = channelStateObjectProvider.getObject(code, channel.getVolume(), channelSolution); |
|
|
|
deviceState.getChannelStateMap().put(code, channelState); |
|
|
|
} |
|
|
|
log.info("初始化 initDeviceState完毕"); |
|
|
|
} |
|
|
|
|
|
|
|