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.AjaxResult;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.common.utils.MessageUtils;
import com.shkj.common.utils.poi.ExcelUtil;
import com.shkj.wms.bo.SysStockDetailQueryBo;
import com.shkj.wms.bo.WcsAddStockCallbackBo;
import com.shkj.wms.service.IBaseLocationService;
import com.shkj.wms.service.IBusinOutInPlanService;
import com.shkj.wms.service.ISysStockDetailService;
import com.shkj.wms.vo.SysStockDetailConVo;
import com.shkj.wms.vo.SysStockDetailVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * 库存明细
 *
 * @author zyc
 * @menu 库存明细管理
 * @date 2023-05-13
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/detail")
public class SysStockDetailController extends BaseController {
    private final ISysStockDetailService iSysStockDetailService;

    private final IBusinOutInPlanService iBusinOutInPlanService;

    /**
     * 库存明细查询-在库查询
     *
     * @param bo
     * @return
     */
    @GetMapping("/StockInquiry")
    public TableDataInfo<SysStockDetailConVo> StockInquiry( SysStockDetailQueryBo bo) {
        startPage();
        List<SysStockDetailConVo> sysStockDetailVoList = iSysStockDetailService.StockInquiry(bo);
        return getDataTable(sysStockDetailVoList);
    }

    /**
     * 库存明细查询-在库查询
     *
     * @param bo
     * @return
     */
    @PostMapping("/StockInquiryPda")
    public TableDataInfo<SysStockDetailConVo> StockInquiryPda(@RequestBody SysStockDetailQueryBo bo) {
        startPage();
        List<SysStockDetailConVo> sysStockDetailVoList = iSysStockDetailService.StockInquiryPda(bo);
        return getDataTable(sysStockDetailVoList);
    }

    /**
     * 导出库存明细查询
     */
    @GetMapping("/export")
    public void export(HttpServletResponse response, SysStockDetailQueryBo bo) {
        List<SysStockDetailConVo> sysStockDetailVoList = iSysStockDetailService.StockInquiryPda(bo);
        ExcelUtil<SysStockDetailConVo> util = new ExcelUtil<SysStockDetailConVo>(SysStockDetailConVo.class);
        util.exportExcel(response, sysStockDetailVoList, "库存明细");
    }

    @PostMapping("/exportBody")
    public  List<SysStockDetailConVo> exportBody(@RequestBody SysStockDetailQueryBo bo) {
        List<SysStockDetailConVo> sysStockDetailVoList = iSysStockDetailService.StockInquiryPda(bo);
        return sysStockDetailVoList;
    }


    /***********************************************wcs 对接**********************************************/


    /**
     * 堆垛机入库回调--实际添加库存
     *
     * @return
     */
    @PostMapping("/wcsActualAddStock")
    @RepeatSubmit
    @Log(title = "实际添加库存", businessType = BusinessType.INSERT)
    public Result<Boolean> wcsActualAddStock(@Valid @RequestBody WcsAddStockCallbackBo bo) {
        return iBusinOutInPlanService.wcsActualAddStock(bo);
    }

}
