package com.mvc.controller.tyrq;

import com.mvc.model.*;
import com.mvc.model.tyrq.TyrqStatisticsModel;
import com.mvc.service.taizhang.StationAccService;
import com.mvc.service.tyrq.TyrqStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "太原天然气相关接口")
@RequestMapping("/TyrqStatisticsAction")
@Controller
public class TyrqStatisticsAction {

    @Resource
    private TyrqStatisticsService tyrqStatisticsService;

    @Resource
    private StationAccService stationAccService;

    @ApiOperation("根据遥测站编码获取统计数据")
    @RequestMapping(value = "/getStatisticsData", method = RequestMethod.GET)
    @ResponseBody
    public ResultGeekerModel getStatisticsData(String stationCode) {
        ResultGeekerModel resultModel;
        try {
            TyrqStatisticsModel res = tyrqStatisticsService.getStatisticsDataByStationCode(stationCode);
            resultModel = new ResultGeekerModel(res);
        } catch (Exception e) {
            e.printStackTrace();
            resultModel = new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }

    @ApiOperation("根据用户自定义编码获取统计数据")
    @RequestMapping(value = "/findStationAccByUserDefinedCode", method = RequestMethod.GET)
    @ResponseBody
    public ResultGeekerModel findStationAccByUserDefinedCode(String userDefinedCode,String unitCode) {
        ResultGeekerModel resultModel;
        try {
            StationAccModel temp = stationAccService.findStationAccByUserDefinedCode(userDefinedCode,unitCode);
            if(temp!=null){
                TyrqStatisticsModel res = tyrqStatisticsService.getStatisticsDataByStationCode(temp.getStationCode());
                resultModel = new ResultGeekerModel(res);
            }else {
                resultModel = new ResultGeekerModel("未匹配到台账信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            resultModel = new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }

    /*@ApiOperation("根据单位代码获取统计数据")
    @RequestMapping(value = "/getStatisticsData", method = RequestMethod.GET)
    @ResponseBody
    public ResultGeekerModel getStatisticsData(String unitCode) {
        ResultGeekerModel resultModel;
        try {
            TyrqStatisticsModel res = tyrqStatisticsService.getStatisticsData(unitCode);
            resultModel = new ResultGeekerModel(res);
        } catch (Exception e) {
            e.printStackTrace();
            resultModel = new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }*/
}
