MaintenanceController.class.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 MaintenanceController extends ComController{
  13. public function index(){
  14. // print_r($_SESSION['phone']);
  15. $data=I();
  16. // print_r($data);
  17. $sql="select * from ytiot_t_maintenance_person where phone='".$data['phone']."'";//.$_SESSION['phone'];//17621295894";
  18. $res=add66($sql);
  19. // print_r($res);
  20. if($res!=null){
  21. // print_r($sql);
  22. // exit();
  23. $a='';
  24. $a1='';
  25. foreach ($res as $key=>$value){
  26. $a.="'".$value['company_code']."',";
  27. $a1.="'".$value['id']."',";
  28. }
  29. $b=rtrim($a, ',');
  30. $b1=rtrim($a1, ',');
  31. // print_r($b);
  32. $time=date("Y-m-d");
  33. $sql1="select * from ytiot_t_maintenance_plan where personnel in(".$b1.") and planned_date='".$time."'";//and compamy_code in(".$b.")"
  34. $res1=add66($sql1);
  35. // print_r($res1);exit();
  36. $lx1='';
  37. foreach ($res1 as $key=>$value){
  38. $sql2="select * from ytiot_t_route2 where id=".$value['route'];
  39. $res2=add($sql2);
  40. // print_r($res2);
  41. $lx=$res2[0]['route'];
  42. $res1[$key]['route_name']=$res2[0]['route_name'];
  43. $lx1=explode(",",$lx);
  44. // print_r(count(explode(",",$lx)));
  45. for ($i=0; $i<count(explode(",",$lx)); $i++){
  46. // print_r('测试1:'.$lx1[$i]);
  47. $sql4="select * from ytiot_t_maintenance where id=".$lx1[$i];
  48. $res4=add($sql4);
  49. $sql3="select * from ytiot_t_maintenance_record where point_position=".$res4[0]['id']." and personnel=".$value['personnel']." and inspection_time like '".$time."%' and route=".$res2[0]['id']." and company_code=".$value['company_code'];
  50. $res3=add($sql3);
  51. // print_r($res4);
  52. $res5[$key]['dw'][$i]['xj_name']=$res4[0]['xj_name'];
  53. $res5[$key]['dw'][$i]['address']=$res4[0]['address'];
  54. $res5[$key]['dw'][$i]['label']=$res4[0]['label'];
  55. $res5[$key]['dw'][$i]['xjd_id']=$res4[0]['id'];
  56. $res5[$key]['route_name']=$res1[$key]['route_name'];
  57. $res5[$key]['id']=$res1[$key]['id'];
  58. $res5[$key]['completion_status']=round($res1[$key]['completion_status']);
  59. $res5[$key]['company']=$res1[$key]['company_code'];
  60. if(empty($res3)){
  61. $res5[$key]['dw'][$i]['pd']=0;
  62. }else{
  63. $res5[$key]['dw'][$i]['pd']=1;
  64. }
  65. }
  66. }
  67. //微信扫一扫
  68. # 引入
  69. // Vendor('WxJDK.JSSDK');
  70. # 公众号获取
  71. $appid = C('APPID');
  72. # 公众号获取
  73. $appSecret = C('SECRET');
  74. # 实例化
  75. $wx = new \JSSDK($appid,$appSecret);
  76. # 获取参数
  77. $info = $wx-> getWxConfig();
  78. # 传参页面
  79. $this -> assign('wxConfig',$info);
  80. // dump($res5,'1','<pre></pre>','0');
  81. // print_r($res5);
  82. // print_r($res5);
  83. // echo $data['companyid'];
  84. // print_t($data);
  85. // $this->assign('company',$data['companyid']);
  86. $this->assign('res5',$res5);
  87. //
  88. $this->display('Index/maintenance_system');
  89. }else{
  90. // $res5=array();
  91. // $this->assign('res5',$res5);
  92. //
  93. $this->display('Index/maintenance_system');
  94. }
  95. }
  96. }