|
|
@ -1,44 +0,0 @@ |
|
|
|
package com.iflytop.gd.app.command.control; |
|
|
|
|
|
|
|
import com.iflytop.gd.app.core.BaseCommandHandler; |
|
|
|
import com.iflytop.gd.app.model.bo.status.device.TrayState; |
|
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceStateService; |
|
|
|
import com.iflytop.gd.app.service.device.module.SolutionModuleService; |
|
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
|
import com.iflytop.gd.common.exception.AppException; |
|
|
|
import com.iflytop.gd.common.result.ResultCode; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
/** |
|
|
|
* 拍照 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
@CommandMapping("take_photo")//业务指令注解 |
|
|
|
public class TakePhotoCommand extends BaseCommandHandler { |
|
|
|
private final SolutionModuleService solutionModuleService; |
|
|
|
private final DeviceStateService deviceStateService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
if(deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() != 1){ |
|
|
|
throw new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY); |
|
|
|
} |
|
|
|
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); |
|
|
|
if (trayState != null && trayState.getCrafts() != null) { |
|
|
|
throw new AppException(ResultCode.CRAFT_RUNNING); |
|
|
|
} |
|
|
|
return runAsync(() -> { |
|
|
|
solutionModuleService.fillLightOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), 100.0); |
|
|
|
solutionModuleService.takePhoto(cmdDTO.getCommandId(), cmdDTO.getCommand());//拍照 |
|
|
|
solutionModuleService.fillLightClose(cmdDTO.getCommandId(), cmdDTO.getCommand());//关闭补光灯 |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|