package com.its.op.controller.its.history;

import com.its.op.dto.its.code.TbClctSystStupDto;
import com.its.op.dto.its.link.TbLinkDto;
import com.its.op.dto.its.link.TbLinkTrafClctHsAnalDto;
import com.its.op.service.its.code.TbClctSystStupService;
import com.its.op.service.its.link.TbLinkService;
import com.its.op.service.its.link.TbLinkTrafClctHsService;
import com.sun.istack.Nullable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "02.이력조회-4.수집데이터분석")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/history/clct-analysis")
public class TbLinkTrafClctHsAnalController {

    private final TbLinkService linkService;
    private final TbClctSystStupService clctSystStupService;
    private final TbLinkTrafClctHsService service;

    @ApiOperation(value = "수집시스템 조회(TB_CLCT_SYST_STUP)", response = TbClctSystStupDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/clct-syst-stup", produces = {"application/json; charset=utf8"})
    public List<TbClctSystStupDto> findAllClctSystStup() {
        return this.clctSystStupService.findAll();
    }

    @ApiOperation(value = "링크정보 도로정보 전체조회-지역센터(TB_LINK)", response = TbLinkDto.class)
    @GetMapping(value = "/road-link", produces = {"application/json; charset=utf8"})
    public List<TbLinkDto> findLocalRoadLinkAll() {
        return this.linkService.findLocalRoadLinkAll();
    }

    @ApiOperation(value = "링크 소통상황 수집데이터분석(TB_LINK_TRAF_CLCT_HS, TB_CLCT_SYST_STUP)", response = TbLinkTrafClctHsAnalDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbLinkTrafClctHsAnalDto> findAllAnalByDateRange(
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH24MI00)", example = "20210112152000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH24MI59)", example = "20221112152059", required = true)
            @RequestParam String TO_DT,
            @ApiParam(name = "id", value = "링크 ID 목록", example = "{2280212200,2280212300}", required = false)
            @RequestParam(required = false, name = "ids") @Nullable List<Long> ids) {
        return this.service.findAllAnalByDateRange(FROM_DT, TO_DT, ids);
    }

}
