Browse Source

fix:添加溶液从配方中获取转数

master
白凤吉 6 days ago
parent
commit
c71a6d7d80
  1. 19
      src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java

19
src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java

@ -14,6 +14,8 @@ import com.iflytop.handacid.app.core.state.DeviceState;
import com.iflytop.handacid.app.model.dto.CommandDTO; import com.iflytop.handacid.app.model.dto.CommandDTO;
import com.iflytop.handacid.app.service.ChannelCtrlService; import com.iflytop.handacid.app.service.ChannelCtrlService;
import com.iflytop.handacid.app.service.DeviceCommandService; import com.iflytop.handacid.app.service.DeviceCommandService;
import com.iflytop.handacid.common.model.entity.Formulation;
import com.iflytop.handacid.common.service.FormulationService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -31,6 +33,7 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("solution_add_start") @CommandMapping("solution_add_start")
public class SolutionAddStartCommand extends BaseCommandHandler { public class SolutionAddStartCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService; private final DeviceCommandService deviceCommandService;
private final FormulationService formulationService;
private final ChannelCtrlService channelCtrlService; private final ChannelCtrlService channelCtrlService;
private final DeviceState deviceState; private final DeviceState deviceState;
@ -46,9 +49,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler {
} }
ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr); ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr);
channelCodeList.add(channelCode); channelCodeList.add(channelCode);
Double volume = jsonObject.getDouble("volume");
if (volume == null) {
throw new IllegalArgumentException("参数 volume 不能为空");
Double formulationId = jsonObject.getDouble("formulationId");
if (formulationId == null) {
throw new IllegalArgumentException("参数 formulationId 不能为空");
} }
} }
SolutionAddMode mode = commandDTO.getEnumParam("mode", SolutionAddMode.class); SolutionAddMode mode = commandDTO.getEnumParam("mode", SolutionAddMode.class);
@ -68,8 +71,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler {
JSONObject jsonObject = jsonArray.getJSONObject(i); JSONObject jsonObject = jsonArray.getJSONObject(i);
String channelCodeStr = jsonObject.getStr("channelCode"); String channelCodeStr = jsonObject.getStr("channelCode");
ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr); ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr);
Double volume = jsonObject.getDouble("volume");
DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, volume);
Long formulationId = jsonObject.getLong("formulationId");
Formulation formulation = formulationService.getById(formulationId);
DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, formulation.getRevolutions());
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand));
} }
CommandUtil.wait(commandFutureList); CommandUtil.wait(commandFutureList);
@ -81,8 +85,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler {
JSONObject jsonObject = jsonArray.getJSONObject(i); JSONObject jsonObject = jsonArray.getJSONObject(i);
String channelCodeStr = jsonObject.getStr("channelCode"); String channelCodeStr = jsonObject.getStr("channelCode");
ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr); ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr);
Double volume = jsonObject.getDouble("volume");
DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, volume);
Double formulationId = jsonObject.getDouble("formulationId");
Formulation formulation = formulationService.getById(formulationId);
DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, formulation.getRevolutions());
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand));
} }
CommandUtil.wait(commandFutureList); CommandUtil.wait(commandFutureList);

Loading…
Cancel
Save