<?php

namespace app\admin\controller;
use think\Controller;
use think\Db;
class Warn extends Common
{
public function index($id){
echo $id;die;
$warn=Db::table('warn_cfg')->where('eqmid',$id)->find();
$this->assign('warn',$warn);
if(request()->isPost()){
$data=input('post.');
$sql1="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$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="insert 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.") on duplicate key update ".$sql3;
$setsql=Db::execute("$sql");
if($setsql){
$this->success('更新成功！');
}else{
$this->error('更新失败！');
}
}
return $this->fetch();
}
}
?>