import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {SERVER_API_URL} from '../app.constants';
import {Observable} from 'rxjs/Rx';
import {CommonService} from '../shared/common/common.service';

@Injectable()
export class AnalysisService {

    constructor(private http: HttpClient,private commonSer:CommonService) {
    }

    //按事件分类导出报表
    exportByType(data): Observable<any>{
        return this.http.get(SERVER_API_URL + '/syseventCount/export/type?'+this.commonSer.toQuery(data) );
    }

    //按事件处理人导出报表
    exportByuser(data): Observable<any>{
        return this.http.get(SERVER_API_URL + '/syseventCount/export/user?'+this.commonSer.toQuery(data));
    }

    //按事件解决状态导出报表
    exportByStatus(data): Observable<any>{
        return this.http.get(SERVER_API_URL + '/syseventCount/export/status?'+this.commonSer.toQuery(data));
    }

    //按事件分类统计
    eventByType(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/syseventCount/type' ,data);
    }

    //按解决状态统计
    operateStatus(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/syseventCount/operateStatus' ,data);
    }

    //按处理人统计
    operateUser(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/syseventCount/operateUser' ,data);
    }

    //可用性统计
    findFailureRate(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/statistics/findFailureRate' ,data);
    }

    //告警总数top10
    waringCountTop(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/statistics/waringCountTop' ,data);
    }

    //告警总数趋势
    waringTrend(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/statistics/waringTrend' ,data);
    }

    //常发问题TOP10
    commonProblemTop(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/statistics/commonProblemTop' ,data);
    }

    //查询异常设备名
    findHostNameByStatisticalReport(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/statistics/findHostNameByStatisticalReport' ,data);
    }

    //查询所有主机的警告数和高危报警数
    findWarningByAll(params): Observable<any>{
        return this.http.get(SERVER_API_URL + '/statistics/findWarningByAll/' + params);
    }

    //查询报警主机 和报警数量 以及最高报警级别
    findHostWarningCount(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/statistics/findHostWarningCount' , data);
    }

    //统计报告
    statisticalReport(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/statistics/statisticalReport' , data);
    }

    //统计报告弹出框
    reportCount(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/trigger/find' , data);
    }

}
