package com.sw.mes.fb.instoreapply.dao;

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.fb.instoreapply.entity.InstoreApply;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
* @Author
* @Description：
* @Date:
* @Modified By:
*/
public interface InstoreApplyDao extends BaseDao<InstoreApply, Integer> {
    //根据日期获取当天最大流水号
    @Query(value="SELECT IFNULL(MAX(sort),0) AS maxSort FROM zhxx_fb_instore_apply WHERE date=?1 FOR UPDATE ",nativeQuery = true)
    Integer getMaxSortByDate(String date);

    List<InstoreApply> findByOrderNo(String orderNo);

    @Query(value = "SELECT type FROM  zhxx_fb_inspection_crystral_detail WHERE section_no_yb = ?1 and `status` = 1  ORDER BY id desc limit 0,1",nativeQuery = true)
    String getDetailType(String sectionNoYb);

    @Query(value = "SELECT type FROM  zhxx_fb_inspection_crystral_detail WHERE section_no_fb = ?1 and `status` = 1  ORDER BY id desc limit 0,1",nativeQuery = true)
    String getDetailTypeByFb(String sectionNoFb);

    @Query(value = "SELECT count(*) FROM zhxx_operate_check_out WHERE checkout_name = '一次检验' and section_no_fb = ?1",nativeQuery = true)
    int getRepetitionSectionNoFb(String sectionNoFb);
}
