package com.sw.mes.sap.dao;

import java.util.List;
import com.sw.mes.sap.entity.LogSapMesInteractive;
import com.sw.mes.core.base.BaseDao;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import com.sw.mes.core.annotation.Jinko;


/**
 * 晶科SAP下发生产工单通信记录Dao接口
 * 
 * @author liru
 * @date 2023-12-29
 */
@Jinko(value="晶科SAP下发生产工单通信记录Service接口",author = "liru")
public interface LogSapMesInteractiveDao extends BaseDao<LogSapMesInteractive, Long>
{
	@Query(value = "SELECT * FROM `log_sap_mes_interactive` WHERE  `context` LIKE ?2 AND `controller_name` = ?1 ORDER BY id DESC LIMIT 1 ", nativeQuery = true)
	LogSapMesInteractive getSapLog(String contrallName, String aufnr);

	@Query(value = "SELECT * FROM `log_sap_mes_interactive` WHERE `controller_name` = ?1 and create_time >= ?2 and create_time <= ?3 ORDER BY id ASC ", nativeQuery = true)
	List<LogSapMesInteractive> findByControllerNameAndTimeRange(String controllerName, String createTimeStart,
			String createTimeEnd);

	@Query(value = "SELECT * FROM `log_sap_mes_interactive` WHERE `controller_name` = ?1 ORDER BY id ASC", nativeQuery = true)
	List<LogSapMesInteractive> findByControllerName(String controllerName);

}
