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 org.springframework.beans.factory.annotation.Autowired;
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 java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/outputspeed")
public class OutputSpeedController {

    @Autowired
    private InputoroutputspeedtotalService inputoroutputspeedtotalService;

    /**切入切出列表**/
    @PostMapping("/outputSpeedlist")
    @ResponseBody
    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.emptyresultset.code, vos);
        }

    }

    /**切入切出历史列表**/
    @PostMapping("/outputspeedhistorylist")
    @ResponseBody
    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.emptyresultset.code, vos);
        }

    }


}
