package com.tofly.ghrq_route.module.user.domain;

import com.tofly.ghrq_route.base.url.NetRequestURL;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.Unique;
import org.greenrobot.greendao.annotation.Generated;

@Entity(nameInDb = "DB_USER_ONLINE_MAP_DATA")
public class UserOnlineMapDataBean {
    /**
     * id : 44
     * pid : 24
     * name : 影像(天地图)
     * cval : http://192.168.2.246:6080/arcgis/rest/services/deyang/IMAGE_QY_DEYANG/MapServer
     * createTime : 2020-04-10 10:50:09
     * createUser : 42
     * ckey : raster1
     */

    public enum MAP_CODE_KEY {
        MAP_CODE_TPK("privateterrain", "privateterrain1", 0),              //在线地图底图TPK
        MAP_CODE_TPK1("terrain", "dixing1", 0),                     //在线地图底图TPK1 - 天地图
        MAP_CODE_OFFLINE_TPK("mobilegis", "offlineterrain1", 0),      //离线地图底图TPK
        MAP_CODE_PIPE("pipe", "pipe1",  1),                       //在线地图管线图geo
        MAP_CODE_OFFLINE_PIPE("mobilegis", "offlinepipe1", 1),        //离线地图管线图geo
        MAP_CODE_POI("poi", "zjsjfw",  2),                         //在线地图地名图层poi
        MAP_CODE_IMAGE("raster", "raster1", 0),                    //在线地图影像图raster
        MAP_CODE_OFFLINE_IMAGE("mobilegis", "offlineraster1",  0),     //离线地图影像图raster
        MAP_CODE_BURST("apiburstpipe", "apiburstpipe1", 3);              //在线地图爆管分析服务

        MAP_CODE_KEY(String code, String ckey, int priority) {
            this.code = code;
            this.ckey = ckey;
            this.priority = priority;
        }

        public String getCode() {
            return code;
        }

        public String getCkey() {
            return ckey;
        }

        public int getPriority() {
            return priority;
        }

        public static MAP_CODE_KEY Code(String ckey) {
            switch (ckey) {
                case "privateterrain":
                    return MAP_CODE_TPK;
                case "terrain":
                    return MAP_CODE_TPK1;
                case "pipe":
                    return MAP_CODE_PIPE;
                case "poi":
                    return MAP_CODE_POI;
                case "raster":
                    return MAP_CODE_IMAGE;
                case "offlineterrain1":
                    return MAP_CODE_OFFLINE_TPK;
                case "offlinepipe1":
                    return MAP_CODE_OFFLINE_PIPE;
                case "offlineraster1":
                    return MAP_CODE_OFFLINE_IMAGE;
                case "apiburstpipe":
                    return MAP_CODE_BURST;
            }
            return MAP_CODE_TPK;
        }

        public static MAP_CODE_KEY[] Priority(int priority) {
            switch (priority) {
                case 0:
                    return new MAP_CODE_KEY[] {MAP_CODE_TPK, MAP_CODE_IMAGE};
                case 1:
                    return new MAP_CODE_KEY[] {MAP_CODE_PIPE};
                case 2:
                    return new MAP_CODE_KEY[] {MAP_CODE_POI};
            }
            return new MAP_CODE_KEY[] {MAP_CODE_TPK, MAP_CODE_IMAGE};
        }

        final String code;
        final String ckey;
        final int priority;
    }

    @Id @Unique @NotNull
    private String id;
    private int pid;
    private String name;
    private String cval;
    private String createTime;
    private int createUser;
    private String ckey;
    private String code;
    private String userid;

    @Generated(hash = 1351528539)
    public UserOnlineMapDataBean(@NotNull String id, int pid, String name, String cval,
            String createTime, int createUser, String ckey, String code, String userid) {
        this.id = id;
        this.pid = pid;
        this.name = name;
        this.cval = cval;
        this.createTime = createTime;
        this.createUser = createUser;
        this.ckey = ckey;
        this.code = code;
        this.userid = userid;
    }

    @Generated(hash = 1702844933)
    public UserOnlineMapDataBean() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getPid() {
        return pid;
    }

    public void setPid(int pid) {
        this.pid = pid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCval() {
        return cval;
    }

    public void setCval(String cval) {
        this.cval = cval;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public int getCreateUser() {
        return createUser;
    }

    public void setCreateUser(int createUser) {
        this.createUser = createUser;
    }

    public String getCkey() {
        return ckey;
    }

    public void setCkey(String ckey) {
        this.ckey = ckey;
    }

    public String getUserid() {
        return this.userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public static String replaceOnlineMapAddr(String map_addr) {
        String ret_addr = map_addr;
        int index = map_addr.indexOf("/arcgis/rest");
        if (index != -1) {
            ret_addr = NetRequestURL.getHttpHead() + map_addr.substring(index);
        }
        return ret_addr;
    }
}
