FireInspectorController.class.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. include '../Common/function.php';
  5. class FireInspectorController extends ComController
  6. {
  7. public function catalog()
  8. {
  9. $Data = I();
  10. // print_r($Data);
  11. $this->assign('companyid', $Data['companyid']);
  12. $this->display('Index/rgdcd_catalog');
  13. }
  14. public function index_list()
  15. {
  16. $Data = I('');
  17. $ResData = ytapi_query("select count(*) from person_data where clzt=0 and company_code=" . $Data['companyid']);
  18. $this->assign('dcd', $ResData[0]['count(*)']);
  19. $this->assign('companyid', $Data['companyid']);
  20. // print_r($Data['companyid']);
  21. $this->display('Index/fire_inspector');
  22. // print_r($ResData[0]['count(*)']);
  23. }
  24. public function electronics_list()
  25. {
  26. $Data = I('');
  27. // print_r($Data);
  28. $ResData = ytapi_query("select count(*) from jingan_analysis_data where status=0 and clzt=0 and company_code=" . $Data['companyid']." and content != '设备离线'");
  29. $this->assign('dcd', $ResData[0]['count(*)']);
  30. $this->assign('companyid', $Data['companyid']);;
  31. $this->display('Index/electronics_inspector');
  32. }
  33. public function change()
  34. {
  35. $Data = I('');
  36. $company_code = $Data['companyid'];
  37. switch ($Data['type']) {
  38. case 'untreated':
  39. $status = "and clzt=0";
  40. break;
  41. case 'treated':
  42. $status = "and clzt=1";
  43. break;
  44. default:
  45. break;
  46. }
  47. $ResData = ytapi_query("select id,content,timestamp,artificial_code,clzt from person_data where company_code='" . $company_code . "' " . $status . " order by timestamp desc LIMIT 1000");
  48. // print_r($ResData);
  49. foreach ($ResData as $key => $value) {
  50. $str = str_replace('"]', '', $ResData[$key]['content']);
  51. $ResData[$key]['content'] = str_replace('["', '', $str);
  52. }
  53. // print_r($company_code);
  54. $this->assign('companyid', $company_code);
  55. $this->assign('ResData', $ResData);
  56. $this->display('Index/fire_inspector-list');
  57. }
  58. public function change1()
  59. {
  60. $Data = I('');
  61. $company_code = $Data['companyid'];
  62. // print_r($Data);
  63. // exit();
  64. switch ($Data['type']) {
  65. case 'untreated':
  66. $status = "and clzt=0";
  67. break;
  68. case 'treated':
  69. $status = "and clzt=1";
  70. break;
  71. default:
  72. break;
  73. }
  74. // print_r("select id,content,timestamp,supervise_code,clzt from jingan_analysis_data where status=0 and content !='设备离线' and company_code='" . $company_code . "' " . $status . " order by timestamp desc LIMIT 1000");
  75. // exit();
  76. $ResData = ytapi_query("select id,content,timestamp,supervise_code,clzt from jingan_analysis_data where status=0 and content !='设备离线' and company_code='" . $company_code . "' " . $status . " order by timestamp desc LIMIT 1000");
  77. foreach ($ResData as $key => $value) {
  78. $str = str_replace('"]', '', $ResData[$key]['content']);
  79. $ResData[$key]['content'] = str_replace('["', '', $str);
  80. }
  81. $this->assign('companyid', $company_code);
  82. $this->assign('ResData', $ResData);
  83. // print_r($ResData);
  84. // exit();
  85. $this->display('Index/electronics_inspector-list');
  86. }
  87. //报警明细
  88. public function index()
  89. {
  90. $Data = I();
  91. // print_r($Data['companyid']);
  92. $res = ytapi_query("select * from person_data where id=" . $Data['id']);
  93. if ($res[0]['clzt']) {
  94. $res[0]['wtype'] = "已处理";
  95. } else {
  96. $res[0]['wtype'] = "未处理";
  97. }
  98. $str = str_replace('"]', '', $res[0]['content']);
  99. $res[0]['content'] = str_replace('["', '', $str);
  100. if ($res[0]['cl_time'] == '1978-00-00 00:00:00') {
  101. $res[0]['cl_time'] = '';
  102. }
  103. $this->assign('companyid', $Data['companyid']);
  104. $this->assign('res', $res[0]);
  105. if ($res[0]['clzt'] == 0) {
  106. $this->display('Index/dcdyclxq');
  107. } else {
  108. $this->display('Index/dcdwclxq');
  109. }
  110. }
  111. //电子督察单报警明细
  112. public function index1()
  113. {
  114. $Data = I();
  115. $res = ytapi_query("select * from jingan_analysis_data where id=" . $Data['id']." and status=0");
  116. if ($res[0]['clzt']) {
  117. $res[0]['wtype'] = "已处理";
  118. } else {
  119. $res[0]['wtype'] = "未处理";
  120. }
  121. $str = str_replace('"]', '', $res[0]['content']);
  122. $res[0]['content'] = str_replace('["', '', $str);
  123. if ($res[0]['cl_time'] == '1978-00-00 00:00:00') {
  124. $res[0]['cl_time'] = '';
  125. }
  126. // print_r($res);
  127. if ($res[0]['type']==1||$res[0]['type']==2||$res[0]['type']==3){
  128. if (!empty($res[0]['mainframe_id'])){
  129. $a=substr($res[0]['mainframe_id'],2);
  130. }
  131. $arr=M()->query("select owner_name from sp_owner where owner_code='".$a."'");
  132. // print_r("select info from sp_owner_point where device_code='".$a."' and `loop`=".$res[0]['loop_number']." and pno=".$res[0]['position_number']."");
  133. if(strlen($res[0]['loop_number'])==4){
  134. $zj=substr($res[0]['loop_number'],0,strlen($res[0]['loop_number'])-3);
  135. $hl=(int)substr($res[0]['loop_number'],1);
  136. $arr1=M()->query("select info from sp_owner_point where device_code='".$a."' and `loop`='".$hl."' and pno='".$res[0]['position_number']."' and host_num='".$zj."'");
  137. }else{
  138. $arr1=M()->query("select info from sp_owner_point where device_code='".$a."' and `loop`='".$res[0]['loop_number']."' and pno='".$res[0]['position_number']."'");
  139. }
  140. if (!empty($arr1[0]['info'])){
  141. $res[0]['nr']="设备名称:".$arr[0]['owner_name'].",回路号:".$res[0]['loop_number'].",点位号:".$res[0]['position_number'].",点位描述:".$arr1[0]['info']."";
  142. }else{
  143. $res[0]['nr']="设备名称:".$arr[0]['owner_name'].",回路号:".$res[0]['loop_number'].",点位号:".$res[0]['position_number'];
  144. }
  145. }else if ($res[0]['type']==4){
  146. if (strpos($res[0]['content'],"泵") !== false){
  147. if (!empty($res[0]['device_id'])){
  148. // print_r($res[0]['device_id']);
  149. // print_r("select owner_name from sp_owner where owner_code='".substr($res[0]['device_id'],0,strlen($res[0]['device_id'])-1)."'");
  150. $arr=M()->query("select owner_name from sp_owner where owner_code='".substr($res[0]['device_id'],0,strlen($res[0]['device_id'])-1)."'");
  151. if (!empty($arr[0]['owner_name'])){
  152. $res[0]['nr']="设备名称:".$arr[0]['owner_name'];
  153. }else{
  154. $arr1=M()->query("select owner_name from sp_owner where owner_code='".$res[0]['device_id']."'");
  155. if (!empty($arr1[0]['owner_name'])){
  156. $res[0]['nr']="设备名称:".$arr1[0]['owner_name'];
  157. }else{
  158. $res[0]['nr']="";
  159. }
  160. }
  161. }
  162. }
  163. }else{
  164. $res[0]['nr']="";
  165. }
  166. // print_r($res[0]);
  167. $this->assign('companyid', $Data['companyid']);
  168. $this->assign('res', $res[0]);
  169. if ($res[0]['clzt'] == 0) {
  170. $this->display('Index/dzdcdyclxq');
  171. } else {
  172. $this->display('Index/dzdcdwclxq');
  173. }
  174. }
  175. //提交上传
  176. public function outputs()
  177. {
  178. // dump(I());
  179. if ($_SESSION['phone'] == '15000012454' || $_SESSION['idphone'] == '15000012454') {
  180. $html = <<<HTML
  181. <!doctype html>
  182. <html lang="en">
  183. <head>
  184. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  185. <meta charset="utf-8">
  186. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  187. <meta content="yes" name="apple-mobile-web-app-capable">
  188. <meta content="black" name="apple-mobile-web-app-status-bar-style">
  189. <meta content="telephone=no" name="format-detection">
  190. <title>访客无权限修改</title>
  191. </head>
  192. <body>
  193. 访客无权限修改!
  194. </body>
  195. </html>
  196. HTML;
  197. echo $html;
  198. exit;
  199. }
  200. $Data = I();
  201. $cl_time = Date('Y-m-d H:i:s');
  202. if (!empty($_SESSION['idphone'])) {
  203. $Data['clr'] = $_SESSION['idphone'];
  204. }
  205. if (!empty($_SESSION['phone'])) {
  206. $Data['clr'] = $_SESSION['phone'];
  207. }
  208. if ($Data['plcl'] == 1)//
  209. {
  210. $ResData = ytapi_query("select * from person_data where artificial_code='" . $Data['artificial_code'] . "' and clzt=0 LIMIT 1");
  211. $res_u = ytapi_insert("update person_data set clzt=1,clnr='" . $Data['clnr'] . "',clr_phone='" . $Data['clr'] . "',cl_time='" . $cl_time . "' where artificial_code='" . $Data['artificial_code'] . "' and clzt=0");
  212. $data = [
  213. 'sign' => $ResData[0]['sign'],
  214. 'artificial_id' => $ResData[0]['artificial_id'],
  215. 'artificial_code' => $ResData[0]['artificial_code'],
  216. 'pid' => $ResData[0]['pid'],
  217. 'status' => $ResData[0]['status'],
  218. 'content' => $ResData[0]['content'],
  219. ];
  220. $url = 'http://47.98.201.187:55335/report';
  221. $data = json_encode($data);
  222. // $result = http_post_advertise($url,$data);
  223. } else {
  224. $res_u = ytapi_insert("update person_data set clzt=1,clnr='" . $Data['clnr'] . "',clr_phone='" . $Data['clr'] . "',cl_time='" . $cl_time . "' where id=" . $Data['id']);
  225. $ResData = ytapi_query("select * from person_data where id=" . $Data['id']);
  226. // $Data['companyid']=10209;
  227. if ($Data['companyid'] == 10209 || $Data['companyid'] == 10198 || $Data['companyid'] == 10195 || $Data['companyid'] == 10078 || $Data['companyid'] == 10069 || $Data['companyid'] == 10083 || $Data['companyid'] == 10064 || $Data['companyid'] == 10067 || $Data['companyid'] == 10215 ||
  228. $Data['companyid'] == 10216 || $Data['companyid'] == 10214 || $Data['companyid'] == 10212 || $Data['companyid'] == 10206 || $Data['companyid'] == 10114 || $Data['companyid'] == 10077 || $Data['companyid'] == 10122 || $Data['companyid'] == 10074 || $Data['companyid'] == 10076 ||
  229. $Data['companyid'] == 10079 || $Data['companyid'] == 10066 || $Data['companyid'] == 10065 || $Data['companyid'] == 10070 || $Data['companyid'] == 10063) {
  230. $area_status = 2;
  231. } elseif ($Data['companyid'] == 10113 || $Data['companyid'] == 10012) {
  232. $area_status = 1;
  233. }
  234. $data = [
  235. "SubType" => '999',
  236. // 'sign'=>$ResData[0]['sign'],
  237. 'artificial_id' => $ResData[0]['artificial_id'],
  238. 'reason' => $ResData[0]['clnr'],
  239. 'handler' => $ResData[0]['clr_phone'],
  240. 'mobile' => $ResData[0]['clr_phone'],
  241. 'area_status' => $area_status,
  242. ];
  243. // print_r($data);
  244. // exit();
  245. $url = 'http://47.98.201.187:55335/report';
  246. $data = json_encode($data);
  247. $result = http_post_advertise($url, $data);
  248. }
  249. $resurl = 'http://' . $_SERVER['SERVER_NAME'] . $Data['url'];
  250. $html = <<<HTML
  251. <!doctype html>
  252. <html lang="en">
  253. <head>
  254. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  255. <meta charset="utf-8">
  256. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  257. <meta content="yes" name="apple-mobile-web-app-capable">
  258. <meta content="black" name="apple-mobile-web-app-status-bar-style">
  259. <meta content="telephone=no" name="format-detection">
  260. <meta http-equiv="refresh" content="2;url=$resurl" />
  261. <title>保存成功</title>
  262. </head>
  263. <body>
  264. 保存成功,正在跳转。。。
  265. </body>
  266. </html>
  267. HTML;
  268. echo $html;
  269. //echo json_encode($arr) ;
  270. }
  271. //电子督察单提交
  272. public function outputs1()
  273. {
  274. if ($_SESSION['phone'] == '15000012454' || $_SESSION['idphone'] == '15000012454') {
  275. $html = <<<HTML
  276. <!doctype html>
  277. <html lang="en">
  278. <head>
  279. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  280. <meta charset="utf-8">
  281. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  282. <meta content="yes" name="apple-mobile-web-app-capable">
  283. <meta content="black" name="apple-mobile-web-app-status-bar-style">
  284. <meta content="telephone=no" name="format-detection">
  285. <title>访客无权限修改</title>
  286. </head>
  287. <body>
  288. 访客无权限修改!
  289. </body>
  290. </html>
  291. HTML;
  292. echo $html;
  293. exit;
  294. }
  295. $Data = I();
  296. $cl_time = Date('Y-m-d H:i:s');
  297. if (!empty($_SESSION['idphone'])) {
  298. $Data['clr'] = $_SESSION['idphone'];
  299. }
  300. if (!empty($_SESSION['phone'])) {
  301. $Data['clr'] = $_SESSION['phone'];
  302. }
  303. // print_r("update jingan_analysis_data set clzt=1,clnr='" . $Data['clnr'] . "',cl_phone='" . $Data['clr'] . "',cl_time='" . $cl_time . "' where id=" . $Data['id']);exit();
  304. $res_u = ytapi_insert("update jingan_analysis_data set clzt=1,clnr='" . $Data['clnr'] . "',cl_phone='" . $Data['clr'] . "',cl_time='" . $cl_time . "' where id=" . $Data['id']);
  305. $ResData = ytapi_query("select * from jingan_analysis_data where id=" . $Data['id']);
  306. // $Data['companyid']=10209;
  307. if ($Data['companyid'] == 10209 || $Data['companyid'] == 10198 || $Data['companyid'] == 10195 || $Data['companyid'] == 10078 || $Data['companyid'] == 10069 || $Data['companyid'] == 10083 || $Data['companyid'] == 10064 || $Data['companyid'] == 10067 || $Data['companyid'] == 10215 ||
  308. $Data['companyid'] == 10216 || $Data['companyid'] == 10214 || $Data['companyid'] == 10212 || $Data['companyid'] == 10206 || $Data['companyid'] == 10114 || $Data['companyid'] == 10077 || $Data['companyid'] == 10122 || $Data['companyid'] == 10074 || $Data['companyid'] == 10076 ||
  309. $Data['companyid'] == 10079 || $Data['companyid'] == 10066 || $Data['companyid'] == 10065 || $Data['companyid'] == 10070 || $Data['companyid'] == 10063) {
  310. $area_status = 2;
  311. } elseif ($Data['companyid'] == 10113 || $Data['companyid'] == 10012) {
  312. $area_status = 1;
  313. }
  314. $data = [
  315. "SubType" => $Data['SubType'],
  316. 'artificial_id' => $ResData[0]['supervise_id'],
  317. 'reason' => $ResData[0]['clnr'],
  318. 'handler' => $ResData[0]['cl_phone'],
  319. 'mobile' => $ResData[0]['cl_phone'],
  320. 'area_status' => $area_status,
  321. ];
  322. // $url="http://iot.usky.cn:80/ytapi/admin/order/aepceshi";
  323. $url = 'http://47.98.201.187:55335/report';
  324. $data = json_encode($data);
  325. $result = http_post_advertise($url, $data);
  326. $resurl = 'http://' . $_SERVER['SERVER_NAME'] . $Data['url'];
  327. $html = <<<HTML
  328. <!doctype html>
  329. <html lang="en">
  330. <head>
  331. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  332. <meta charset="utf-8">
  333. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  334. <meta content="yes" name="apple-mobile-web-app-capable">
  335. <meta content="black" name="apple-mobile-web-app-status-bar-style">
  336. <meta content="telephone=no" name="format-detection">
  337. <meta http-equiv="refresh" content="2;url=$resurl" />
  338. <title>保存成功</title>
  339. </head>
  340. <body>
  341. 保存成功,正在跳转。。。
  342. </body>
  343. </html>
  344. HTML;
  345. echo $html;
  346. //echo json_encode($arr) ;
  347. }
  348. }