<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
class Warn extends Common
{
    public function index($id){
        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
					 $this->error('更新失败！');
				  }
			}
        return $this->fetch();
    }

    public function epa($id){ //普通油色谱
        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
            
        return $this->fetch();

   }
   public function epa_1($id){ //光声光谱
        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
            
        return $this->fetch();

   }
   public function epa_2($id){ //油中气设备
        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
            
        return $this->fetch();

   }
    public function eiact($id){
        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE INTO warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=" . $v . "";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=" . $v . "";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
    public function etp($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
    public function sf6_h($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
   //   add by ramon 2023-04-11
    public function sf6env_h($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
    public function pd_h($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
    public function mic($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
    public function eif($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }

        return $this->fetch();

    }
    public function otp($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }

        return $this->fetch();

    }
    public function eia($id){
       
        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }

        return $this->fetch();

    }
        public function scur($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    public function jdw($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    // 电缆沟
    // 开关室1
    public function dlgkg1_awater($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }    

    public function dlgkg1_tmp($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    
    // 开关室2
    public function dlgkg2_awater($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }    

    public function dlgkg2_tmp($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    // 母线洞
     public function dlgdong1_tmp($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    public function dlgdong2_tmp($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    public function dlgdong3_tmp($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    public function dlgdong_awater($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    // 烟雾告警
    public function dlg_modevcomf($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
    }  
    
    // 光纖測溫
    public function etp_gxcw($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
   
   // raozu測溫
    public function etp_rzcw($id){

        $warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
        $this->assign('warn',$warn);
        if(request()->isPost()){
            $data=input('post.');
            $sql1="REPLACE into warn_cfg (eqmid";
            $sql2=$id;
            $sql3="";
            $updatesql="";
            foreach ($data as $k=>$v){
                $sql1=$sql1.",".$k;
                if($v=="")
                {
                    $sql2 = $sql2 . ",NULL";
                }
                else {
                    $sql2 = $sql2 .",". $v;
                }
                if($sql3=="") {
                    $sql3 = $sql3 . $k . "=values(" . $k . ")";
                }
                else{
                    $sql3 = $sql3 .",". $k . "=values(" . $k . ")";
                }
            }
            $sql=$sql1.") values(".$sql2.")";
            $setsql=Db::execute("$sql");
            if($setsql){
                $this->success('更新成功！');
            }else{
                $this->error('更新失败！');
            }
        }
        return $this->fetch();
   }
}

?>


