package com.gyee.frame.controller.benchmarking;

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.Windturbineinfodaytop;
import com.gyee.frame.model.auto.Windturbineinfodaytop2;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.model.custom.ValueVo;
import com.gyee.frame.service.Windturbineinfodaytop2Service;
import com.gyee.frame.service.WindturbineinfodaytopService;
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.GetMapping;
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.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/benchmarking")
@Api(value = "等级评估功能",tags =  "等级评估功能")
public class BenchmarkingController {
//    @Resource
//    private Windturbineinfodaytop3Service windturbineinfodaytop2Service;
    @Resource
    private Windturbineinfodaytop2Service windturbineinfodaytop2Service;
    @Resource
    private WindturbineinfodaytopService windturbineinfodaytopService;

    /**查询等级评估日所有信息**/

    @GetMapping("/gadaylist")
    @ResponseBody
    @ApiOperation(value = "查询等级评估日所有信息", notes = "查询等级评估日所有信息")
    @ApiImplicitParams({

            @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
    public AjaxResult gadaylist(String wpId, String recorddate) {

        Date tempDate=null;
        if (StringUtils.isNotEmpty(recorddate))
        {
            tempDate=DateUtils.parseDate(recorddate);
        }
        List<Windturbineinfodaytop2> ls=windturbineinfodaytop2Service.gadaylist(wpId,tempDate);

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

    }
    /**按页查询等级评估日所有信息**/
    @PostMapping("/gadaylistByPage")
    @ResponseBody
    @ApiOperation(value = "按页查询等级评估日所有信息", notes = "按页查询等级评估日所有信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tablepar", value = "分页排序对象", required = true, dataType = "Tablepar", paramType = "query"),
            @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
    public AjaxResult gadaylistByPage(Tablepar tablepar,String wpId, String recorddate) {

        Date tempDate=null;
        if (StringUtils.isNotEmpty(recorddate))
        {
            tempDate=DateUtils.parseDate(recorddate);
        }
        PageInfo<Windturbineinfodaytop2> ls=windturbineinfodaytop2Service.gadaylistByPage(tablepar,wpId,tempDate);


        return	AjaxResult.successData(AjaxStatus.success.code,ls);

    }
    /**按页查询等级评估月所有信息**/
    @PostMapping("/gamonthlistByPage")
    @ResponseBody
    @ApiOperation(value = "按页查询等级评估月所有信息", notes = "按页查询等级评估月所有信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tablepar", value = "分页排序对象", required = true, dataType = "Tablepar", paramType = "query"),
            @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "month", value = "月", required = true, dataType = "string", paramType = "query")})

    public AjaxResult gamonthlistByPage(Tablepar tablepar,String wpId, String year,String month) {


        PageInfo<Windturbineinfodaytop2> ls=windturbineinfodaytop2Service.gamonthlistByPage(tablepar,wpId,year,month);

        return	AjaxResult.successData(AjaxStatus.success.code,ls);

    }
    /**按页查询等级评估年所有信息**/
    @PostMapping("/gayearlistByPage")
    @ResponseBody
    @ApiOperation(value = "按页查询等级评估年所有信息", notes = "按页查询等级评估年所有信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tablepar", value = "分页排序对象", required = true, dataType = "Tablepar", paramType = "query"),
            @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年", required = true, dataType = "string", paramType = "query")})
    public AjaxResult gayearlistByPage(Tablepar tablepar,String wpId, String year) {


        PageInfo<Windturbineinfodaytop2> ls=windturbineinfodaytop2Service.gayearlistByPage(tablepar,wpId,year);

        return	AjaxResult.successData(AjaxStatus.success.code,ls);

    }
    /**按等级评估ID查询相应信息返回玫瑰图**/
    @GetMapping("/wtchart")
    @ResponseBody
    @ApiOperation(value = "按等级评估ID查询相应信息返回玫瑰图", notes = "按等级评估ID查询相应信息返回玫瑰图")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gaid1", value = "等级评估对象编号1", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "gaid2", value = "等级评估对象编号2", required = true, dataType = "string", paramType = "query")})
    public AjaxResult wtchart(String gaid1,String gaid2) {


        if (StringUtils.isNotEmpty(gaid1) && StringUtils.isNotEmpty(gaid2))
        {
            List<ValueVo> ls1=windturbineinfodaytop2Service.wtchart(gaid1);
            List<ValueVo> ls2=windturbineinfodaytop2Service.wtchart(gaid2);

            Map<String,List<ValueVo>> map=new HashMap();

            map.put("gaid1",ls1);
            map.put("gaid2",ls2);

            return	AjaxResult.successData(AjaxStatus.success.code,map);
        }

         return	AjaxResult.error(AjaxStatus.error.code,null);
    }

    /**按等级评估ID查询相应详细信息**/
    @GetMapping("/wtinfo")
    @ResponseBody
    @ApiOperation(value = "按等级评估ID查询相应详细信息", notes = "按等级评估ID查询相应详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gaid1", value = "等级评估对象编号1", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "gaid2", value = "等级评估对象编号2", required = true, dataType = "string", paramType = "query")})
    public AjaxResult wtinfo(String gaid1,String gaid2) {


        if (StringUtils.isNotEmpty(gaid1) && StringUtils.isNotEmpty(gaid2))
        {
            Map<String,Windturbineinfodaytop2> map=new HashMap();

            Windturbineinfodaytop2 wtd1=windturbineinfodaytop2Service.selectByPrimaryKey(gaid1);
            Windturbineinfodaytop2 wtd2=windturbineinfodaytop2Service.selectByPrimaryKey(gaid2);

            map.put("gaid1",wtd1);
            map.put("gaid2",wtd2);

            return	AjaxResult.successData(AjaxStatus.success.code,map);
        }

        return	AjaxResult.error(AjaxStatus.error.code,null);
    }


    @PostMapping("/gadayhistlist")
    @ResponseBody
    @ApiOperation(value = "查询日历史信息", notes = "查询日历史信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
    public AjaxResult gadayhistlist(Tablepar tablepar,String wtId, String recorddate) {

        Date tempDate=null;
        if (StringUtils.isNotEmpty(recorddate))
        {
            tempDate=DateUtils.parseDate(recorddate);
        }
        List<Windturbineinfodaytop> ls=windturbineinfodaytopService.gadayhistlist(wtId,tempDate);


        return	AjaxResult.successData(AjaxStatus.success.code,ls);

    }

    @PostMapping("/gamonthhistlist")
    @ResponseBody
    @ApiOperation(value = "查询月历史信息", notes = "查询月历史信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "month", value = "月", required = true, dataType = "string", paramType = "query")})

    public AjaxResult gamonthhistlist(String wtId, String year,String month) {


        List<Windturbineinfodaytop> ls=windturbineinfodaytopService.gamonthhistlist(wtId,year,month);

        return	AjaxResult.successData(AjaxStatus.success.code,ls);

    }
    /**按页查询等级评估年所有信息**/
    @PostMapping("/gayearhistlist")
    @ResponseBody
    @ApiOperation(value = "查询年历史信息", notes = "查询年历史信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年", required = true, dataType = "string", paramType = "query")})
    public AjaxResult gayearhistlist(Tablepar tablepar,String wtId, String year) {


        List<Windturbineinfodaytop> ls=windturbineinfodaytopService.gayearhistlist(wtId,year);

        return	AjaxResult.successData(AjaxStatus.success.code,ls);

    }
}
