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

@Injectable()
export class OverAllService {

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

    //获取分组信息 --列表
    getgroups(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/groups/getgroups', data);
    }

    //查询模板组-----列表
    getTemplateGroups(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/groups/getTemplateGroups');
    }

    //资源列表--资源分组  ---主机组下拉框
    findGroup(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/groups/getAll');
    }

    //获取分组信息  --编辑页面获取分组  1 表示模板 0表示主机
    getEditGroups(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/groups/getAllUpdate/' + params);
    }

    //资源列表--所有类型
    find(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/find', data);
    }

    //停止-开启监控
    updateHostStatus(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/updateHostStatus?' +this.commonSer.toQuery(data));
    }

    //批量停止开启监控接口
    batchStopOrOpen(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/batchStopOrOpen', data);
    }

    //资源列表--设备类型
    findType(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/hostType/selectAllEquipmentType');
    }

    //根据设备类型查询主机资源
    findHostByType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/selectAllHostByType/', data);
    }

    //资源列表--查询主机
    findDetail(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/find', data);
    }

    //资源详情
    findDetailed(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findDetailed/' + data);
    }

    //平均响应时间
    responseTime(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/responseTime/' + data);
    }

    //丢包率
    losed(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/losed/' + data);
    }

    //CPU使用率
    cupUsed(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/cpuUsed/' + data.hostId);
    }

    //内存使用率
    used(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/used/' + data.hostId);
    }

    //磁盘使用率
    disks(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/disks/' + data.hostId);
    }

    //进出口流量    --SNMP
    inOutInfoSnmp(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/inOutInfo', data);
    }

    //进出口流量    --
    inOutInfoAgent(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/inOutInfoAgent/' + data);
    }

    //主机接口
    findInterface(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findInterface/' + params);
    }

    //查询键值
    zabbixKey(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/zabbixKey/find/' + data);
    }

    //创建监控点
    create(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/save', data);
    }

    //删除资源--get
    deleteHostGet(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/deleteHost/' + data);
    }

    //批量删除资源--post
    deleteHostPost(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/deleteHost', data);
    }

    //添加资源
    createHost(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/create', data);
    }

    //模版信息
    templates(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/template/list');
    }

    //添加分组
    createGroup(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/groups/create', data);
    }

    //修改分组
    updataGroup(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/groups/update', data);
    }

    //删除分组
    deleteGroup(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/groups/delete', data);
    }

    //删除监控项
    deleteItem(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/delete', data);
    }

    //监控设备数
    findSize(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findSize');
    }

    //监测点列表--type
    findCheckByType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/page', data);
    }

    //查询监控项
    findItemDetail(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/item/find/' + params);
    }

    //监控项分类
    findItemType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/application/find', data);
    }

    //新增监控项分类
    createItemType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/application/create', data);
    }

    //监测点状态统计
    findItemCount(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/item/finditemstatus/' + params);
    }

    //监测点图形数据
    findGraphData(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/graph/findGraphData/', data);
    }

    //监控项修改状态
    itemUpdate(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/item/updata/', data);
    }

    itemUpdata(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/update', data);
    }

    //临时暂停
    tempStop(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/tempStop', data);
    }

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

    //查询所有告警组
    findWarnAll(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/alertGroup/findAll');
    }

    //修改资源
    updateHost(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/host/updataHost', data);
    }

    //根据host的启用状态查询count 记录数
    findHostCountByStatus(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findHostCountByStatus/' + params);
    }

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

    //网站监测
    //查询网站监测列表
    findWebscenario(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/find', data);
    }

    //修改网站监测
    updateWebscenario(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/webscenario/update', data);
    }

    //创建网站监测
    createWebscenario(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/create', data);
    }

    //临时暂停
    tempStopWebscenario(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/tempStop', data);
    }

    //取消临时暂停
    tempStopCancelWebscenario(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/temp-stop-cancel/' + params);
    }

    //启用禁用网站监测
    statusBatch(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/statusBatch', data);
    }

    //批量删除网站监测
    deleteBatch(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/delete', data);
    }

    //查找单个网站监测(数据回显接口)
    findWeb(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find/' + params);
    }

    //添加告警-查询告警目标接口
    findAlertAim(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find-alert-aim/' + params);
    }

    //添加告警接口
    addWebAction(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/add-web-action', data);
    }

    //查找最近一条监测状态
    findCurrentState(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find-current-state/' + params);
    }

    //查找监测图表数据
    findChart(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/findChart', data);
    }

    //查找阈值设定
    findTrigger(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find-trigger/' + params);
    }

    //网站监测历史告警
    findAlert(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/findAlert', data);
    }

    //统计网站监测告警种类
    countStatus(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/countStatus');
    }

    //查找所有设备类型tree
    findTree(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/hostType/findTree');
    }

    //创建触发器
    createTrigger(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/createItemTrigger', data);
    }

    //修改触发器
    updateTrigger(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/trigger/update', data);
    }

    //查看映射值
    findValuemap(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/valuemap/find');
    }

    //创建模板
    createTemplates(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/templates/create', data);
    }

    //修改模板
    updateTemplates(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/templates/update', data);
    }

    //克隆模板
    cloneTemplates(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/templates/clone', data);
    }

    //删除模板（支持批量删除）
    deleteTemplates(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/templates/delete', data);
    }

    //查询模板
    findTemplates(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/templates/find', data);
    }

    //添加主机自动发现
    createLldrule(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/lldrule/create', data);
    }

    //修改主机自动发现
    updateLldrule(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/lldrule/update', data);
    }

    //主机自动发现列表
    findPageLldrule(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/lldrule/findPage', data);
    }

    //删除主机自动发现
    deleteLldrule(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/lldrule/delete', data);
    }

    //自动发现 详情
    findLldrule(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/lldrule/find/' + params);
    }

    //分页查询触发器
    findPageTrigger(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/triggerPrototype/findPage', data);
    }

    //主键查询触发器原型
    findTriggerById(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/triggerPrototype/find/' + params);
    }

    //删除触发器
    deleteTrigger(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/triggerPrototype/delete', data);
    }

    //修改触发器原型
    updateTriggerPrototype(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/triggerPrototype/update', data);
    }

    //添加触发器原型
    createTriggerPrototype(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/triggerPrototype/create', data);
    }

    //添加监控项原型
    createItemPrototype(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itemprototype/create', data);
    }

    //删除监控项原型
    deleteItemPrototype(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itemprototype/delete', data);
    }

    //分页查询监控项原型
    findItemPrototype(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itemprototype/findPage', data);
    }

    //修改监控项原型
    updateItemPrototype(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itemprototype/update', data);
    }

    //主键查询监控项原型
    findItemById(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/itemprototype/find/' + params);
    }

    //创建阈值
    createTri(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/trigger/create', data);
    }

    //修改阈值
    updateTri(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/trigger/update', data);
    }

    //查询阈值列表
    findTri(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/trigger/findTrigger', data);
    }

    //删除触发器
    deleteTri(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/trigger/delete', data);
    }

    //下载xml模板
    exportTemplates(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/templates/export', data);
    }

    //上传xml模板
    importTemplates(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/templates/import', data);
    }

    //主机四种状态数（优化）
    findHostCountByStatusByHost(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findHostCountByStatus');
    }

    //分页查询主机（优化）
    findHostPageNew(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/findHostPageNew', data);
    }

    //通过sql查询主机（优化）
    findHostNew(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/findHostNew', data);
    }

    //发送利用率排名
    homeUseOrder(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/home/useOrder/' + params);
    }

    //查询业务系统的安全运行天数
    findSafeRunDayList(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itservice/findSafeRunDayList', data);
    }

    //查询主机cpu内存使用率排名列表
    runStateOrder(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/home/runStateOrder/' + params);
    }

    //查询主机发送接收流量排名列表
    homeFlowOrder(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/home/flowOrder/' + params);
    }

    //查询监控项流量排名列表
    flowOrderByItem(params1, params2): Observable<any> {
        return this.http.get(SERVER_API_URL + '/home/flowOrderByItem/' + params1 + '/' + params2);
    }

//    无锡监狱

    //查找所有有数据的网口
    findNetworkCard(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/hostSwitch/findNetworkCard/' + params);
    }

    //查询网卡流量图表接口
    findNetworkFlow(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/hostSwitch/findNetworkFlow', data);
    }

    //根据类型查询图表数据(右上角指标趋势)
    findChartByKey(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/hostSwitch/findChartByKey', data);
    }

    //根据数据库类型查找数据库详细指标
    findDatabaseDetailByHost(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itemDatabase/findDatabaseDetailByHost', data);
    }

    //查找数据库详情指标
    findIndexDetail(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itemDatabase/findIndexDetail', data);
    }

    //查找数据库详情指标
    findChartData(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/itemDatabase/findChartData', data);
    }

    //根据主机查询所有的数据库类型
    findAllDatabaseByHost(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/itemDatabase/findAllDatabaseByHost/' + params);
    }

    //根据主机查询告警总数趋势图表
    waringTrendByHost(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/statistics/waringTrendByHost', data);
    }

    //查询系统信息
    getSystem(): Observable<any> {
        return this.http.get('./json/system.json');
    }
}
