MaintinfoController.class.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. use Think\Upload;
  5. include '../Common/function.php';
  6. class MaintinfoController extends ComController {
  7. public function index()
  8. { $Data=I();
  9. // $this->assign('phone',$Data['phone']);
  10. // $this->assign('companyid',$Data['companyid']);
  11. $wxry_id_sql="select * from ytiot_xj_inspectors where phone='".$Data['phone']."' and zn in(4,5,6,7)";
  12. $res=add66($wxry_id_sql);
  13. // print_r($res);
  14. $wxry_id_list="";
  15. if($res!=null){
  16. foreach ($res as $key=>$value){
  17. // print_r($key);
  18. if ($key==0){
  19. // print_r("第".$key.$res[$key]['id']);
  20. $wxry_id_list.= $res[$key]['id'];
  21. }else{
  22. // print_r("第".$key.$res[$key]['id']);
  23. $wxry_id_list.=','. $res[$key]['id'];
  24. }
  25. }
  26. // print_r($wxry_id_list);
  27. $zp_sql="select * from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") order by cl_type asc";
  28. $zp=add66($zp_sql);
  29. $dqsj1=date("Y-m-d",time());
  30. $arr = array();
  31. foreach ($zp as $key=>$value){
  32. $a=date('Y-m-d', strtotime($zp[$key]['y_complete_time']));
  33. $a1=date('Y-m-d', strtotime($zp[$key]['sh_time']));
  34. if($zp[$key]['cl_type']==1 || $zp[$key]['cl_type']==2 || $zp[$key]['cl_type']==3 || ($zp[$key]['cl_type']==4 && $a1==$dqsj1) || ($zp[$key]['cl_type']==5 && $a1>=$dqsj1)){
  35. if ($zp[$key]['sj_type']==1){
  36. $arr[$key]['sj_type_name']='故障';
  37. }elseif ($zp[$key]['sj_type']==2){
  38. $arr[$key]['sj_type_name']='隐患';
  39. }elseif ($zp[$key]['sj_type']==3){
  40. $arr[$key]['sj_type_name']='其他';
  41. }
  42. // if ($zp[$key]['cl_type']==1){
  43. // $arr[$key]['cl_type_anme']='未处理';
  44. // }elseif ($zp[$key]['cl_type']==2){
  45. // $arr[$key]['cl_type_anme']='未审核';
  46. // }elseif ($zp[$key]['cl_type']==3){
  47. // $arr[$key]['cl_type_anme']='审核未通过';
  48. // }elseif ($zp[$key]['cl_type']==4){
  49. // $arr[$key]['cl_type_anme']='已完成';
  50. // }elseif ($zp[$key]['cl_type']==5){
  51. // $arr[$key]['cl_type_anme']='超时完成';
  52. // }
  53. $arr[$key]['wx_name']=$zp[$key]['wx_name'];
  54. $arr[$key]['id']=$zp[$key]['id'];
  55. $arr[$key]['cl_type']=$zp[$key]['cl_type'];
  56. }
  57. }
  58. // $zsl_sql="select count(*) as zsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type in(1,2,3,4,5)";
  59. // $zsl=add66($zsl_sql);
  60. // print_r($zsl_sql);
  61. // print_r($zsl);
  62. $wclsl_sql="select count(*) as wclsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=1";
  63. $wclsl=add66($wclsl_sql);
  64. if (empty($wclsl)){
  65. $wclsl[0]['wclsl']=0;
  66. }
  67. $wshsl_sql="select count(*) as wshsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=2";
  68. $wshsl=add66($wshsl_sql);
  69. if (empty($wshsl)){
  70. $wshsl[0]['wshsl']=0;
  71. }
  72. $shwtgsl_sql="select count(*) as shwtgsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=3";
  73. $shwtgsl=add66($shwtgsl_sql);
  74. if (empty($shwtgsl)){
  75. $shwtgsl[0]['shwtgsl']=0;
  76. }
  77. $ywcsl_sql="select count(*) as ywcsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=4 and sh_time='%".$dqsj1."%'";
  78. $ywcsl=add66($ywcsl_sql);
  79. if (empty($ywcsl)){
  80. $ywcsl[0]['ywcsl']=0;
  81. }
  82. $cswcsl_sql="select count(*) as cswcsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=5 and sh_time='%".$dqsj1."%'";
  83. $cswcsl=add66($cswcsl_sql);
  84. if (empty($cswcsl)){
  85. $cswcsl[0]['cswcsl']=0;
  86. }
  87. $zsl=$wclsl[0]['wclsl']+$wshsl[0]['wshsl']+$shwtgsl[0]['shwtgsl']+$ywcsl[0]['ywcsl']+$cswcsl[0]['cswcsl'];
  88. $this->assign('zsl',$zsl);
  89. $this->assign('wclsl',$wclsl[0]['wclsl']);
  90. $this->assign('wshsl',$wshsl[0]['wshsl']);
  91. $this->assign('shwtgsl',$shwtgsl[0]['shwtgsl']);
  92. $this->assign('ywcsl',$ywcsl[0]['ywcsl']);
  93. $this->assign('cswcsl',$cswcsl[0]['cswcsl']);
  94. $this->assign('companyid',$Data['companyid']);
  95. // print_r($arr);
  96. $this->assign('ResData',$arr);
  97. }
  98. // print_r($arr);
  99. // exit();
  100. $this->display('Maintinfo/device_manger');
  101. }
  102. public function bd(){
  103. $Data=I();
  104. // print_r($Data);
  105. $jlid_sql = "select dwjl_id,sj_type,id from ytiot_xj_event_processing where id=".$Data['id'];
  106. // print_r("测试0".$jlid_sql);
  107. $jlid=add66($jlid_sql);
  108. // print_r("测试0".$jlid);
  109. if ($jlid[0]['sj_type']==1){
  110. $sj_type_name='故障';
  111. }elseif ($jlid[0]['sj_type']==2){
  112. $sj_type_name='隐患';
  113. }elseif ($jlid[0]['sj_type']==3){
  114. $sj_type_name='其他';
  115. }
  116. if($jlid!=null){
  117. $dwid_sql = "select spot_id from ytiot_xj_spot_operation_record where id=".$jlid[0]['dwjl_id'];
  118. // print_r("测试1".$dwid_sql);
  119. $dwid=add66($dwid_sql);
  120. // print_r("测试2".$dwid);
  121. if($dwid[0]['spot_id']!=null){
  122. $dz_sql = "select spot_address from ytiot_xj_inspection_points where id=".$dwid[0]['spot_id'];
  123. $dz=add66($dz_sql);
  124. if($dz[0]['spot_address']!=null){
  125. $address=$dz[0]['spot_address'];
  126. }
  127. }
  128. }
  129. // print_r($sj_type_name);
  130. $this->assign('sj_type_name',$sj_type_name);
  131. $this->assign('id',$jlid[0]['id']);
  132. $this->assign('address',$address);
  133. $this->display('Maintinfo/bxform');
  134. }
  135. public function tj()
  136. {
  137. $Data=I();
  138. $time=date('Y-m-d h:i:s',time());
  139. $BasefName='';
  140. $tmpFilePath = $_FILES['img']['tmp_name'];
  141. //确保我们有一个文件路径
  142. if ($tmpFilePath != ""){
  143. //设置我们的新文件路径
  144. $FileCode=date('YmdHis').rand(1000,9999);
  145. $FileName=$_FILES['img']['name'];
  146. $FileType=strtolower(substr(strrchr($FileName,'.'),1));
  147. $BasefName=$FileCode.'.'.$FileType;
  148. $newFilePath ='/var/www/html/jdxf/Maintinfo/image/'.$BasefName;
  149. $newFilePath1 ='https://qhome.usky.cn/jdxf/Maintinfo/image/'.$BasefName;
  150. //将文件上传到临时目录中
  151. if(move_uploaded_file($tmpFilePath, $newFilePath)) {
  152. // $newFilePath =$BasefName;
  153. $sql="update ytiot_xj_event_processing set data1='1',jg_remarks='".$Data['jg_remarks']."',cl_time='".$time."',picture_path='".$newFilePath1."',cl_type=2 where id=".$Data['id'];
  154. $val=$res1=addDataInfo($sql);
  155. if($val){
  156. // echo "<script>window.history.go(-2);</script>";
  157. $this->success('保存成功',U('Maintinfo/index'),3);
  158. }else{
  159. $this->error('上传失败');
  160. }
  161. }else{
  162. $this->error('上传失败');
  163. }
  164. }
  165. }
  166. public function change()
  167. {
  168. $Data=I('');
  169. $Map['sp_monitor.company']=$Data['companyid'];
  170. switch ($Data['type'])
  171. {
  172. case 'fire':
  173. $Map['sp_monitor.dwtype']=1;
  174. break;
  175. case 'water':
  176. $Map['sp_monitor.dwtype']=array('in','2,5');
  177. break;
  178. case 'fume':
  179. $Map['sp_monitor.dwtype']=3;
  180. break;
  181. case 'rtu':
  182. $Map['sp_monitor.dwtype']=6;
  183. break;
  184. case 'efire':
  185. $Map['sp_monitor.dwtype']=7;
  186. break;
  187. default:
  188. break;
  189. }
  190. $count=M('monitor')->where($Map)->count();
  191. $this->assign('count',$count);
  192. $this->assign('phone',$Data['phone']);
  193. $this->assign('companyid',$Data['companyid']);
  194. $this->assign('type',$Data['type']);
  195. //print_r($Map);
  196. $ResData=M('monitor')->where($Map)->select();
  197. $this->assign('ResData',$ResData);
  198. $this->display('Maintinfo/dmanger-list');
  199. }
  200. public function setform()
  201. {
  202. $Data=I();
  203. $this->assign('ownname',$Data[owner_name]);
  204. $this->assign('companyid',$Data[companyid]);
  205. $this->assign('ownid',$Data[owner_code]);
  206. $this->assign('type',$Data['type']);
  207. $this->assign('editor',$Data['phone']);
  208. $time=date('Y-m-d h:i:s',time());
  209. if($Data['companyid']){
  210. $ResData=M('owner_company')->where("owner_id=$Data[companyid]")->find();
  211. }
  212. $this->assign('owner_name',$ResData['owner_name']);
  213. $this->assign('address',$ResData['owner_address']);
  214. $BasefName='';
  215. $tmpFilePath = $_FILES['img']['tmp_name'];
  216. //确保我们有一个文件路径
  217. if ($tmpFilePath != ""){
  218. //设置我们的新文件路径
  219. $FileCode=date('YmdHis').rand(1000,9999);
  220. $FileName=$_FILES['img']['name'];
  221. $FileType=strtolower(substr(strrchr($FileName,'.'),1));
  222. $BasefName=$FileCode.'.'.$FileType;
  223. $newFilePath ='/var/www/html/jdxf/Maintinfo/image/'.$BasefName;
  224. //将文件上传到临时目录中
  225. if(move_uploaded_file($tmpFilePath, $newFilePath)) {
  226. $newFilePath =$BasefName;
  227. $sql="insert into sp_maint_infolist(owner_code,owner_name,owner_address,comp_name,company,type,image,datetime,content,editor) value(
  228. '$Data[owner_code]','$Data[ownname]','$Data[owner_address]','$Data[owner_name]','$Data[companyid]','$Data[types]','$newFilePath','$time','$Data[content]','$Data[editors]')";
  229. if($Data[editors]){
  230. $val=M()->execute($sql);
  231. if($val){
  232. echo "<script>window.history.go(-2);</script>";
  233. }else{
  234. $this->error('上传失败');
  235. }
  236. }
  237. }else{
  238. $this->error('上传失败');
  239. }
  240. }
  241. $this->display('Maintinfo/setform');
  242. }
  243. public function maintlist()
  244. { $Data=I();
  245. $Map['sp_maint_info.type']=$Data['type'];
  246. $Map['sp_maint_info.company']=$Data['compangid'];
  247. $counts=M('maint_info')->where($Map)->count();
  248. //echo $counts;
  249. $ResData=M('maint_info')->where($Map)->order("datetime desc")->select();
  250. //echo M('maint_info')->getLastSql();
  251. $this->assign('ResData',$ResData);
  252. $this->assign('counts',$counts);
  253. $this->assign('count',$Data['count']);
  254. $this->assign('type',$Data['type']);
  255. $this->assign('companyid',$Data['compangid']);
  256. $this->display('Maintinfo/maint-list');
  257. }
  258. }
  259. ?>