ScanwbController.class.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: TianFeng
  5. * Date: 2019-03-18
  6. * Time: 15:38
  7. */
  8. namespace Home\Controller;
  9. use Think\Controller;
  10. include '../Common/function.php';
  11. class ScanwbController extends ComController {
  12. public function pdsflr(){
  13. $data=I('post.data');
  14. $company=I('post.company');
  15. $wxjid=I('post.wxjid');
  16. $wxjid1=explode('-',$wxjid);
  17. // print_r($wxjid);
  18. // echo $wxjid;
  19. // exit();
  20. $sql="select * from ytiot_t_maintenance_person where phone=".$_SESSION['phone'];
  21. $res=add($sql);
  22. if(empty($res)){
  23. echo 1;
  24. exit();
  25. }
  26. $sql1="select * from ytiot_t_qrcode_analysis2 where analysis_content='".$data."'";
  27. $res1=add($sql1);
  28. if(empty($res1)){
  29. echo 2;
  30. exit();
  31. }
  32. if(!empty($wxjid1)){
  33. // echo $wxjid1[0];
  34. $sql66="select * from ytiot_t_qrcode_analysis2 where id=".$wxjid1[0];
  35. $res66=add66($sql66);
  36. if($data!=$res66[0]['analysis_content']){
  37. echo 3;
  38. exit();
  39. }
  40. }
  41. $planned_date=date('Y-m-d');
  42. // $sql2="select * from ytiot_t_patrol_plan where personnel=".$res[0]['id']." and planned_date='".$planned_date."'";
  43. $sql2="select * from ytiot_t_maintenance_plan where id=".$wxjid1[1]." and planned_date='".$planned_date."'";
  44. $res2=add($sql2);
  45. $inspection_time=date('Y-m-d H:i:s');
  46. $res4=array();
  47. $res4['ms']=5;
  48. $res4['name_id']=$res2[0]['personnel'];
  49. $res4['analysis_content_id']=$wxjid1[0];
  50. $res4['inspection_time']=$inspection_time;
  51. $res4['route_id']=$res2[0]['route'];
  52. $res4['company']=$res2[0]['compoany_code'];
  53. $res4['xjjh_id']=$wxjid1[1];
  54. $res4['xjd_id']=$wxjid1[2];
  55. // print_r($res4);
  56. if (empty($res2)){
  57. echo 4;
  58. exit();
  59. }else{
  60. foreach ($res2 as $key=>$value){
  61. $sql3="select * from ytiot_t_route2 where id= ".$res2[0]['route'];
  62. $res3=add($sql3);
  63. if(!empty($res3)){
  64. // if(strpos($res3[$key]['route'],$res1[0]['id']) !== false){
  65. echo json_encode($res4);
  66. exit();
  67. // }else{
  68. // echo 6;
  69. // exit();
  70. // }
  71. }
  72. }
  73. }
  74. }
  75. public function sftjewm(){
  76. $data=I('post.data');
  77. $company=I('post.company');
  78. // $sql="insert into ytiot_t_qrcode_analysis (analysis_content) value ('".$data."')";
  79. $sql="insert into ytiot_t_qrcode_analysis2 (analysis_content,company_code) value ('".$data."','".$company."')";
  80. $res=addDataInfo($sql);
  81. if($res){
  82. echo 1;
  83. exit();
  84. }else{
  85. echo 0;
  86. exit();
  87. }
  88. }
  89. // public function qd(){
  90. // $data=I();
  91. // $sql="insert into ytiot_t_maintenance_record value (".$data['name'].",".$data['route'].",'".$data['inspection_time']."',".$data['analysis_content'].",".$data['firecl'].",'".$data['qk']."')";
  92. // $res=addDataInfo($sql);
  93. // if($res){
  94. //
  95. // }else{
  96. // $this->display('Index2/wbprc1');
  97. // }
  98. //
  99. // }
  100. public function wbfrom(){
  101. $res1 =I();
  102. $this->assign('res1',$res1);
  103. $this->display('Index2/wbfrom');
  104. }
  105. public function xjd_inset(){
  106. $data=I();
  107. // print_r($data);
  108. // exit();
  109. $sql4="select id,completion_status,company_code from ytiot_t_maintenance_plan where id=".$data['xjjh_id'];
  110. // print_r($data);
  111. // print_r($sql4);exit();
  112. $patrol_planid=add($sql4);
  113. // $sql88="select id from ytiot_t_qrcode_analysis id=".$data['analysis_content'];
  114. // $analysis_content=add($sql88);
  115. // $sql1="select id from ytiot_t_patrol_point where label=".$data['analysis_content'];
  116. // $resid=add($sql1);
  117. if(empty($data['xjd_id'])){
  118. $this->success('维保点为空',U('Index/index'),3);
  119. exit();
  120. }
  121. $sql8="select company_code from ytiot_t_maintenance_person where id=".$data['name_id'];
  122. $rescompany_code=add($sql8);
  123. if(empty($rescompany_code)){
  124. $this->success('维保人为空',U('Index/index'),3);
  125. exit();
  126. }
  127. // print_r($patrol_planid);exit();
  128. $sql2="insert into ytiot_t_maintenance_record (personnel,route,inspection_time,point_position,xjzt,qk,company_code) value (".$data['name_id'].",".$data['route'].",'".$data['inspection_time']."','".$data['xjd_id']."',".$data['zt'].",'".$data['qk']."','".$patrol_planid[0]['company_code']."')";
  129. // echo $sql;
  130. // exit();
  131. $res=addDataInfo($sql2);
  132. if($res){
  133. $sql3="select route from ytiot_t_route2 where id=".$data['route'];
  134. $routeid=add($sql3);
  135. $arr=explode(",",$routeid[0]['route']);//二维码解析id
  136. $z=count($arr);
  137. $bl1=1/$z*100;
  138. $bl=round($bl1,2);
  139. $time=date("Y-m-d");
  140. // $sql4="select id,completion_status from ytiot_t_patrol_plan where route=".$data['route']." and personnel=".$data['name_id']." and planned_date='".$time."' and company_code=".$data['company'];
  141. // $sql4="select id,completion_status from ytiot_t_patrol_plan where id=".$data['xjjh_id'];
  142. // $patrol_planid=add($sql4);
  143. // print_r($sql4);
  144. // print_r($patrol_planid);
  145. // exit();
  146. // $zbl=(int)$patrol_planid[0]['completion_status']+(int)$bl;
  147. $zbl=$patrol_planid[0]['completion_status']+$bl;
  148. // $sql5="update ytiot_t_patrol_plan set completion_status=".$zbl." where route=".$data['route']." and personnel=".$data['name_id']." and planned_date='".$time."'";
  149. $sql5="update ytiot_t_maintenance_plan set completion_status=".$zbl." where id=".$data['xjjh_id'];
  150. // print_r($sql5);
  151. // exit();
  152. $res1=addDataInfo($sql5);
  153. if($res1){
  154. // $this->success('保存成功',U('Inspection/index'),3);
  155. $this->success('保存成功',U('Maintenance/index?companyid='.$rescompany_code[0]['company_code']),3);
  156. }else{
  157. $this->success('保存失败1bl',U('Maintenance/index'),3);
  158. }
  159. }else{
  160. $this->success('保存失败',U('Index/index'),3);
  161. }
  162. }
  163. }