InspectionController.class.php.bak.2021-01-19 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: TianFeng
  5. * Date: 2019-03-20
  6. * Time: 12:37
  7. */
  8. namespace Home\Controller;
  9. use Think\Controller;
  10. include '../Common/function.php';
  11. include '/var/www/html/jdxf/Public/vendor/WxJDK/JSSDK.php';
  12. class InspectionController extends ComController
  13. {
  14. public function index()
  15. {
  16. // print_r($_SESSION['phone']);
  17. $data = I();
  18. // print_r($data);
  19. $sql = "select * from ytiot_xj_inspectors where phone='" . $data['phone'] . "' and zn in(2,3,6,7)";//.$_SESSION['phone'];//17621295894";
  20. $res = add66($sql);
  21. $dq_time = date("Y-m-d");
  22. $arr = array();
  23. if ($res != null) {
  24. $ry = count($res);
  25. $ry_id_list = '';
  26. for ($i = 0; $i < $ry; $i++) {
  27. if ($i == 0) {
  28. $ry_id_list = $res[$i]['id'];
  29. } else {
  30. $ry_id_list .= ',' . $res[$i]['id'];
  31. }
  32. }
  33. // $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";
  34. $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";
  35. $team_res = add66($team_personnel_sql);
  36. // print_r($team_res);
  37. if ($team_res != null) {
  38. $td_id_ct = count($team_res);
  39. $td_id_list = '';
  40. for ($i = 0; $i < $td_id_ct; $i++) {
  41. if ($i == 0) {
  42. $td_id_list = $team_res[$i]['team_id'];
  43. } else {
  44. $td_id_list .= ',' . $team_res[$i]['team_id'];
  45. }
  46. }
  47. $plan_child_sql = "select * from ytiot_xj_plan_child where inspect_date='" . $dq_time . "' and team_id in(" . $td_id_list . ") and data2='1'";
  48. // print_r($plan_child_sql);
  49. $plan_child_res = add66($plan_child_sql);
  50. // print_r($plan_child_res);
  51. if ($plan_child_res != null) {
  52. foreach ($plan_child_res as $key => $value) {
  53. $plan_master_sql = "select plan_name from ytiot_xj_plan_master where id=" . $value['zb_id'];
  54. // print_r($plan_master_sql);
  55. $plan_master_res = add66($plan_master_sql);
  56. // print_r($plan_master_res);
  57. $spot_operation_record_sql = "select * from ytiot_xj_spot_operation_record where zb_id=" . $value['id'];
  58. // print_r($spot_operation_record_sql);
  59. $spot_operation_record_res = add66($spot_operation_record_sql);
  60. // print_r($spot_operation_record_res);
  61. if ($spot_operation_record_res != null && $plan_master_res != null) {
  62. foreach ($spot_operation_record_res as $key1 => $value1) {
  63. $dw_sql = "select * from ytiot_xj_inspection_points where id=" . $value1['spot_id'];
  64. $dw_res = add66($dw_sql);
  65. // print_r($dw_res);
  66. if ($dw_res != null) {
  67. $arr[$key]['id'] = $plan_child_res[$key]['id'];
  68. $arr[$key]['completion'] = $plan_child_res[$key]['completion'];
  69. $arr[$key]['plan_name'] = "任务名称:" . $plan_master_res[0]['plan_name'];
  70. $arr[$key]['bw'][$key1]['id'] = $spot_operation_record_res[$key1]['spot_id'];
  71. $arr[$key]['bw'][$key1]['spot_name'] = "点位名称:" . $dw_res[0]['spot_name'];
  72. $arr[$key]['bw'][$key1]['data3'] = $spot_operation_record_res[$key1]['data3'];
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
  80. $appid = C('APPID');
  81. # 公众号获取
  82. $appSecret = C('SECRET');
  83. # 实例化
  84. $wx = new \JSSDK($appid, $appSecret);
  85. # 获取参数
  86. $info = $wx->getWxConfig();
  87. # 传参页面
  88. $this->assign('wxConfig', $info);
  89. $this->assign('res5', $arr);
  90. // print_r($res[0]['id']);
  91. $this->assign('wbr_id', $res[0]['id']);
  92. $this->display('Index/inspection_system');
  93. }
  94. public function wb_index()
  95. {
  96. $Data = I();
  97. $this->assign('companyid', $Data['companyid']);
  98. $this->display('Index/wb_menu');
  99. }
  100. public function xj_index()
  101. {
  102. $Data = I();
  103. $this->assign('companyid', $Data['companyid']);
  104. $this->display('Index/xj_menu');
  105. }
  106. public function index2()
  107. {
  108. // print_r($_SESSION['phone']);
  109. $data = I();
  110. // print_r($data);
  111. $sql = "select * from ytiot_xj_inspectors where phone='" . $data['phone'] . "' and zn in(1,3,5,7)";//.$_SESSION['phone'];//17621295894";
  112. $res = add66($sql);
  113. // print_r($res);
  114. $dq_time = date("Y-m-d");
  115. $arr = array();
  116. if ($res != null) {
  117. $ry = count($res);
  118. $ry_id_list = '';
  119. for ($i = 0; $i < $ry; $i++) {
  120. if ($i == 0) {
  121. $ry_id_list = $res[$i]['id'];
  122. } else {
  123. $ry_id_list .= ',' . $res[$i]['id'];
  124. }
  125. }
  126. // $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";
  127. $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";
  128. $team_res = add66($team_personnel_sql);
  129. // print_r($team_res);
  130. if ($team_res != null) {
  131. $td_id_ct = count($team_res);
  132. $td_id_list = '';
  133. for ($i = 0; $i < $td_id_ct; $i++) {
  134. if ($i == 0) {
  135. $td_id_list = $team_res[$i]['team_id'];
  136. } else {
  137. $td_id_list .= ',' . $team_res[$i]['team_id'];
  138. }
  139. }
  140. $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'";
  141. // $plan_child_sql="select * from ytiot_xj_plan_child where inspect_date='".$dq_time."' and team_id in(".$td_id_list.") and data2='2'";
  142. // print_r($plan_child_sql);
  143. $plan_child_res = add66($plan_child_sql);
  144. // print_r($plan_child_res);
  145. if ($plan_child_res != null) {
  146. foreach ($plan_child_res as $key => $value) {
  147. // print_r(strtotime("+7 day",strtotime($plan_child_res[$key]['inspect_date'])));
  148. if (($plan_child_res[$key]['cycle'] == 0 && $plan_child_res[$key]['inspect_date'] == $dq_time) ||
  149. ($plan_child_res[$key]['cycle'] == 1 && strtotime("+7 day", strtotime($plan_child_res[$key]['inspect_date'])) > strtotime($dq_time)) ||
  150. ($plan_child_res[$key]['cycle'] == 2 && strtotime("+1 month", strtotime($plan_child_res[$key]['inspect_date'])) > strtotime($dq_time))) {
  151. $plan_master_sql = "select plan_name from ytiot_xj_plan_master where id=" . $value['zb_id'];
  152. // print_r($plan_master_sql);
  153. $plan_master_res = add66($plan_master_sql);
  154. // print_r($plan_master_res);
  155. $spot_operation_record_sql = "select * from ytiot_xj_spot_operation_record where zb_id=" . $value['id'];
  156. // print_r($spot_operation_record_sql);
  157. $spot_operation_record_res = add66($spot_operation_record_sql);
  158. // print_r($spot_operation_record_res);
  159. if ($spot_operation_record_res != null && $plan_master_res != null) {
  160. foreach ($spot_operation_record_res as $key1 => $value1) {
  161. $dw_sql = "select * from ytiot_xj_inspection_points where id=" . $value1['spot_id'];
  162. $dw_res = add66($dw_sql);
  163. // print_r($dw_res);
  164. if ($dw_res != null) {
  165. $arr[$key]['id'] = $plan_child_res[$key]['id'];
  166. $arr[$key]['completion'] = $plan_child_res[$key]['completion'];
  167. $arr[$key]['plan_name'] = "任务名称:" . $plan_master_res[0]['plan_name'];
  168. $arr[$key]['bw'][$key1]['id'] = $spot_operation_record_res[$key1]['spot_id'];
  169. $arr[$key]['bw'][$key1]['spot_name'] = "点位名称:" . $dw_res[0]['spot_name'];
  170. $arr[$key]['bw'][$key1]['data3'] = $spot_operation_record_res[$key1]['data3'];
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. $appid = C('APPID');
  180. # 公众号获取
  181. $appSecret = C('SECRET');
  182. # 实例化
  183. $wx = new \JSSDK($appid, $appSecret);
  184. # 获取参数
  185. $info = $wx->getWxConfig();
  186. # 传参页面
  187. $this->assign('wxConfig', $info);
  188. $this->assign('res5', $arr);
  189. // print_r($arr);
  190. $this->assign('wbr_id', $res[0]['id']);
  191. $this->display('Index/maintenance_system');
  192. }
  193. public function maintenance_record()
  194. {
  195. $data = I();
  196. $sql = "select * from ytiot_xj_spot_operation_record where data3=2 and data2=2 order by id desc";
  197. $res = add($sql);
  198. foreach ($res as $key => $value) {
  199. if ($res[$key]['spot_abnormal'] == 0) {
  200. $res[$key]['spot_status'] = "正常";
  201. } elseif ($res[$key]['spot_abnormal'] == 1) {
  202. $res[$key]['spot_status'] = "异常";
  203. } elseif ($res[$key]['spot_abnormal'] == 2) {
  204. $res[$key]['spot_status'] = "故障";
  205. } elseif ($res[$key]['spot_abnormal'] == 3) {
  206. $res[$key]['spot_status'] = "其他";
  207. }
  208. if (!empty($res[$key]['spot_id'])) {
  209. $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[$key]['spot_id'];
  210. $points_res = add($points_sql);
  211. $res[$key]['spot_name'] = $points_res[0]['spot_name'];
  212. // $res[$key]['spot_address']=$points_res[0]['spot_address'];
  213. }
  214. if (!empty($res[$key]['spot_id'])) {
  215. $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[$key]['zb_id'];
  216. $jhz_res = add($jhz_sql);
  217. $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
  218. $jh_res = add($jh_sql);
  219. $res[$key]['plan_name'] = $jh_res[0]['plan_name'];
  220. // $res[$key]['spot_address']=$jh_res[0]['spot_address'];
  221. }
  222. // if (!empty($res[$key]['spot_id'])){
  223. // $zrr_sql="select * from ytiot_xj_inspectors where id=".$res[$key]['wbr_id'];
  224. // $zrr_res=add($zrr_sql);
  225. // $res[$key]['name']=$zrr_res[0]['name'];
  226. // $res[$key]['spot_address']=$zrr_res[0]['phone'];
  227. // }
  228. }
  229. $this->assign('companyid', $data['companyid']);
  230. $this->assign('res', $res);
  231. $this->display('Index/maintenance_list');
  232. }
  233. public function inspection_record()
  234. {
  235. $data = I();
  236. $sql = "select * from ytiot_xj_spot_operation_record where data3=2 and data2=1 order by id desc";
  237. $res = add($sql);
  238. foreach ($res as $key => $value) {
  239. if ($res[$key]['spot_abnormal'] == 0) {
  240. $res[$key]['spot_status'] = "正常";
  241. } elseif ($res[$key]['spot_abnormal'] == 1) {
  242. $res[$key]['spot_status'] = "异常";
  243. } elseif ($res[$key]['spot_abnormal'] == 2) {
  244. $res[$key]['spot_status'] = "故障";
  245. } elseif ($res[$key]['spot_abnormal'] == 3) {
  246. $res[$key]['spot_status'] = "其他";
  247. }
  248. if (!empty($res[$key]['spot_id'])) {
  249. $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[$key]['spot_id'];
  250. $points_res = add($points_sql);
  251. $res[$key]['spot_name'] = $points_res[0]['spot_name'];
  252. }
  253. if (!empty($res[$key]['spot_id'])) {
  254. $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[$key]['zb_id'];
  255. $jhz_res = add($jhz_sql);
  256. $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
  257. $jh_res = add($jh_sql);
  258. $res[$key]['plan_name'] = $jh_res[0]['plan_name'];
  259. }
  260. }
  261. $this->assign('companyid', $data['companyid']);
  262. $this->assign('res', $res);
  263. $this->display('Index/inspection_list');
  264. }
  265. public function details()
  266. {
  267. $data = I();
  268. $record_id = $data['id'];
  269. $sql = "select * from ytiot_xj_spot_operation_record where id=" . $record_id;
  270. $res = add($sql);
  271. if ($res[0]['spot_abnormal'] == 0) {
  272. $res[0]['spot_status'] = "正常";
  273. } elseif ($res[0]['spot_abnormal'] == 1) {
  274. $res[0]['spot_status'] = "异常";
  275. } elseif ($res[0]['spot_abnormal'] == 2) {
  276. $res[0]['spot_status'] = "故障";
  277. } elseif ($res[0]['spot_abnormal'] == 3) {
  278. $res[0]['spot_status'] = "其他";
  279. }
  280. if (!empty($res[0]['spot_id'])) {
  281. $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[0]['zb_id'];
  282. $jhz_res = add($jhz_sql);
  283. $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
  284. $jh_res = add($jh_sql);
  285. $res[0]['plan_name'] = $jh_res[0]['plan_name'];
  286. }
  287. if (!empty($res[0]['spot_id'])) {
  288. $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[0]['spot_id'];
  289. $points_res = add($points_sql);
  290. $res[0]['spot_name'] = $points_res[0]['spot_name'];
  291. $res[0]['spot_address'] = $points_res[0]['spot_address'];
  292. }
  293. if (!empty($res[0]['wbr_id'])) {
  294. $zrr_sql = "select * from ytiot_xj_inspectors where id=" . $res[0]['wbr_id'];
  295. $zrr_res = add($zrr_sql);
  296. $res[0]['name'] = $zrr_res[0]['name'];
  297. $res[0]['phone'] = $zrr_res[0]['phone'];
  298. }
  299. if (!empty($res[0]['company_code'])) {
  300. // $zrr_sql="select * from ytiot_xj_inspectors where id=".$res[0]['company_code'];
  301. // $zrr_res=add($zrr_sql);
  302. $company_data = M()->query("select owner_name,owner_address from sp_owner_company where building_id='" . $res[0]['company_code'] . "'");
  303. $res[0]['owner_name'] = $company_data[0]['owner_name'];
  304. $res[0]['owner_address'] = $company_data[0]['owner_address'];
  305. }
  306. if (!empty($res[0]['id'])) {
  307. $photos_sql = "select report_photos from ytiot_xj_operation_record_photos where dwczjl_id=" . $res[0]['id'];
  308. $photos_res = add($photos_sql);
  309. $res[0]['report_photos'] = $photos_res[0]['report_photos'];
  310. }
  311. $this->assign('companyid', $data['companyid']);
  312. $this->assign('res', $res[0]);
  313. $this->display('Index/maintenance_details');
  314. }
  315. public function xj_details()
  316. {
  317. $data = I();
  318. $record_id = $data['id'];
  319. $sql = "select * from ytiot_xj_spot_operation_record where id=" . $record_id;
  320. $res = add($sql);
  321. if ($res[0]['spot_abnormal'] == 0) {
  322. $res[0]['spot_status'] = "正常";
  323. } elseif ($res[0]['spot_abnormal'] == 1) {
  324. $res[0]['spot_status'] = "异常";
  325. } elseif ($res[0]['spot_abnormal'] == 2) {
  326. $res[0]['spot_status'] = "故障";
  327. } elseif ($res[0]['spot_abnormal'] == 3) {
  328. $res[0]['spot_status'] = "其他";
  329. }
  330. if (!empty($res[0]['spot_id'])) {
  331. $jhz_sql = "select * from ytiot_xj_plan_child where id=" . $res[0]['zb_id'];
  332. $jhz_res = add($jhz_sql);
  333. $jh_sql = "select * from ytiot_xj_plan_master where id=" . $jhz_res[0]['zb_id'];
  334. $jh_res = add($jh_sql);
  335. $res[0]['plan_name'] = $jh_res[0]['plan_name'];
  336. }
  337. if (!empty($res[0]['spot_id'])) {
  338. $points_sql = "select * from ytiot_xj_inspection_points where id=" . $res[0]['spot_id'];
  339. $points_res = add($points_sql);
  340. $res[0]['spot_name'] = $points_res[0]['spot_name'];
  341. $res[0]['spot_address'] = $points_res[0]['spot_address'];
  342. }
  343. if (!empty($res[0]['wbr_id'])) {
  344. $zrr_sql = "select * from ytiot_xj_inspectors where id=" . $res[0]['wbr_id'];
  345. $zrr_res = add($zrr_sql);
  346. $res[0]['name'] = $zrr_res[0]['name'];
  347. $res[0]['phone'] = $zrr_res[0]['phone'];
  348. }
  349. if (!empty($res[0]['company_code'])) {
  350. // $zrr_sql="select * from ytiot_xj_inspectors where id=".$res[0]['company_code'];
  351. // $zrr_res=add($zrr_sql);
  352. $company_data = M()->query("select owner_name,owner_address from sp_owner_company where building_id='" . $res[0]['company_code'] . "'");
  353. $res[0]['owner_name'] = $company_data[0]['owner_name'];
  354. $res[0]['owner_address'] = $company_data[0]['owner_address'];
  355. }
  356. if (!empty($res[0]['id'])) {
  357. $photos_sql = "select report_photos from ytiot_xj_operation_record_photos where dwczjl_id=" . $res[0]['id'];
  358. $photos_res = add($photos_sql);
  359. $res[0]['report_photos'] = $photos_res[0]['report_photos'];
  360. }
  361. $this->assign('companyid', $data['companyid']);
  362. $this->assign('res', $res[0]);
  363. $this->display('Index/inspectione_details');
  364. }
  365. public function getDeviceList()
  366. {
  367. $Data = I();
  368. $record_id = $Data['record_id'];
  369. $spot_id = $Data['spot_id'];
  370. $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;
  371. $res = add($sql);
  372. $this->assign('record_id', $record_id);
  373. $this->assign('spot_id', $spot_id);
  374. $this->assign('res', $res);
  375. $this->display('point_details/point_details');
  376. }
  377. public function getDeviceDetails()
  378. {
  379. $Data = I();
  380. $record_id = $Data['record_id'];
  381. $spot_id = $Data['spot_id'];
  382. $this->assign('record_id', $record_id);
  383. $this->assign('spot_id', $spot_id);
  384. if ($Data['dwtype'] == 16) {
  385. $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
  386. $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
  387. $gzsj = M()->query("select data4,time from sp_video2017 where device_code='" . $Data['deviceid'] . "' order by time desc");
  388. if (!empty($owner_xx[0]['rtmp'])) {
  389. $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
  390. } else {
  391. $owner_xx[0]['rtmp'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;无';
  392. }
  393. $this->assign('type_name', "视频监控");
  394. $this->assign('type', "video");
  395. $this->assign('companyid', $Data['companyid']);
  396. $this->assign('owner_xx', $owner_xx);
  397. $this->assign('owner_address', $owner_address);
  398. $this->assign('gzsj', $gzsj);
  399. $this->display('point_details/000001');
  400. } else if ($Data['dwtype'] == 17) {
  401. $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
  402. $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
  403. $gzsj = M()->query("select data4,time from sp_lifter2017 where device_code='" . $Data['deviceid'] . "' order by time desc");
  404. if (!empty($owner_xx[0]['rtmp'])) {
  405. $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
  406. } else {
  407. $owner_xx[0]['rtmp'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;无';
  408. }
  409. $this->assign('type_name', "电梯监控");
  410. $this->assign('type', "elevator");
  411. $this->assign('companyid', $Data['companyid']);
  412. $this->assign('owner_xx', $owner_xx);
  413. $this->assign('owner_address', $owner_address);
  414. $this->assign('gzsj', $gzsj);
  415. $this->display('point_details/000001');
  416. } else if ($Data['dwtype'] == 4) {
  417. $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
  418. $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
  419. $gzsj = M()->query("select data4,time from sp_d" . $Data['deviceid'] . " where device_code='" . $Data['deviceid'] . "' order by time desc");
  420. if (!empty($owner_xx[0]['rtmp'])) {
  421. $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
  422. } else {
  423. $owner_xx[0]['rtmp'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;无';
  424. }
  425. $this->assign('type_name', "消防栓监控");
  426. $this->assign('type', "firehydrant");
  427. $this->assign('companyid', $Data['companyid']);
  428. $this->assign('owner_xx', $owner_xx);
  429. $this->assign('owner_address', $owner_address);
  430. $this->assign('gzsj', $gzsj);
  431. $this->display('point_details/000001');
  432. } else if ($Data['dwtype'] == 128) {
  433. $owner_xx = M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls,dwtype from sp_owner where owner_code='" . $Data['deviceid'] . "'");
  434. $owner_address = M()->query("select owner_address from sp_owner_company where owner_id='" . $Data['companyid'] . "'");
  435. $gzsj = M()->query("select device_status,time from sp_iw2017 where device_code='" . $Data['deviceid'] . "' order by time desc");
  436. if (!empty($owner_xx[0]['rtmp'])) {
  437. $owner_xx[0]['rtmp'] = $owner_xx[0]['rtmp'];
  438. } else {
  439. $owner_xx[0]['rtmp'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;无';
  440. }
  441. if ($gzsj[0]['device_status']) {
  442. $gzsj[0]['data4'] = '正常';
  443. } else {
  444. $gzsj[0]['data4'] = '打开告警';
  445. }
  446. $this->assign('type_name', "井盖监控");
  447. $this->assign('type', "firehydrant");
  448. $this->assign('companyid', $Data['companyid']);
  449. $this->assign('owner_xx', $owner_xx);
  450. $this->assign('owner_address', $owner_address);
  451. $this->assign('gzsj', $gzsj);
  452. $this->display('point_details/000001');
  453. } else {
  454. $res = M()->query("SELECT * FROM sp_v_deviceall WHERE deviceid='" . $Data['deviceid'] . "'");
  455. $azwz = M()->query("select unitinfo from sp_owner where owner_code='" . $Data['deviceid'] . "'");
  456. $res[0]['azwz'] = $azwz[0]['unitinfo'];
  457. //在线离线权限问题
  458. $login_phone = M()->query("SELECT * FROM sp_login_phone");
  459. $phone_arr = array();
  460. foreach ($login_phone as $key => $value) {
  461. $phone_arr[$key] = $login_phone[$key]['phone'];
  462. }
  463. $phone = $_SESSION['phone'];
  464. $isin = in_array($phone, $phone_arr);
  465. if ($isin) {
  466. $phone_pd = 1;
  467. } else {
  468. $phone_pd = 0;
  469. }
  470. $time = M()->query("SELECT device_id,MAX(data_time) as data_time FROM sp_owner_status WHERE device_id='" . $Data['deviceid'] . "'");
  471. if (!empty($time)) {
  472. $stime = date('Y-m-d h:i:s', time());
  473. $etime = $time[0]['data_time'];
  474. $hour = intval((strtotime($stime) - strtotime($etime)) / 3600);
  475. if ($hour < 24) {
  476. $zs_status = '在线';
  477. } else {
  478. $zs_status = '离线';
  479. }
  480. } else {
  481. $zs_status = '状态不存在';
  482. }
  483. if ($res[0]['dwtype'] != 1) {
  484. if ($phone_pd == 1) {
  485. $res[0]['zs_status'] = $zs_status;
  486. }
  487. }
  488. if (!empty($res[0]['rtmp'])) {
  489. $res[0]['rtmp'] = $res[0]['rtmp'];
  490. } else {
  491. $res[0]['rtmp'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;无';
  492. }
  493. $this->assign('list', $res[0]);
  494. $this->assign('companyid', $Data['companyid']);
  495. $dwtype = $res[0]['dwtype'];
  496. $deviceid = $Data['deviceid'];
  497. if ($dwtype == 1) {
  498. $j2017 = M('hj2017');
  499. $counts = $j2017->order('time desc')->where(array('device_code' => $deviceid))->count('id');//总数
  500. $j_counts = $j2017->where(array('device_code' => $deviceid, 'clzt' => '1'))->count('id');//解决总数
  501. $d_counts = $j2017->where(array('device_code' => $deviceid, 'clwb' => '否'))->count('id');//真实总数
  502. $w_counts = $j2017->where(array('device_code' => $deviceid, 'clwb' => '是'))->count('id');//wb总数
  503. $this->assign('dwtype', 1);
  504. $this->assign('counts', $counts);
  505. $this->assign('j_counts', $j_counts);
  506. $this->assign('z_counts', $d_counts);
  507. $this->assign('w_counts', $w_counts);
  508. $this->display('point_details/000002');
  509. }
  510. if ($dwtype == 2) {
  511. $shui = M()->query("select * from sp_owner_sync_data where device_id='" . $Data['deviceid'] . "' and point_code=4 order by data_time desc");
  512. $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");
  513. $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");
  514. $a = array();
  515. $b = array();
  516. $electric = array();
  517. $signal = array();
  518. foreach ($shui as $value) {
  519. $a[] = $value['data_time'];
  520. $b[] = $value['point_data'];
  521. }
  522. foreach ($electric_data as $value) {
  523. $electric[] = $value['point_data'];
  524. }
  525. foreach ($signal_data as $value) {
  526. $signal[] = $value['point_data'] * 20;
  527. }
  528. $bb = $shui[0];
  529. $this->assign('bb', $bb['point_data']);
  530. $this->assign('dwtype', 2);
  531. $this->assign('time', json_encode($a));
  532. $this->assign('data4', json_encode($b));
  533. $this->assign('electric', json_encode($electric));
  534. $this->assign('signal', json_encode($signal));
  535. $this->display('point_details/000004');
  536. }
  537. if ($dwtype == 3) {
  538. $fume = M()->query("select RSRQ, DeviceStatus, BatteryLevel, storeTime, device_id from sp_y" . $deviceid . " ORDER BY storeTime DESC limit 1");
  539. $a = M()->query("select dwtype, sim,install_time,rtmp,hls from sp_owner where owner_code='" . $deviceid . "'");
  540. if ($a[0]['dwtype'] == 3) {
  541. $a[0]['dwtype'] = '烟感';
  542. }
  543. if (!empty($a[0]['rtmp'])) {
  544. $a[0]['rtmp'] = $a[0]['rtmp'];
  545. } else {
  546. $a[0]['rtmp'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;无';
  547. }
  548. foreach ($fume as $key => $arr) {
  549. if ($fume[$key]['devicestatus'] == 7) {
  550. $fume[$key]['type'] = '正常';
  551. } else if ($fume[$key]['devicestatus'] == 5) {
  552. $fume[$key]['type'] = '故障';
  553. } else if ($fume[$key]['devicestatus'] == 4) {
  554. $fume[$key]['type'] = '低压';
  555. } else if ($fume[$key]['devicestatus'] == 2) {
  556. $fume[$key]['type'] = '报警静音';
  557. } else if ($fume[$key]['devicestatus'] == 1) {
  558. $fume[$key]['type'] = '报警';
  559. }
  560. }
  561. $this->assign('dwtype', 3);
  562. $this->assign('a', $a);
  563. $this->assign('fume', $fume);
  564. $this->display('point_details/000003');
  565. }
  566. //液位
  567. if ($dwtype == 5) {
  568. $shui = M()->query("select * from sp_owner_sync_data where device_id='" . $Data['deviceid'] . "' and point_code=4 order by data_time desc");
  569. $a = array();
  570. $b = array();
  571. foreach ($shui as $value) {
  572. $a[] = $value['data_time'];
  573. $b[] = $value['point_data'];
  574. }
  575. $bb = $shui[0];
  576. $this->assign('bb', $bb['point_data']);
  577. $this->assign('dwtype', 5);
  578. $this->assign('time', json_encode($a));
  579. $this->assign('data4', json_encode($b));
  580. $this->display('point_details/000007');
  581. }
  582. if ($dwtype == 6) {
  583. $rtu = M()->query("SELECT id,data4,ncmd,`time`,data1,data2,CASE WHEN `port`='E6' THEN '模拟量' WHEN `port`='E3' THEN '开关量' END as types
  584. FROM sp_d" . $deviceid . " WHERE id in(SELECT MAX(id)
  585. FROM sp_d" . $deviceid . " GROUP BY `port`,ncmd) AND ncmd !='' "
  586. . (($deviceid == '4023363030303635') ? " AND (ncmd !='02' OR `port`!='E6') " :
  587. (($deviceid == '4023363030303639') ? " AND (ncmd !='03' OR `port`!='E6') " :
  588. (($deviceid == '4023363030303434') ? " AND (ncmd !='04' OR `port`!='E3') AND (ncmd !='05' OR `port`!='E3')" :
  589. (($deviceid == '4023363030303336') ? " AND (ncmd !='01' OR `port`!='E6') " :
  590. (($deviceid == '4023363030303733') ? " AND (ncmd !='05' AND ncmd !='06' )" : "")))))//山海大酒店B1楼水泵房02端口模拟量因设备故障,暂时屏蔽
  591. );
  592. $this->assign('dwtype', 6);
  593. $this->assign('rtu', $rtu);
  594. $res = M()->query("SELECT systype FROM sp_owner_port where owner_code='" . $deviceid . "'");
  595. $this->assign("trues", '0' . $res[0]['systype']);
  596. $this->display('point_details/000005');
  597. }
  598. // 电气火灾
  599. if ($dwtype == 7) {
  600. $install_time = M()->query("select install_time,rtmp,hls,owner_name,sim from sp_owner where owner_code='" . $Data['deviceid'] . "'");
  601. $owner_address = M()->query("select owner_address from sp_owner_company where owner_id=" . $Data['companyid']);
  602. $true_status = M()->query("select true_status from sp_devices_status where deviceid=" . $Data['deviceid']);
  603. $xssj = M()->query("select * from sp_owner_status where device_id='" . $Data['deviceid'] . "'");
  604. $zxsj = M()->query("select max(data_time) as zxsj from sp_owner_status where device_id='" . $Data['deviceid'] . "'");
  605. if ($true_status[0]['true_status'] == '75') {
  606. $dstatus = '离线';
  607. } else {
  608. $dstatus = '在线';
  609. }
  610. if (!empty($install_time[0]['rtmp'])) {
  611. $install_time[0]['rtmp'] = $install_time[0]['rtmp'];
  612. } else {
  613. $install_time[0]['rtmp'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;无';
  614. }
  615. $data = array(
  616. 'owner_name' => $install_time[0]['owner_name'],
  617. 'dstatus' => $dstatus,
  618. 'dthz' => '电气火灾',
  619. 'deviceid' => $Data['deviceid'],
  620. 'sim' => $install_time[0]['sim'],
  621. 'install_time' => $install_time[0]['install_time'],
  622. 'owner_address' => $owner_address[0]['owner_address'],
  623. 'rtmp' => $install_time[0]['rtmp'],
  624. 'hls' => $install_time[0]['hls'],
  625. );
  626. $this->assign('dwtype', 7);
  627. $this->assign('xssj', $xssj);
  628. $this->assign('zxsj', $zxsj);
  629. $this->assign('data', $data);
  630. $this->display('point_details/000006');
  631. }
  632. }
  633. }
  634. }