|
@@ -55,24 +55,48 @@ class IndexController extends MainController
|
|
public function reportdata()
|
|
public function reportdata()
|
|
{
|
|
{
|
|
$PRIMARYADDR = $this->request->param('PRIMARYADDR');
|
|
$PRIMARYADDR = $this->request->param('PRIMARYADDR');
|
|
|
|
+ $type = $this->request->param('type', 0);
|
|
|
|
+ if (!intval($this->userid)) {
|
|
|
|
+ $this->api_return_json(array('msg' => '请重新登录'), 0);
|
|
|
|
+ }
|
|
if (isset($PRIMARYADDR) && intval($PRIMARYADDR)) {
|
|
if (isset($PRIMARYADDR) && intval($PRIMARYADDR)) {
|
|
- //报警设备 查站点id下的
|
|
|
|
- $reportdata = Db::table('reportdata')
|
|
|
|
- ->alias('rp')
|
|
|
|
- ->where(array(array('rp.ALARMENDTIME', '=', ''), array('rp.PRIMARYADDR', '=', $PRIMARYADDR)))
|
|
|
|
- ->join('realtimedata rt', 'rt.DEVICEID=rp.DEVICEID and rt.PRIMARYADDR=rp.PRIMARYADDR', 'left')
|
|
|
|
- ->field('rp.*,rt.STATUS,rt.LASTTRANSDATE')
|
|
|
|
- ->select();
|
|
|
|
|
|
+ //如果为真查询关注报警设备
|
|
|
|
+ if ($type) {
|
|
|
|
+ $reportdata = Db::table('follow')
|
|
|
|
+ ->alias('f')
|
|
|
|
+ ->where(array(array('f.UID', '=', $this->userid), array('rp.ALARMENDTIME', '=', ''), array('f.PID', '=', $PRIMARYADDR)))
|
|
|
|
+ ->join('reportdata rp', 'f.DID=rp.DEVICEID and F.PID=rp.PRIMARYADDR', 'left')
|
|
|
|
+ ->join('realtimedata rt', 'f.DID=rt.DEVICEID and F.PID=rt.PRIMARYADDR', 'left')
|
|
|
|
+ ->field('rp.*,rt.STATUS,rt.LASTTRANSDATE')
|
|
|
|
+ ->select();
|
|
|
|
+ } else {
|
|
|
|
+ //报警设备 查站点id下的
|
|
|
|
+ $reportdata = Db::table('reportdata')
|
|
|
|
+ ->alias('rp')
|
|
|
|
+ ->where(array(array('rp.ALARMENDTIME', '=', ''), array('rp.PRIMARYADDR', '=', $PRIMARYADDR)))
|
|
|
|
+ ->join('realtimedata rt', 'rt.DEVICEID=rp.DEVICEID and rt.PRIMARYADDR=rp.PRIMARYADDR', 'left')
|
|
|
|
+ ->field('rp.*,rt.STATUS,rt.LASTTRANSDATE')
|
|
|
|
+ ->select();
|
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- //报警设备 查所有
|
|
|
|
- $reportdata = Db::table('reportdata')
|
|
|
|
- ->alias('rp')
|
|
|
|
- ->where(array(array('rp.ALARMENDTIME', '=', '')))
|
|
|
|
- ->join('realtimedata rt', 'rt.DEVICEID=rp.DEVICEID and rt.PRIMARYADDR=rp.PRIMARYADDR', 'left')
|
|
|
|
- ->field('rp.*,rt.STATUS,rt.LASTTRANSDATE')
|
|
|
|
- ->select();
|
|
|
|
-
|
|
|
|
|
|
+ if ($type) {
|
|
|
|
+ $reportdata = Db::table('follow')
|
|
|
|
+ ->alias('f')
|
|
|
|
+ ->where(array(array('f.UID', '=', $this->userid), array('rp.ALARMENDTIME', '=', '')))
|
|
|
|
+ ->join('reportdata rp', 'f.DID=rp.DEVICEID and F.PID=rp.PRIMARYADDR', 'left')
|
|
|
|
+ ->join('realtimedata rt', 'f.DID=rt.DEVICEID and F.PID=rt.PRIMARYADDR', 'left')
|
|
|
|
+ ->field('rp.*,rt.STATUS,rt.LASTTRANSDATE')
|
|
|
|
+ ->select();
|
|
|
|
+ } else {
|
|
|
|
+ //报警设备 查所有
|
|
|
|
+ $reportdata = Db::table('reportdata')
|
|
|
|
+ ->alias('rp')
|
|
|
|
+ ->where(array(array('rp.ALARMENDTIME', '=', '')))
|
|
|
|
+ ->join('realtimedata rt', 'rt.DEVICEID=rp.DEVICEID and rt.PRIMARYADDR=rp.PRIMARYADDR', 'left')
|
|
|
|
+ ->field('rp.*,rt.STATUS,rt.LASTTRANSDATE')
|
|
|
|
+ ->select();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
$arr = array(1 => '80℃', 2 => '2:100℃', 3 => '130℃');
|
|
$arr = array(1 => '80℃', 2 => '2:100℃', 3 => '130℃');
|
|
$sta = array('在线', '报警', '不在线', '未配置');
|
|
$sta = array('在线', '报警', '不在线', '未配置');
|
|
@@ -80,14 +104,16 @@ class IndexController extends MainController
|
|
$v['TEMPERTHRESHOLD'] = $arr[$v['TEMPERTHRESHOLD']];
|
|
$v['TEMPERTHRESHOLD'] = $arr[$v['TEMPERTHRESHOLD']];
|
|
$v['STATUS'] = $sta[$v['STATUS']];
|
|
$v['STATUS'] = $sta[$v['STATUS']];
|
|
$v['ADDRESS'] = $v['STATIONNAME'] . $v['POWERDISCABNAME'] . $v['CELLNAME'];
|
|
$v['ADDRESS'] = $v['STATIONNAME'] . $v['POWERDISCABNAME'] . $v['CELLNAME'];
|
|
- $v['DEVICENAME']=$v['DEVICENAME']?$v['DEVICENAME']:'未命名';
|
|
|
|
|
|
+ $v['DEVICENAME'] = $v['DEVICENAME'] ? $v['DEVICENAME'] : '未命名';
|
|
|
|
+ $res = Db::table('follow')->where([['PID', '=', $v['PRIMARYADDR']], ['DID', '=', $v['DEVICEID']]])->count();
|
|
|
|
+ $v['is_follow'] = $res ? 1 : 0;
|
|
}
|
|
}
|
|
$this->api_return_json(compact('reportdata'), 1);
|
|
$this->api_return_json(compact('reportdata'), 1);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
*
|
|
*
|
|
- * @name 添加设备
|
|
|
|
|
|
+ * @name 添加/编辑设备
|
|
* */
|
|
* */
|
|
public function addequipment()
|
|
public function addequipment()
|
|
{
|
|
{
|
|
@@ -108,12 +134,49 @@ class IndexController extends MainController
|
|
$this->api_return_json(array('msg' => '请填写纬度'));
|
|
$this->api_return_json(array('msg' => '请填写纬度'));
|
|
}
|
|
}
|
|
|
|
|
|
- $res = Db::name('device')->insertGetId($param);
|
|
|
|
|
|
+ //修改
|
|
|
|
+ if ($param['ID']) {
|
|
|
|
+ $ID=$param['ID'];
|
|
|
|
+ unset($param['ID']);
|
|
|
|
+ $res = Db::name('device')->where([['ID','=',$ID]])->update($param);
|
|
|
|
+ } else {
|
|
|
|
+ $res = Db::name('device')->insert($param);
|
|
|
|
+ }
|
|
if ($res) {
|
|
if ($res) {
|
|
$this->api_return_json(array('msg' => '添加成功'), 1);
|
|
$this->api_return_json(array('msg' => '添加成功'), 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ /*
|
|
|
|
+ * @name 编辑页面数据接口
|
|
|
|
+ * */
|
|
|
|
+ public function edit(){
|
|
|
|
+ $ID = $this->request->param('ID');
|
|
|
|
+ $edit['PRIMARYADDR']="";
|
|
|
|
+ $edit['REPEATERNAME']="";
|
|
|
|
+ $edit['STATIONNAME']="";
|
|
|
|
+ $edit['DVICLONGITUDE']="";
|
|
|
|
+ $edit['DVICLATITUDE']="";
|
|
|
|
+
|
|
|
|
+ if ($ID) {
|
|
|
|
+ $edit = Db::name('device')->where([['ID','=',$ID]])->find();
|
|
|
|
+ }
|
|
|
|
+ $this->api_return_json(compact('edit'), 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * @name 时间数据记录
|
|
|
|
+ * */
|
|
|
|
+
|
|
|
|
+ public function timeadd(){
|
|
|
|
+ $ALARMSTARTTIME = $this->request->param('ALARMSTARTTIME');
|
|
|
|
+ $ALARMENDTIME = $this->request->param('ALARMENDTIME');
|
|
|
|
+ if(isset($ALARMENDTIME)&&isset($ALARMENDTIME)){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ $this->api_return_json(array('msg' => '时间周期不能为空'), 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|