package com.gyee.frame.controller.health;

import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.model.auto.LossPowerRate;
import com.gyee.frame.service.LossPowerRateService;
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("/losspowerratehealth")
@Api(value = "性能损失走势" ,tags =  "性能损失走势")
public class LossPowerRateHealthController {

    @Resource
    private LossPowerRateService lossPowerRateService;

    /**性能损失走势列表**/
    @PostMapping("/losspowerrateList")
    @ResponseBody
    @ApiOperation(value = "性能损失走势列表", notes = "性能损失走势列表")
    @ApiImplicitParams({
            @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 losspowerrateList(String wtId,String beginDate,String endDate) throws Exception {

       List<LossPowerRate>  vos = new ArrayList<LossPowerRate>();
        if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate))
        {
            vos=lossPowerRateService.getLossPowerRateListBywtId(wtId, DateUtils.parseStrtoDate(beginDate), DateUtils.parseStrtoDate(endDate));
        }

        if (null!=vos) {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        } else {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        }

    }

    /**性能损失走势图表**/
    @PostMapping("/getChartlist")
    @ResponseBody
    @ApiOperation(value = "性能损失走势图表", notes = "性能损失走势图表")
    @ApiImplicitParams({
            @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 getChartlist(String wtId,String beginDate,String endDate) throws Exception {

        List<List<List<Object>>>  vos = new ArrayList<>();
        if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate))
        {
            vos=lossPowerRateService.getChartlist(wtId, DateUtils.parseStrtoDate(beginDate), DateUtils.parseStrtoDate(endDate));
        }

        if (null!=vos) {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        } else {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        }

    }

}
