package com.foreverwin.mesnac.dispatch.mapper;

import com.foreverwin.mesnac.common.dto.SfcDispatchDto;
import com.foreverwin.mesnac.dispatch.dto.IssueItemDto;
import com.foreverwin.mesnac.dispatch.model.CallItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Leon.L
 * @since 2021-06-30
 */
@Repository
public interface CallItemMapper extends BaseMapper<CallItem> {

    List<CallItem> selectEffectedCallItemByDispatchBo(@Param("sfcDispatchBo") String sfcDispatchBo);

    List<CallItem> selectDispatchCallItem(List<SfcDispatchDto> list);

    void deleteCallItem(List<SfcDispatchDto> list);

    void deleteDispatchCallItem(List<SfcDispatchDto> list);

    List<CallItem> selectCallItemAndType(@Param("sfcDispatchBo") String sfcDispatchBo);

    List<CallItem> findCallItemList(Map paramMap);

    List<CallItem> findCallItemDetailList(CallItem callItem);

    List<CallItem> findCallItemListPda(@Param("site") String site,@Param("locale") String locale,@Param("user") String user,@Param("callItem")CallItem callItem);

    List<CallItem> findCallItemDetailListByDispatchBo(@Param("site") String site, @Param("list") List<String> list);

    void updateCallItemStatusByDispatchBo(@Param("status") String status, @Param("user") String user, @Param("dateTime") LocalDateTime dateTime, @Param("list") List<String> list);

    /**
     * PDA生产叫料--修改叫料状态
     * @param status
     * @param user
     * @param dateTime
     * @param callItem
     */
    void updateCallItemStatusByCallItem(@Param("site") String site, @Param("status") String status, @Param("user") String user, @Param("dateTime") LocalDateTime dateTime, @Param("callItem") CallItem callItem);

    List<CallItem> findRefreshCallItemPda(@Param("list") List<String> list);

    void updateCallItemStatusByHandle(@Param("status") String status, @Param("user") String user, @Param("dateTime") LocalDateTime dateTime, @Param("list") List<CallItem> list);

    void updateCallItemStatusByCallItemNo(@Param("status") String status, @Param("user") String user, @Param("dateTime") LocalDateTime dateTime, @Param("list") List<String> list);

    void refreshRequiredTime(@Param("user") String user, @Param("dateTime") LocalDateTime dateTime, @Param("list") List<String> list);


    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    List<CallItem> findIssueMatchCallItemList(@Param("site")String site, @Param("workOrder")String workOrder, @Param("blankingSize")String blankingSize, @Param("resource")String resource, @Param("item")String item);

    // 查询叫料记录,根据发料情况，更新叫料数据
    List<CallItem> findIssueMatchCallItemListPda(@Param("site")String site, @Param("workCenter")String workCenter, @Param("blankingSize")String blankingSize, @Param("resource")String resource, @Param("item")String item);

    //车间发料查询
    List<CallItem> finsIssueItemListToResource(IssueItemDto issueItemDto);
    List<CallItem> finsIssueItemListNoResource(IssueItemDto issueItemDto);

    //车间发料PDA界面查询
    List<CallItem> finsIssueItemListNoResourcePda(IssueItemDto issueItemDto);
    List<CallItem> finsIssueItemListToResourcePda(IssueItemDto issueItemDto);

}