3 changed files with 90 additions and 193 deletions
-
110src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java
-
76src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java
-
97src/main/java/com/iflytop/handacid/app/command/control/SolutionPreFillStartCommand.java
@ -1,55 +1,55 @@ |
|||||
//package com.iflytop.handacid.app.command.control; |
|
||||
// |
|
||||
//import com.iflytop.handacid.app.common.annotation.CommandMapping; |
|
||||
//import com.iflytop.handacid.app.common.enums.ChannelCode; |
|
||||
//import com.iflytop.handacid.app.common.enums.Direction; |
|
||||
//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.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.concurrent.CompletableFuture; |
|
||||
// |
|
||||
///** |
|
||||
// * 蠕动泵旋转 |
|
||||
// */ |
|
||||
//@Slf4j |
|
||||
//@Component |
|
||||
//@RequiredArgsConstructor |
|
||||
//@CommandMapping("pump_rotate_start") |
|
||||
//public class PumpRotateStartCommand extends BaseCommandHandler { |
|
||||
// private final DeviceCommandService deviceCommandService; |
|
||||
// private final ChannelCtrlService channelCtrlService; |
|
||||
// |
|
||||
// @Override |
|
||||
// public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
||||
// ChannelCode channelCode = commandDTO.getEnumParam("channelCode", ChannelCode.class); |
|
||||
// if (channelCode == null) { |
|
||||
// throw new IllegalArgumentException("参数 channelCode 不能为空"); |
|
||||
// } |
|
||||
// Direction direction = commandDTO.getEnumParam("direction", Direction.class); |
|
||||
// if (direction == null) { |
|
||||
// throw new IllegalArgumentException("参数 direction 不能为空"); |
|
||||
// } |
|
||||
// return runAsync(() -> { |
|
||||
// if(Direction.FORWARD.equals(direction)) { |
|
||||
// DeviceCommand deviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode); |
|
||||
// CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); |
|
||||
// CommandUtil.wait(commandFuture); |
|
||||
// }else{ |
|
||||
// DeviceCommand deviceCommand = channelCtrlService.getPumpBackwardRotateCommandByChannel(channelCode); |
|
||||
// CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); |
|
||||
// CommandUtil.wait(commandFuture); |
|
||||
// } |
|
||||
// |
|
||||
// }); |
|
||||
// } |
|
||||
//} |
|
||||
// |
|
||||
|
package com.iflytop.handacid.app.command.control; |
||||
|
|
||||
|
import com.iflytop.handacid.app.common.annotation.CommandMapping; |
||||
|
import com.iflytop.handacid.app.common.enums.ChannelCode; |
||||
|
import com.iflytop.handacid.app.common.enums.Direction; |
||||
|
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.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.concurrent.CompletableFuture; |
||||
|
|
||||
|
/** |
||||
|
* 蠕动泵旋转 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@RequiredArgsConstructor |
||||
|
@CommandMapping("pump_rotate_start") |
||||
|
public class PumpRotateStartCommand extends BaseCommandHandler { |
||||
|
private final DeviceCommandService deviceCommandService; |
||||
|
private final ChannelCtrlService channelCtrlService; |
||||
|
|
||||
|
@Override |
||||
|
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
||||
|
ChannelCode channelCode = commandDTO.getEnumParam("channelCode", ChannelCode.class); |
||||
|
if (channelCode == null) { |
||||
|
throw new IllegalArgumentException("参数 channelCode 不能为空"); |
||||
|
} |
||||
|
Direction direction = commandDTO.getEnumParam("direction", Direction.class); |
||||
|
if (direction == null) { |
||||
|
throw new IllegalArgumentException("参数 direction 不能为空"); |
||||
|
} |
||||
|
return runAsync(() -> { |
||||
|
if(Direction.FORWARD.equals(direction)) { |
||||
|
DeviceCommand deviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode); |
||||
|
CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); |
||||
|
CommandUtil.wait(commandFuture); |
||||
|
}else{ |
||||
|
DeviceCommand deviceCommand = channelCtrlService.getPumpBackwardRotateCommandByChannel(channelCode); |
||||
|
CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); |
||||
|
CommandUtil.wait(commandFuture); |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
@ -1,63 +1,34 @@ |
|||||
//package com.iflytop.handacid.app.command.control; |
|
||||
// |
|
||||
//import cn.hutool.json.JSONArray; |
|
||||
//import cn.hutool.json.JSONObject; |
|
||||
//import com.iflytop.handacid.app.common.annotation.CommandMapping; |
|
||||
//import com.iflytop.handacid.app.common.enums.ChannelCode; |
|
||||
//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.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_pre_fill_start") |
|
||||
//public class SolutionPreFillStartCommand extends BaseCommandHandler { |
|
||||
// private final DeviceCommandService deviceCommandService; |
|
||||
// private final ChannelCtrlService channelCtrlService; |
|
||||
// private final DeviceState deviceState; |
|
||||
// |
|
||||
// @Override |
|
||||
// public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
||||
// JSONArray jsonArray = commandDTO.getJSONArrayParam("channelArray"); |
|
||||
// List<ChannelCode> channelCodeList = new ArrayList<>(); |
|
||||
// for (int i = 0; i < jsonArray.size(); i++) { |
|
||||
// JSONObject jsonObject = jsonArray.getJSONObject(i); |
|
||||
// String channelCodeStr = jsonObject.getStr("channelCode"); |
|
||||
// if (channelCodeStr == null) { |
|
||||
// throw new IllegalArgumentException("参数 channelCode 不能为空"); |
|
||||
// } |
|
||||
// } |
|
||||
// return runAsync(() -> { |
|
||||
// for (ChannelCode channelCode : channelCodeList) { |
|
||||
// deviceState.getChannelStateMap().get(channelCode).setStateCode(ChannelStateCode.PRE); |
|
||||
// } |
|
||||
// List<CommandFuture> commandFutureList = new ArrayList<>(); |
|
||||
// for (int i = 0; i < jsonArray.size(); i++) { |
|
||||
// JSONObject jsonObject = jsonArray.getJSONObject(i); |
|
||||
// String channelCodeStr = jsonObject.getStr("channelCode"); |
|
||||
// ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr); |
|
||||
// DeviceCommand deviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode); |
|
||||
// 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.core.command.BaseCommandHandler; |
||||
|
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.concurrent.CompletableFuture; |
||||
|
|
||||
|
/** |
||||
|
* 开始预充(废弃) |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@RequiredArgsConstructor |
||||
|
@CommandMapping("solution_pre_fill_start") |
||||
|
public class SolutionPreFillStartCommand extends BaseCommandHandler { |
||||
|
private final DeviceCommandService deviceCommandService; |
||||
|
private final ChannelCtrlService channelCtrlService; |
||||
|
private final DeviceState deviceState; |
||||
|
|
||||
|
@Override |
||||
|
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
||||
|
return runAsync(() -> { |
||||
|
channelCtrlService.solutionPreFillStart(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue