package com.foreverwin.mesnac.meapi.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.mesnac.meapi.dto.BomComponentDto;
import com.foreverwin.mesnac.meapi.model.BomComponent;
import com.foreverwin.modular.core.util.FrontPage;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author Ervin Chen
 * @since 2020-10-19
 */
public interface BomComponentService extends IService<BomComponent> {

    /**
     *  分页查询
     * @param frontPage
     * @return
     */
    IPage<BomComponent> selectPage(FrontPage<BomComponent> frontPage, BomComponent bomComponent);

    List<BomComponent> selectList(BomComponent bomComponent);

    List<BomComponent> listByBomBo(String bomBo);

    List<BomComponent> selectListByShopOrderBo(String shopOrderBo);

    List<BomComponent> selectListByShopOrderBoItemBo(String shopOrderBo, String itemBo);

    /**
     * 校验给定的物料组件在BOM中是否属于主物料
     * @param bomBo
     * @param componentBo 物料组件BO
     * @return
     */
    boolean validateMainComponent(String bomBo, String componentBo);

    /**
     * 校验物料是否属于当前物料清单组件
     * @param bomBo
     * @param item
     * @return
     */
    boolean validateComponentOwnerBom(String bomBo, String item);


    /**
     * 装配查询精准追溯BOMComponent
     * @param bomBo
     * @param operationBo
     * @return
     */

    List<BomComponent> selectBomComponentByOperation(String bomBo, String operationBo);

    /**
     * 查询需要装配的数量
     * @param bomBo
     * @param operationBo
     * @return
     */
    Integer getNeedAssemblyQty(String bomBo, String operationBo);



    /**
     * 根据sfc和工序查物料清单组件
     * @param site
     * @param SfcBo
     * @param operation
     * @return
     */
    List<BomComponent> selectListBySfcBoOAndOperationBo(String site, String SfcBo, String operation);

    /**
     * 根据BOM和编码查询
     * @param bomBo
     * @param bomItemNoList
     * @return
     */
    List<BomComponent> selectListByBomBoAndBomItemNo(String bomBo, List<String> bomItemNoList);

    /**
     * 查找产线下未结案工单物料清单
     * @param workCenterBO
     */
    List<BomComponent> selectShopOrderBomComponentByWorkCenterBo(String workCenterBO);

    List<BomComponentDto> getSfcBomComponent(String sfcBo);
}