package com.sw.mes.yb.turnstore.service;

import com.sw.mes.base.factory.inspect.dto.SupportRuleDto;
import com.sw.mes.base.factory.inspect.entity.BarSupportRule;
import com.sw.mes.core.base.BaseService;
import com.sw.mes.core.dto.TrayPostDto;
import com.sw.mes.core.dto.TurnstoreTrayDto;
import com.sw.mes.core.entity.TurnstoreTrayItem;
import com.sw.mes.core.response.Result;
import com.sw.mes.inspect.entity.YbInspectData;
import com.sw.mes.yb.turnstore.dto.WmsToYbReceiveDto;
import com.sw.mes.yb.turnstore.entity.TurnstoreTray;

import java.util.List;

/**
 * @Author
 * @Description：
 * @Date:
 * @Modified By:
 */
public interface TurnstoreTrayService extends BaseService<TurnstoreTray> {
    String createTray(BarSupportRule ruleDto, TurnstoreTray turnstoreTray, List<TurnstoreTrayItem> items, String trayNo1, String trayNo2);

    void updateTray(TurnstoreTray turnstoreTray, List<TurnstoreTrayItem> items);

    void reGetSapOrderNo(List<String> sectionNos);

    void reGetSapOrderNoNotRechcek(List<String> sectionNos);

    void toWms(Integer id);

    /**
     * 校验组托规则
     *
     * @param ruleDto     组托规则
     * @param inspectData 晶段信息
     * @return 是否符合
     */
    String validateRules(SupportRuleDto ruleDto, YbInspectData inspectData);

    /**
     * 更新详情
     *
     * @param turnstoreTray
     * @param turnstoreTrayItemList
     */
    void updateItem(TurnstoreTray turnstoreTray, List<TurnstoreTrayItem> turnstoreTrayItemList, Boolean autoReceive);

    /**
     * @param trayNo 托号
     * @return
     */
    TurnstoreTray findByTrayNo(String trayNo);

    /**
     * @param turnstoreTrayDto
     * @param turnstoreTrayItemList
     * @param autoReceive           是否自动接收，用于自动化流程
     * @return
     */
    Result initiateReceipt(TurnstoreTrayDto turnstoreTrayDto, List<TurnstoreTrayItem> turnstoreTrayItemList, Boolean autoReceive);

    void updateTrayState(WmsToYbReceiveDto receiveDto, TurnstoreTray turnstoreTray, List<TurnstoreTrayItem> trayItemList);

    /**
     * 生成托号
     *
     * @param ruleDto
     * @param turnstoreTray
     */
    String createTrayNo(BarSupportRule ruleDto, TurnstoreTray turnstoreTray);

    List<TurnstoreTrayItem> groupItemList(YbInspectData inspectData);

    Result valudate(YbInspectData inspectData);

    Result<String>  updateState(TurnstoreTray entity, TrayPostDto trayPostDto);

    void updateTurnstoreTrayStateById(WmsToYbReceiveDto wmsToYbReceiveDto, TurnstoreTray turnstoreTray);

    void updateTrayItemState(WmsToYbReceiveDto wmsToYbReceiveDto, TurnstoreTray turnstoreTray, List<TurnstoreTrayItem> trayItemList);
}
