|
@@ -43,8 +43,15 @@ class IndexController extends MainController
|
|
|
$v['DVICLONGITUDE'] = $res['gg_lon'];
|
|
|
$v['DVICLATITUDE'] = $res['gg_lat'];
|
|
|
}
|
|
|
+ $ALARMSTARTTIME=config('app.ALARMSTARTTIME');
|
|
|
+ $ALARMENDTIME=config('app.ALARMENDTIME');
|
|
|
|
|
|
- $this->api_return_json(compact('index'), 1);
|
|
|
+
|
|
|
+ $datatime=array('ALARMSTARTTIME'=>$ALARMSTARTTIME,'ALARMENDTIME'=>$ALARMENDTIME);
|
|
|
+ $num=Db::table('reportdata')->where([['ALARMSTARTTIME','<',$ALARMSTARTTIME],['ALARMENDTIME','>',$ALARMENDTIME]])->count();
|
|
|
+
|
|
|
+
|
|
|
+ $this->api_return_json(compact('index','datatime','num'), 1);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -134,17 +141,26 @@ class IndexController extends MainController
|
|
|
$this->api_return_json(array('msg' => '请填写纬度'));
|
|
|
}
|
|
|
|
|
|
+ $data=array();
|
|
|
+ $data['PRIMARYADDR']=$param['PRIMARYADDR'];
|
|
|
+ $data['REPEATERNAME']=$param['REPEATERNAME'];
|
|
|
+ $data['STATIONNAME']=$param['STATIONNAME'];
|
|
|
+ $data['DVICLONGITUDE']=$param['DVICLONGITUDE'];
|
|
|
+ $data['DVICLATITUDE']=$param['DVICLATITUDE'];
|
|
|
+
|
|
|
//修改
|
|
|
- if ($param['ID']) {
|
|
|
+ if (!empty($param['ID'])) {
|
|
|
$ID=$param['ID'];
|
|
|
unset($param['ID']);
|
|
|
- $res = Db::name('device')->where([['ID','=',$ID]])->update($param);
|
|
|
+ $res = Db::name('primarydev')->where([['ID','=',$ID]])->update($data);
|
|
|
} else {
|
|
|
- $res = Db::name('device')->insert($param);
|
|
|
+ $res = Db::name('primarydev')->insert($data);
|
|
|
}
|
|
|
+
|
|
|
if ($res) {
|
|
|
$this->api_return_json(array('msg' => '添加成功'), 1);
|
|
|
- }
|
|
|
+ }else
|
|
|
+ $this->api_return_json(array('msg' => '操作失败'));
|
|
|
}
|
|
|
/*
|
|
|
* @name 编辑页面数据接口
|
|
@@ -158,7 +174,7 @@ class IndexController extends MainController
|
|
|
$edit['DVICLATITUDE']="";
|
|
|
|
|
|
if ($ID) {
|
|
|
- $edit = Db::name('device')->where([['ID','=',$ID]])->find();
|
|
|
+ $edit = Db::name('primarydev')->where([['ID','=',$ID]])->find();
|
|
|
}
|
|
|
$this->api_return_json(compact('edit'), 1);
|
|
|
}
|
|
@@ -170,11 +186,63 @@ class IndexController extends MainController
|
|
|
public function timeadd(){
|
|
|
$ALARMSTARTTIME = $this->request->param('ALARMSTARTTIME');
|
|
|
$ALARMENDTIME = $this->request->param('ALARMENDTIME');
|
|
|
- if(isset($ALARMENDTIME)&&isset($ALARMENDTIME)){
|
|
|
-
|
|
|
+ if(isset($ALARMSTARTTIME)&&isset($ALARMENDTIME)){
|
|
|
+ config('app.ALARMENDTIME',strtotime($ALARMENDTIME));
|
|
|
+ config('app.ALARMSTARTTIME',strtotime($ALARMSTARTTIME));
|
|
|
}
|
|
|
$this->api_return_json(array('msg' => '时间周期不能为空'), 1);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ *
|
|
|
+ * @name FPA列表
|
|
|
+ * */
|
|
|
+ public function deviceinfo(){
|
|
|
+ $PRIMARYADDR = $this->request->param('PRIMARYADDR',0);
|
|
|
+
|
|
|
+ $deviceinfo = Db::table('deviceinfo')
|
|
|
+ ->alias('d')
|
|
|
+ ->where( array(array('d.PRIMARYADDR', '=', $PRIMARYADDR)))
|
|
|
+ ->join('realtimedata rt', 'rt.DEVICEID=d.DEVICEID and rt.PRIMARYADDR=d.PRIMARYADDR', 'left')
|
|
|
+ ->field('d.*,rt.STATUS,rt.LASTTRANSDATE')
|
|
|
+ ->select();
|
|
|
+ $arr = array(1 => '80℃', 2 => '2:100℃', 3 => '130℃');
|
|
|
+ $sta = array('在线', '报警', '不在线', '未配置');
|
|
|
+ foreach ($deviceinfo as $k => &$v) {
|
|
|
+ $v['TEMPERTHRESHOLD'] = $arr[$v['TEMPERTHRESHOLD']];
|
|
|
+ $v['STATUS'] = $sta[$v['STATUS']];
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->api_return_json(compact('deviceinfo'), 1);
|
|
|
+
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ *
|
|
|
+ * @name FPA添加编辑
|
|
|
+ * */
|
|
|
+ public function deviceinfoinfo(){
|
|
|
+ $param=$this->request->param();
|
|
|
+ if(!isset($param['DEVICEID'])||empty($param['DEVICEID'])){$this->api_return_json(array('msg' => '请填写监测点ID'));}
|
|
|
+ if(!isset($param['DEVICENAME'])||empty($param['DEVICENAME'])){$this->api_return_json(array('msg' => '请填写FPA名称'));}
|
|
|
+ if(!isset($param['TEMPERTHRESHOLD'])||empty($param['TEMPERTHRESHOLD'])){$this->api_return_json(array('msg' => '请选择温度阈值'));}
|
|
|
+ if(!isset($param['CELLNAME'])||empty($param['CELLNAME'])){$this->api_return_json(array('msg' => '请填写小室名称'));}
|
|
|
+ if(!isset($param['POWERDISCABVOLUME'])||empty($param['POWERDISCABVOLUME'])){$this->api_return_json(array('msg' => '请填写开关柜小室体积'));}
|
|
|
+ if(!isset($param['TEMPERPATCHNUM'])||empty($param['TEMPERPATCHNUM'])){$this->api_return_json(array('msg' => '请填写感温贴片数量'));}
|
|
|
+ //修改
|
|
|
+ if ($param['ID']) {
|
|
|
+ $ID=$param['ID'];
|
|
|
+ unset($param['ID']);
|
|
|
+ $str='添加';
|
|
|
+ $res = Db::name('deviceinfo')->where([['ID','=',$ID]])->update($param);
|
|
|
+ } else {
|
|
|
+ $str='编辑';
|
|
|
+ $res = Db::name('deviceinfo')->insert($param);
|
|
|
+ }
|
|
|
+ if ($res) {
|
|
|
+ $this->api_return_json(array('msg' => $str.'成功'), 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|