MeasureController.class.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class MeasureController extends ComController
  5. {
  6. public function index(){
  7. $Data = I('');
  8. $Map['company']=$Data['companyid'];
  9. $Map['clzt']=0;
  10. if ($Data['companyid']==10215){
  11. $ResData1=M()->query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype not LIKE '%离线%' and clzt=0");
  12. $ResData2=M()->query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype LIKE '%离线%' AND time < '2021-03-10' and clzt=0");
  13. if (empty($ResData1)){
  14. $ResData1[0]['sl']=0;
  15. }
  16. if (empty($ResData2)){
  17. $ResData2[0]['sl']=0;
  18. }
  19. $ResData=$ResData1[0]['sl']+$ResData2[0]['sl'];
  20. }else{
  21. // $ResData=M('v_rtu2017_2')->where($Map)->count('id');
  22. $ResData3 = M()->query("SELECT count(*) as sl FROM sp_rtu2017 as a JOIN sp_owner AS b ON a.device_code=b.owner_code where company='".$Data['companyid']."' and clzt='0' and dwtype=6 order by a.id desc limit 1000");
  23. $ResData=$ResData3[0]['sl'];
  24. }
  25. $this->assign('wjcn',$ResData);
  26. $this->assign('companyid',$Data['companyid']);
  27. $this->display('Index/measure');
  28. }
  29. public function change()
  30. {
  31. $Data = I('');
  32. $page = $Data['page'];
  33. $size = 20;
  34. $startpage=($page - 1) * 20;
  35. $Map['company'] = $Data['companyid'];
  36. switch ($Data['type']) {
  37. case 'untreated':
  38. $Map['clzt'] = 0;
  39. $clzt=' and clzt=0 ';
  40. break;
  41. case 'treated':
  42. $Map['clzt'] = 1;
  43. $clzt=' and clzt=1 ';
  44. break;
  45. default:
  46. break;
  47. }
  48. if ($Data['companyid']==10215){
  49. $ResData = M()->query("SELECT * from sp_v_rtu2017_2 where company='10215' AND wtype LIKE '%离线%' AND time < '2021-03-10' ".$clzt." UNION all(SELECT * from sp_v_rtu2017_2 where company='10215' AND wtype NOT LIKE '%离线%' ".$clzt.") ORDER BY time DESC limit ".$startpage.",".$size);
  50. }else{
  51. // $ResData = M('v_rtu2017_2')->where($Map)->order("id desc")->limit(1000)->select();
  52. $ResData = M()->query("SELECT a.*,b.dwtype,b.owner_name,b.company,concat(a.data4,',',a.data2) AS wtype FROM sp_rtu2017 as a JOIN sp_owner AS b ON a.device_code=b.owner_code where b.company='".$Map['company']."' ".$clzt." and b.dwtype=6 order by a.id desc limit ".$startpage.",".$size);
  53. }
  54. // print_r($ResData);exit();
  55. // $this->assign('ResData', $ResData);
  56. // $this->display('Index/measure-list');
  57. echo json_encode($ResData);
  58. }
  59. }