package com.its.api.its.repository.link;

import com.its.api.its.model.dto.analysis.TbTrfcPrcnStatInf;
import com.its.api.its.model.entity.link.TbTrfcPrcnStat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TbTrfcPrcnStatRepository extends JpaRepository<TbTrfcPrcnStat, String>, JpaSpecificationExecutor<TbTrfcPrcnStat> {

    @Query("select p.prcnDt as prcnDt, p.linkLigtNum as ligtNum, p.linkDelyNum as delyNum, p.linkCngsNum as cngsNum from TbTrfcPrcnStat p where p.prcnDt between :fromDt and :toDt")
    List<TbTrfcPrcnStatInf> findAllByDateRangeLINK(@Param("fromDt") String fromDt, @Param("toDt") String toDt);

    @Query("select p.prcnDt as prcnDt, p.ifscLigtNum as ligtNum, p.ifscDelyNum as delyNum, p.ifscCngsNum as cngsNum from TbTrfcPrcnStat p where p.prcnDt between :fromDt and :toDt")
    List<TbTrfcPrcnStatInf> findAllByDateRangeIFSC(@Param("fromDt") String fromDt, @Param("toDt") String toDt);

    @Query("select p.prcnDt as prcnDt, p.roadLigtNum as ligtNum, p.roadDelyNum as delyNum, p.roadCngsNum as cngsNum from TbTrfcPrcnStat p where p.prcnDt between :fromDt and :toDt")
    List<TbTrfcPrcnStatInf> findAllByDateRangeROAD(@Param("fromDt") String fromDt, @Param("toDt") String toDt);

    @Query("select p.prcnDt as prcnDt, p.vmsIfscLigtNum as ligtNum, p.vmsIfscDelyNum as delyNum, p.vmsIfscCngsNum as cngsNum from TbTrfcPrcnStat p where p.prcnDt between :fromDt and :toDt")
    List<TbTrfcPrcnStatInf> findAllByDateRangeVMS(@Param("fromDt") String fromDt, @Param("toDt") String toDt);
}
