package com.sw.mes.yb.accessory.dao;

import com.sw.mes.yb.accessory.entity.AccessoryApply;
import com.sw.mes.core.base.BaseDao;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
* @Author
* @Description：
* @Date:
* @Modified By:
*/
public interface AccessoryApplyDao extends BaseDao<AccessoryApply, Long> {

    List<AccessoryApply> findByGoodsCodeAndState(String goodsCode, String state);

    @Query(value = "SELECT * FROM zhxx_accessory_apply WHERE goods_code=?1 AND equipment_id=?2 AND state=?3 ", nativeQuery = true)
    List<AccessoryApply> findByGoodsCodeAndEquipmentIdAndState(String goodsCode, Long equipmentId, String state);

    List<AccessoryApply> findByPickNo(String pickNo);

    @Query(value = "SELECT * FROM zhxx_accessory_apply zaa WHERE zaa.goods_code = ?2 AND zaa.apply_date >= ?1 ORDER BY zaa.id DESC", nativeQuery = true)
    List<AccessoryApply> findByApplyDateAndGoodsCode(Date applyDate, String goodsCode);

//    @Query(value = "SELECT * FROM zhxx_accessory_apply WHERE codes=?1 AND equipment_id=?2 AND state=?3 ", nativeQuery = true)
//    List<AccessoryApply> findByCodesAndEquipment_idAndState(String codes, Long equipmentId, String state);
}
