5 changed files with 70 additions and 53 deletions
-
9src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStartCommand.java
-
96src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStopCommand.java
-
4src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java
-
5src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java
-
9src/main/resources/sql/init.sql
@ -1,48 +1,48 @@ |
|||||
package com.iflytop.handacid.app.command.control; |
|
||||
|
|
||||
import com.iflytop.handacid.app.common.annotation.CommandMapping; |
|
||||
import com.iflytop.handacid.app.common.enums.ChannelStateCode; |
|
||||
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.state.ChannelState; |
|
||||
import com.iflytop.handacid.app.core.state.DeviceState; |
|
||||
import com.iflytop.handacid.app.model.dto.CommandDTO; |
|
||||
import com.iflytop.handacid.app.service.ChannelCtrlService; |
|
||||
import com.iflytop.handacid.app.service.DeviceCommandService; |
|
||||
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; |
|
||||
|
|
||||
/** |
|
||||
* 停止排空 |
|
||||
*/ |
|
||||
@Slf4j |
|
||||
@Component |
|
||||
@RequiredArgsConstructor |
|
||||
@CommandMapping("solution_drain_stop") |
|
||||
public class SolutionDrainStopCommand extends BaseCommandHandler { |
|
||||
private final DeviceCommandService deviceCommandService; |
|
||||
private final ChannelCtrlService channelCtrlService; |
|
||||
private final DeviceState deviceState; |
|
||||
|
|
||||
@Override |
|
||||
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
||||
List<ChannelState> channelCodeList = deviceState.filterChannelStatesByState(ChannelStateCode.DRAIN); |
|
||||
return runAsync(() -> { |
|
||||
List<CommandFuture> commandFutureList = new ArrayList<>(); |
|
||||
for (ChannelState channelState : channelCodeList) { |
|
||||
channelState.setStateCode(ChannelStateCode.DRAIN); |
|
||||
DeviceCommand deviceCommand = channelCtrlService.getPumpStopCommandByChannel(channelState.getChannelCode()); |
|
||||
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); |
|
||||
} |
|
||||
CommandUtil.wait(commandFutureList); |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
//package com.iflytop.handacid.app.command.control; |
||||
|
// |
||||
|
//import com.iflytop.handacid.app.common.annotation.CommandMapping; |
||||
|
//import com.iflytop.handacid.app.common.enums.ChannelStateCode; |
||||
|
//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.state.ChannelState; |
||||
|
//import com.iflytop.handacid.app.core.state.DeviceState; |
||||
|
//import com.iflytop.handacid.app.model.dto.CommandDTO; |
||||
|
//import com.iflytop.handacid.app.service.ChannelCtrlService; |
||||
|
//import com.iflytop.handacid.app.service.DeviceCommandService; |
||||
|
//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; |
||||
|
// |
||||
|
///** |
||||
|
// * 停止排空 |
||||
|
// */ |
||||
|
//@Slf4j |
||||
|
//@Component |
||||
|
//@RequiredArgsConstructor |
||||
|
//@CommandMapping("solution_drain_stop") |
||||
|
//public class SolutionDrainStopCommand extends BaseCommandHandler { |
||||
|
// private final DeviceCommandService deviceCommandService; |
||||
|
// private final ChannelCtrlService channelCtrlService; |
||||
|
// private final DeviceState deviceState; |
||||
|
// |
||||
|
// @Override |
||||
|
// public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
||||
|
// List<ChannelState> channelCodeList = deviceState.filterChannelStatesByState(ChannelStateCode.DRAIN); |
||||
|
// return runAsync(() -> { |
||||
|
// List<CommandFuture> commandFutureList = new ArrayList<>(); |
||||
|
// for (ChannelState channelState : channelCodeList) { |
||||
|
// channelState.setStateCode(ChannelStateCode.DRAIN); |
||||
|
// DeviceCommand deviceCommand = channelCtrlService.getPumpStopCommandByChannel(channelState.getChannelCode()); |
||||
|
// commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); |
||||
|
// } |
||||
|
// CommandUtil.wait(commandFutureList); |
||||
|
// }); |
||||
|
// } |
||||
|
//} |
||||
|
// |
Write
Preview
Loading…
Cancel
Save
Reference in new issue