FireController.class.php.bak.2022-01-27 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 clzt='0' ";
  31. break;
  32. case 'treated':
  33. $Map['clzt'] = 1;
  34. $where=" and clzt='1' ";
  35. break;
  36. default:
  37. break;
  38. }
  39. $device = M()->query("SELECT owner_code,owner_name FROM sp_owner WHERE company in(".$Map['company'].") and dwtype in(1,3)");
  40. if (!empty($device)){
  41. $str = "";
  42. foreach ($device as $val) {
  43. $str .= "'" . $val['owner_code'] . "',";
  44. }
  45. $newstr = substr($str, 0, strlen($str) - 1);
  46. $ResData = M()->query("select data2 as ftype , time ,device_code ,clzt ,id ,data4 from sp_hj2017 WHERE device_code in(".$newstr.") ".$where." order by id desc limit 1000");
  47. if (!empty($ResData)){
  48. foreach ($ResData as $key => $value){
  49. foreach ($device as $key1=>$value1){
  50. if ($ResData[$key]['device_code']==$device[$key1]['owner_code']){
  51. $ResData[$key]['owner_name']=$device[$key1]['owner_name'];
  52. }
  53. }
  54. }
  55. }
  56. }
  57. // $ResData = M()->query("select a.data2 as ftype , a.time ,b.owner_name ,a.clzt ,a.id ,a.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");
  58. // $ResData = M('v_hj2017_2')->where($Map)->order("time desc")->limit(500)->select();
  59. $this->assign('ResData', $ResData);
  60. $this->display('Index/fire-list');
  61. }
  62. //获取设备编号
  63. public function getDeviceCode($company,$dwtype)
  64. {
  65. $device = M()->query("SELECT owner_code FROM sp_owner WHERE company in(".$company.") and dwtype in(".$dwtype.")");
  66. $str = "";
  67. foreach ($device as $val) {
  68. $str .= "'" . $val['owner_code'] . "',";
  69. }
  70. $newstr = substr($str, 0, strlen($str) - 1);
  71. return $newstr;
  72. }
  73. //无用
  74. public function change1()
  75. {
  76. $Data = I('');
  77. $Map['company'] = $Data['companyid'];
  78. $type = $Data['type'];
  79. switch ($type) {
  80. case 'untreated':
  81. $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");
  82. break;
  83. case 'treated':
  84. $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");
  85. break;
  86. default:
  87. $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");
  88. break;
  89. }
  90. $this->assign('ResData', $ResData);
  91. $this->display('Index/fire-list');
  92. }
  93. }
  94. ?>