MonthlyReportController.class.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. use Think\Db;
  5. include '../Common/function.php';
  6. class MonthlyReportController extends ComController
  7. {
  8. //月报列表
  9. public function getMonthlyReportList(){
  10. $data =I();
  11. $company_code=$data['company_code'];
  12. $sql="select id,company_code,company_name,event_time from yt_t_month_report where company_code='".$company_code."' GROUP BY event_time";
  13. $R=query_187_ytIoT($sql);
  14. $res['msg'] = '操作成功';
  15. $res['flag'] = true;
  16. $res['data'] = $R;
  17. echo json_encode($res);
  18. }
  19. //月报详情
  20. public function getMonthlyReportDetails(){
  21. $data =I();
  22. $company_code=$data['company_code'];
  23. $id=$data['id'];
  24. $sql="select * from yt_t_month_report where id=".$id;
  25. $res=query_187_ytIoT($sql);
  26. if (!empty($res)){
  27. $project_info=json_decode($res[0]['project_info'], true);
  28. $instal_device_info=json_decode($res[0]['instal_device_info'], true);
  29. $device_cout=$instal_device_info['total'];
  30. unset($instal_device_info['total']);
  31. foreach ($instal_device_info as $key => $value){
  32. $instal_device_info[$key]['xh']=$key;
  33. }
  34. $monitor_point_info=json_decode($res[0]['monitor_point_info'],true);
  35. $point_count=$monitor_point_info['total'];
  36. unset($monitor_point_info['total']);
  37. foreach ($monitor_point_info as $key => $value){
  38. $monitor_point_info[$key]['xh']=$key;
  39. }
  40. $count_time=json_decode($res[0]['count_time'],true);
  41. $count_report=json_decode($res[0]['count_report'],true);
  42. foreach ($count_report as $key => $value){
  43. $count_report[$key]['xh']=$key;
  44. }
  45. $alarm_total=json_decode($res[0]['alarm_total'],true);
  46. $fire_data=json_decode($res[0]['fire_data'],true);
  47. $fire_data['process_rate']=$fire_data['process_rate']*1000;
  48. $fire_data['unprocess']=$fire_data['unprocess']*1000;
  49. $water_data=json_decode($res[0]['water_data'],true);
  50. $rtu_data=json_decode($res[0]['rtu_data'],true);
  51. $conclusion=json_decode($res[0]['conclusion'],true);
  52. $other=$conclusion['other'];
  53. $propose_data=$conclusion['propose'];
  54. $propose=array();
  55. $a=0;
  56. foreach ($propose_data as $key => $value){
  57. if (!empty($propose_data[$key]['data1'])){
  58. $propose[$a]['data1']=$propose_data[$key]['data1'];
  59. $a+=1;
  60. }
  61. }
  62. $D['project_info']=$project_info;
  63. $D['instal_device_info']=$instal_device_info;
  64. $D['monitor_point_info']=$monitor_point_info;
  65. $D['count_time']=$count_time;
  66. $D['count_report']=$count_report;
  67. $D['alarm_total']=$alarm_total;
  68. $D['fire_data']=$fire_data;
  69. $D['water_data']=$water_data;
  70. $D['rtu_data']=$rtu_data;
  71. $D['propose']=$propose;
  72. $D['other']=$other;
  73. $D['device_cout']=$device_cout;
  74. $D['point_count']=$point_count;
  75. $R['msg'] = '操作失败';
  76. $R['flag'] = true;
  77. $R['company_code'] = $company_code;
  78. $R['company_name'] = $res[0]['company_name'];
  79. $R['event_time'] = $res[0]['event_time'];
  80. $R['data'] = $D;
  81. // print_r($R);
  82. echo json_encode($R);
  83. }else{
  84. $R['msg'] = '操作失败';
  85. $R['flag'] = false;
  86. $R['data'] = $res;
  87. echo json_encode($R);
  88. }
  89. }
  90. }