package com.shkj.wms.controller.business;


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.BusinCallPalletBo;
import com.shkj.wms.bo.BusinPickupAddBo;
import com.shkj.wms.bo.BusinPickupQueryBo;
import com.shkj.wms.service.IBusinPickupService;
import com.shkj.wms.vo.BusinPickupVo;
import com.shkj.wms.vo.CallPalletQtyVo;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

@Api("取货相关")
@RequiredArgsConstructor(onConstructor_ =@Autowired)
@RestController
@RequestMapping("/wms/pickup")
public class BusinPickupController extends BaseController {

    @Resource
    IBusinPickupService iBusinPickupService;


    @Log(title = "App取货查询",businessType = BusinessType.UPDATE)
    @GetMapping("/getBusinPickupList")
    @RepeatSubmit
    public Result<BusinPickupVo> getBusinPickupList(BusinPickupQueryBo bo) {

        List<BusinPickupVo> businPickupList = iBusinPickupService.getBusinPickupList(bo);
        businPickupList.stream().forEach(e->{
                e.setTaskCode(String.valueOf(e.getTaskId()));
        });
        return Result.ok().data(businPickupList);

    }


    @Log(title = "App取货-确认取货",businessType = BusinessType.UPDATE)
    @PostMapping("/saveBusinPickupRecord")
    @RepeatSubmit
    public Result<Boolean> saveBusinPickupRecord(@Valid @RequestBody BusinPickupAddBo bo) {
        return iBusinPickupService.saveBusinPickupRecord(bo);
    }

    @Log(title = "PC空治具返回",businessType = BusinessType.UPDATE)
    @PostMapping("/returnNullTray")
    @RepeatSubmit
    public Result returnNullTray(){
        return iBusinPickupService.returnNullTray();
    }
    /**
     * 查看出库异常点呼叫的空治具agv是否到达
     */

    @PostMapping("/AGVNullReach")
    public Result  AGVNullReach(@RequestParam  String taskid){
        return iBusinPickupService.AGVNullReach(taskid);
    }

    @PostMapping("/QueryPOutDerive")
    public Result QueryPOutDerive(){
        return iBusinPickupService.QueryPOutDerive();
    }


    /**
     * 平库出库呼叫空托
     * @param bo
     * @return
     */
    @PostMapping("/callPallet")
    public Result  callPallet(@RequestBody BusinCallPalletBo bo ){

        return iBusinPickupService.callPallet(bo);
    }

    /**
     * 空治具待到达平库出库的数量（在途、待到达）
     * @param
     * @return
     */
    @GetMapping("/callPalletQty")
    public Result<Boolean>  callPalletQty(){
        return Result.ok().data(iBusinPickupService.callPalletQty());
    }
}
