package com.its.op.service.its.scrs;

import com.its.op.dao.mapper.its.scrs.ScTfvlStatisticsMapper;
import com.its.op.dto.its.scrs.ScTfvlDto;
import com.its.op.dto.its.scrs.ScTfvlParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@Service
public class ScTfvlStatisticsService {

    private final ScTfvlStatisticsMapper mapper;

    /**
     * 교차로 교통량 원시 수집 이력(5분)
     * @param ixrId
     * @param cmraIds
     * @param fromDt
     * @param toDt
     * @return
     */
    public List<ScTfvlDto> findTfvl05M(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvl05M(param);
    }

    /**
     * 교차로 교통량 원시 수집 이력(5분 - 차선별)
     * @param ixrId
     * @param cmraIds
     * @param lanes
     * @param fromDt
     * @param toDt
     * @return
     */
    public List<ScTfvlDto> findTfvl05MLane(String ixrId, List<String> cmraIds, List<Integer> lanes, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .lanes(lanes)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvl05MLane(param);
    }

    public List<ScTfvlDto> findTfvl15M(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvl15M(param);
    }

    public List<ScTfvlDto> findTfvl15MLane(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvl15MLane(param);
    }

    public List<ScTfvlDto> findTfvl30M(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvl30M(param);
    }

    public List<ScTfvlDto> findTfvl30MLane(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvl30MLane(param);
    }

    public List<ScTfvlDto> findTfvlHH(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvlHH(param);
    }

    public List<ScTfvlDto> findTfvlHHLane(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvlHHLane(param);
    }

    public List<ScTfvlDto> findTfvlDD(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvlDD(param);
    }

    public List<ScTfvlDto> findTfvlDDLane(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvlDDLane(param);
    }

    public List<ScTfvlDto> findTfvlMN(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvlMN(param);
    }

    public List<ScTfvlDto> findTfvlMNLane(String ixrId, List<String> cmraIds, String fromDt, String toDt) {
        ScTfvlParam param = ScTfvlParam.builder()
                .ixrId(ixrId)
                .cmraIds(cmraIds)
                .fromDt(fromDt)
                .toDt(toDt)
                .build();
        return this.mapper.findTfvlMNLane(param);
    }
}
