package com.shkj.wms.controller.business;

import com.shkj.common.annotation.Log;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.wms.bo.AdjustLocationBo;
import com.shkj.wms.bo.BusinStockMoveSQueryBo;
import com.shkj.wms.domain.BaseLocation;
import com.shkj.wms.service.IBusinStockMoveDService;
import com.shkj.wms.service.ISysStockDetailService;
import com.shkj.wms.vo.BusinStockMoveDVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 库内货位调整管理
 *
 * @author lch
 * @menu 库内货位调整管理
 * @date 2022-06-10
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/stock/adjust")
public class BusinStockLocationAdjustController extends BaseController {

    private final ISysStockDetailService iSysStockDetailService;
    private final IBusinStockMoveDService iBusinStockMoveDService;


    /**
     * 货位调整时选择目的货位下拉框列表
     *
     * @return
     */
    @GetMapping("/getEmptyLocation")
    public Result<List<BaseLocation>> getEmptyLocation() {
        return iSysStockDetailService.getEmptyLocation();
    }

    /**
     * 货位调整
     *
     * @param bo
     * @return
     */
    @PostMapping("/adjustLocation")
    @Log(title = "货位调整", businessType = BusinessType.INSERT)
    public Result<Boolean> adjustLocation(@Valid @RequestBody AdjustLocationBo bo) {
        return iBusinStockMoveDService.adjustLocation(bo);
    }


    /**
     * 报表看板-货位调整记录
     */
    @GetMapping("/list")
    public TableDataInfo<BusinStockMoveDVo> list(BusinStockMoveSQueryBo bo) {
        startPage();
        List<BusinStockMoveDVo> list = iBusinStockMoveDService.queryList(bo);
        return getDataTable(list);
    }
}
