|
|
@ -5,8 +5,11 @@ import com.iflytop.colortitration.app.common.enums.MultipleModuleCode; |
|
|
|
import com.iflytop.colortitration.app.core.command.BaseCommandHandler; |
|
|
|
import com.iflytop.colortitration.app.model.dto.CommandDTO; |
|
|
|
import com.iflytop.colortitration.app.service.module.TitrationModuleService; |
|
|
|
import com.iflytop.colortitration.app.websocket.server.WebSocketSender; |
|
|
|
import com.iflytop.colortitration.common.exception.AppException; |
|
|
|
import com.iflytop.colortitration.common.model.entity.Solutions; |
|
|
|
import com.iflytop.colortitration.common.result.ResultCode; |
|
|
|
import com.iflytop.colortitration.common.service.SolutionsService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -23,23 +26,23 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@CommandMapping("solution_add_start") |
|
|
|
public class SolutionAddCommand extends BaseCommandHandler { |
|
|
|
private final TitrationModuleService titrationModuleService; |
|
|
|
private final WebSocketSender webSocketSender; |
|
|
|
private final SolutionsService solutionService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
|
|
String moduleCodeStr = commandDTO.getStringParam("titrationModuleCode"); |
|
|
|
Long solutionId = commandDTO.getLongParam("solutionId"); |
|
|
|
Solutions solution = solutionService.getById(solutionId); |
|
|
|
Double volume = commandDTO.getDoubleParam("volume"); |
|
|
|
String type = commandDTO.getStringParam("type"); |
|
|
|
if (type.equals("drop")) { |
|
|
|
volume = 0.5; |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(moduleCodeStr) || solutionId == null || StringUtils.isEmpty(type)) { |
|
|
|
if (StringUtils.isEmpty(moduleCodeStr) || solutionId == null) { |
|
|
|
throw new AppException(ResultCode.INVALID_PARAMETER);//参数缺失 |
|
|
|
} |
|
|
|
MultipleModuleCode titrationModuleCode = MultipleModuleCode.valueOf(moduleCodeStr); |
|
|
|
Double finalVolume = volume; |
|
|
|
return runAsync(() -> { |
|
|
|
//移动滴定电机到滴定位 |
|
|
|
webSocketSender.pushLog(titrationModuleCode.name(), "加液:", solution.getName() + " " + finalVolume + "ml"); |
|
|
|
titrationModuleService.titrationMotorMoveToSolution(titrationModuleCode); |
|
|
|
titrationModuleService.addSolutionStart(titrationModuleCode, solutionId, finalVolume); |
|
|
|
}); |
|
|
|