加酸仪(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

  1. package com.iflytop.handacid.app.service;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.iflytop.handacid.app.common.enums.SystemConfigKey;
  4. import com.iflytop.handacid.app.core.state.ChannelState;
  5. import com.iflytop.handacid.app.core.state.DeviceState;
  6. import com.iflytop.handacid.app.model.bo.SyncOperationsChannel;
  7. import com.iflytop.handacid.app.model.dto.SyncOperationsDTO;
  8. import com.iflytop.handacid.common.model.entity.Channel;
  9. import com.iflytop.handacid.common.model.entity.SystemConfig;
  10. import com.iflytop.handacid.common.service.ChannelService;
  11. import com.iflytop.handacid.common.service.SystemConfigService;
  12. import lombok.RequiredArgsConstructor;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.stereotype.Service;
  15. /**
  16. * 设备
  17. */
  18. @Slf4j
  19. @Service
  20. @RequiredArgsConstructor
  21. public class DeviceService {
  22. private final DeviceState deviceState;
  23. private final SystemConfigService systemConfigService;
  24. private final ChannelService channelService;
  25. public void syncOperations(SyncOperationsDTO syncOperationsDTO) {
  26. deviceState.setMode(syncOperationsDTO.getMode());
  27. systemConfigService.updateValueByKey(SystemConfigKey.SOLUTION_ADD_MODE, syncOperationsDTO.getMode().toString());
  28. for (SyncOperationsChannel syncOperationsChannel : syncOperationsDTO.getChannels()) {
  29. ChannelState channelState = deviceState.getChannelStateMap().get(syncOperationsChannel.getChannelCode());
  30. channelState.setSelected(syncOperationsChannel.isSelected());
  31. channelState.setTargetVolume(syncOperationsChannel.getTargetVolume());
  32. Channel channel = channelService.getOne(new LambdaQueryWrapper<>(Channel.class).eq(Channel::getCode, syncOperationsChannel.getChannelCode()));
  33. channel.setTargetVolume(syncOperationsChannel.getTargetVolume());
  34. channelService.updateById(channel);
  35. }
  36. }
  37. }