package com.shkj.wms.controller.busin;

import com.shkj.common.annotation.Log;
import com.shkj.common.annotation.RepeatSubmit;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.enums.BusinessType;
import com.shkj.wms.bo.AGVStatesBo;
import com.shkj.wms.bo.AGVUploadStatusBo;
import com.shkj.wms.third.rcs.RCSUtil;
import com.shkj.wms.bo.AGVMoveBo;
import com.shkj.wms.bo.BusinTaskQueryBo;
import com.shkj.wms.domain.BusinDataTask;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RequiredArgsConstructor(onConstructor_ =@Autowired)
@RestController
@RequestMapping("/wcs/agv")
public class AgvController extends BaseController{


  private final RCSUtil rcsUtil;
    /**
     * 获取AGV实时数据信息，存储及推送数据
     */
    @Log(title = "获取AGVS实时数据",businessType = BusinessType.UPDATE)
    @PostMapping("/getRcsRobotsStatesInfo")
    @RepeatSubmit
    public Result<AGVStatesBo> getRcsRobotsStatesInfo(@Valid @RequestBody String mapId){

        return rcsUtil.rcsRobotsStates(mapId);
    }


  /**
   * AGV上报任务每一步状态
   */
  @Log(title = "上报任务每一步状态",businessType = BusinessType.UPDATE)
  @PostMapping("/uploadAgvTaskStatus")
  @RepeatSubmit
  public Result<AGVStatesBo> uploadAgvTaskStatus(@Valid @RequestBody AGVUploadStatusBo bo){
    return rcsUtil.uploadAgvTaskStatus(bo);
  }


  /**
   * AGV上报任务每一步状态
   */
  @Log(title = "上报任务每一步状态",businessType = BusinessType.UPDATE)
  @PostMapping("/uploadAgvTaskStatusTmp")
//  @RepeatSubmit
  public Result<AGVStatesBo> uploadAgvTaskStatusTmp(@Valid @RequestBody AGVUploadStatusBo bo){
    return rcsUtil.uploadAgvTaskStatusTmp(bo);
  }

  /**
   * AGV搬运接口,包括临时点位
   */
  @Log(title = "AGV搬运接口",businessType = BusinessType.UPDATE)
  @PostMapping("/moveByAGV")
  @RepeatSubmit
  public Result<Boolean> moveByAGV(@Valid @RequestBody AGVMoveBo bo){
    return rcsUtil.moveByAGV(bo);
  }

  /**
   * AGV搬运接口,包括临时点位
   */
  @Log(title = "AGV搬运接口",businessType = BusinessType.UPDATE)
  @PostMapping("/moveByAGVTmp")
  @RepeatSubmit
  public Result<Boolean> moveByAGVTmp(@RequestBody BusinTaskQueryBo bo){
    return rcsUtil.moveByAGVTmp(bo);
  }

  /**
   * AGV更换目标点接口
   */
  @Log(title = "AGV更换目标点接口",businessType = BusinessType.UPDATE)
  @PostMapping("/removePoint")
  public Result<Boolean> removePoint(@RequestBody AGVUploadStatusBo bo){
    return rcsUtil.removePoint(bo);
  }
}
