package com.gyee.frame.controller.outputspeed;

import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.model.auto.Inputoroutputspeedtotal;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.service.InputoroutputspeedtotalService;
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.Date;
import java.util.List;

@Controller
@RequestMapping("/outputspeed")
@Api(value = "切入切出管理",tags =  "切入切出管理")
public class OutputSpeedController {

    @Resource
    private InputoroutputspeedtotalService inputoroutputspeedtotalService;

    /**切入切出列表**/
    @PostMapping("/outputSpeedlist")
    @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 outputSpeedlist(Tablepar tablepar, String wpId, String recorddate) {

        List<Inputoroutputspeedtotal> vos=new ArrayList<>();
        if (StringUtils.notEmp(wpId) && StringUtils.notEmp(recorddate))
        {
            Date date=DateUtils.parseStrtoDate(recorddate);
            vos=inputoroutputspeedtotalService.getInputoroutputspeedtotal(tablepar, wpId, date);
        }

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

    }

    /**切入切出历史列表**/
    @PostMapping("/outputspeedhistorylist")
    @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 = "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 outputspeedhistorylist(Tablepar tablepar, String wpId,String wtId, String beginDate,String endDate) {

        List<Inputoroutputspeedtotal> vos=new ArrayList<>();
        if (StringUtils.notEmp(wpId) && StringUtils.notEmp(beginDate) &&  StringUtils.notEmp(endDate))
        {

            vos=inputoroutputspeedtotalService.getInputoroutputspeedtotal(tablepar, wpId,wtId, DateUtils.parseDate(beginDate),DateUtils.parseDate(endDate));
        }

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

    }


}
