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

@Injectable()
export class WorkService {

    constructor(private http: HttpClient) {
    }

    //事件转派
    transfer(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/sysevent/transfer' ,data);
    }

    //修改事件
    update(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/sysevent/update' ,data);
    }

    //删除事件
    delete(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/sysevent/delete' ,data);
    }

    //查找事件列表
    find(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/sysevent/find' ,data);
    }

    //根据事件编号查询
    findByNo(params): Observable<any>{
        return this.http.get(SERVER_API_URL + '/sysevent/find/' +params);
    }

    //添加事件
    create(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/sysevent/create' ,data);
    }

    //事件信息流转记录查询接口
    transferInfo(params): Observable<any>{
        return this.http.get(SERVER_API_URL + '/sysevent/transferInfo/' +params);
    }

    //处理事件
    deal(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/sysevent/deal' ,data);
    }

    //修改巡检计划
    updatePlan(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/plan/update' ,data);
    }

    //删除计划
    deletePlan(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/plan/delete' ,data);
    }

    //查找单个计划
    findPlan(params): Observable<any>{
        return this.http.get(SERVER_API_URL + '/plan/find/' +params);
    }

    //查询列表
    findPlanList(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/plan/find' ,data);
    }

    //添加巡检计划
    createPlan(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/plan/create' ,data);
    }

    //修改资产分类
    updateType(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/inventory/updateType' ,data);
    }

    //查询所有父级资产类型
    findByParentType(): Observable<any>{
        return this.http.get(SERVER_API_URL + '/inventory/findByParentType' );
    }

    //根据父级类型查询子级
    findByParentidCount(params): Observable<any>{
        return this.http.get(SERVER_API_URL + '/inventory/findByParentidCount/' +params);
    }

    //创建资产分类
    createType(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/inventory/createType' ,data);
    }

    //根据主键id查询资产类型
    findType(params): Observable<any>{
        return this.http.get(SERVER_API_URL + '/inventory/findType/' ,params);
    }

    //根据资产类型id 查询没有配置主机的资产
    selectByInventoryTypeidAndHostidNull(params): Observable<any>{
        return this.http.get(SERVER_API_URL + '/inventory/selectByInventoryTypeidAndHostidNull/' ,params);
    }

    //设置资产匹配的主机
    updateHostid(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/inventory/updateHostid' ,data);
    }

    //根据type查找
    findByType(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/syseventType/findByType' ,data);
    }
}
