package com.yn.bftl.thirdparty.common.repository;

import com.yn.bftl.common.modules.company.entity.Company;
import com.yn.bftl.common.modules.inventory.entity.Warehouse;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * WarehouseRepository
 *
 * @author wangwenliang
 * @create 2021年4月25日15:39:25
 **/
@Repository
public interface WarehouseRepository extends JpaRepository<Warehouse, Long> {

    /**
     * 获取企业的默认仓库
     * @param companyId
     * @return
     */
    Warehouse findByCompanyIdAndIsDefaultIsTrue(Long companyId);

    /**
     * 获取企业的默认仓库
     * @param code
     * @return
     */
    Warehouse findByCode(String code);

    List<Warehouse> findAllByCompany(Company company);

    /**
     * 仓库-列表
     *
     * @param erpCode:ERP编码
     * @param erpAccountSetId:ERP账套ID
     * @return List<Warehouse>
     * @description 根据ERP编码和企业ID查询
     * @author huabiao
     * @create 2022/5/18  14:31
     */
    List<Warehouse> findAllByErpCodeAndErpAccountSetId(String erpCode, Long erpAccountSetId);

    /**
     * 仓库-列表
     *
     * @param erpCode:仓库ERP编码
     * @param code:ERP账套编码
     * @param orgCode:组织编码
     * @return List<Warehouse>
     * @description 仓库ERP编码+ERP账套编码+组织编码唯一
     * @author huabiao
     * @create 2022/5/18  14:31
     */
    List<Warehouse> findAllByErpCodeAndErpAccountSetCodeAndErpAccountSetOrgCode(String erpCode, String code, String orgCode);
    
    /**
     * 仓库-根据ERP编码查询
     *
     * @param erpCode ERP编码
     * @return 仓库列表
     * @author huabiao
     * @create 2023/2/22  16:38
     */
    List<Warehouse> findAllByErpCode(String erpCode);

}
