package com.sw.mes.sap.dao;

import com.sw.mes.core.dto.wms.ReportSapWorkinghoursDto;
import org.springframework.data.jpa.repository.Query;

import com.sw.mes.core.annotation.Jinko;
import com.sw.mes.core.base.BaseDao;
import com.sw.mes.sap.entity.ReportSapWorkinghours;

import java.util.List;


/**
 * MES报工SAP工时接口Dao接口
 *
 * @author liru
 * @date 2024-01-07
 */
@Jinko(value="MES报工SAP工时接口Service接口",author = "liru")
public interface ReportSapWorkinghoursDao extends BaseDao<ReportSapWorkinghours, Long>
{

    ReportSapWorkinghours findByRemarkAndProcName(String remark, String procName);

    @Query(value = "select * from report_sap_workinghours where if(?1 is null, 1=1, remark = ?1) and proc_name = ?2 and crystal_no = ?3", nativeQuery = true)
    List<ReportSapWorkinghoursDto> findByRemarkAndProcNameAndCrystalNo(String remark, String procName, String crystalNo);

    @Query(value = "select count(id) from report_sap_workinghours where production_order_id=?1 and `status`=0", nativeQuery = true)
	Long getSendSapLog(String aUFNR);
}
