package com.its.op.controller.its.scrs;

import com.its.op.dto.its.scrs.ScSrvcDto;
import com.its.op.dto.its.scrs.ScSrvcPtrnDto;
import com.its.op.service.its.scrs.ScSrvcStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/scrs/statistics/srvc")
@Api(tags = "14.스마트교차로-2.통계-2.교차로 서비스수준 통계")
public class ScSrvcStatisticsController {

    private final ScSrvcStatisticsService service;

    @ApiOperation(value = "서비스수준 15분 통계", response = ScSrvcDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/15m", produces = {"application/json; charset=utf8"})
    public List<ScSrvcDto> findSrvc15M(
            @ApiParam(name = "ixrIds", value = "교차로 목록", example = "[11,12]", required = true)
            @RequestParam List<String> ixrIds,
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH240000)", example = "20210112150000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH245959)", example = "20221112155959", required = true)
            @RequestParam String TO_DT) {
        return this.service.findSrvc15M(ixrIds, FROM_DT, TO_DT);
    }

    @ApiOperation(value = "서비스수준 시간 통계", response = ScSrvcDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/hh", produces = {"application/json; charset=utf8"})
    public List<ScSrvcDto> findSrvcHH(
            @ApiParam(name = "ixrIds", value = "교차로 목록", example = "[11,12]", required = true)
            @RequestParam List<String> ixrIds,
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH240000)", example = "20210112150000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH245959)", example = "20221112155959", required = true)
            @RequestParam String TO_DT) {
        return this.service.findSrvcHH(ixrIds, FROM_DT, TO_DT);
    }

    @ApiOperation(value = "서비스수준 일 통계", response = ScSrvcDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/dd", produces = {"application/json; charset=utf8"})
    public List<ScSrvcDto> findSrvcDD(
            @ApiParam(name = "ixrIds", value = "교차로 목록", example = "[11,12]", required = true)
            @RequestParam List<String> ixrIds,
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH240000)", example = "20210112150000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH245959)", example = "20221112155959", required = true)
            @RequestParam String TO_DT) {
        return this.service.findSrvcDD(ixrIds, FROM_DT, TO_DT);
    }

    @ApiOperation(value = "서비스수준 월 통계", response = ScSrvcDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/mn", produces = {"application/json; charset=utf8"})
    public List<ScSrvcDto> findSrvcMN(
            @ApiParam(name = "ixrIds", value = "교차로 목록", example = "[11,12]", required = true)
            @RequestParam List<String> ixrIds,
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH240000)", example = "20210112150000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH245959)", example = "20221112155959", required = true)
            @RequestParam String TO_DT) {
        return this.service.findSrvcMN(ixrIds, FROM_DT, TO_DT);
    }

    @ApiOperation(value = "서비스수준 패턴 비교", response = ScSrvcPtrnDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/ptrn/{ixrId}/{baseDay}/{compDay}", produces = {"application/json; charset=utf8"})
    public List<ScSrvcPtrnDto> findSrvcPtrnCompare(
            @PathVariable("ixrId") final String ixrId,
            @PathVariable("baseDay") final String baseDay,
            @PathVariable("compDay") final String compDay) {
        return this.service.findSrvcPtrnCompare(ixrId, baseDay, compDay);
    }

}
