package com.tofly.ghrq_route.module.map.service;

import android.content.Context;

import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.StringRequest;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.tofly.ghrq_route.base.BaseApp;
import com.tofly.ghrq_route.base.url.NetRequestURL;
import com.tofly.ghrq_route.base.URLResponseCode;
import com.tofly.ghrq_route.module.map.controller.MapServiceCallback;
import com.tofly.ghrq_route.module.map.domain.LayerSidBean;
import com.tofly.ghrq_route.module.pipeAnalyze.domain.PipeAnalysisResultBean;
import com.tofly.ghrq_route.module.pipeAnalyze.domain.PipeAnalyzeFindTaskBean;
import com.tofly.ghrq_route.module.pipeAnalyze.domain.PipeAnalyzeStatusBean;
import com.tofly.ghrq_route.module.sqlite.DBDaoHelper;
import com.tofly.ghrq_route.module.user.domain.UserBean;
import com.tofly.ghrq_route.module.user.domain.UserOnlineMapDataBean;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapServiceImpl {
    private DBDaoHelper dbDaoHelper;

    private static final String usertoken_text = "usertoken";
    private static final String summary_text = "summary";
    private static final String pipe_name_text = "pipefeatureclassname";
    private static final String pipe_id_text = "pipeobjectid";
    private static final String commit_format_text = "f";
    private static final String commit_format_value = "json";
    private static final String search_layerids_text = "layerids";
    private static final String search_fileds_text = "layerdbname";

    public MapServiceImpl(){
        dbDaoHelper = DBDaoHelper.getInstance();
    }

    public void commitPipeAnalyzePoint(Context context, final double x, final double y, final MapServiceCallback mapServiceCallback) {
        String url = NetRequestURL.getMapConfigUrl();
        //Http post请求,用户登录
        StringRequest postRequest = new StringRequest(Request.Method.POST,
                url, response -> {
                    URLResponseCode.URLResponse responseCode = new URLResponseCode.URLResponse(response);
                    if (responseCode.getCode() == URLResponseCode.ErrorCode.SUCCESS){
                        mapServiceCallback.onCommitPipeAnalyzePoint(true, responseCode.getCode(), responseCode.getMessage());
                    }else {
                        mapServiceCallback.onCommitPipeAnalyzePoint(false, responseCode.getCode(), responseCode.getMessage());
                    }
                }, error -> {
                    //登录失败
                    if (error.networkResponse != null) {
                        try {
                            String errString = new String(error.networkResponse.data, "UTF-8");
                            mapServiceCallback.onCommitPipeAnalyzePoint(false, error.networkResponse.statusCode, errString);
                        } catch (UnsupportedEncodingException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                            mapServiceCallback.onCommitPipeAnalyzePoint(false, error.networkResponse.statusCode, null);
                        }
                    }else {
                        String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                        mapServiceCallback.onCommitPipeAnalyzePoint(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString);
                    }
                }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("x", x + "");
                params.put("y", y + "");
                params.put("isuse", "true");
                return params;
            }

            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return NetRequestURL.newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    public String layerInfoUrl = "/exts/TFGeoAPISOE/getLayerInfor";
    public void getLayerInfo(Context context, String gisToken, String pipe_id, MapServiceCallback mapServiceCallback) {
        UserBean userBean = BaseApp.getInstance().getLoginUser();
        String urlQuery = NetRequestURL.ONLINE_PIPE_INTERNAL;
        UserOnlineMapDataBean.MAP_CODE_KEY MAP_BURST =
                UserOnlineMapDataBean.MAP_CODE_KEY.Code(UserOnlineMapDataBean.MAP_CODE_KEY.MAP_CODE_PIPE.getCode());
        UserOnlineMapDataBean burstDataBean =
                dbDaoHelper.getUserOnlineMapData(userBean.getUserid(), MAP_BURST.getCode());
        if (burstDataBean != null) {
            String burst_url = burstDataBean.getCval();
            if (burst_url != null && !burst_url.isEmpty()){
                urlQuery = NetRequestURL.getReplaceUrl(burst_url) + layerInfoUrl;
            }
        }

        StringRequest postRequest = new StringRequest(Request.Method.POST,
                urlQuery, response -> {
            URLResponseCode.URLResponse responseCode = URLResponseCode.URLResponse.FastResponse(response);
            String layerdbname = responseCode.queryRows("layerdbname");
            if (layerdbname != null) {
                mapServiceCallback.onGetLayerInfo(true, responseCode.getCode(), responseCode.getMessage(), layerdbname);
            }else  {
                mapServiceCallback.onGetLayerInfo(false, responseCode.getCode(), responseCode.getMessage(), layerdbname);
            }

        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    mapServiceCallback.onGetLayerInfo(false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    mapServiceCallback.onGetLayerInfo(false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                mapServiceCallback.onGetLayerInfo(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<>();
                params.put(usertoken_text, gisToken);
                params.put(search_layerids_text, "[" + pipe_id + "]");
                params.put(commit_format_text, commit_format_value);
                return params;
            }

        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }


    public void submitPipeAnalyzeJob(Context context, String gisToken, String pipe_id, String featureName, MapServiceCallback mapServiceCallback) {
        UserBean userBean = BaseApp.getInstance().getLoginUser();
        String urlQuery = NetRequestURL.ONLINE_BURST_INTERNAL;
        UserOnlineMapDataBean.MAP_CODE_KEY MAP_BURST =
                UserOnlineMapDataBean.MAP_CODE_KEY.Code(UserOnlineMapDataBean.MAP_CODE_KEY.MAP_CODE_BURST.getCode());
        UserOnlineMapDataBean burstDataBean =
                dbDaoHelper.getUserOnlineMapData(userBean.getUserid(), MAP_BURST.getCode());
        if (burstDataBean != null) {
            String burst_url = burstDataBean.getCval();
            if (burst_url != null && !burst_url.isEmpty()){
                urlQuery = NetRequestURL.getReplaceUrl(burst_url) + "/submitJob";
            }
        }

        StringRequest postRequest = new StringRequest(Request.Method.POST,
                urlQuery, response -> {
            URLResponseCode.URLResponse responseCode = URLResponseCode.URLResponse.FastResponse(response);
            String jobId = responseCode.queryResult("jobId");
            mapServiceCallback.onSubmitPipeAnalyzeJobt(true, responseCode.getCode(), responseCode.getMessage(), jobId);
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    mapServiceCallback.onSubmitPipeAnalyzeJobt(false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    mapServiceCallback.onSubmitPipeAnalyzeJobt(false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                mapServiceCallback.onSubmitPipeAnalyzeJobt(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<>();
                params.put(usertoken_text, gisToken);
                params.put(pipe_id_text, pipe_id);
                params.put(pipe_name_text, featureName);
                params.put(commit_format_text, commit_format_value);
                return params;
            }

        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    public void getPipeAnalyzeJobStatus(Context context, String tag, String job_id, MapServiceCallback mapServiceCallback) {
        UserBean userBean = BaseApp.getInstance().getLoginUser();
        String urlQuery = NetRequestURL.ONLINE_BURST_INTERNAL + "/jobs/" + job_id + "?f=json";
        UserOnlineMapDataBean.MAP_CODE_KEY MAP_BURST =
                UserOnlineMapDataBean.MAP_CODE_KEY.Code(UserOnlineMapDataBean.MAP_CODE_KEY.MAP_CODE_BURST.getCode());
        UserOnlineMapDataBean burstDataBean =
                dbDaoHelper.getUserOnlineMapData(userBean.getUserid(), MAP_BURST.getCode());
        if (burstDataBean != null) {
            String burst_url = burstDataBean.getCval();
            if (burst_url != null && !burst_url.isEmpty()){
                urlQuery = NetRequestURL.getReplaceUrl(burst_url) + "/jobs/" + job_id + "?f=json";
            }
        }

        StringRequest postRequest = new StringRequest(Request.Method.GET,
                urlQuery, response -> {
            URLResponseCode.URLResponse responseCode = URLResponseCode.URLResponse.FastResponse(response);
            if (responseCode.getCode() == URLResponseCode.ErrorCode.SUCCESS){
                String rowsArray = responseCode.getResult();
                PipeAnalyzeStatusBean statusBean = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                if (rowsArray != null) {
                    try {
                        Gson gson = new Gson();
                        PipeAnalyzeStatusBean bean = gson.fromJson(rowsArray, new TypeToken<PipeAnalyzeStatusBean>(){}.getType());
                        if (bean != null) {
                            statusBean = bean;
                            resCode = responseCode.getCode();
                            parseErrMsg = responseCode.getMessage();
                            result = true;
                        }
                    } catch (Exception e) {
                        mapServiceCallback.onGetPipeAnalyzeJobStatus(false, resCode, parseErrMsg, null);
                    }
                }
                mapServiceCallback.onGetPipeAnalyzeJobStatus(result, resCode, parseErrMsg, statusBean);
            }else {
                mapServiceCallback.onGetPipeAnalyzeJobStatus(false, responseCode.getCode(), responseCode.getMessage(), null);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    mapServiceCallback.onGetPipeAnalyzeJobStatus(false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    mapServiceCallback.onGetPipeAnalyzeJobStatus(false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                mapServiceCallback.onGetPipeAnalyzeJobStatus(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<>();
                return params;
            }
        };
        BaseApp.addRequest(context.getClass().getName() + tag, postRequest);
    }

    public void getPipeAnalyzeResult(Context context, String job_id, String paramUrl, MapServiceCallback mapServiceCallback) {
        UserBean userBean = BaseApp.getInstance().getLoginUser();
        String urlQuery = NetRequestURL.ONLINE_BURST_INTERNAL + "/jobs/" + job_id + "/" + paramUrl + "?f=json";
        UserOnlineMapDataBean.MAP_CODE_KEY MAP_BURST =
                UserOnlineMapDataBean.MAP_CODE_KEY.Code(UserOnlineMapDataBean.MAP_CODE_KEY.MAP_CODE_BURST.getCode());
        UserOnlineMapDataBean burstDataBean =
                dbDaoHelper.getUserOnlineMapData(userBean.getUserid(), MAP_BURST.getCode());
        if (burstDataBean != null) {
            String burst_url = burstDataBean.getCval();
            if (burst_url != null && !burst_url.isEmpty()){
                urlQuery = NetRequestURL.getReplaceUrl(burst_url) + "/jobs/" + job_id + "/" + paramUrl + "?f=json";
            }
        }

        StringRequest postRequest = new StringRequest(Request.Method.GET,
                urlQuery, response -> {
            URLResponseCode.URLResponse responseCode = URLResponseCode.URLResponse.FastResponse(response);
            if (responseCode.getCode() == URLResponseCode.ErrorCode.SUCCESS){
                String rowsArray = responseCode.queryResult("value");
                PipeAnalysisResultBean resultBean = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                if (rowsArray != null) {
                    try {
                        Gson gson = new Gson();
                        PipeAnalysisResultBean bean = gson.fromJson(rowsArray, new TypeToken<PipeAnalysisResultBean>(){}.getType());
                        if (bean != null) {
                            resultBean = bean;
                            resCode = responseCode.getCode();
                            parseErrMsg = responseCode.getMessage();
                            result = true;
                        }
                    } catch (Exception e) {
                        mapServiceCallback.onGetPipeAnalyzeResult(false, resCode, parseErrMsg, null);
                    }
                }
                mapServiceCallback.onGetPipeAnalyzeResult(result, resCode, parseErrMsg, resultBean);
            }else {
                mapServiceCallback.onGetPipeAnalyzeResult(false, responseCode.getCode(), responseCode.getMessage(), null);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    mapServiceCallback.onGetPipeAnalyzeResult(false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    mapServiceCallback.onGetPipeAnalyzeResult(false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                mapServiceCallback.onGetPipeAnalyzeResult(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<>();
                return params;
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    public void pipeAnalyzeFindTask(Context context, String job_url, String layername, MapServiceCallback mapServiceCallback) {
        String urlQuery = job_url + "/find?f=json" + "&searchFields=" + search_fileds_text + "&searchText=" + layername + "&layers=0,1";
        StringRequest postRequest = new StringRequest(Request.Method.GET,
                urlQuery, response -> {
            URLResponseCode.URLResponse responseCode = URLResponseCode.URLResponse.FastResponse(response);
            if (responseCode.getCode() == URLResponseCode.ErrorCode.SUCCESS){
                String rowsArray = responseCode.queryResult("results");
                List<PipeAnalyzeFindTaskBean> taskList = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                if (rowsArray != null) {
                    try {
                        Gson gson = new Gson();
                        List<PipeAnalyzeFindTaskBean> taskBeans = gson.fromJson(rowsArray, new TypeToken<List<PipeAnalyzeFindTaskBean>>(){}.getType());
                        if (taskBeans != null) {
                            taskList = taskBeans;
                            resCode = responseCode.getCode();
                            parseErrMsg = responseCode.getMessage();
                            result = true;
                        }
                    } catch (Exception e) {
                        mapServiceCallback.onPipeAnalyzeFindTask(false, resCode, parseErrMsg, null);
                    }
                }
                mapServiceCallback.onPipeAnalyzeFindTask(result, resCode, parseErrMsg, taskList);
            }else {
                mapServiceCallback.onPipeAnalyzeFindTask(false, responseCode.getCode(), responseCode.getMessage(), null);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    mapServiceCallback.onPipeAnalyzeFindTask(false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    mapServiceCallback.onPipeAnalyzeFindTask(false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                mapServiceCallback.onPipeAnalyzeFindTask(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<>();
                return params;
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    public void getLayerIdBySid(Context context, String sid, MapServiceCallback mapServiceCallback) {
        String urlQuery = NetRequestURL.newApi_dyrq.getQrcodeLayerUrl()  + "?sbid=" + sid;
        StringRequest postRequest = new StringRequest(Request.Method.GET,
                urlQuery, response -> {
            URLResponseCode.URLResponse responseCode = URLResponseCode.URLResponse.FastResponse(response);
            if (responseCode.getCode() == URLResponseCode.ErrorCode.SUCCESS){
                String rowsArray = responseCode.queryResult("results");
                LayerSidBean layerSidBean = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                if (rowsArray != null) {
                    try {
                        Gson gson = new Gson();
                        LayerSidBean sidBean = gson.fromJson(rowsArray, new TypeToken<LayerSidBean>(){}.getType());
                        if (sidBean != null) {
                            layerSidBean = sidBean;
                            resCode = responseCode.getCode();
                            parseErrMsg = responseCode.getMessage();
                            result = true;
                        }
                    } catch (Exception e) {
                        mapServiceCallback.onGetLayerIdBySid(false, resCode, parseErrMsg, layerSidBean);
                    }
                }
                mapServiceCallback.onGetLayerIdBySid(result, resCode, parseErrMsg, layerSidBean);
            }else {
                mapServiceCallback.onGetLayerIdBySid(false, responseCode.getCode(), responseCode.getMessage(), null);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    mapServiceCallback.onGetLayerIdBySid(false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    mapServiceCallback.onGetLayerIdBySid(false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                mapServiceCallback.onGetLayerIdBySid(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            public Map<String, String> getHeaders() {
                return NetRequestURL.newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    public void query_device_by_sid(Context context, String sid, MapServiceCallback mapServiceCallback) {
        UserBean userBean = BaseApp.getInstance().getLoginUser();
        String urlQuery = NetRequestURL.ONLINE_PIPE_INTERNAL + "/find?f=json&searchText=" + sid + "&layers=" + NetRequestURL.newApi_dyrq.Const.ALL_LAYER_IDS;
        UserOnlineMapDataBean.MAP_CODE_KEY MAP_PIPE =
                UserOnlineMapDataBean.MAP_CODE_KEY.Code(UserOnlineMapDataBean.MAP_CODE_KEY.MAP_CODE_PIPE.getCode());
        UserOnlineMapDataBean pipeDataBean =
                dbDaoHelper.getUserOnlineMapData(userBean.getUserid(), MAP_PIPE.getCode());
        if (pipeDataBean != null) {
            String pipe_url = pipeDataBean.getCval();
            if (pipe_url != null && !pipe_url.isEmpty()){
                urlQuery = NetRequestURL.getReplaceUrl(pipe_url) + "/find?f=json&searchText=" + sid + "&layers=" + NetRequestURL.newApi_dyrq.Const.ALL_LAYER_IDS;
            }
        }
        StringRequest postRequest = new StringRequest(Request.Method.GET,
                urlQuery, response -> {
            URLResponseCode.URLResponse responseCode = URLResponseCode.URLResponse.FastResponse(response);
            if (responseCode.getCode() == URLResponseCode.ErrorCode.SUCCESS){
                String rowsArray = responseCode.getResult();
                JsonObject jsonGeometry = null;
                JsonObject jsonAttributes = null;
                String tableName = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                if (rowsArray != null) {
                    try {
                        Gson gson = new Gson();
                        JsonObject configs = gson.fromJson(rowsArray, new TypeToken<JsonObject>() {}.getType());
                        if (configs != null) {
                            JsonArray results = configs.getAsJsonArray("results");
                            JsonObject result0 = results.get(0).getAsJsonObject();
                            if (result0 != null) {
                                jsonGeometry = result0.getAsJsonObject("geometry");
                                jsonAttributes = result0.getAsJsonObject("attributes");
                                tableName = result0.get("layerName").getAsString();
                                resCode = responseCode.getCode();
                                parseErrMsg = responseCode.getMessage();
                                result = true;
                            }
                        }
                    } catch (Exception e) {
                        mapServiceCallback.onQueryMapBySid(false, resCode, parseErrMsg, null, null, null);
                    }
                }
                mapServiceCallback.onQueryMapBySid(result, resCode, parseErrMsg, jsonAttributes, jsonGeometry, tableName);
            }else {
                mapServiceCallback.onQueryMapBySid(false, responseCode.getCode(), responseCode.getMessage(), null, null, null);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    mapServiceCallback.onQueryMapBySid(false, error.networkResponse.statusCode, errString, null, null, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    mapServiceCallback.onQueryMapBySid(false, error.networkResponse.statusCode, null, null, null, null);
                }
            } else {
                String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                mapServiceCallback.onQueryMapBySid(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null, null, null);
            }
        }){
            @Override
            protected Response<String> parseNetworkResponse(NetworkResponse response) {
                String parsed;
                try {
                    parsed = new String(response.data, "UTF-8");
                } catch (UnsupportedEncodingException var4) {
                    parsed = new String(response.data);
                }
                return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response));
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }
}
