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

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

import java.util.List;

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

    @Query(value = "select * from production_process_working_step where area = ?1 AND start_time >= ?2 AND start_time < ?3", nativeQuery = true)
    List<ProcessWorkingStep> getEveryStepNumber(String area, String startTime, String endTime);

    @Query(value = "SELECT A.lot_no from (select lot_no from production_process_working_step where area = ?1 ORDER BY start_time DESC LIMIT 1000000000) A WHERE A.lot_no is not null GROUP BY SUBSTR(A.lot_no,3,4)", nativeQuery = true)
    List<String> getEveryStepNumberGroupByLotNo(String area);

    @Query(value = "select * from production_process_working_step where lot_no in ?1", nativeQuery = true)
    List<ProcessWorkingStep> getEveryStepNumberByLotNo(List<String> lotNoList);
}