package com.bailuntec.mapper;

import com.bailuntec.domain.dto.OutStockQuantity;
import com.bailuntec.domain.dto.PurchaseTransitQuantity;
import com.bailuntec.domain.dto.TransferTransitQuantity;
import com.bailuntec.domain.entity.DcMidTransit;
import com.bailuntec.domain.example.DcMidTransitExample;
import org.apache.ibatis.annotations.Param;

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

public interface DcMidTransitMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    long countByExample(DcMidTransitExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int deleteByExample(DcMidTransitExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int insert(DcMidTransit record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int insertSelective(DcMidTransit record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     * @project https://github.com/itfsw/mybatis-generator-plugin
     */
    DcMidTransit selectOneByExample(DcMidTransitExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    List<DcMidTransit> selectByExample(DcMidTransitExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    DcMidTransit selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int updateByExampleSelective(@Param("record") DcMidTransit record, @Param("example") DcMidTransitExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int updateByExample(@Param("record") DcMidTransit record, @Param("example") DcMidTransitExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int updateByPrimaryKeySelective(DcMidTransit record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     */
    int updateByPrimaryKey(DcMidTransit record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     * @project https://github.com/itfsw/mybatis-generator-plugin
     */
    int upsert(DcMidTransit record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table dc_mid_transit
     *
     * @mbg.generated
     * @project https://github.com/itfsw/mybatis-generator-plugin
     */
    int upsertSelective(DcMidTransit record);

    void calculateTransferTransit(@Param("list") List<TransferTransitQuantity> list, @Param("localDateTime") LocalDateTime localDateTime);

    void calculatePurchaseTransit(@Param("list") List<PurchaseTransitQuantity> list, @Param("localDateTime") LocalDateTime localDateTime);

    void calculateOutStock(@Param("list") List<OutStockQuantity> list, @Param("localDateTime") LocalDateTime localDateTime);

    // 慢查询
    void insertMidDailyTransit();

    //todo 慢查询
    List<OutStockQuantity> selectQuantityOutStock();

    //todo 慢查询优化
    List<PurchaseTransitQuantity> selectQuantityPurchaseTransit();

    /**
     * 查询调拨在途
     *
     * @return 调拨在途
     */
    List<TransferTransitQuantity> selectQuantityTransferTransit();

    void updateOldTransferToZero(@Param("transferModified") String transferModified);

    void updateOldPurchaseToZero(@Param("purchaseModified") String purchaseModified);

    void updateOldOutStockToZero(@Param("outStockModified") String outStockModified);

    LocalDateTime selectMaxOutStockModified();

    LocalDateTime selectMaxTransferModified();

    LocalDateTime selectMaxPurchaseModified();

    LocalDateTime selectMaxUnshippedModified();

    void updateOldUnshippedToZero(@Param("unshippedModified") LocalDateTime unshippedModified);

    void calculateUnShipped();

    void updateSkuUnitPrice();

    void selectUnShipped();

    void deleteMidDailyTransit();
}
