FireController.class.php.bak.2021-12-20-1 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. //include '../Common/function.php';
  5. class FireController extends ComController
  6. {
  7. public function index()
  8. {
  9. $Data = I();
  10. $Map['company'] = $Data['companyid'];
  11. $Map['clzt'] = 0;
  12. $device_code_list=$this->getDeviceCode($Data['companyid'],"1,3");
  13. if (!empty($device_code_list)){
  14. $ResData=M()->query("SELECT count(*) as hj FROM sp_hj2017 where device_code in(".$device_code_list.") and clzt='0'");
  15. }else{
  16. $ResData[0]['hj']= 0;
  17. }
  18. // $ResData=M()->query("SELECT count(a.id) as hj FROM sp_hj2017 as a join sp_owner as b ON a.device_code=b.owner_code WHERE b.dwtype in(1,3) and b.company='".$Map['company']."' and a.clzt='0'");
  19. $this->assign('wcl', $ResData[0]['hj']);
  20. $this->assign('companyid', $Data['companyid']);
  21. $this->display('Index/fire');
  22. }
  23. public function change()
  24. {
  25. $Data = I('');
  26. $Map['company'] = $Data['companyid'];
  27. switch ($Data['type']) {
  28. case 'untreated':
  29. $Map['clzt'] = 0;
  30. $where=" and a.clzt='0' ";
  31. break;
  32. case 'treated':
  33. $Map['clzt'] = 1;
  34. $where=" and a.clzt='1' ";
  35. break;
  36. default:
  37. break;
  38. }
  39. $ResData = M()->query("select a.data2 as ftype , a.time ,b.owner_name as owner_name ,a.clzt as clzt ,a.id as id ,a.data4 as data4 from sp_hj2017 as a join sp_owner as b ON a.device_code=b.owner_code WHERE b.dwtype in(1,3) and b.company='".$Map['company']."' ".$where." order by a.id desc limit 500");
  40. // $ResData = M('v_hj2017_2')->where($Map)->order("time desc")->limit(500)->select();
  41. //print_r($ResData);exit();
  42. $this->assign('ResData', $ResData);
  43. $this->display('Index/fire-list');
  44. }
  45. //获取设备编号
  46. public function getDeviceCode($company,$dwtype)
  47. {
  48. $device = M()->query("SELECT owner_code FROM sp_owner WHERE company in(".$company.") and dwtype in(".$dwtype.")");
  49. $str = "";
  50. foreach ($device as $val) {
  51. $str .= "'" . $val['owner_code'] . "',";
  52. }
  53. $newstr = substr($str, 0, strlen($str) - 1);
  54. return $newstr;
  55. }
  56. //无用
  57. public function change1()
  58. {
  59. $Data = I('');
  60. $Map['company'] = $Data['companyid'];
  61. $type = $Data['type'];
  62. switch ($type) {
  63. case 'untreated':
  64. $ResData = M()->query("select sp_hj2017.time, sp_hj2017.data2, sp_owner.owner_name, sp_hj2017.clzt, sp_hj2017.id, sp_hj2017.data4 from sp_owner join sp_hj2017 on sp_owner.owner_code=sp_hj2017.device_code where company=" . $Map['company'] . " and clzt=0 order by time desc limit 500");
  65. break;
  66. case 'treated':
  67. $ResData = M()->query("select sp_hj2017.time, sp_hj2017.data2, sp_owner.owner_name, sp_hj2017.clzt, sp_hj2017.id, sp_hj2017.data4 from sp_owner join sp_hj2017 on sp_owner.owner_code=sp_hj2017.device_code where company=" . $Map['company'] . " and clzt=1 order by time desc limit 500");
  68. break;
  69. default:
  70. $ResData = M()->query("select sp_hj2017.time, sp_hj2017.data2, sp_owner.owner_name, sp_hj2017.clzt, sp_hj2017.id, sp_hj2017.data4 from sp_owner join sp_hj2017 on sp_owner.owner_code=sp_hj2017.device_code where company=" . $Map['company'] . " order by time desc limit 500");
  71. break;
  72. }
  73. $this->assign('ResData', $ResData);
  74. $this->display('Index/fire-list');
  75. }
  76. }
  77. ?>