FireInspectorController.class.php.bak.2021-12-16 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class FireInspectorController extends ComController
  5. {
  6. //人员督察单列表查询
  7. public function getManualInspectorList(){
  8. $Data = I('');
  9. $clzt = $Data['clzt'];
  10. $start_time = $Data['start_time'];
  11. $end_time = $Data['end_time'];
  12. $company_code = $Data['company_code'];
  13. if (empty($company_code)){
  14. $res['msg'] = '操作失败,缺少参数';
  15. $res['flag'] = false;
  16. echo json_encode($res);
  17. }
  18. $where='';
  19. if (isset($clzt)){
  20. $where.=" and clzt=".$clzt." ";
  21. }
  22. if (!empty($start_time)){
  23. $where.=" and timestamp>='".$start_time."'";
  24. }
  25. if (!empty($end_time)){
  26. $where.=" and timestamp<'".$end_time."'";
  27. }
  28. $Res = query_187_ytapi("select count(*) as record_count from person_data where company_code='" . $company_code."'".$where);
  29. $ResData = query_187_ytapi("select id,content,timestamp,artificial_code,clzt from person_data where company_code='" . $company_code . "' ".$where." order by timestamp desc LIMIT 1000");
  30. foreach ($ResData as $key => $value) {
  31. $str = str_replace('"]', '', $ResData[$key]['content']);
  32. $ResData[$key]['content'] = str_replace('["', '', $str);
  33. }
  34. $res['msg'] = '操作成功';
  35. $res['flag'] = true;
  36. $res['record_count'] = (int)$Res[0]['record_count'];
  37. $res['data'] = $ResData;
  38. echo json_encode($res);
  39. }
  40. //人员督察单详情查询
  41. public function getManualInspectorDetails(){
  42. $Data = I();
  43. $id=$Data['id'];
  44. $company_code = $Data['company_code'];
  45. if (empty($id)){
  46. $res['msg'] = '操作失败,缺少参数';
  47. $res['flag'] = false;
  48. echo json_encode($res);
  49. }
  50. $Res = query_187_ytapi("select * from person_data where id=" .$id);
  51. if ($Res[0]['clzt']) {
  52. $Res[0]['wtype'] = "已处理";
  53. } else {
  54. $Res[0]['wtype'] = "未处理";
  55. }
  56. $str = str_replace('"]', '', $Res[0]['content']);
  57. $Res[0]['content'] = str_replace('["', '', $str);
  58. if ($Res[0]['cl_time'] == '1978-00-00 00:00:00') {
  59. $Res[0]['cl_time'] = '';
  60. }
  61. $res['msg'] = '操作成功';
  62. $res['flag'] = true;
  63. $res['data'] = $Res;
  64. echo json_encode($res);
  65. }
  66. //电子督察单列表页
  67. public function getElectronicInspectorList(){
  68. $Data = I('');
  69. $clzt = $Data['clzt'];
  70. $start_time = $Data['start_time'];
  71. $end_time = $Data['end_time'];
  72. $company_code = $Data['company_code'];
  73. if (empty($company_code)){
  74. $res['msg'] = '操作失败,缺少参数';
  75. $res['flag'] = false;
  76. echo json_encode($res);
  77. }
  78. $where='';
  79. if (isset($clzt)){
  80. $where.=" and clzt=".$clzt." ";
  81. }
  82. if (!empty($start_time)){
  83. $where.=" and timestamp>='".$start_time."'";
  84. }
  85. if (!empty($end_time)){
  86. $where.=" and timestamp<'".$end_time."'";
  87. }
  88. $Res = query_187_ytapi("select count(*) as record_count from jingan_analysis_data where status=0 and company_code='" . $company_code."' and content != '设备离线'".$where);
  89. $ResData = query_187_ytapi("select id,content,timestamp,supervise_code,clzt from jingan_analysis_data where status=0 and content !='设备离线' and company_code='" . $company_code . "' " . $where . " order by timestamp desc");
  90. foreach ($ResData as $key => $value) {
  91. $str = str_replace('"]', '', $ResData[$key]['content']);
  92. $ResData[$key]['content'] = str_replace('["', '', $str);
  93. }
  94. $res['msg'] = '操作成功';
  95. $res['flag'] = true;
  96. $res['record_count'] = (int)$Res[0]['record_count'];
  97. $res['data'] = $ResData;
  98. echo json_encode($res);
  99. }
  100. //电子督察单详情页
  101. public function getElectronicInspectorDetails(){
  102. $Data = I();
  103. if (empty($Data['id'])){
  104. $res['msg'] = '操作失败,缺少参数';
  105. $res['flag'] = false;
  106. echo json_encode($res);
  107. }
  108. $Res = query_187_ytapi("select * from jingan_analysis_data where id=" . $Data['id']." and status=0");
  109. // print_r($Res);
  110. if ($Res[0]['clzt']) {
  111. $Res[0]['wtype'] = "已处理";
  112. } else {
  113. $Res[0]['wtype'] = "未处理";
  114. }
  115. $str = str_replace('"]', '', $Res[0]['content']);
  116. $Res[0]['content'] = str_replace('["', '', $str);
  117. if ($Res[0]['cl_time'] == '1978-00-00 00:00:00') {
  118. $Res[0]['cl_time'] = '';
  119. }
  120. if ($Res[0]['type']==1||$Res[0]['type']==2||$Res[0]['type']==3){
  121. if (!empty($Res[0]['mainframe_id'])){
  122. $a=substr($Res[0]['mainframe_id'],2);
  123. }
  124. $arr=M()->query("select owner_name from sp_owner where owner_code='".$a."'");
  125. if(strlen($Res[0]['loop_number'])==4){
  126. $zj=substr($Res[0]['loop_number'],0,strlen($Res[0]['loop_number'])-3);
  127. $hl=(int)substr($Res[0]['loop_number'],1);
  128. $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."'");
  129. }else{
  130. $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']."'");
  131. }
  132. if (!empty($arr1[0]['info'])){
  133. $Res[0]['nr']="设备名称:".$arr[0]['owner_name'].",回路号:".$Res[0]['loop_number'].",点位号:".$Res[0]['position_number'].",点位描述:".$arr1[0]['info']."";
  134. }else{
  135. $Res[0]['nr']="设备名称:".$arr[0]['owner_name'].",回路号:".$Res[0]['loop_number'].",点位号:".$Res[0]['position_number'];
  136. }
  137. }else if ($Res[0]['type']==4){
  138. if (strpos($Res[0]['content'],"泵") !== false){
  139. if (!empty($Res[0]['device_id'])){
  140. $arr=M()->query("select owner_name from sp_owner where owner_code='".substr($Res[0]['device_id'],0,strlen($Res[0]['device_id'])-1)."'");
  141. if (!empty($arr[0]['owner_name'])){
  142. $Res[0]['nr']="设备名称:".$arr[0]['owner_name'];
  143. }else{
  144. $arr1=M()->query("select owner_name from sp_owner where owner_code='".$Res[0]['device_id']."'");
  145. if (!empty($arr1[0]['owner_name'])){
  146. $Res[0]['nr']="设备名称:".$arr1[0]['owner_name'];
  147. }else{
  148. $Res[0]['nr']="";
  149. }
  150. }
  151. }
  152. }
  153. }else{
  154. $Res[0]['nr']="";
  155. }
  156. $res['msg'] = '操作成功';
  157. $res['flag'] = true;
  158. $res['data'] = $Res;
  159. echo json_encode($res);
  160. }
  161. //人员督察单处理
  162. public function setManualInspector(){
  163. $Data = I();
  164. $cl_time = Date('Y-m-d H:i:s');
  165. if (!empty($_SESSION['phone'])) {
  166. $Data['clr'] = $_SESSION['phone'];
  167. }
  168. if ($Data['plcl'] == 1)
  169. {
  170. $ResData = query_187_ytapi("select * from person_data where artificial_code='" . $Data['artificial_code'] . "' and clzt=0 LIMIT 1");
  171. $res_u = insert_187_ytapi("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");
  172. // $data = [
  173. // 'sign' => $ResData[0]['sign'],
  174. // 'artificial_id' => $ResData[0]['artificial_id'],
  175. // 'artificial_code' => $ResData[0]['artificial_code'],
  176. // 'pid' => $ResData[0]['pid'],
  177. // 'status' => $ResData[0]['status'],
  178. // 'content' => $ResData[0]['content'],
  179. // ];
  180. } else {
  181. // print_r("update person_data set clzt=1,clnr='" . $Data['clnr'] . "',clr_phone='" . $Data['clr'] . "',cl_time='" . $cl_time . "' where id=" . $Data['id']);
  182. $res_u = ytapi187_inset("update person_data set clzt=1,clnr='" . $Data['clnr'] . "',clr_phone='" . $Data['clr'] . "',cl_time='" . $cl_time . "' where id=" . $Data['id']);
  183. $ResData = ytapi187_query("select * from person_data where id=" . $Data['id']);
  184. if ($Data['company_code'] == 10209 || $Data['company_code'] == 10198 || $Data['company_code'] == 10195 || $Data['company_code'] == 10078 || $Data['company_code'] == 10069 || $Data['company_code'] == 10083 ||
  185. $Data['comcompany_code'] == 10064 || $Data['company_code'] == 10067 || $Data['company_code'] == 10215 || $Data['company_code'] == 10216 || $Data['company_code'] == 10214 || $Data['company_code'] == 10212 ||
  186. $Data['company_code'] == 10206 || $Data['company_code'] == 10114 || $Data['company_code'] == 10077 || $Data['company_code'] == 10122 || $Data['company_code'] == 10074 || $Data['company_code'] == 10076 ||
  187. $Data['company_code'] == 10079 || $Data['company_code'] == 10066 || $Data['company_code'] == 10065 || $Data['company_code'] == 10070 || $Data['company_code'] == 10063) {
  188. $area_status = 2;
  189. } elseif ($Data['company_code'] == 10113 || $Data['company_code'] == 10012) {
  190. $area_status = 1;
  191. }
  192. $data = [
  193. "SubType" => '999',
  194. 'artificial_id' => $ResData[0]['artificial_id'],
  195. 'reason' => $ResData[0]['clnr'],
  196. 'handler' => $ResData[0]['clr_phone'],
  197. 'mobile' => $ResData[0]['clr_phone'],
  198. 'area_status' => $area_status,
  199. ];
  200. $url = 'http://47.98.201.187:55335/report';
  201. $data = json_encode($data);
  202. $result = http_post_advertise($url, $data);
  203. }
  204. if ($res_u){
  205. $res['msg'] = '操作成功';
  206. $res['flag'] = true;
  207. echo json_encode($res);
  208. }else{
  209. $res['msg'] = '操作失败';
  210. $res['flag'] = false;
  211. echo json_encode($res);
  212. }
  213. }
  214. //电子督察单处理
  215. public function setElectronicInspector(){
  216. $Data = I();
  217. $cl_time = Date('Y-m-d H:i:s');
  218. if (!empty($_SESSION['phone'])) {
  219. $Data['clr'] = $_SESSION['phone'];
  220. }
  221. $res_u = ytapi187_inset("update jingan_analysis_data set clzt=1,clnr='" . $Data['clnr'] . "',cl_phone='" . $Data['clr'] . "',cl_time='" . $cl_time . "' where id=" . $Data['id']);
  222. $ResData = ytapi187_query("select * from jingan_analysis_data where id=" . $Data['id']);
  223. if ($Data['company_code'] == 10209 || $Data['company_code'] == 10198 || $Data['company_code'] == 10195 || $Data['company_code'] == 10078 || $Data['company_code'] == 10069 ||
  224. $Data['company_code'] == 10083 || $Data['company_code'] == 10064 || $Data['company_code'] == 10067 || $Data['company_code'] == 10215 || $Data['company_code'] == 10216 ||
  225. $Data['company_code'] == 10214 || $Data['company_code'] == 10212 || $Data['company_code'] == 10206 || $Data['company_code'] == 10114 || $Data['company_code'] == 10077 ||
  226. $Data['company_code'] == 10122 || $Data['company_code'] == 10074 || $Data['company_code'] == 10076 || $Data['company_code'] == 10079 || $Data['company_code'] == 10066 ||
  227. $Data['company_code'] == 10065 || $Data['company_code'] == 10070 || $Data['company_code'] == 10063) {
  228. $area_status = 2;
  229. } elseif ($Data['company_code'] == 10113 || $Data['company_code'] == 10012) {
  230. $area_status = 1;
  231. }
  232. $data = [
  233. "SubType" => $Data['SubType'],
  234. 'artificial_id' => $ResData[0]['supervise_id'],
  235. 'reason' => $ResData[0]['clnr'],
  236. 'handler' => $ResData[0]['cl_phone'],
  237. 'mobile' => $ResData[0]['cl_phone'],
  238. 'area_status' => $area_status,
  239. ];
  240. $url = 'http://47.98.201.187:55335/report';
  241. $data = json_encode($data);
  242. $result = http_post_advertise($url, $data);
  243. if ($res_u){
  244. $res['msg'] = '操作成功';
  245. $res['flag'] = true;
  246. echo json_encode($res);
  247. }else{
  248. $res['msg'] = '操作失败';
  249. $res['flag'] = false;
  250. echo json_encode($res);
  251. }
  252. }
  253. }