123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace Home\Controller;
- use Think\Controller;
- use Think\Db;
- include '../Common/function.php';
- class MonthlyReportController extends ComController
- {
- //月报列表
- public function getMonthlyReportList(){
- $data =I();
- $company_code=$data['company_code'];
- $sql="select id,company_code,company_name,event_time from yt_t_month_report where company_code='".$company_code."' GROUP BY event_time";
- $R=query_187_ytIoT($sql);
- $res['msg'] = '操作成功';
- $res['flag'] = true;
- $res['data'] = $R;
- echo json_encode($res);
- }
- //月报详情
- public function getMonthlyReportDetails(){
- $data =I();
- $company_code=$data['company_code'];
- $id=$data['id'];
- $sql="select * from yt_t_month_report where id=".$id;
- $res=query_187_ytIoT($sql);
- if (!empty($res)){
- $project_info=json_decode($res[0]['project_info'], true);
- $instal_device_info=json_decode($res[0]['instal_device_info'], true);
- $device_cout=$instal_device_info['total'];
- unset($instal_device_info['total']);
- foreach ($instal_device_info as $key => $value){
- $instal_device_info[$key]['xh']=$key;
- }
- $monitor_point_info=json_decode($res[0]['monitor_point_info'],true);
- $point_count=$monitor_point_info['total'];
- unset($monitor_point_info['total']);
- foreach ($monitor_point_info as $key => $value){
- $monitor_point_info[$key]['xh']=$key;
- }
- $count_time=json_decode($res[0]['count_time'],true);
- $count_report=json_decode($res[0]['count_report'],true);
- foreach ($count_report as $key => $value){
- $count_report[$key]['xh']=$key;
- }
- $alarm_total=json_decode($res[0]['alarm_total'],true);
- $fire_data=json_decode($res[0]['fire_data'],true);
- $fire_data['process_rate']=$fire_data['process_rate']*1000;
- $fire_data['unprocess']=$fire_data['unprocess']*1000;
- $water_data=json_decode($res[0]['water_data'],true);
- $rtu_data=json_decode($res[0]['rtu_data'],true);
- $conclusion=json_decode($res[0]['conclusion'],true);
- $other=$conclusion['other'];
- $propose_data=$conclusion['propose'];
- $propose=array();
- $a=0;
- foreach ($propose_data as $key => $value){
- if (!empty($propose_data[$key]['data1'])){
- $propose[$a]['data1']=$propose_data[$key]['data1'];
- $a+=1;
- }
- }
- $D['project_info']=$project_info;
- $D['instal_device_info']=$instal_device_info;
- $D['monitor_point_info']=$monitor_point_info;
- $D['count_time']=$count_time;
- $D['count_report']=$count_report;
- $D['alarm_total']=$alarm_total;
- $D['fire_data']=$fire_data;
- $D['water_data']=$water_data;
- $D['rtu_data']=$rtu_data;
- $D['propose']=$propose;
- $D['other']=$other;
- $D['device_cout']=$device_cout;
- $D['point_count']=$point_count;
- $R['msg'] = '操作失败';
- $R['flag'] = true;
- $R['company_code'] = $company_code;
- $R['company_name'] = $res[0]['company_name'];
- $R['event_time'] = $res[0]['event_time'];
- $R['data'] = $D;
- // print_r($R);
- echo json_encode($R);
- }else{
- $R['msg'] = '操作失败';
- $R['flag'] = false;
- $R['data'] = $res;
- echo json_encode($R);
- }
- }
- }
|