Browse Source

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

master
白凤吉 5 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.service.ChannelCtrlService;
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.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -31,6 +33,7 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("solution_add_start")
public class SolutionAddStartCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final FormulationService formulationService;
private final ChannelCtrlService channelCtrlService;
private final DeviceState deviceState;
@ -46,9 +49,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler {
}
ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr);
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);
@ -68,8 +71,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String channelCodeStr = jsonObject.getStr("channelCode");
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));
}
CommandUtil.wait(commandFutureList);
@ -81,8 +85,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String channelCodeStr = jsonObject.getStr("channelCode");
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));
}
CommandUtil.wait(commandFutureList);

Loading…
Cancel
Save