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.custom.PartbjcountVo;
import com.gyee.frame.model.custom.WindturbinebjCountVo;
import com.gyee.frame.service.health.PartBjService;
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("/partbj")
@Api(value = "批次报警分析" ,tags =  "批次报警分析")
public class PartBjController {

    @Resource
    private PartBjService partBjService;

    /**批次报警分析**/
    @PostMapping("/partbjList")
    @ResponseBody
    @ApiOperation(value = "批次报警分析主列表", notes = "批次报警分析主列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

    public AjaxResult partbjList(String recorddate) throws Exception {

        List<PartbjcountVo> vos = new ArrayList<PartbjcountVo>();
        if (StringUtils.notEmp(recorddate))
        {
            vos=partBjService.getPartBjCountList(DateUtils.parseStrtoDate(recorddate));
        }

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

    }

    /**批次报警分析**/
    @PostMapping("/partbjsubList")
    @ResponseBody
    @ApiOperation(value = "批次报警分析明细列表", notes = "批次报警分析明细列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lnid", value = "线路编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "part", value = "部件编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

    public AjaxResult partbjsubList(String lnid, String part, String recorddate) throws Exception {

        List<WindturbinebjCountVo> vos = new ArrayList<WindturbinebjCountVo>();
        if (StringUtils.notEmp(recorddate))
        {
            vos=partBjService.getWindturbinebjCountVoList(lnid,  part,DateUtils.parseStrtoDate(recorddate));
        }

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

    }

}
