package com.cim.idm.dao;

import com.cim.idm.model.dto.delivery.*;
import com.cim.idm.model.po.delivery.MaterialDelivery;
import com.cim.idm.model.po.delivery.MaterialDeliveryReceive;
import com.cim.idm.model.po.MaterialReceiveRequest;
import com.cim.idm.model.dto.PurchaseDto;
import com.cim.idm.model.vo.DeliveryReceiveDetailVo;
import com.cim.idm.model.vo.MaterialReceiveRequestVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Mapper
public interface DeliveryDao {

    /**
     * 新增到货单
     */
    int createDelivery(@Param("dto") DeliveryDto dto,
                       @Param("state") String state);

    /**
     * 新增到货单关系
     */
    int createRelation(@Param("receiveList") List<DeliveryRelationDto> receiveList);

    /**
     * 获取采购订单
     */
    List<MaterialReceiveRequestVo> getReceiveList(@Param("dto") PurchaseDto dto,
                                               @Param("typeList") List<String> typeList);

    /**
     * 获取入库详情
     */
    @MapKey("storeDetail")
    List<Map<String, Object>> getStoreDetail(@Param("siteName") String siteName,
                                             @Param("nameList") List<String> nameList,
                                             @Param("deliveryName") String deliveryName);

    /**
     * 获取入库批次
     */
    @MapKey("storeCharge")
    List<Map<String, Object>> getStoreCharge(@Param("siteName") String siteName,
                                             @Param("nameList") List<String> nameList);

    /**
     * 根据 key 获取值
     */
    MaterialDelivery getByKey(@Param("dto") StoreDetailDto storeDetailDto);

    /**
     * 根据 key 获取采购单
     */
    MaterialReceiveRequest getReceiveByKey(@Param("dto") StoreDetailDto storeDetailDto);

    /**
     * 根据到库单获取采购单名称
     */
    List<MaterialDeliveryReceive> getReceiveByDelivery(@Param("dto") StoreDetailDto storeDetailDto);

    /**
     * 根据到库单获取采购单名称
     * @param nameList 到库单
     * @return 采购单名称列表
     */
    List<DeliveryReceiveDetailVo> getReceiveDetail(@Param("nameList") List<String> nameList);

    /**
     * 获取到货单
     * @param dto 请求
     * @return 采购订单
     */
    List<MaterialDelivery> getDeliveryList(@Param("dto") DeliveryListDto dto);

    /**
     * 删除到货单
     * @param deliveryDelDto 请求
     * @return 结果
     */
    int delDelivery(@Param("dto") DeliveryDelDto deliveryDelDto);

    /**
     * 删除到货单关系
     * @param deliveryDelDto 请求
     * @return 结果
     */
    int delDeliveryRel(@Param("dto") DeliveryDelDto deliveryDelDto);
}
