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

import java.util.List;

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

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

	List<InputFurnaceBurden> findByAgainTaskDetailId(Long ainTaskDetailId);

	InputFurnaceBurden findTopByAgainTaskDetailIdOrderByIdDesc(Long ainTaskDetailId);

	@Query(value = "select * from production_input_furnace_burden where start_time >= ?1 and start_time < ?2 and series = ?3",nativeQuery = true)
	List<InputFurnaceBurden> findByStartTime(String startTime, String endTime, String series);

	@Query(value = "SELECT fb.* FROM production_input_furnace_burden AS fb \n" +
			"INNER JOIN production_again_task_detail AS atd ON fb.again_task_detail_id = atd.id \n" +
			"WHERE atd.raw_status IN (3, 4) AND fb.confirm = 0 AND fb.lot_no = ?1 ",nativeQuery = true)
	List<InputFurnaceBurden> findUnconfirmedTask(String lotNo);

	@Query(value = "SELECT fb.* FROM production_input_furnace_burden AS fb \n" +
			"INNER JOIN production_again_task_detail AS atd ON fb.again_task_detail_id = atd.id \n" +
			"WHERE atd.raw_status NOT IN(2, 5) AND fb.lot_no = ?1 AND fb.again_num = ?2 AND fb.confirm = ?3 ",nativeQuery = true)
	List<InputFurnaceBurden> findTask(String lotNo, Integer againNum, Integer confirm);

}
