加酸仪(java版本)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.9 KiB

package com.iflytop.handacid.app.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.iflytop.handacid.app.common.enums.SystemConfigKey;
import com.iflytop.handacid.app.core.state.ChannelState;
import com.iflytop.handacid.app.core.state.DeviceState;
import com.iflytop.handacid.app.model.bo.SyncOperationsChannel;
import com.iflytop.handacid.app.model.dto.SyncOperationsDTO;
import com.iflytop.handacid.common.model.entity.Channel;
import com.iflytop.handacid.common.model.entity.SystemConfig;
import com.iflytop.handacid.common.service.ChannelService;
import com.iflytop.handacid.common.service.SystemConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 设备
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class DeviceService {
private final DeviceState deviceState;
private final SystemConfigService systemConfigService;
private final ChannelService channelService;
public void syncOperations(SyncOperationsDTO syncOperationsDTO) {
deviceState.setMode(syncOperationsDTO.getMode());
systemConfigService.updateValueByKey(SystemConfigKey.SOLUTION_ADD_MODE, syncOperationsDTO.getMode().toString());
for (SyncOperationsChannel syncOperationsChannel : syncOperationsDTO.getChannels()) {
ChannelState channelState = deviceState.getChannelStateMap().get(syncOperationsChannel.getChannelCode());
channelState.setSelected(syncOperationsChannel.isSelected());
channelState.setTargetVolume(syncOperationsChannel.getTargetVolume());
Channel channel = channelService.getOne(new LambdaQueryWrapper<>(Channel.class).eq(Channel::getCode, syncOperationsChannel.getChannelCode()));
channel.setTargetVolume(syncOperationsChannel.getTargetVolume());
channelService.updateById(channel);
}
}
}