123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- <?php
- /**
- * Created by PhpStorm.
- * User: TianFeng
- * Date: 2019-03-20
- * Time: 12:37
- */
- namespace Home\Controller;
- use Think\Controller;
- include '../Common/function.php';
- include '/var/www/html/jdxf/Public/vendor/WxJDK/JSSDK.php';
- class InspectionController extends ComController
- {
- public function index()
- {
- // print_r($_SESSION['phone']);
- $data = I();
- // print_r($data);
- $sql = "select * from ytiot_xj_inspectors where phone='" . $data['phone'] . "' and zn in(2,3,6,7)";//.$_SESSION['phone'];//17621295894";
- $res = add66($sql);
- $dq_time = date("Y-m-d");
- $arr = array();
- if ($res != null) {
- $ry = count($res);
- $ry_id_list = '';
- for ($i = 0; $i < $ry; $i++) {
- if ($i == 0) {
- $ry_id_list = $res[$i]['id'];
- } else {
- $ry_id_list .= ',' . $res[$i]['id'];
- }
- }
- // $team_personnel_sql = "select a.team_id from ytiot_xj_team_personnel as a join ytiot_xj_plan_team as b on a.team_id=b.id where person_liable_id=".$res[0]['id']." or people_id=".$res[0]['id']." group by a.team_id";
- $team_personnel_sql = "select a.team_id from ytiot_xj_team_personnel as a join ytiot_xj_plan_team as b on a.team_id=b.id where person_liable_id in(" . $ry_id_list . ") or people_id in(" . $ry_id_list . ") group by a.team_id";
- $team_res = add66($team_personnel_sql);
- // print_r($team_res);
- if ($team_res != null) {
- $td_id_ct = count($team_res);
- $td_id_list = '';
- for ($i = 0; $i < $td_id_ct; $i++) {
- if ($i == 0) {
- $td_id_list = $team_res[$i]['team_id'];
- } else {
- $td_id_list .= ',' . $team_res[$i]['team_id'];
- }
- }
- $plan_child_sql = "select * from ytiot_xj_plan_child where inspect_date='" . $dq_time . "' and team_id in(" . $td_id_list . ") and data2='1'";
- // print_r($plan_child_sql);
- $plan_child_res = add66($plan_child_sql);
- // print_r($plan_child_res);
- if ($plan_child_res != null) {
- foreach ($plan_child_res as $key => $value) {
- $plan_master_sql = "select plan_name from ytiot_xj_plan_master where id=" . $value['zb_id'];
- // print_r($plan_master_sql);
- $plan_master_res = add66($plan_master_sql);
- // print_r($plan_master_res);
- $spot_operation_record_sql = "select * from ytiot_xj_spot_operation_record where zb_id=" . $value['id'];
- // print_r($spot_operation_record_sql);
- $spot_operation_record_res = add66($spot_operation_record_sql);
- // print_r($spot_operation_record_res);
- if ($spot_operation_record_res != null && $plan_master_res != null) {
- foreach ($spot_operation_record_res as $key1 => $value1) {
- $dw_sql = "select * from ytiot_xj_inspection_points where id=" . $value1['spot_id'];
- $dw_res = add66($dw_sql);
- // print_r($dw_res);
- if ($dw_res != null) {
- $arr[$key]['id'] = $plan_child_res[$key]['id'];
- $arr[$key]['completion'] = $plan_child_res[$key]['completion'];
- $arr[$key]['plan_name'] = "任务名称:" . $plan_master_res[0]['plan_name'];
- $arr[$key]['bw'][$key1]['id'] = $spot_operation_record_res[$key1]['spot_id'];
- $arr[$key]['bw'][$key1]['spot_name'] = "点位名称:" . $dw_res[0]['spot_name'];
- $arr[$key]['bw'][$key1]['data3'] = $spot_operation_record_res[$key1]['data3'];
- }
- }
- }
- }
- }
- }
- }
- $appid = C('APPID');
- # 公众号获取
- $appSecret = C('SECRET');
- # 实例化
- $wx = new \JSSDK($appid, $appSecret);
- # 获取参数
- $info = $wx->getWxConfig();
- # 传参页面
- $this->assign('wxConfig', $info);
- $this->assign('res5', $arr);
- // print_r($res[0]['id']);
- $this->assign('wbr_id', $res[0]['id']);
- $this->display('Index/inspection_system');
- }
- public function wb_index()
- {
- $Data = I();
- $this->assign('companyid', $Data['companyid']);
- $this->display('Index/wb_menu');
- }
- public function xj_index()
- {
- $Data = I();
- $this->assign('companyid', $Data['companyid']);
- $this->display('Index/xj_menu');
- }
- public function index2()
- {
- // print_r($_SESSION['phone']);
- $data = I();
- // print_r($data);
- $sql = "select * from ytiot_xj_inspectors where phone='" . $data['phone'] . "' and zn in(1,3,5,7)";//.$_SESSION['phone'];//17621295894";
- $res = add66($sql);
- // print_r($res);
- $dq_time = date("Y-m-d");
- $arr = array();
- if ($res != null) {
- $ry = count($res);
- $ry_id_list = '';
- for ($i = 0; $i < $ry; $i++) {
- if ($i == 0) {
- $ry_id_list = $res[$i]['id'];
- } else {
- $ry_id_list .= ',' . $res[$i]['id'];
- }
- }
- // $team_personnel_sql = "select a.team_id from ytiot_xj_team_personnel as a join ytiot_xj_plan_team as b on a.team_id=b.id where person_liable_id=".$res[0]['id']." or people_id=".$res[0]['id']." group by a.team_id";
- $team_personnel_sql = "select a.team_id from ytiot_xj_team_personnel as a join ytiot_xj_plan_team as b on a.team_id=b.id where person_liable_id in(" . $ry_id_list . ") or people_id in(" . $ry_id_list . ") group by a.team_id";
- $team_res = add66($team_personnel_sql);
- // print_r($team_res);
- if ($team_res != null) {
- $td_id_ct = count($team_res);
- $td_id_list = '';
- for ($i = 0; $i < $td_id_ct; $i++) {
- if ($i == 0) {
- $td_id_list = $team_res[$i]['team_id'];
- } else {
- $td_id_list .= ',' . $team_res[$i]['team_id'];
- }
- }
- $plan_child_sql = "select a.*,b.cycle from ytiot_xj_plan_child as a join ytiot_xj_plan_master as b on a.zb_id=b.id where a.team_id in(" . $td_id_list . ") and a.data2='2'";
- // $plan_child_sql="select * from ytiot_xj_plan_child where inspect_date='".$dq_time."' and team_id in(".$td_id_list.") and data2='2'";
- // print_r($plan_child_sql);
- $plan_child_res = add66($plan_child_sql);
- // print_r($plan_child_res);
- if ($plan_child_res != null) {
- foreach ($plan_child_res as $key => $value) {
- // print_r(strtotime("+7 day",strtotime($plan_child_res[$key]['inspect_date'])));
- if (($plan_child_res[$key]['cycle'] == 0 && $plan_child_res[$key]['inspect_date'] == $dq_time) ||
- ($plan_child_res[$key]['cycle'] == 1 && strtotime("+7 day", strtotime($plan_child_res[$key]['inspect_date'])) > strtotime($dq_time)) ||
- ($plan_child_res[$key]['cycle'] == 2 && strtotime("+1 month", strtotime($plan_child_res[$key]['inspect_date'])) > strtotime($dq_time))) {
- $plan_master_sql = "select plan_name from ytiot_xj_plan_master where id=" . $value['zb_id'];
- // print_r($plan_master_sql);
- $plan_master_res = add66($plan_master_sql);
- // print_r($plan_master_res);
- $spot_operation_record_sql = "select * from ytiot_xj_spot_operation_record where zb_id=" . $value['id'];
- // print_r($spot_operation_record_sql);
- $spot_operation_record_res = add66($spot_operation_record_sql);
- // print_r($spot_operation_record_res);
- if ($spot_operation_record_res != null && $plan_master_res != null) {
- foreach ($spot_operation_record_res as $key1 => $value1) {
- $dw_sql = "select * from ytiot_xj_inspection_points where id=" . $value1['spot_id'];
- $dw_res = add66($dw_sql);
- // print_r($dw_res);
- if ($dw_res != null) {
- $arr[$key]['id'] = $plan_child_res[$key]['id'];
- $arr[$key]['completion'] = $plan_child_res[$key]['completion'];
- $arr[$key]['plan_name'] = "任务名称:" . $plan_master_res[0]['plan_name'];
- $arr[$key]['bw'][$key1]['id'] = $spot_operation_record_res[$key1]['spot_id'];
- $arr[$key]['bw'][$key1]['spot_name'] = "点位名称:" . $dw_res[0]['spot_name'];
- $arr[$key]['bw'][$key1]['data3'] = $spot_operation_record_res[$key1]['data3'];
- }
- }
- }
- }
- }
- }
- }
- }
- $appid = C('APPID');
- # 公众号获取
- $appSecret = C('SECRET');
- # 实例化
- $wx = new \JSSDK($appid, $appSecret);
- # 获取参数
- $info = $wx->getWxConfig();
- # 传参页面
- $this->assign('wxConfig', $info);
- $this->assign('res5', $arr);
- // print_r($arr);
- $this->assign('wbr_id', $res[0]['id']);
- $this->display('Index/maintenance_system');
- }
- public function maintenance_record()
- {
- $data = I();
- $sql = "select * from ytiot_xj_spot_operation_record where data3=2 and data2=2 order by id desc";
- $res = add($sql);
- foreach ($res as $key => $value) {
- if ($res[$key]['spot_abnormal'] == 0) {
- $res[$key]['spot_status'] = "正常";
- } elseif ($res[$key]['spot_abnormal'] == 1) {
- $res[$key]['spot_status'] = "异常";
- } elseif ($res[$key]['spot_abnormal'] == 2) {
- $res[$key]['spot_status'] = "故障";
- } elseif ($res[$key]['spot_abnormal'] == 3) {
- $res[$key]['spot_status'] = "其他";
- }
- if (!empty($res[$key]['spot_id'])) {
- $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[$key]['spot_id'];
- $points_res = add($points_sql);
- $res[$key]['spot_name'] = $points_res[0]['spot_name'];
- // $res[$key]['spot_address']=$points_res[0]['spot_address'];
- }
- if (!empty($res[$key]['spot_id'])) {
- $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[$key]['zb_id'];
- $jhz_res = add($jhz_sql);
- $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
- $jh_res = add($jh_sql);
- $res[$key]['plan_name'] = $jh_res[0]['plan_name'];
- // $res[$key]['spot_address']=$jh_res[0]['spot_address'];
- }
- // if (!empty($res[$key]['spot_id'])){
- // $zrr_sql="select * from ytiot_xj_inspectors where id=".$res[$key]['wbr_id'];
- // $zrr_res=add($zrr_sql);
- // $res[$key]['name']=$zrr_res[0]['name'];
- // $res[$key]['spot_address']=$zrr_res[0]['phone'];
- // }
- }
- $this->assign('companyid', $data['companyid']);
- $this->assign('res', $res);
- $this->display('Index/maintenance_list');
- }
- public function inspection_record()
- {
- $data = I();
- $sql = "select * from ytiot_xj_spot_operation_record where data3=2 and data2=1 order by id desc";
- $res = add($sql);
- foreach ($res as $key => $value) {
- if ($res[$key]['spot_abnormal'] == 0) {
- $res[$key]['spot_status'] = "正常";
- } elseif ($res[$key]['spot_abnormal'] == 1) {
- $res[$key]['spot_status'] = "异常";
- } elseif ($res[$key]['spot_abnormal'] == 2) {
- $res[$key]['spot_status'] = "故障";
- } elseif ($res[$key]['spot_abnormal'] == 3) {
- $res[$key]['spot_status'] = "其他";
- }
- if (!empty($res[$key]['spot_id'])) {
- $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[$key]['spot_id'];
- $points_res = add($points_sql);
- $res[$key]['spot_name'] = $points_res[0]['spot_name'];
- }
- if (!empty($res[$key]['spot_id'])) {
- $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[$key]['zb_id'];
- $jhz_res = add($jhz_sql);
- $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
- $jh_res = add($jh_sql);
- $res[$key]['plan_name'] = $jh_res[0]['plan_name'];
- }
- }
- $this->assign('companyid', $data['companyid']);
- $this->assign('res', $res);
- $this->display('Index/inspection_list');
- }
- public function details()
- {
- $data = I();
- $record_id = $data['id'];
- $sql = "select * from ytiot_xj_spot_operation_record where id=" . $record_id;
- $res = add($sql);
- if ($res[0]['spot_abnormal'] == 0) {
- $res[0]['spot_status'] = "正常";
- } elseif ($res[0]['spot_abnormal'] == 1) {
- $res[0]['spot_status'] = "异常";
- } elseif ($res[0]['spot_abnormal'] == 2) {
- $res[0]['spot_status'] = "故障";
- } elseif ($res[0]['spot_abnormal'] == 3) {
- $res[0]['spot_status'] = "其他";
- }
- if (!empty($res[0]['spot_id'])) {
- $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[0]['zb_id'];
- $jhz_res = add($jhz_sql);
- $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
- $jh_res = add($jh_sql);
- $res[0]['plan_name'] = $jh_res[0]['plan_name'];
- }
- if (!empty($res[0]['spot_id'])) {
- $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[0]['spot_id'];
- $points_res = add($points_sql);
- $res[0]['spot_name'] = $points_res[0]['spot_name'];
- $res[0]['spot_address'] = $points_res[0]['spot_address'];
- }
- if (!empty($res[0]['wbr_id'])) {
- $zrr_sql = "select * from ytiot_xj_inspectors where id=" . $res[0]['wbr_id'];
- $zrr_res = add($zrr_sql);
- $res[0]['name'] = $zrr_res[0]['name'];
- $res[0]['phone'] = $zrr_res[0]['phone'];
- }
- if (!empty($res[0]['company_code'])) {
- // $zrr_sql="select * from ytiot_xj_inspectors where id=".$res[0]['company_code'];
- // $zrr_res=add($zrr_sql);
- $company_data = M()->query("select owner_name,owner_address from sp_owner_company where building_id='" . $res[0]['company_code'] . "'");
- $res[0]['owner_name'] = $company_data[0]['owner_name'];
- $res[0]['owner_address'] = $company_data[0]['owner_address'];
- }
- if (!empty($res[0]['id'])) {
- $photos_sql = "select report_photos from ytiot_xj_operation_record_photos where dwczjl_id=" . $res[0]['id'];
- $photos_res = add($photos_sql);
- $res[0]['report_photos'] = $photos_res[0]['report_photos'];
- }
- $this->assign('companyid', $data['companyid']);
- $this->assign('res', $res[0]);
- $this->display('Index/maintenance_details');
- }
- public function xj_details()
- {
- $data = I();
- $record_id = $data['id'];
- $sql = "select * from ytiot_xj_spot_operation_record where id=" . $record_id;
- $res = add($sql);
- if ($res[0]['spot_abnormal'] == 0) {
- $res[0]['spot_status'] = "正常";
- } elseif ($res[0]['spot_abnormal'] == 1) {
- $res[0]['spot_status'] = "异常";
- } elseif ($res[0]['spot_abnormal'] == 2) {
- $res[0]['spot_status'] = "故障";
- } elseif ($res[0]['spot_abnormal'] == 3) {
- $res[0]['spot_status'] = "其他";
- }
- if (!empty($res[0]['spot_id'])) {
- $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[0]['zb_id'];
- $jhz_res = add($jhz_sql);
- $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
- $jh_res = add($jh_sql);
- $res[0]['plan_name'] = $jh_res[0]['plan_name'];
- }
- if (!empty($res[0]['spot_id'])) {
- $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[0]['spot_id'];
- $points_res = add($points_sql);
- $res[0]['spot_name'] = $points_res[0]['spot_name'];
- $res[0]['spot_address'] = $points_res[0]['spot_address'];
- }
- if (!empty($res[0]['wbr_id'])) {
- $zrr_sql = "select * from ytiot_xj_inspectors where id=" . $res[0]['wbr_id'];
- $zrr_res = add($zrr_sql);
- $res[0]['name'] = $zrr_res[0]['name'];
- $res[0]['phone'] = $zrr_res[0]['phone'];
- }
- if (!empty($res[0]['company_code'])) {
- // $zrr_sql="select * from ytiot_xj_inspectors where id=".$res[0]['company_code'];
- // $zrr_res=add($zrr_sql);
- $company_data = M()->query("select owner_name,owner_address from sp_owner_company where building_id='" . $res[0]['company_code'] . "'");
- $res[0]['owner_name'] = $company_data[0]['owner_name'];
- $res[0]['owner_address'] = $company_data[0]['owner_address'];
- }
- if (!empty($res[0]['id'])) {
- $photos_sql = "select report_photos from ytiot_xj_operation_record_photos where dwczjl_id=" . $res[0]['id'];
- $photos_res = add($photos_sql);
- $res[0]['report_photos'] = $photos_res[0]['report_photos'];
- }
- $this->assign('companyid', $data['companyid']);
- $this->assign('res', $res[0]);
- $this->display('Index/inspectione_details');
- }
- public function getDeviceList()
- {
- $Data = I();
- $record_id = $Data['record_id'];
- $spot_id = $Data['spot_id'];
- $sql = "select a.spot_id,b.* from ytIoT.ytiot_xj_spot_equipment as a JOIN jdxf.sp_owner as b ON a.equipment_code=b.owner_code where spot_id=" . $spot_id;
- $res = add($sql);
- $this->assign('record_id', $record_id);
- $this->assign('spot_id', $spot_id);
- $this->assign('res', $res);
- $this->display('point_details/point_details');
- }
- public function getDeviceDetails()
- {
- $Data = I();
- $record_id = $Data['record_id'];
- $spot_id = $Data['spot_id'];
- $this->assign('record_id', $record_id);
- $this->assign('spot_id', $spot_id);
- if ($Data['dwtype'] == 16) {
- $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
- $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
- $gzsj = M()->query("select data4,time from sp_video2017 where device_code='" . $Data['deviceid'] . "' order by time desc");
- if (!empty($owner_xx[0]['rtmp'])) {
- $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
- } else {
- $owner_xx[0]['rtmp'] = ' 无';
- }
- $this->assign('type_name', "视频监控");
- $this->assign('type', "video");
- $this->assign('companyid', $Data['companyid']);
- $this->assign('owner_xx', $owner_xx);
- $this->assign('owner_address', $owner_address);
- $this->assign('gzsj', $gzsj);
- $this->display('point_details/000001');
- } else if ($Data['dwtype'] == 17) {
- $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
- $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
- $gzsj = M()->query("select data4,time from sp_lifter2017 where device_code='" . $Data['deviceid'] . "' order by time desc");
- if (!empty($owner_xx[0]['rtmp'])) {
- $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
- } else {
- $owner_xx[0]['rtmp'] = ' 无';
- }
- $this->assign('type_name', "电梯监控");
- $this->assign('type', "elevator");
- $this->assign('companyid', $Data['companyid']);
- $this->assign('owner_xx', $owner_xx);
- $this->assign('owner_address', $owner_address);
- $this->assign('gzsj', $gzsj);
- $this->display('point_details/000001');
- } else if ($Data['dwtype'] == 4) {
- $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
- $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
- $gzsj = M()->query("select data4,time from sp_d" . $Data['deviceid'] . " where device_code='" . $Data['deviceid'] . "' order by time desc");
- if (!empty($owner_xx[0]['rtmp'])) {
- $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
- } else {
- $owner_xx[0]['rtmp'] = ' 无';
- }
- $this->assign('type_name', "消防栓监控");
- $this->assign('type', "firehydrant");
- $this->assign('companyid', $Data['companyid']);
- $this->assign('owner_xx', $owner_xx);
- $this->assign('owner_address', $owner_address);
- $this->assign('gzsj', $gzsj);
- $this->display('point_details/000001');
- } else if ($Data['dwtype'] == 128) {
- $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
- $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
- $gzsj = M()->query("select device_status,time from sp_iw2017 where device_code='" . $Data['deviceid'] . "' order by time desc");
- if (!empty($owner_xx[0]['rtmp'])) {
- $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
- } else {
- $owner_xx[0]['rtmp'] = ' 无';
- }
- if ($gzsj[0]['device_status']) {
- $gzsj[0]['data4'] = '正常';
- } else {
- $gzsj[0]['data4'] = '打开告警';
- }
- $this->assign('type_name', "井盖监控");
- $this->assign('type', "firehydrant");
- $this->assign('companyid', $Data['companyid']);
- $this->assign('owner_xx', $owner_xx);
- $this->assign('owner_address', $owner_address);
- $this->assign('gzsj', $gzsj);
- $this->display('point_details/000001');
- } else {
- $res = M()->query("SELECT * FROM sp_v_deviceall WHERE deviceid='" . $Data['deviceid'] . "'");
- $azwz = M()->query("select unitinfo from sp_owner where owner_code='" . $Data['deviceid'] . "'");
- $res[0]['azwz'] = $azwz[0]['unitinfo'];
- //在线离线权限问题
- $login_phone = M()->query("SELECT * FROM sp_login_phone");
- $phone_arr = array();
- foreach ($login_phone as $key => $value) {
- $phone_arr[$key] = $login_phone[$key]['phone'];
- }
- $phone = $_SESSION['phone'];
- $isin = in_array($phone, $phone_arr);
- if ($isin) {
- $phone_pd = 1;
- } else {
- $phone_pd = 0;
- }
- $time = M()->query("SELECT device_id,MAX(data_time) as data_time FROM sp_owner_status WHERE device_id='" . $Data['deviceid'] . "'");
- if (!empty($time)) {
- $stime = date('Y-m-d h:i:s', time());
- $etime = $time[0]['data_time'];
- $hour = intval((strtotime($stime) - strtotime($etime)) / 3600);
- if ($hour < 24) {
- $zs_status = '在线';
- } else {
- $zs_status = '离线';
- }
- } else {
- $zs_status = '状态不存在';
- }
- if ($res[0]['dwtype'] != 1) {
- if ($phone_pd == 1) {
- $res[0]['zs_status'] = $zs_status;
- }
- }
- if (!empty($res[0]['rtmp'])) {
- $res[0]['rtmp'] = $res[0]['rtmp'];
- } else {
- $res[0]['rtmp'] = ' 无';
- }
- $this->assign('list', $res[0]);
- $this->assign('companyid', $Data['companyid']);
- $dwtype = $res[0]['dwtype'];
- $deviceid = $Data['deviceid'];
- if ($dwtype == 1) {
- $j2017 = M('hj2017');
- $counts = $j2017->order('time desc')->where(array('device_code' => $deviceid))->count('id');//总数
- $j_counts = $j2017->where(array('device_code' => $deviceid, 'clzt' => '1'))->count('id');//解决总数
- $d_counts = $j2017->where(array('device_code' => $deviceid, 'clwb' => '否'))->count('id');//真实总数
- $w_counts = $j2017->where(array('device_code' => $deviceid, 'clwb' => '是'))->count('id');//wb总数
- $this->assign('dwtype', 1);
- $this->assign('counts', $counts);
- $this->assign('j_counts', $j_counts);
- $this->assign('z_counts', $d_counts);
- $this->assign('w_counts', $w_counts);
- $this->display('point_details/000002');
- }
- if ($dwtype == 2) {
- $shui = M()->query("select * from sp_owner_sync_data where device_id='" . $Data['deviceid'] . "' and point_code=4 order by data_time desc");
- $electric_data = M()->query("select point_data from sp_owner_sync_data where device_id='" . $Data['deviceid'] . "' and point_code=2 order by data_time desc");
- $signal_data = M()->query("select point_data from sp_owner_sync_data where device_id='" . $Data['deviceid'] . "' and point_code=3 order by data_time desc");
- $a = array();
- $b = array();
- $electric = array();
- $signal = array();
- foreach ($shui as $value) {
- $a[] = $value['data_time'];
- $b[] = $value['point_data'];
- }
- foreach ($electric_data as $value) {
- $electric[] = $value['point_data'];
- }
- foreach ($signal_data as $value) {
- $signal[] = $value['point_data'] * 20;
- }
- $bb = $shui[0];
- $this->assign('bb', $bb['point_data']);
- $this->assign('dwtype', 2);
- $this->assign('time', json_encode($a));
- $this->assign('data4', json_encode($b));
- $this->assign('electric', json_encode($electric));
- $this->assign('signal', json_encode($signal));
- $this->display('point_details/000004');
- }
- if ($dwtype == 3) {
- $fume = M()->query("select RSRQ, DeviceStatus, BatteryLevel, storeTime, device_id from sp_y" . $deviceid . " ORDER BY storeTime DESC limit 1");
- $a = M()->query("select dwtype, sim,install_time,rtmp,hls from sp_owner where owner_code='" . $deviceid . "'");
- if ($a[0]['dwtype'] == 3) {
- $a[0]['dwtype'] = '烟感';
- }
- if (!empty($a[0]['rtmp'])) {
- $a[0]['rtmp'] = $a[0]['rtmp'];
- } else {
- $a[0]['rtmp'] = ' 无';
- }
- foreach ($fume as $key => $arr) {
- if ($fume[$key]['devicestatus'] == 7) {
- $fume[$key]['type'] = '正常';
- } else if ($fume[$key]['devicestatus'] == 5) {
- $fume[$key]['type'] = '故障';
- } else if ($fume[$key]['devicestatus'] == 4) {
- $fume[$key]['type'] = '低压';
- } else if ($fume[$key]['devicestatus'] == 2) {
- $fume[$key]['type'] = '报警静音';
- } else if ($fume[$key]['devicestatus'] == 1) {
- $fume[$key]['type'] = '报警';
- }
- }
- $this->assign('dwtype', 3);
- $this->assign('a', $a);
- $this->assign('fume', $fume);
- $this->display('point_details/000003');
- }
- //液位
- if ($dwtype == 5) {
- $shui = M()->query("select * from sp_owner_sync_data where device_id='" . $Data['deviceid'] . "' and point_code=4 order by data_time desc");
- $a = array();
- $b = array();
- foreach ($shui as $value) {
- $a[] = $value['data_time'];
- $b[] = $value['point_data'];
- }
- $bb = $shui[0];
- $this->assign('bb', $bb['point_data']);
- $this->assign('dwtype', 5);
- $this->assign('time', json_encode($a));
- $this->assign('data4', json_encode($b));
- $this->display('point_details/000007');
- }
- if ($dwtype == 6) {
- $rtu = M()->query("SELECT id,data4,ncmd,`time`,data1,data2,CASE WHEN `port`='E6' THEN '模拟量' WHEN `port`='E3' THEN '开关量' END as types
- FROM sp_d" . $deviceid . " WHERE id in(SELECT MAX(id)
- FROM sp_d" . $deviceid . " GROUP BY `port`,ncmd) AND ncmd !='' "
- . (($deviceid == '4023363030303635') ? " AND (ncmd !='02' OR `port`!='E6') " :
- (($deviceid == '4023363030303639') ? " AND (ncmd !='03' OR `port`!='E6') " :
- (($deviceid == '4023363030303434') ? " AND (ncmd !='04' OR `port`!='E3') AND (ncmd !='05' OR `port`!='E3')" :
- (($deviceid == '4023363030303336') ? " AND (ncmd !='01' OR `port`!='E6') " :
- (($deviceid == '4023363030303733') ? " AND (ncmd !='05' AND ncmd !='06' )" : "")))))//山海大酒店B1楼水泵房02端口模拟量因设备故障,暂时屏蔽
- );
- $this->assign('dwtype', 6);
- $this->assign('rtu', $rtu);
- $res = M()->query("SELECT systype FROM sp_owner_port where owner_code='" . $deviceid . "'");
- $this->assign("trues", '0' . $res[0]['systype']);
- $this->display('point_details/000005');
- }
- // 电气火灾
- if ($dwtype == 7) {
- $install_time = M()->query("select install_time,rtmp,hls,owner_name,sim from sp_owner where owner_code='" . $Data['deviceid'] . "'");
- $owner_address = M()->query("select owner_address from sp_owner_company where owner_id=" . $Data['companyid']);
- $true_status = M()->query("select true_status from sp_devices_status where deviceid=" . $Data['deviceid']);
- $xssj = M()->query("select * from sp_owner_status where device_id='" . $Data['deviceid'] . "'");
- $zxsj = M()->query("select max(data_time) as zxsj from sp_owner_status where device_id='" . $Data['deviceid'] . "'");
- if ($true_status[0]['true_status'] == '75') {
- $dstatus = '离线';
- } else {
- $dstatus = '在线';
- }
- if (!empty($install_time[0]['rtmp'])) {
- $install_time[0]['rtmp'] = $install_time[0]['rtmp'];
- } else {
- $install_time[0]['rtmp'] = ' 无';
- }
- $data = array(
- 'owner_name' => $install_time[0]['owner_name'],
- 'dstatus' => $dstatus,
- 'dthz' => '电气火灾',
- 'deviceid' => $Data['deviceid'],
- 'sim' => $install_time[0]['sim'],
- 'install_time' => $install_time[0]['install_time'],
- 'owner_address' => $owner_address[0]['owner_address'],
- 'rtmp' => $install_time[0]['rtmp'],
- 'hls' => $install_time[0]['hls'],
- );
- $this->assign('dwtype', 7);
- $this->assign('xssj', $xssj);
- $this->assign('zxsj', $zxsj);
- $this->assign('data', $data);
- $this->display('point_details/000006');
- }
- }
- }
- }
|