Index.php 4.0 KB
<?php

namespace addons\jiangxingapi\controller;

use app\common\controller\Api;
use think\addons\Controller;
use think\Db;

class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];
    protected $water_levelsql = "reservoir_rain_water_level_copy";//水位sql
    protected $rain_rainfallsql = "reservoir_rain_rainfall_copy";//雨量sql
    protected $dam_seepagesql = "reservoir_dam_seepage_copy";//渗流sql
    protected $dam_isotonicsql = "reservoir_dam_isotonic_copy";//渗压sql
    protected $dam_displacementsql = "reservoir_dam_displacement_copy";//渗压sql
    protected $reservoir_rain_flowsql = "reservoir_rain_flow";//流量sql

    /**
     * 查询水位
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function water_level(){
        $number=$this->request->param("number");//设备编号
        $res=Db::name($this->water_levelsql)->where("number",$number)->select();
        foreach ($res as $k=>$v){
            $res[$k]['createtime']=date("Y-m-d H:i:s",$res[$k]['createtime']);
        }
        $this->success("查询成功",$res);
    }

    /**
     * 查询雨量
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function rainfall(){
        $number=$this->request->param("number");//设备编号
        $res=Db::name($this->rain_rainfallsql)->where("number",$number)->select();
        foreach ($res as $k=>$v){
            $res[$k]['createtime']=date("Y-m-d H:i:s",$res[$k]['createtime']);
        }
        $this->success("查询成功",$res);
    }


    /**
     * 查询渗流
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function transfusion(){
        $number=$this->request->param("number");//设备编号
        $res=Db::name($this->dam_seepagesql)->where("equipment_id",$number)->select();
        foreach ($res as $k=>$v){
            $res[$k]['createtime']=date("Y-m-d H:i:s",$res[$k]['createtime']);
        }
        $this->success("查询成功",$res);
    }

    /**
     * 查询渗流
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function osmotic(){
        $number=$this->request->param("number");//设备编号
        $res=Db::name($this->dam_isotonicsql)->where("equipment_id",$number)->select();
        foreach ($res as $k=>$v){
            $res[$k]['createtime']=date("Y-m-d H:i:s",$res[$k]['createtime']);
        }
        $this->success("查询成功",$res);
    }

    /**
     * 查询渗流
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function displacement(){
        $number=$this->request->param("number");//设备编号
        $res=Db::name($this->dam_displacementsql)->where("number",$number)->select();
        foreach ($res as $k=>$v){
            $res[$k]['createtime']=date("Y-m-d H:i:s",$res[$k]['createtime']);
        }
        $this->success("查询成功",$res);
    }



  /**
     * 查询流量
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function flow(){
        $number=$this->request->param("number");//设备编号
        $res=Db::name($this->reservoir_rain_flowsql)->where("number",$number)->select();
        foreach ($res as $k=>$v){
            $res[$k]['createtime']=date("Y-m-d H:i:s",$res[$k]['createtime']);
        }
        $this->success("查询成功",$res);
    }

}