diff --git a/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStartCommand.java b/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStartCommand.java index 5aef560..de7afa8 100644 --- a/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStartCommand.java +++ b/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStartCommand.java @@ -2,6 +2,7 @@ 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.enums.SystemConfigKey; import com.iflytop.handacid.app.common.utils.CommandUtil; import com.iflytop.handacid.app.core.command.BaseCommandHandler; import com.iflytop.handacid.app.core.command.CommandFuture; @@ -11,6 +12,7 @@ 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 com.iflytop.handacid.common.service.SystemConfigService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -30,6 +32,7 @@ public class SolutionDrainStartCommand extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; private final ChannelCtrlService channelCtrlService; private final DeviceState deviceState; + private final SystemConfigService systemConfigService; @Override public CompletableFuture handle(CommandDTO commandDTO) { @@ -38,10 +41,14 @@ public class SolutionDrainStartCommand extends BaseCommandHandler { List commandFutureList = new ArrayList<>(); for (ChannelState channelState : channelCodeList) { channelState.setStateCode(ChannelStateCode.DRAIN); - DeviceCommand deviceCommand = channelCtrlService.getPumpBackwardRotateCommandByChannel(channelState.getChannelCode()); + Double drainRevolutions = systemConfigService.getValueByKeyToDouble(SystemConfigKey.DRAIN_REVOLUTIONS); + DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelState.getChannelCode(), -drainRevolutions); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); } CommandUtil.wait(commandFutureList); + for (ChannelState channelState : channelCodeList) { + channelState.setStateCode(ChannelStateCode.IDLE); + } }); } } diff --git a/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStopCommand.java b/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStopCommand.java index e2a7dcc..6d69b88 100644 --- a/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStopCommand.java +++ b/src/main/java/com/iflytop/handacid/app/command/control/SolutionDrainStopCommand.java @@ -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 handle(CommandDTO commandDTO) { - List channelCodeList = deviceState.filterChannelStatesByState(ChannelStateCode.DRAIN); - return runAsync(() -> { - List 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 handle(CommandDTO commandDTO) { +// List channelCodeList = deviceState.filterChannelStatesByState(ChannelStateCode.DRAIN); +// return runAsync(() -> { +// List 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); +// }); +// } +//} +// diff --git a/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java b/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java index 82801f7..448fd66 100644 --- a/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java +++ b/src/main/java/com/iflytop/handacid/app/common/enums/SystemConfigKey.java @@ -17,4 +17,8 @@ public enum SystemConfigKey { * 设备SN码 */ DEVICE_SN, + /** + * 排空转数 + */ + DRAIN_REVOLUTIONS, } diff --git a/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java b/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java index 49c664c..1ea6dbd 100644 --- a/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java +++ b/src/main/java/com/iflytop/handacid/common/service/SystemConfigService.java @@ -26,6 +26,11 @@ public class SystemConfigService extends ServiceImpl(SystemConfig.class).eq(SystemConfig::getKey, key)); + return systemConfig != null ? Double.parseDouble(systemConfig.getValue()) : null; + } + public boolean updateValueByKey(SystemConfigKey key, String value){ SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<>(SystemConfig.class).eq(SystemConfig::getKey, key)); systemConfig.setValue(value); diff --git a/src/main/resources/sql/init.sql b/src/main/resources/sql/init.sql index 134dc8c..89128e6 100644 --- a/src/main/resources/sql/init.sql +++ b/src/main/resources/sql/init.sql @@ -86,10 +86,11 @@ CREATE TABLE IF NOT EXISTS system_config ( ); INSERT OR IGNORE INTO system_config (id, key, value, description) VALUES - (1, 'SOLUTION_ADD_MODE','AUTO', '加液模式'), - (2, 'SOLUTION_ADD_DELAY','3', '自动加液间隔'), - (3, 'PUMP_CONVERSION_FACTOR','100', '蠕动泵转数与泵位置换算系数'), - (4, 'DEVICE_SN','ABCDEFG202507312000000001', '设备SN码'); + (1, 'SOLUTION_ADD_MODE', 'AUTO', '加液模式'), + (2, 'SOLUTION_ADD_DELAY', '3', '自动加液间隔'), + (3, 'PUMP_CONVERSION_FACTOR', '100', '蠕动泵转数与泵位置换算系数'), + (4, 'DEVICE_SN', 'ABCDEFG202507312000000001', '设备SN码'), + (5, 'DRAIN_REVOLUTIONS', '50', '排空转数'); -- 系统日志 CREATE TABLE IF NOT EXISTS system_log (