package com.shkj.wcs.controller.busin;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shkj.common.annotation.Log;
import com.shkj.common.annotation.RepeatSubmit;
import com.shkj.common.core.domain.Result;
import com.shkj.common.enums.BusinessType;
import com.shkj.common.utils.DateUtils;
import com.shkj.wcs.bo.AGVFeedbackBo;
import com.shkj.wcs.bo.ExtraData;
import com.shkj.wcs.bo.WcsRequestBo;
import com.shkj.wcs.domain.BusinDataTask;
import com.shkj.wcs.service.IBusinDataTaskService;
import com.shkj.wcs.third.rcs.RCSUtil;
import com.shkj.wcs.third.rcs.dto.RcsCreateTaskDto;
import com.shkj.wcs.third.rcs.vo.RcsResponseVo;
import com.shkj.wcs.third.workbinWcs.WCSUtil;
import com.shkj.wcs.third.workbinWcs.dto.UploadWCSTaskStatusBody;
import com.shkj.wcs.third.workbinWcs.dto.UploadWCSTaskStatusDto;
import com.shkj.wcs.third.workbinWcs.dto.WcsCreateTaskHeader;
import com.shkj.wcs.vo.QueryAreaStatusVo;
import com.shkj.wcs.vo.WcsResponseVo;
import com.shkj.wms.enums.TaskStatusEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.exceptions.TooManyResultsException;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Slf4j
@RequiredArgsConstructor(onConstructor_ =@Autowired)
@RestController
@RequestMapping("/agvapi")
public class AgvTaskContorller {

    @Autowired
    private RCSUtil rcsUtil;

    @Autowired
    private IBusinDataTaskService iBusinDataTaskService;
    @Autowired
    private WCSUtil wcsUtil;


    /**
     * 查询每个库区状态
     */
    @Log(title = "查询每个库区状态",businessType = BusinessType.UPDATE)
    @PostMapping("/toKjWcs/queryAreaStatus")
    @RepeatSubmit
    public WcsResponseVo queryAreaStatus(@RequestBody WcsRequestBo wcsRequestBo){
        // 请求agv接口...
        List<QueryAreaStatusVo> areaStatusVos = new ArrayList<>();
        return  WcsResponseVo.success(areaStatusVos);
    }

    /**
     * 下发任务
     */

    @Log(title = "下发任务测试接口",businessType = BusinessType.UPDATE)
    @PostMapping("/toAgv/rcsCreateTask")
    @RepeatSubmit
    public Result rcsCreateTask(@RequestBody RcsCreateTaskDto rcsCreateTaskDto){
        // 请求agv接口...

        return  rcsUtil.rcsCreateTask(rcsCreateTaskDto);
    }

    /**
     * 任务执行过程回馈接口
     */

    @Log(title = "任务执行过程回馈接口",businessType = BusinessType.UPDATE)
    @PostMapping("/toKjWcs/rcsFeedbackTask")
    @RepeatSubmit
    public RcsResponseVo rcsFeedbackTask(@RequestBody AGVFeedbackBo bo){
        return iBusinDataTaskService.rcsFeedbackTask(bo);
    }

}
