package com.oqpo.api.mapper.stockmng;


import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
import com.oqpo.api.entity.stockmng.StckSaleMgntDtlHistEntity;
import com.oqpo.api.web.dto.request.GridRequest;
import com.oqpo.api.web.dto.request.stockmng.StockMngCddGridRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface StockMngMapper {

    List<StckMgntBaseInfoEntity> selectStockMngGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("sWhsId") String sWhsId, @Param("sLocation") String sLocation,
                                                        @Param("sItemStCd") String sItemStCd, @Param("sItemType") String sItemType, @Param("sItemGubun") String sItemGubun,
                                                        @Param("sItemClass1") String sItemClass1, @Param("sItemClass2") String sItemClass2, @Param("sItemClass3") String sItemClass3,
                                                        @Param("sItemClass4") String sItemClass4, @Param("sItemId") String sItemId, @Param("sItemNm") String sItemNm,
                                                        GridRequest gridRequest) throws Exception;

    int selectStockMngGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("sWhsId") String sWhsId, @Param("sLocation") String sLocation,
                              @Param("sItemStCd") String sItemStCd, @Param("sItemType") String sItemType, @Param("sItemGubun") String sItemGubun,
                              @Param("sItemClass1") String sItemClass1, @Param("sItemClass2") String sItemClass2, @Param("sItemClass3") String sItemClass3,
                              @Param("sItemClass4") String sItemClass4, @Param("sItemId") String sItemId, @Param("sItemNm") String sItemNm) throws Exception;

    List<StckMgntDtlHistEntity> selectStockHistGridList(@Param("sBrandId") String sBrandId, @Param("sWhsId") String sWhsId, @Param("sLocation") String sLocation,
                                                        @Param("sItemId") String sItemId, @Param("sInoutCd") String sInoutCd,
                                                        @Param("fromDt") String fromDt, @Param("toDt") String toDt,
                                                        GridRequest gridRequest) throws Exception;

    int selectStockHistGridCnt(@Param("sBrandId") String sBrandId, @Param("sWhsId") String sWhsId, @Param("sLocation") String sLocation,
                               @Param("sItemId") String sItemId, @Param("sInoutCd") String sInoutCd,
                               @Param("fromDt") String fromDt, @Param("toDt") String toDt) throws Exception;

    StckMgntBaseInfoEntity selectStckMgntBaseInfo(@Param("brandId") String brandId, @Param("whsId") String whsId,
                                                  @Param("location") String location, @Param("itemId") String itemId) throws Exception;

    StckMgntBaseInfoEntity selectStckMgntBaseInfo4CddProc(@Param("brandId") String brandId, @Param("whsId") String whsId,
                                                          @Param("location") String location, @Param("itemId") String itemId) throws Exception;

    int insertStckMgntBaseInfo(@Param("userId") String userId, StckMgntBaseInfoEntity entity) throws Exception;

    int updateStckMgntBaseInfo4StckProc(@Param("userId") String userId, StckMgntBaseInfoEntity entity) throws Exception;

    int updateStckMgntBaseInfo4BaseChg(@Param("userId") String userId, StckMgntBaseInfoEntity entity) throws Exception;

    int updateStckMgntBaseInfo4Delete(@Param("userId") String userId, StckMgntBaseInfoEntity entity) throws Exception;

    int insertStckMgntDtlHist(@Param("userId") String userId, StckMgntDtlHistEntity entity) throws Exception;

    List<StckMgntBaseInfoEntity> selectStockCddGridList(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("whsId") String whsId, @Param("location") String location,
                                                        List<StockMngCddGridRequest.StockCddReqData> gridItemData) throws Exception;

    int updateStckPoUseQty(@Param("userId") String userId, @Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
    int updateMinusStckPoUseQty(@Param("userId") String userId, @Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
    int updateMinStockQty(@Param("userId") String userId, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;

    int insertMultiStckMgntDtlHist(@Param("userId") String userId, List<StckMgntDtlHistEntity> gridInsertData) throws Exception;

    /* 재고수량 증가 - 입고처리로 인함 */
    int updateWarehouseStockQty(@Param("userId") String userId, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;

    List<StckMgntBaseInfoEntity> selectWhsLocOutPassQty(@Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location,
                                                        List<StckMgntBaseInfoEntity> itemList) throws Exception;

    /* 창고별 품목 현황 */
    List<StckMgntBaseInfoEntity> selectPopItemStockMngGridList(@Param("sBrandId") String sBrandId, @Param("sWhsId") String sWhsId, @Param("sLocation") String sLocation
                                                        ,@Param("sItemNm") String sItemNm, GridRequest gridRequest) throws Exception;

    int selectPopItemStockMngGridCnt(@Param("sBrandId") String sBrandId, @Param("sWhsId") String sWhsId, @Param("sLocation") String sLocation
                                     ,@Param("sItemNm") String sItemNm) throws Exception;

    StckMgntBaseInfoEntity selectPopItemStockInfo(@Param("sBrandId") String sBrandId, @Param("sWhsId") String sWhsId, @Param("sLocation") String sLocation
            ,@Param("sBarcode") String sBarcode) throws Exception;


    int insertInOutStckMgntBaseInfo(@Param("userId") String userId, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;

    List<StckMgntBaseInfoEntity> selectWhsLocationItemList(@Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location) throws Exception;


    StckMgntBaseInfoEntity selectBoWhsInfo(@Param("oqBrandId") String oqBrandId, @Param("oqStoreId") String oqStoreId) throws Exception;

    int insertStckSaleMgntDtlHist(@Param("userId") String userId, List<StckSaleMgntDtlHistEntity> gridUpdateData) throws Exception;

}
