MeasuresController.class.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class MeasuresController 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. $Map['company'] = $Data['companyid'];
  33. switch ($Data['type']) {
  34. case 'untreated':
  35. $Map['clzt'] = 0;
  36. $clzt=' and clzt=0 ';
  37. break;
  38. case 'treated':
  39. $Map['clzt'] = 1;
  40. $clzt=' and clzt=1 ';
  41. break;
  42. default:
  43. break;
  44. }
  45. if ($Data['companyid']==10215){
  46. $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");
  47. }else{
  48. // $ResData = M('v_rtu2017_2')->where($Map)->order("id desc")->limit(1000)->select();
  49. $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']."' and clzt='0' and b.dwtype=6 order by a.id desc limit 1000");
  50. }
  51. // print_r($ResData);exit();
  52. $this->assign('ResData', $ResData);
  53. $this->display('Index/measure-list');
  54. }
  55. }