package com.yuchen.saas.park.service.controller.third;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.request.ElevatorPointRequest;
import com.yuchen.saas.park.api.request.ThirdCallElevatorRequest;
import com.yuchen.saas.park.api.request.ThirdElevatorMonitorRunningStateRequest;
import com.yuchen.saas.park.api.request.ThirdKeepElevatorDoorRequest;
import com.yuchen.saas.park.api.response.ThirdElevatorMonitorRunningStateResponse;
import com.yuchen.saas.park.api.response.ThirdElevatorPointResponse;
import com.yuchen.saas.park.api.response.ElevatorMonitorRunningStateResponse;
import com.yuchen.saas.park.api.vo.door.PlDoorPointForRobotVO;
import com.yuchen.saas.park.api.vo.request.PlDoorPointReq;
import com.yuchen.saas.park.service.annotation.Signature;
import com.yuchen.saas.park.service.service.elevator.ISaasParkElevatorManageLocationService;
import com.yuchen.saas.park.service.service.elevator.ISaasParkElevatorMonitorRunningStateService;
import com.yuchen.saas.park.service.service.pldoor.PlDoorPointService;
import com.yuchen.saas.park.service.service.pldoor.PlDoorUserPointSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author: baichaojie
 * @CreateTime: 2024/10/30 11:28
 * @Description: 第三方机器人调用接口
 * @Version: 1.0
 */

@Api(tags = "机器人第三方调用 前端控制器")
@RestController
@RequestMapping("/third")
public class ThirdRobotController {

    @Autowired
    private  ISaasParkElevatorMonitorRunningStateService iSaasParkElevatorMonitorService;
    @Autowired
    private PlDoorUserPointSetService plDoorUserPointSetService;
    @Autowired
    private PlDoorPointService plDoorPointService;

    @Autowired
    private ISaasParkElevatorManageLocationService iSaasParkElevatorManageLocationService;



    /**
     * 梯控-呼梯
     * @param reqDTO
     * @return
     */
    //@Signature
    @PostMapping("/callElevator")
    @ApiOperation(value = "梯控-呼梯", notes = "梯控-呼梯")
    public R callElevator(@Valid ThirdCallElevatorRequest reqDTO) {
        boolean b = iSaasParkElevatorMonitorService.callElevator(reqDTO);
        return R.data(b);
    }



    /**
     * 梯控-开门保持指令
     * @param reqDTO
     * @return
     */
    //@Signature
    @PostMapping("/keepElevatorDoor")
    @ApiOperation(value = "梯控-开门保持指令", notes = "梯控-开门保持指令")
    public R keepElevatorDoor(@Valid ThirdKeepElevatorDoorRequest reqDTO) {
        boolean b = iSaasParkElevatorMonitorService.keepElevatorDoor(reqDTO.getId(),reqDTO.getDoorStatus());
        return R.data(b);
    }

    /**
     * 梯控-电梯运行状态
     * @param reqDTO
     * @param query
     * @return
     */
    @Signature
    @GetMapping("/getElevatorDeviceRunningState")
    @ApiOperation(value = "梯控-电梯运行列表", notes = "梯控-电梯运行状态列表")
    public R<IPage<ThirdElevatorMonitorRunningStateResponse>> list(@Valid ThirdElevatorMonitorRunningStateRequest reqDTO, Query query) {
        return iSaasParkElevatorMonitorService.thirdList(reqDTO, query);
    }

    @Signature
    @GetMapping("/getPointList")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "机器人获取园区门禁点列表", notes = "机器人获取园区门禁点列表")
    public R<List<PlDoorPointForRobotVO>> getPointList(Long parkId) {
        List<PlDoorPointForRobotVO> pointListForRobot = plDoorPointService.getPointListForRobot(parkId);
        return R.data(pointListForRobot);
    }

    /**
     * MC机器人远程开门接口
     * @param robotSn
     * @param parkId
     * @param pointId
     * @return
     */
    @Signature
    @GetMapping("/openDoor")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "机器人远程开门接口", notes = "机器人远程开门接口")
    public R openDoor(String robotSn, Long parkId, Long pointId) {
        return R.status(plDoorUserPointSetService.openDoorForMcRobot(robotSn, parkId,pointId));
    }

    /**
     * 梯控-电梯设备
     *
     * @param reqDTO
     * @param query
     * @return
     */
    @Signature
    @GetMapping("/getElevatorDevice")
    @ApiOperation(value = "梯控-设备列表", notes = "梯控-设备列表")
    public R<IPage<ThirdElevatorPointResponse>> getElevatorDevice(@Valid ElevatorPointRequest reqDTO, Query query) {
        return iSaasParkElevatorManageLocationService.thirdList(reqDTO, query);
    }





}