package com.shkj.wms.controller.temp;

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.core.page.TableDataInfo;
import com.shkj.wms.bo.*;
import com.shkj.wms.config.ValidList;
import com.shkj.wms.domain.BaseBarcodesIn;
import com.shkj.wms.service.IBaseBarcodesInService;
import com.shkj.wms.service.IBusinBillheadService;
import com.shkj.wms.service.IBusinDataTaskService;
import com.shkj.wms.service.IPutInOutStorageService;
import com.shkj.wms.vo.BasePointDeviceVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

@RequiredArgsConstructor(onConstructor_ =@Autowired)
@RestController
@RequestMapping("/wms/billin")
public class BusinBillInController extends BaseController {

    @Autowired
    IBusinBillheadService iBusinBillheadService;

    @Autowired
    IBaseBarcodesInService iBaseBarcodesInService;

    @Autowired
    IBusinDataTaskService iBusinDataTaskService;

    @Autowired
    IPutInOutStorageService iPutInOutStorageService;


    /**
     * 人工下料，确认入库接口
     */
    @PostMapping("/saveBillTaskIn")
    @RepeatSubmit
    public Result<Boolean> saveBillTaskIn(@Valid @RequestBody BillTaskAddbo billTaskAddbo){
        return iPutInOutStorageService.saveBillTaskIn(billTaskAddbo);
    }


    /**
     * 自动入库流程(物料到位后，生成入库任务，待任务下发)
     */
    @PostMapping("/saveBusinBillTaskData")
    @RepeatSubmit
    public Result<Long> saveBusinBillTaskData(@Valid @RequestBody MachineHandAddBo bo){
        return iPutInOutStorageService.saveBusinBillTaskData(bo);
    }

    /**
     * 堆垛机入库完成后，增加库存
     */
    @PostMapping("/productDeposit")
    @RepeatSubmit
    public Result<Boolean> productDeposit(@RequestParam Long taskId){
        return iPutInOutStorageService.productDeposit(taskId);
    }



    /**
     * 传入任务ID，执行任务相关流程
     */
    @PostMapping("/exeTaskProcess")
    @RepeatSubmit
    public Result<String> saveBusinBillTaskData(BusinTaskExeBo bo){
        return iPutInOutStorageService.exeTaskPutinStorage(bo);
    }



    /**
     * 人工下料，入库计划管理接口
     */
    @GetMapping("/getBillInPlanData")
    @RepeatSubmit
    public TableDataInfo<BaseBarcodesIn> getBillInPlanData(BaseBarcodesInQueryBo bo)
    {
        startPage();
        List<BaseBarcodesIn> list =iBaseBarcodesInService.getBillInPlanData(bo);
        return getDataTable(list);
    }

    /**
     * App人工入库，呼叫空治具，创建任务
     */
    @PostMapping("/callContainer")
    @RepeatSubmit
    public Result<Boolean> callContainer(@RequestBody BaseContainerCallBo  bo){
        return iBusinDataTaskService.insertBusinTask(bo);
    }

    /**
     * App人工入库，获取人工入库点位
     */
    @GetMapping("/getManualWarehousingPoint")
    @RepeatSubmit
    public Result<BasePointDeviceVo> getManualWarehousingPoint(){
        return iBusinDataTaskService.getManualWarehousingPoint();
    }



    /**
     * App补货入库---治具出库
     */
    @GetMapping("/getReplenishmentAndOutbound")
    @RepeatSubmit
    public Result<Boolean> getReplenishmentAndOutbound(BusinOutboundQueryBo bo){
        return iBusinDataTaskService.getReplenishmentAndOutbound(bo);
    }


    /**
     * App补货入库---确认入库
     */
    @GetMapping("/saveReplenishmentBillTaskIn")
    @RepeatSubmit
    public Result<Boolean> saveReplenishmentBillTaskIn(BillTaskAddbo bo){
        return iPutInOutStorageService.saveBillTaskIn(bo);
    }

}
