|
|
@ -6,6 +6,7 @@ import com.iflytop.handacid.app.common.utils.CommandUtil; |
|
|
|
import com.iflytop.handacid.app.core.command.BaseCommandHandler; |
|
|
|
import com.iflytop.handacid.app.core.command.CommandFuture; |
|
|
|
import com.iflytop.handacid.app.core.command.DeviceCommand; |
|
|
|
import com.iflytop.handacid.app.core.command.DeviceCommandGenerator; |
|
|
|
import com.iflytop.handacid.app.model.dto.CommandDTO; |
|
|
|
import com.iflytop.handacid.app.service.ChannelCtrlService; |
|
|
|
import com.iflytop.handacid.app.service.DeviceCommandService; |
|
|
@ -13,6 +14,8 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
/** |
|
|
@ -28,14 +31,14 @@ public class PumpRotateStopCommand extends BaseCommandHandler { |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
|
|
ChannelCode channelCode = commandDTO.getEnumParam("channelCode", ChannelCode.class); |
|
|
|
if (channelCode == null) { |
|
|
|
throw new IllegalArgumentException("参数 channelCode 不能为空"); |
|
|
|
} |
|
|
|
return runAsync(() -> { |
|
|
|
List<CommandFuture> commandFutureList = new ArrayList<>(); |
|
|
|
for(ChannelCode channelCode : ChannelCode.values()) { |
|
|
|
DeviceCommand deviceCommand = channelCtrlService.getPumpStopCommandByChannel(channelCode); |
|
|
|
CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); |
|
|
|
CommandUtil.wait(commandFuture); |
|
|
|
commandFutureList.add(commandFuture); |
|
|
|
} |
|
|
|
CommandUtil.wait(commandFutureList); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|