package com.gyee.frame.controller.goodness;

import com.github.pagehelper.PageInfo;
import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.model.auto.Windturbineanalysisday;
import com.gyee.frame.model.auto.Windturbinegoodness;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.service.WindturbineanalysisdayService;
import com.gyee.frame.service.goodness.WindturbinegoodnessService;
import com.gyee.frame.util.DateUtils;
import com.gyee.frame.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 单机性能分析列表
 */
@Controller
@RequestMapping("/goodness")
@Api(value = "单机信息总览首页",tags =  "单机信息总览首页")
public class WindturbinegoodnessController {
    @Resource
    private WindturbinegoodnessService windturbinegoodnessService;
    @Resource
    private WindturbineanalysisdayService windturbineanalysisdayService;


    /**
     * 获得单机性能总览列表信息
     *
     * @param tablepar
     * @param wpId
     * @param recorddate
     * @return
     */
    @PostMapping("/windturbinegoodness")
    @ResponseBody
    @ApiOperation(value = "获得单机性能总览列表信息", notes = "获得单机性能总览列表信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tablepar", value = "分页排序对象", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

    public AjaxResult windturbinegoodness(Tablepar tablepar, String wpId, String recorddate) {

        PageInfo<Windturbinegoodness> resultList = windturbinegoodnessService.windturbinegoodnessList(tablepar, wpId, recorddate);
        if (resultList != null) {
            return AjaxResult.successData(AjaxStatus.success.code, resultList);
        } else {
            return AjaxResult.successData(AjaxStatus.success.code, resultList);
        }
    }


    /**
     * 获得单机性能总览历史列表信息
     *
     * @param tablepar
     * @param wtId
     * @param beginDate
     * @param endDate
     * @return
     */
    @PostMapping("/goodhistorylist")
    @ResponseBody
    @ApiOperation(value = "获得单机性能总览历史列表信息", notes = "获得单机性能总览历史列表信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tablepar", value = "分页排序对象", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "beginDate", value = "开始日期", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束日期", required = true, dataType = "string", paramType = "query")})

    public AjaxResult goodhistorylist(Tablepar tablepar, String wtId, String beginDate, String endDate) {
        List<Windturbineanalysisday> resultList =new ArrayList<>();
        if(StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate) )
        {
            resultList = windturbineanalysisdayService.goodhistorylist(tablepar,wtId, DateUtils.parseDate(beginDate),  DateUtils.parseDate(endDate));
        }
        if (resultList != null) {
            return AjaxResult.successData(AjaxStatus.success.code, resultList);
        } else {
            return AjaxResult.successData(AjaxStatus.success.code, resultList);
        }
    }

}
