package com.mvc.controller.tyrq;

import com.mvc.service.tyrq.TyrqDataExportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "太原天然气数据导出接口")
@RequestMapping("/TyrqDataExportAction")
@Controller
public class TyrqDataExportAction {
    @Resource
    private TyrqDataExportService tyrqDataExportService;

    /**
     * 导出单表数据
     * @param response HttpServletResponse
     * @param stationCode 站代码
     * @param startTime 起始时间
     * @param endTime 结束时间
     */
    @ApiOperation("导出单表数据")
    @RequestMapping(value = "/exportSingleMeterData/{stationCode}/{startTime}/{endTime}", method = RequestMethod.GET)
    @ResponseBody
    public void exportSingleMeterData(HttpServletResponse response,
                                      @PathVariable("stationCode") String stationCode,
                                      @PathVariable("startTime") String startTime,
                                      @PathVariable("endTime") String endTime) {
        tyrqDataExportService.exportSingleMeterData(response, stationCode, startTime, endTime);
    }

    /**
     * 导出多表数据
     * @param response HttpServletResponse
     * @param unitCode 单位代码
     * @param startTime 起始时间
     * @param endTime 结束时间
     */
    @ApiOperation("导出多表数据")
    @RequestMapping(value = "/exportMultipleMeterDataByUnitCode/{unitCode}/{startTime}/{endTime}", method = RequestMethod.GET)
    @ResponseBody
    public void exportMultipleMeterDataByUnitCode(HttpServletResponse response,
                                                  @PathVariable("unitCode") String unitCode,
                                                  @PathVariable("startTime") String startTime,
                                                  @PathVariable("endTime") String endTime
    ) {
        tyrqDataExportService.exportMultipleMeterDataByUnitCode(response, unitCode, startTime, endTime);
    }
}
