package com.huimv.env.controller;

import com.alibaba.fastjson.JSONArray;
import com.huimv.common.utils.Result;
import com.huimv.env.service.IEnvironmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Project : huimv.shiwan
 * @Package : com.huimv.biosafety.uface.controller
 * @Description : TODO
 * @Version : 1.0
 * @Author : ZhuoNing
 * @Create : 2020-12-25
 **/
@CrossOrigin
@RestController
@RequestMapping(value = "/environment")
public class EnvironmentController {
    @Autowired
    private IEnvironmentService environmentService;

    /**
     * @Method      : getLastEnvData
     * @Description : 
     * @Params      : []
     * @Return      : com.huimv.common.utils.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2020/12/28       
     * @Time        : 20:48
     */
    @RequestMapping("/getLastEnvData")
    public Result getLastEnvData(){
        int mcid = 39;
        //
        return environmentService.getLastEnvData(mcid);
    }

    /**
     * @Method      : getLastEnvData2
     * @Description : 
     * @Params      : []
     * @Return      : com.huimv.common.utils.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2020/12/28       
     * @Time        : 20:48
     */
    @RequestMapping("/getLastEnvData2")
    public Result getLastEnvData2(){
        int mcid = 39;
        //
        return environmentService.getLastEnvData2(mcid);
    }

    /**
     * @Method      : getZsda
     * @Description : 读取所有和包括栏期
     * @Params      : []
     * @Return      : com.huimv.common.utils.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2020/12/28       
     * @Time        : 20:48
     */
    @RequestMapping(value="/getZsda",method = RequestMethod.GET)
    public Result getZsda(@RequestParam(value = "mcid") Integer mcid){
        //
        return environmentService.getZsda(mcid);
    }

    /**
     * @Method      : getLastEnvByLq
     * @Description : 
     * @Params      : [lqid]
     * @Return      : com.huimv.common.utils.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2020/12/28       
     * @Time        : 20:51
     */
    @RequestMapping(value="/getLastEnvByLq",method = RequestMethod.GET)
    public Result getLastEnvByLq(@RequestParam(value = "lqid") Integer lqid){
        //
        return environmentService.getLastEnvByLq(lqid);
    }

    @RequestMapping(value="/getTemperature",method = RequestMethod.GET)
    public Result getTemperature(@RequestParam(value = "lqid") Integer lqid){
        // 获取
        return environmentService.getTemperatureOnToday(lqid);
    }

    @RequestMapping(value="/getAmmoniaAndHumidity",method = RequestMethod.GET)
    public Result getAmmoniaAndHumidity(@RequestParam(value = "lqid") Integer lqid){

        return environmentService.getAmmoniaAndHumidityOnToday(lqid);
    }

    @RequestMapping("/details")
    public Result getEnvDetails() {
        // 获取环保数据
        return environmentService.getEnvDetails();
    }



}
