package com.gyee.frame.controller.monitor;

import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.service.websocket.WtInfoPushService;
import com.gyee.frame.service.websocket.WtWarnPushService;
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.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/monitorwt")
@Api(value = "风机监视" ,tags =  "风机监视")
public class MonitorWtPushController {

    @Resource
    private WtInfoPushService wtInfoPushService;
    @Resource
    private WtWarnPushService wtWarnPushService;


    @PostMapping("/findWtInfo")
    @ResponseBody
    @ApiOperation(value = "风机信息", notes = "风机信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query")
    })

    public AjaxResult findWtInfo(String wtId) throws Exception {


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


        map=wtInfoPushService.findWtInfo(wtId);

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

    }

    @PostMapping("/findWtWarnInfo")
    @ResponseBody
    @ApiOperation(value = "风机报警信息", notes = "风机报警信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query")
    })

    public AjaxResult findWtWarnInfo(String wtId) throws Exception {


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


        map=wtWarnPushService.findWtWarnInfo(wtId);

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

    }

    @PostMapping("/findWtInfoList")
    @ResponseBody
    @ApiOperation(value = "风机信息列表", notes = "风机信息列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")
    })

    public AjaxResult findWtInfoList(String wpId) throws Exception {


        List<Map<String, Object>> vos=  new ArrayList<>();


        vos=wtInfoPushService.findWtInfoList(wpId);

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

    }
}
