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

import android.content.Context;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.mgq.base.utils.string.StringUtil;
import com.tofly.ghrq_route.base.BaseApp;
import com.tofly.ghrq_route.base.C;
import com.tofly.ghrq_route.base.url.NetRequestURL;
import com.tofly.ghrq_route.base.URLResponseCode;
import com.tofly.ghrq_route.base.URLResponseCode.URLResponse;
import com.tofly.ghrq_route.base.URLResponseCode.ErrorCode;
import com.tofly.ghrq_route.common.util.file.FileUtil;
import com.tofly.ghrq_route.common.util.net.volley.InputStreamVolleyRequest;
import com.tofly.ghrq_route.common.util.net.volley.JsonRequestConstant;
import com.tofly.ghrq_route.common.util.net.volley.MultiPartStringRequest;
import com.tofly.ghrq_route.module.trouble.TroubleDaoHelper;
import com.tofly.ghrq_route.base.url.NetRequestURL.newApi_dyrq;
import com.tofly.ghrq_route.module.trouble.controller.TroubleCallBack;
import com.tofly.ghrq_route.module.trouble.domain.AuditFileBean;
import com.tofly.ghrq_route.module.trouble.domain.AuditSchemeBean;
import com.tofly.ghrq_route.module.trouble.domain.DeviceAttributesBean;
import com.tofly.ghrq_route.module.trouble.domain.PipeAttributesBean;
import com.tofly.ghrq_route.module.trouble.domain.RestrictFileBean;
import com.tofly.ghrq_route.module.trouble.domain.TroubleAudioBean;
import com.tofly.ghrq_route.module.trouble.domain.TroubleBean;
import com.tofly.ghrq_route.module.trouble.domain.TroubleEventType;
import com.tofly.ghrq_route.module.trouble.domain.TroublePictureBean;
import com.tofly.ghrq_route.module.trouble.domain.TroublePlanRecordBean;

import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * Created by Amu on 2017/3/8.
 */

public class TroubleServiceImpl implements ITroubleService {
    private Context mContext;

    private TroubleDaoHelper troubleDaoHelper;

    public TroubleServiceImpl(Context context){
        mContext = context;
        troubleDaoHelper = TroubleDaoHelper.getInstance();
    }

    @Override
    public void getTroubleList(Context context, String userid, int select_state, String keyword, final int pageindex, final int pagesize, final TroubleCallBack troubleCallBack) {
        //Http post请求,获取隐患列表
        String url = newApi_dyrq.getTroubleListUrl() + "?current=" + pageindex + "&size=" + pagesize;
        if (userid != null && !userid.isEmpty()) {
            switch (select_state) {
                case TroubleBean.TROUBLE_SELECT_UNDERTAKER_ASSIGN_SCHEME_VERIFY: {
                    String arras = StringUtil.arrayToString(TroubleBean.TROUBLE_UNDERTAKER_PROCESS, ',');
                    url += "&processIds=" + arras + "&teamUserId=" + userid;
                }
                    break;
                case TroubleBean.TROUBLE_SELECT_UNDERSECTARY_ASSIGN_SCHEME_VERIFY: {
                    String arras = StringUtil.arrayToString(TroubleBean.TROUBLE_UNDER_SECTARY_PROCESS, ',');
                    url += "&processIds=" + arras;
                }
                break;
                case TroubleBean.TROUBLE_SELECT_JOB_TAKER_EXECUTE: {
                    String arras = StringUtil.arrayToString(TroubleBean.TROUBLE_JOB_EXECUTE_PROCESS, ',');
                    url += "&processIds=" + arras + "&handleUserid=" + userid;
                }
                    break;
                case TroubleBean.TROUBLE_SELECT_MY_TROUBLE: {
                    url += "&userId=" + userid;
                }
                    break;
                default: {
                    if (keyword != null && !keyword.isEmpty()) {
                        url += "&troubleName=" + keyword;
                    }
                }
                    break;
            }
        }
        StringRequest postRequest = new StringRequest(Request.Method.GET,
                url, response -> {
                    URLResponseCode.URLResponse responseCode = new URLResponseCode.URLResponse(response);
                    if (responseCode.getCode() == URLResponseCode.ErrorCode.SUCCESS){
                        String rowsArray = responseCode.queryResult("records");
                        List<TroubleBean> troubleBeanList = null;
                        int resCode = -1;
                        boolean result = false;
                        String parseErrMsg = "用户解析失败";
                        int total = 0;
                        String strTotal = responseCode.queryResult("total");
                        if (strTotal != null && !strTotal.isEmpty()){
                            total = Integer.parseInt(strTotal);
                        }
                        if (rowsArray != null){
                            try {
                                Gson gson = new Gson();
                                List<TroubleBean> troubleBeens = gson.fromJson(rowsArray, new TypeToken<List<TroubleBean>>(){}.getType());
                                if (troubleBeens != null && troubleBeens.size() >= 0){
                                    troubleBeanList = troubleBeens;
                                    resCode = responseCode.getCode();
                                    parseErrMsg = responseCode.getMessage();
                                    result = true;
                                    //saveTroubles(troubleBeanList);
                                }
                            }catch (Exception e){
                                troubleCallBack.onGetTroubleList(false, resCode, parseErrMsg, null, 0);
                            }
                        }
                        troubleCallBack.onGetTroubleList(result, resCode, parseErrMsg, troubleBeanList, total);
                    }else {
                        troubleCallBack.onGetTroubleList(
                                false, responseCode.getCode(), responseCode.getMessage(), null, 0);
                    }
                }, error -> {
                    //登录失败
                    if (error.networkResponse != null) {
                        try {
                            String errString = new String(error.networkResponse.data, "UTF-8");
                            troubleCallBack.onGetTroubleList(
                                    false, error.networkResponse.statusCode, errString, null, 0);
                        } catch (UnsupportedEncodingException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                            troubleCallBack.onGetTroubleList(
                                    false, error.networkResponse.statusCode, null, null, 0);
                        }
                    }else {
                        String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                        troubleCallBack.onGetTroubleList(
                                false, ErrorCode.HTTPCONN_TIMEOUT, errString, null, 0);
                    }
                }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    private void saveTroubles(List<TroubleBean> troubleBeans){
        if (troubleBeans != null && troubleBeans.size() > 0){
            for (TroubleBean troubleBean : troubleBeans){
                troubleBean.setSave_state(TroubleBean.SERVER_STATE);
            }
            troubleDaoHelper.insertOrUpdateTroubles(troubleBeans);
        }
    }

    @Override
    public void getTroubleAudio(final String token, final String url, final TroubleCallBack troubleCallBack) {
        //Http post请求,用户登录
        InputStreamVolleyRequest getRequest = new InputStreamVolleyRequest(Request.Method.GET, url, response -> {
            // TODO handle the response
            String fileDir = FileUtil.tempFileDir();
            String fileName = UUID.randomUUID().toString() + ".amr";
            File file = new File(fileDir, fileName);
            try {
                if (response != null){
                    InputStream input = new ByteArrayInputStream(response);
                    BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file));
                    byte data[] = new byte[1024];
                    int count;
                    while ((count = input.read(data)) != -1) {
                        outputStream.write(data, 0, count);
                    }
                    outputStream.flush();
                    outputStream.close();
                    input.close();

                    if (file.exists()){
                        troubleCallBack.onGetTroubleAudio(true, 0, null, file.getPath());
                    }else {
                        String errMsg = "用户解析失败";
                        troubleCallBack.onGetTroubleAudio(false, -1, errMsg, null);
                    }
                }
            }catch (Exception e){
                String errMsg = "用户解析失败";
                troubleCallBack.onGetTroubleAudio(false, -1, errMsg, null);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //登录失败
                if (error.networkResponse != null) {
                    try {
                        String errString = new String(error.networkResponse.data, "UTF-8");
                        troubleCallBack.onGetTroubleAudio(false, error.networkResponse.statusCode, errString, null);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        troubleCallBack.onGetTroubleAudio(false, error.networkResponse.statusCode, null, null);
                    }
                }else {
                    String errString = URLResponseCode.ErrorCode.getErrorMessage(URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT);
                    troubleCallBack.onGetTroubleAudio(false, URLResponseCode.ErrorCode.HTTPCONN_TIMEOUT, errString, null);
                }
            }
        }, null){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addStreamRequest(mContext.getClass().getName(), getRequest);
    }

    @Override
    public void getTroubleFile(Context context, String url, final String fileName, String dirPath, TroubleCallBack troubleCallBack) {
        //Http post请求,用户登录
        InputStreamVolleyRequest getRequest = new InputStreamVolleyRequest(Request.Method.GET, url, response -> {
            // TODO handle the response
            String fileDir = dirPath;
            if (fileDir == null || fileDir.isEmpty()) {
                fileDir = FileUtil.tempFileDir();
            }
            File file = new File(fileDir, fileName);
            try {
                if (response != null){
                    InputStream input = new ByteArrayInputStream(response);
                    BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file));
                    byte data[] = new byte[1024];
                    int count;
                    while ((count = input.read(data)) != -1) {
                        outputStream.write(data, 0, count);
                    }
                    outputStream.flush();
                    outputStream.close();
                    input.close();

                    if (file.exists()){
                        troubleCallBack.onGetTroubleFile(true, 0, null, file.getPath());
                    }else {
                        String errMsg = "用户解析失败";
                        troubleCallBack.onGetTroubleFile(false, -1, errMsg, null);
                    }
                }
            }catch (Exception e){
                String errMsg = "用户解析失败";
                troubleCallBack.onGetTroubleFile(false, -1, errMsg, null);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //登录失败
                if (error.networkResponse != null) {
                    try {
                        String errString = new String(error.networkResponse.data, "UTF-8");
                        troubleCallBack.onGetTroubleFile(false, error.networkResponse.statusCode, errString, null);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        troubleCallBack.onGetTroubleFile(false, error.networkResponse.statusCode, null, null);
                    }
                }else {
                    String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                    troubleCallBack.onGetTroubleFile(false, ErrorCode.HTTPCONN_TIMEOUT, errString, null);
                }
            }
        }, null){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addStreamRequest(context.getClass().getName(), getRequest);
    }

    @Override
    public void getTroubleInfo(Context context, String troubleid, final TroubleCallBack troubleCallBack) {
        //Http post请求,获取隐患列表
        String url = newApi_dyrq.getTroubleInfoUrl() + troubleid;
        StringRequest postRequest = new StringRequest(Request.Method.GET,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                String rowsArray = responseCode.getResult();
                TroubleBean troubleBean = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                if (rowsArray != null){
                    try {
                        Gson gson = new Gson();
                        TroubleBean trouble = gson.fromJson(rowsArray, new TypeToken<TroubleBean>(){}.getType());
                        if (trouble != null){
                            troubleBean = trouble;
                            resCode = responseCode.getCode();
                            parseErrMsg = responseCode.getMessage();
                            result = true;
                        }
                    }catch (Exception e){
                        troubleCallBack.onGetTroubleInfo(false, resCode, parseErrMsg, null);
                    }
                }
                troubleCallBack.onGetTroubleInfo(result, resCode, parseErrMsg, troubleBean);
            }else {
                troubleCallBack.onGetTroubleInfo(
                        false, responseCode.getCode(), responseCode.getMessage(), null);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onGetTroubleInfo(
                            false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onGetTroubleInfo(
                            false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onGetTroubleInfo(
                        false, ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    private void saveTrouble(TroubleBean troubleBean){
        troubleDaoHelper.insertOrUpdateTrouble(troubleBean);
    }

    @Override
    public void getTroubleEventType(Context context, TroubleCallBack troubleCallBack) {
        final int pageindex = 1;
        final int pagesize = C.DEFAULT_MAX_LOAD_PAGESIZE;
        String url = newApi_dyrq.getTroubleEventTypeListUrl() + "?current=" + pageindex + "&size=" + pagesize;
        StringRequest postRequest = new StringRequest(Request.Method.GET,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                String rowsArray = responseCode.queryResult("records");
                List<TroubleEventType> eventTypeList = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                int total = 0;
                String strTotal = responseCode.queryResult("total");
                if (strTotal != null && !strTotal.isEmpty()){
                    total = Integer.parseInt(strTotal);
                }
                if (rowsArray != null){
                    try {
                        Gson gson = new Gson();
                        List<TroubleEventType> eventTypes = gson.fromJson(rowsArray, new TypeToken<List<TroubleEventType>>(){}.getType());
                        if (eventTypes != null && eventTypes.size() > 0){
                            eventTypeList = eventTypes;
                            resCode = responseCode.getCode();
                            parseErrMsg = responseCode.getMessage();
                            result = true;
                        }
                    }catch (Exception e){
                        troubleCallBack.onGetDatas(false, resCode, parseErrMsg, null, 0);
                    }
                }
                troubleCallBack.onGetDatas(result, resCode, parseErrMsg, eventTypeList, total);
            }else {
                troubleCallBack.onGetDatas(
                        false, responseCode.getCode(), responseCode.getMessage(), null, 0);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onGetDatas(
                            false, error.networkResponse.statusCode, errString, null, 0);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onGetDatas(
                            false, error.networkResponse.statusCode, null, null, 0);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onGetDatas(false, ErrorCode.HTTPCONN_TIMEOUT, errString, null, 0);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void addTroubleRecord(final String token, final String tableid, final List<TroublePictureBean> photos, final List<TroubleAudioBean> audios, final String notes, final TroubleCallBack troubleCallBack) {
        String url = NetRequestURL.getAddTroubleRecordUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                URLResponse responseCode = new URLResponse(response);
                if (responseCode.getCode() == ErrorCode.SUCCESS){
                    troubleCallBack.onAddTroubleRecord(true, responseCode.getCode(), responseCode.getMessage());
                }else {
                    troubleCallBack.onAddTroubleRecord(false, responseCode.getCode(), responseCode.getMessage());
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //登录失败
                if (error.networkResponse != null) {
                    try {
                        String errString = new String(error.networkResponse.data, "UTF-8");
                        troubleCallBack.onAddTroubleRecord(false, error.networkResponse.statusCode, errString);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        troubleCallBack.onAddTroubleRecord(false, error.networkResponse.statusCode, null);
                    }
                }else {
                    String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                    troubleCallBack.onAddTroubleRecord(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
                }
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("token", token);
                return params;
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                params.put("temp_id", tableid);
                if (notes != null && !notes.isEmpty())
                    params.put("notes", notes);
                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                int count = 1;
                if (photos != null && photos.size() > 0){
                    for (int i = 0; i < photos.size(); i++, count++){
                        TroublePictureBean pictureBean = photos.get(i);
                        String file = pictureBean.getFilepath();
                        String time = pictureBean.getCreateTime();
                        String key = "file" + count + "," + 0 + "," + time;
                        if (file != null && !file.isEmpty())
                            params.put(key, new File(file));
                    }
                }
                if (audios != null && audios.size() > 0){
                    for (int i = 0; i < audios.size(); i++, count++){
                        TroubleAudioBean record = audios.get(i);
                        String file = record.getPath();
                        int second = record.getSecond();
                        String time = record.getCreateTime();
                        String key = "file" + count + "," + second + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(mContext.getClass().getName(), postRequest);
    }

    @Override
    public void getTroubleRecordList(final String token, final String tableid, final String searchDate, final int pageindex, final int pagesize, final TroubleCallBack troubleCallBack)
    {
        String url = NetRequestURL.getTroubleRecordListUrl();
        StringRequest postRequest = new StringRequest(Request.Method.POST,
                url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                URLResponse responseCode = new URLResponse(response);
                if (responseCode.getCode() == ErrorCode.SUCCESS){
                    String rowsArray = responseCode.queryResult("rows");
                    List<TroublePlanRecordBean> recordBeanList = null;
                    int resCode = -1;
                    boolean result = false;
                    String parseErrMsg = "用户解析失败";
                    int total = 0;
                    String strTotal = responseCode.queryResult("total");
                    if (strTotal != null && !strTotal.isEmpty()){
                        total = Integer.parseInt(strTotal);
                    }
                    if (rowsArray != null){
                        try {
                            Gson gson = new Gson();
                            List<TroublePlanRecordBean> recordBeens = gson.fromJson(rowsArray, new TypeToken<List<TroublePlanRecordBean>>(){}.getType());
                            if (recordBeens != null && recordBeens.size() >= 0){
                                recordBeanList = recordBeens;
                                resCode = responseCode.getCode();
                                parseErrMsg = responseCode.getMessage();
                                result = true;
                            }
                        }catch (Exception e){
                            troubleCallBack.onGetTroubleRecordList(false, resCode, parseErrMsg, null, 0);
                        }
                    }
                    troubleCallBack.onGetTroubleRecordList(result, resCode, parseErrMsg, recordBeanList, total);
                }else {
                    troubleCallBack.onGetTroubleRecordList(
                            false, responseCode.getCode(), responseCode.getMessage(), null, 0);
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //登录失败
                if (error.networkResponse != null) {
                    try {
                        String errString = new String(error.networkResponse.data, "UTF-8");
                        troubleCallBack.onGetTroubleRecordList(
                                false, error.networkResponse.statusCode, errString, null, 0);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        troubleCallBack.onGetTroubleRecordList(
                                false, error.networkResponse.statusCode, null, null, 0);
                    }
                }else {
                    String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                    troubleCallBack.onGetTroubleRecordList(
                            false, ErrorCode.HTTPCONN_TIMEOUT, errString, null, 0);
                }
            }
        }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("temp_id", tableid);
                if (searchDate != null && !searchDate.isEmpty())
                    params.put("search_date", searchDate);
                params.put("pageindex", pageindex + "");
                params.put("pagesize", pagesize + "");
                return params;
            }

            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("token", token);
                return params;
            }
        };
        BaseApp.addRequest(mContext.getClass().getName(), postRequest);
    }

    @Override
    public void removeTroubleRecord(final String token, final String tableid, final TroubleCallBack troubleCallBack) {
        String url = NetRequestURL.getRemoveTroubleRecordUrl() + tableid;
        //Http post请求,用户登录
        StringRequest postRequest = new StringRequest(Request.Method.POST,
                url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                URLResponse responseCode = new URLResponse(response);
                if (responseCode.getCode() == ErrorCode.SUCCESS){
                    troubleCallBack.onRemoveTroubleRecord(true, responseCode.getCode(), responseCode.getMessage());
                }else {
                    troubleCallBack.onRemoveTroubleRecord(false, responseCode.getCode(), responseCode.getMessage());
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //登录失败
                if (error.networkResponse != null) {
                    try {
                        String errString = new String(error.networkResponse.data, "UTF-8");
                        troubleCallBack.onRemoveTroubleRecord(false, error.networkResponse.statusCode, errString);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        troubleCallBack.onRemoveTroubleRecord(false, error.networkResponse.statusCode, null);
                    }
                }else {
                    String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                    troubleCallBack.onRemoveTroubleRecord(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
                }
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("token", token);
                return params;
            }
        };
        BaseApp.addRequest(mContext.getClass().getName(), postRequest);
    }

    @Override
    public void addTroubleClearRecord(final String token, final String troubleid, final String plan_point_id, final List<TroublePictureBean> photos, final List<TroubleAudioBean> audios, final String notes, final TroubleCallBack troubleCallBack) {
        String url = NetRequestURL.getAddTroubleClearRecordUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                URLResponse responseCode = new URLResponse(response);
                if (responseCode.getCode() == ErrorCode.SUCCESS){
                    troubleCallBack.onAddTroubleClearRecord(true, responseCode.getCode(), responseCode.getMessage());
                }else {
                    troubleCallBack.onAddTroubleClearRecord(false, responseCode.getCode(), responseCode.getMessage());
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //登录失败
                if (error.networkResponse != null) {
                    try {
                        String errString = new String(error.networkResponse.data, "UTF-8");
                        troubleCallBack.onAddTroubleClearRecord(false, error.networkResponse.statusCode, errString);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        troubleCallBack.onAddTroubleClearRecord(false, error.networkResponse.statusCode, null);
                    }
                }else {
                    String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                    troubleCallBack.onAddTroubleClearRecord(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
                }
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("token", token);
                return params;
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                params.put("tableid", troubleid);
                params.put("temp_id", plan_point_id);
                if (notes != null && !notes.isEmpty())
                    params.put("notes", notes);
                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                int count = 1;
                if (photos != null && photos.size() > 0){
                    for (int i = 0; i < photos.size(); i++, count++){
                        TroublePictureBean pictureBean = photos.get(i);
                        String file = pictureBean.getFilepath();
                        String time = pictureBean.getCreateTime();
                        String key = "file" + count + "," + 0 + "," + time;
                        if (file != null && !file.isEmpty())
                            params.put(key, new File(file));
                    }
                }
                if (audios != null && audios.size() > 0){
                    for (int i = 0; i < audios.size(); i++, count++){
                        TroubleAudioBean record = audios.get(i);
                        String file = record.getPath();
                        int second = record.getSecond();
                        String time = record.getCreateTime();
                        String key = "file" + count + "," + second + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(mContext.getClass().getName(), postRequest);
    }

    @Override
    public void getTroubleClearRecordList(final String token, final String troubleid, final String childPlanId, final int pageindex, final int pagesize, final TroubleCallBack troubleCallBack) {
        String url = NetRequestURL.getTroubleRecordClearUrl();
        StringRequest postRequest = new StringRequest(Request.Method.POST,
                url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                URLResponse responseCode = new URLResponse(response);
                if (responseCode.getCode() == ErrorCode.SUCCESS){
                    String rowsArray = responseCode.queryResult("rows");
                    List<TroublePlanRecordBean> recordBeanList = null;
                    int resCode = -1;
                    boolean result = false;
                    String parseErrMsg = "用户解析失败";
                    int total = 0;
                    String strTotal = responseCode.queryResult("total");
                    if (strTotal != null && !strTotal.isEmpty()){
                        total = Integer.parseInt(strTotal);
                    }
                    if (rowsArray != null){
                        try {
                            Gson gson = new Gson();
                            List<TroublePlanRecordBean> recordBeens = gson.fromJson(rowsArray, new TypeToken<List<TroublePlanRecordBean>>(){}.getType());
                            if (recordBeens != null && recordBeens.size() >= 0){
                                recordBeanList = recordBeens;
                                resCode = responseCode.getCode();
                                parseErrMsg = responseCode.getMessage();
                                result = true;
                            }
                        }catch (Exception e){
                            troubleCallBack.onGetTroubleClearRecord(false, resCode, parseErrMsg, null, 0);
                        }
                    }
                    troubleCallBack.onGetTroubleClearRecord(result, resCode, parseErrMsg, recordBeanList, total);
                }else {
                    troubleCallBack.onGetTroubleClearRecord(
                            false, responseCode.getCode(), responseCode.getMessage(), null, 0);
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //登录失败
                if (error.networkResponse != null) {
                    try {
                        String errString = new String(error.networkResponse.data, "UTF-8");
                        troubleCallBack.onGetTroubleClearRecord(
                                false, error.networkResponse.statusCode, errString, null, 0);
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        troubleCallBack.onGetTroubleClearRecord(
                                false, error.networkResponse.statusCode, null, null, 0);
                    }
                }else {
                    String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                    troubleCallBack.onGetTroubleClearRecord(
                            false, ErrorCode.HTTPCONN_TIMEOUT, errString, null, 0);
                }
            }
        }){
            @Override
            protected Map<String, String> getParams(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("trouble_id", troubleid);
                params.put("child_plan_id", childPlanId);
                params.put("pageindex", pageindex + "");
                params.put("pagesize", pagesize + "");
                return params;
            }
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                Map<String, String> params = new HashMap<String, String>();
                params.put("token", token);
                return params;
            }
        };
        BaseApp.addRequest(mContext.getClass().getName(), postRequest);
    }

    @Override
    public void addTroubleNew(final Context context, final TroubleBean troubleBean, final List<TroublePictureBean> photos,
                              final List<TroubleAudioBean> audios, final List<TroubleAudioBean> files, final TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getUploadTroubleUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
                    URLResponse responseCode = new URLResponse(response);
                    if (responseCode.getCode() == ErrorCode.SUCCESS){
                        troubleCallBack.onAddTrouble(true, responseCode.getCode(), responseCode.getMessage(), null);
                    }else {
                        troubleCallBack.onAddTrouble(false, responseCode.getCode(), responseCode.getMessage(), null);
                    }
                }, error -> {
                    //登录失败
                    if (error.networkResponse != null) {
                        try {
                            String errString = new String(error.networkResponse.data, "UTF-8");
                            troubleCallBack.onAddTrouble(false, error.networkResponse.statusCode, errString, null);
                        } catch (UnsupportedEncodingException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                            troubleCallBack.onAddTrouble(false, error.networkResponse.statusCode, null, null);
                        }
                    }else {
                        String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                        troubleCallBack.onAddTrouble(false, ErrorCode.HTTPCONN_TIMEOUT, errString, null);
                    }
                }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                Map<String, String> headerParams = newApi_dyrq.getHeaderParams();
                headerParams.put("Charset", "utf-8");
                return headerParams;
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患名称*/
                String name = troubleBean.getTroubleName();
                if (name != null && !name.isEmpty()){
                    params.put("troubleName", name);
                }
                /*隐患所属单位*/
                String unitName = troubleBean.getUnitName();
                if (unitName != null && !unitName.isEmpty()){
                    params.put("unitName", unitName);
                }
                /*隐患详情*/
                String troubleInfo = troubleBean.getTroubleInfo();
                if (troubleInfo != null && !troubleInfo.isEmpty()){
                    params.put("troubleInfo", troubleInfo);
                }
                /*隐患地址*/
                String address = troubleBean.getAddress();
                if (address != null && !address.isEmpty()){
                    params.put("address", address);
                }
                int uploadType = troubleBean.getUploadType();
                //params.put("uploadType", uploadType + "");
                if (uploadType == 1) {    //工作日在现场
                    /*隐患类别*/
                    String troubleTypeId = troubleBean.getTroubleTypeId();
                    if (troubleTypeId != null && !troubleTypeId.isEmpty()){
                        params.put("troubleTypeId", troubleTypeId);
                    }
                    /*隐患风险等级*/
                    String levelId = troubleBean.getLevelId();
                    if (levelId != null && !levelId.isEmpty()){
                        params.put("levelId", levelId);
                    }
                    /*承办班长id*/
                    String undertakerUserid = troubleBean.getUndertakerUserid();
                    if (undertakerUserid != null && !undertakerUserid.isEmpty()){
                        params.put("undertakerUserid", undertakerUserid);
                    }
                } else if (uploadType == 2) {    //工作日不在现场
                    /*部门id*/
                    String deptId = troubleBean.getDeptId();
                    if (deptId != null && !deptId.isEmpty()){
                        params.put("deptId", deptId);
                    }
                    /*承办班长id*/
                    String undertakerUserid = troubleBean.getUndertakerUserid();
                    if (undertakerUserid != null && !undertakerUserid.isEmpty()){
                        params.put("undertakerUserid", undertakerUserid);
                    }
                }
                String pipeInfo = troubleBean.getPipeInfo();
                if (pipeInfo != null && !pipeInfo.isEmpty()) {
                    params.put("pipeInfo", pipeInfo);
                }
                String pipeInfoDesc = troubleBean.getPipeInfoDesc();
                if (pipeInfoDesc != null && !pipeInfoDesc.isEmpty()) {
                    params.put("pipeInfoDesc", pipeInfoDesc);
                }

                String deviceInfo = troubleBean.getDeviceInfo();
                if (deviceInfo != null && !deviceInfo.isEmpty()) {
                    params.put("deviceInfo", deviceInfo);
                }
                String deviceInfoDesc = troubleBean.getDeviceInfoDesc();
                if (deviceInfoDesc != null && !deviceInfoDesc.isEmpty()) {
                    params.put("deviceInfoDesc", deviceInfoDesc);
                }
                String findTime = troubleBean.getFindTime();
                if (findTime != null && !findTime.isEmpty()) {
                    params.put("findTime", findTime);
                }
                String locationX = troubleBean.getLocationX();
                if (locationX != null && !locationX.isEmpty()) {
                    params.put("locationX", locationX);
                }
                String locationY = troubleBean.getLocationY();
                if (locationY != null && !locationY.isEmpty()) {
                    params.put("locationY", locationY);
                }
                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                int count = 1;
                if (photos != null && photos.size() > 0){
                    for (int i = 0; i < photos.size(); i++, count++){
                        TroublePictureBean pictureBean = photos.get(i);
                        String file = pictureBean.getFilepath();
                        String time = pictureBean.getCreateTime();
                        long second = pictureBean.getSecond() / 1000;
                        String key = "photo" + count + "," + second + "," + time;
                        if (file != null && !file.isEmpty())
                            params.put(key, new File(file));
                    }
                }
                if (audios != null && audios.size() > 0){
                    for (int i = 0; i < audios.size(); i++, count++){
                        TroubleAudioBean audioBean = audios.get(i);
                        String file = audioBean.getPath();
                        int second = audioBean.getSecond();
                        String time = audioBean.getCreateTime();
                        String key = "audio" + count + "," + second + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                if (files != null && files.size() > 0){
                    for (int i = 0; i < files.size(); i++, count++){
                        TroubleAudioBean audioBean = files.get(i);
                        String file = audioBean.getPath();
                        String time = audioBean.getCreateTime();
                        String key = "other" + count + "," + 0 + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void ondutyUserCheckTrouble(Context context, TroubleBean troubleBean, List<TroublePictureBean> photos,
                                       List<TroubleAudioBean> audios, List<TroubleAudioBean> files, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getOndutyUserCheckUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患id*/
                params.put("id", troubleBean.getId());
                /*隐患详情*/
                String handleResult = troubleBean.getTempHandleResult();
                if (handleResult != null && !handleResult.isEmpty()){
                    params.put("tempHandleProject", handleResult);
                }
                int eventType = troubleBean.getEventType();
                params.put("eventType", eventType + "");
                int trouble_state = troubleBean.getState(); //0：不是隐患 1：是隐患
                if (trouble_state > 0) {    //是隐患
                    /*隐患类别*/
                    String troubleTypeId = troubleBean.getTroubleTypeId();
                    if (troubleTypeId != null && !troubleTypeId.isEmpty()){
                        params.put("troubleTypeId", troubleTypeId);
                    }
                    /*隐患风险等级*/
                    String levelId = troubleBean.getLevelId();
                    if (levelId != null && !levelId.isEmpty()){
                        params.put("levelId", levelId);
                    }
/*                    *//*临时处置方案*//*
                    if (eventType == 1) {    //一般隐患
                        String tempHandleProject = troubleBean.getTempHandleProject();
                        if (tempHandleProject != null && !tempHandleProject.isEmpty()){
                            params.put("tempHandleProject", tempHandleProject);
                        }
                    }*/
                }
/*                String pipeInfo = troubleBean.getPipeInfo();
                if (pipeInfo != null && !pipeInfo.isEmpty()) {
                    params.put("pipeInfo", pipeInfo);
                }
                String pipeInfoDesc = troubleBean.getPipeInfoDesc();
                if (pipeInfoDesc != null && !pipeInfoDesc.isEmpty()) {
                    params.put("pipeInfoDesc", pipeInfoDesc);
                }

                String deviceInfo = troubleBean.getDeviceInfo();
                if (deviceInfo != null && !deviceInfo.isEmpty()) {
                    params.put("deviceInfo", deviceInfo);
                }
                String deviceInfoDesc = troubleBean.getDeviceInfoDesc();
                if (deviceInfoDesc != null && !deviceInfoDesc.isEmpty()) {
                    params.put("deviceInfoDesc", deviceInfoDesc);
                }
                String locationX = troubleBean.getLocationX();
                if (locationX != null && !locationX.isEmpty()) {
                    params.put("locationX", locationX);
                }
                String locationY = troubleBean.getLocationY();
                if (locationY != null && !locationY.isEmpty()) {
                    params.put("locationY", locationY);
                }*/
                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                int count = 1;
                if (photos != null && photos.size() > 0){
                    for (int i = 0; i < photos.size(); i++, count++){
                        TroublePictureBean pictureBean = photos.get(i);
                        String file = pictureBean.getFilepath();
                        String time = pictureBean.getCreateTime();
                        String key = "photo" + count + "," + 0 + "," + time;
                        if (file != null && !file.isEmpty())
                            params.put(key, new File(file));
                    }
                }
                if (audios != null && audios.size() > 0){
                    for (int i = 0; i < audios.size(); i++, count++){
                        TroubleAudioBean audioBean = audios.get(i);
                        String file = audioBean.getPath();
                        int second = audioBean.getSecond();
                        String time = audioBean.getCreateTime();
                        String key = "audio" + count + "," + second + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                if (files != null && files.size() > 0){
                    for (int i = 0; i < files.size(); i++, count++){
                        TroubleAudioBean audioBean = files.get(i);
                        String file = audioBean.getPath();
                        String time = audioBean.getCreateTime();
                        String key = "other" + count + "," + 0 + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void undertakerVerifyTrouble(Context context, TroubleBean troubleBean, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getUndertakerCheckUrl();
        StringRequest postRequest = new StringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public byte[] getBody() {
                JsonObject root = new JsonObject();
                String id = troubleBean.getId();
                root.addProperty("id", id);
                String undertakerHandleUserid = troubleBean.getUndertakerHandleUserId();
                if (undertakerHandleUserid != null && !undertakerHandleUserid.isEmpty()){
                    root.addProperty("undertakerHandleUserid", undertakerHandleUserid);
                }
                String note = troubleBean.getUndertakerCheckNotes();
                if (note != null && !note.isEmpty()) {
                    root.addProperty("undertakerCheckNotes", note);
                }
                Gson gson = new Gson();
                String undertakerCheck = gson.toJson(root);
                return undertakerCheck.getBytes();
            }

            @Override
            public String getBodyContentType() {
                return JsonRequestConstant.PROTOCOL_CONTENT_TYPE;
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void undertakerHandleTrouble(Context context, TroubleBean troubleBean, List<TroublePictureBean> photos,
                                        List<TroubleAudioBean> audios, List<TroubleAudioBean> files, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getUndertakerHandleUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患id*/
                params.put("id", troubleBean.getId());
                /*隐患详情*/
                String handleNotes = troubleBean.getUndertakerHandleNotes();
                if (handleNotes != null && !handleNotes.isEmpty()){
                    params.put("undertakerHandleNotes", handleNotes);
                }
                int eventType = troubleBean.getEventType();
                params.put("state", eventType + "");
                if (eventType == 1) {    //隐患
                    /*隐患类别*/
                    String troubleTypeId = troubleBean.getTroubleTypeId();
                    if (troubleTypeId != null && !troubleTypeId.isEmpty()){
                        params.put("troubleTypeid", troubleTypeId);
                    }
                    /*隐患风险等级*/
                    String levelId = troubleBean.getLevelId();
                    if (levelId != null && !levelId.isEmpty()){
                        params.put("levelid", levelId);
                    }
                }
/*                String pipeInfo = troubleBean.getPipeInfo();
                if (pipeInfo != null && !pipeInfo.isEmpty()) {
                    params.put("pipeInfo", pipeInfo);
                }
                String pipeInfoDesc = troubleBean.getPipeInfoDesc();
                if (pipeInfoDesc != null && !pipeInfoDesc.isEmpty()) {
                    params.put("pipeInfoDesc", pipeInfoDesc);
                }

                String deviceInfo = troubleBean.getDeviceInfo();
                if (deviceInfo != null && !deviceInfo.isEmpty()) {
                    params.put("deviceInfo", deviceInfo);
                }
                String deviceInfoDesc = troubleBean.getDeviceInfoDesc();
                if (deviceInfoDesc != null && !deviceInfoDesc.isEmpty()) {
                    params.put("deviceInfoDesc", deviceInfoDesc);
                }
                String locationX = troubleBean.getLocationX();
                if (locationX != null && !locationX.isEmpty()) {
                    params.put("locationX", locationX);
                }
                String locationY = troubleBean.getLocationY();
                if (locationY != null && !locationY.isEmpty()) {
                    params.put("locationY", locationY);
                }*/
                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                int count = 1;
                if (photos != null && photos.size() > 0){
                    for (int i = 0; i < photos.size(); i++, count++){
                        TroublePictureBean pictureBean = photos.get(i);
                        String file = pictureBean.getFilepath();
                        String time = pictureBean.getCreateTime();
                        String key = "photo" + count + "," + 0 + "," + time;
                        if (file != null && !file.isEmpty())
                            params.put(key, new File(file));
                    }
                }
                if (audios != null && audios.size() > 0){
                    for (int i = 0; i < audios.size(); i++, count++){
                        TroubleAudioBean audioBean = audios.get(i);
                        String file = audioBean.getPath();
                        int second = audioBean.getSecond();
                        String time = audioBean.getCreateTime();
                        String key = "audio" + count + "," + second + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                if (files != null && files.size() > 0){
                    for (int i = 0; i < files.size(); i++, count++){
                        TroubleAudioBean audioBean = files.get(i);
                        String file = audioBean.getPath();
                        String time = audioBean.getCreateTime();
                        String key = "other" + count + "," + 0 + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void underSectaryVerifyAssignTrouble(Context context, TroubleBean troubleBean, AuditSchemeBean schemeBean, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getUnderSectaryCheckUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患id*/
                String id = troubleBean.getId();
                params.put("id", id);
                /*审核状态： 0:转入抢维修 1:继续处理 2:处理完成[必填] 3:是否是存量隐患*/
                int trouble_state = troubleBean.getState();
                params.put("state", trouble_state + "");
                if (trouble_state == 0) {
                    int flag = troubleBean.getFlag();
                    params.put("flag", flag + "");
                    if (schemeBean != null) {
                        String handlerUser = schemeBean.getHandleUserId();
                        params.put("handleUserid", handlerUser);
                        String coprocessor = schemeBean.getCoprocessor();
                        params.put("coprocessor", coprocessor);
                        /*整改方案说明*/
                        String dutyPlanNote = schemeBean.getDutyPlanNote();
                        if (dutyPlanNote != null && !dutyPlanNote.isEmpty()){
                            params.put("dutyPlanNote", dutyPlanNote);
                        }
                    }
                }else if (trouble_state == 1) {
                    String dutyUserId = troubleBean.getMaintainerUserId();
                    if (dutyUserId != null && !dutyUserId.isEmpty()){
                        params.put("otherDutyUserId", dutyUserId);
                    }
                }
                String note = troubleBean.getUndersecretaryCheckNotes();
                if (note != null && !note.isEmpty()) {
                    params.put("undersecretaryCheckNotes", note);
                }
                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                int trouble_state = troubleBean.getState();
                if (trouble_state == 0 && schemeBean != null) { //继续处理
                    /*file1:整改方案*/
                    List<AuditFileBean> rectifyFiles = schemeBean.getRectifyFile();
                    if (rectifyFiles != null && rectifyFiles.size() > 0) {
                        AuditFileBean rectifyFile = rectifyFiles.get(0);
                        String file = rectifyFile.getPath();
                        params.put("rectifyFile", new File(file));
                    }
                    /*file2:管道保护通知书*/
                    rectifyFiles = schemeBean.getProtectNoticeFile();
                    if (rectifyFiles != null && rectifyFiles.size() > 0) {
                        AuditFileBean rectifyFile = rectifyFiles.get(0);
                        String file = rectifyFile.getPath();
                        params.put("protectNoticeFile", new File(file));
                    }
                    /*file3:隐患整改通知书*/
                    rectifyFiles = schemeBean.getRectifyNoticeFile();
                    if (rectifyFiles != null && rectifyFiles.size() > 0) {
                        AuditFileBean rectifyFile = rectifyFiles.get(0);
                        String file = rectifyFile.getPath();
                        params.put("rectifyNoticeFile", new File(file));
                    }
                    /*file4:整改工程决算书*/
                    rectifyFiles = schemeBean.getRectifyFinalFile();
                    if (rectifyFiles != null && rectifyFiles.size() > 0) {
                        AuditFileBean rectifyFile = rectifyFiles.get(0);
                        String file = rectifyFile.getPath();
                        params.put("rectifyFinalFile", new File(file));
                    }
                }

                return params;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void ondutyMakeScheme(Context context, String troubleId, int flag, AuditSchemeBean schemeBean, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getOndutyMakeSchemeUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患id*/
                params.put("id", troubleId);
                if (flag >= 0) {
                    params.put("flag", flag + "");
                }
                String handlerUser = schemeBean.getHandleUserId();
                params.put("handleUserid", handlerUser);
                String coprocessor = schemeBean.getCoprocessor();
                params.put("coprocessor", coprocessor);
                /*整改方案说明*/
                String dutyPlanNote = schemeBean.getDutyPlanNote();
                if (dutyPlanNote != null && !dutyPlanNote.isEmpty()){
                    params.put("dutyPlanNote", dutyPlanNote);
                }

                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                /*file1:整改方案*/
                List<AuditFileBean> rectifyFiles = schemeBean.getRectifyFile();
                if (rectifyFiles != null && rectifyFiles.size() > 0) {
                    AuditFileBean rectifyFile = rectifyFiles.get(0);
                    String file = rectifyFile.getPath();
                    params.put("rectifyFile", new File(file));
                }
                /*file2:管道保护通知书*/
                rectifyFiles = schemeBean.getProtectNoticeFile();
                if (rectifyFiles != null && rectifyFiles.size() > 0) {
                    AuditFileBean rectifyFile = rectifyFiles.get(0);
                    String file = rectifyFile.getPath();
                    params.put("protectNoticeFile", new File(file));
                }
                /*file3:隐患整改通知书*/
                rectifyFiles = schemeBean.getRectifyNoticeFile();
                if (rectifyFiles != null && rectifyFiles.size() > 0) {
                    AuditFileBean rectifyFile = rectifyFiles.get(0);
                    String file = rectifyFile.getPath();
                    params.put("rectifyNoticeFile", new File(file));
                }
                /*file4:整改工程决算书*/
                rectifyFiles = schemeBean.getRectifyFinalFile();
                if (rectifyFiles != null && rectifyFiles.size() > 0) {
                    AuditFileBean rectifyFile = rectifyFiles.get(0);
                    String file = rectifyFile.getPath();
                    params.put("rectifyFinalFile", new File(file));
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void sectaryVerifyScheme(Context context, TroubleBean troubleBean, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getSectaryCheckUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患id*/
                String id = troubleBean.getId();
                params.put("troubleId", id);
                /*审核状态： 0:转入抢维修 1:继续处理 2:处理完成[必填] 3:是否是存量隐患*/
                int verify_state = troubleBean.getState();
                params.put("secretaryCheckState", verify_state + "");
                String note = troubleBean.getNotes();
                if (note != null && !note.isEmpty()) {
                    params.put("secretaryCheckNotes", note);
                }
                return params;
            }

/*            @Override
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<>();
                *//*隐患id*//*
                String id = troubleBean.getId();
                params.put("troubleId", id);
                *//*审核状态： 0:转入抢维修 1:继续处理 2:处理完成[必填] 3:是否是存量隐患*//*
                int verify_state = troubleBean.getState();
                params.put("secretaryCheckState", verify_state + "");
                String note = troubleBean.getNotes();
                if (note != null && !note.isEmpty()) {
                    params.put("secretaryCheckNotes", note);
                }
                return params;
            }*/
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void ondutyHandleScheme(Context context, TroubleBean troubleBean, String handleNotes, List<TroublePictureBean> photos, List<TroubleAudioBean> audios, List<TroubleAudioBean> files, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getOndutyHandleSchemeUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患id*/
                params.put("id", troubleBean.getId());
                /*隐患详情*/
                if (handleNotes != null && !handleNotes.isEmpty()){
                    params.put("handleNote", handleNotes);
                }
                return params;
            }

            @Override
            public Map<String, File> getFileUploads() {
                Map<String, File> params = new HashMap<>();
                int count = 1;
                if (photos != null && photos.size() > 0){
                    for (int i = 0; i < photos.size(); i++, count++){
                        TroublePictureBean pictureBean = photos.get(i);
                        String file = pictureBean.getFilepath();
                        String time = pictureBean.getCreateTime();
                        String key = "photo" + count + "," + 0 + "," + time;
                        if (file != null && !file.isEmpty())
                            params.put(key, new File(file));
                    }
                }
                if (audios != null && audios.size() > 0){
                    for (int i = 0; i < audios.size(); i++, count++){
                        TroubleAudioBean audioBean = audios.get(i);
                        String file = audioBean.getPath();
                        int second = audioBean.getSecond();
                        String time = audioBean.getCreateTime();
                        String key = "audio" + count + "," + second + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                if (files != null && files.size() > 0){
                    for (int i = 0; i < files.size(); i++, count++){
                        TroubleAudioBean audioBean = files.get(i);
                        String file = audioBean.getPath();
                        String time = audioBean.getCreateTime();
                        String key = "file" + count + "," + 0 + "," + time;;
                        if (file != null && !file.isEmpty()){
                            params.put(key, new File(file));
                        }
                    }
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void undersectaryVerifyHandle(Context context, TroubleBean troubleBean, TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getUndersectaryHandleCheckUrl();
        MultiPartStringRequest postRequest = new MultiPartStringRequest(Request.Method.POST,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public Map<String, String> getStringUploads() {
                Map<String, String> params = new HashMap<>();
                /*隐患id*/
                String id = troubleBean.getId();
                params.put("troubleId", id);
                /*审核状态： 0:转入抢维修 1:继续处理 2:处理完成[必填] 3:是否是存量隐患*/
                int verify_state = troubleBean.getState();
                params.put("handleCheck", verify_state + "");
                String note = troubleBean.getNotes();
                if (note != null && !note.isEmpty()) {
                    params.put("handleCheckNote", note);
                }
                return params;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void updatePipeDevice(final Context context, final TroubleBean troubleBean, final TroubleCallBack troubleCallBack) {
        String url = newApi_dyrq.getUpdatePipeDeviceUrl();
        StringRequest postRequest = new StringRequest(Request.Method.PUT,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                troubleCallBack.onSetData(true, responseCode.getCode(), responseCode.getMessage());
            }else {
                troubleCallBack.onSetData(false, responseCode.getCode(), responseCode.getMessage());
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, errString);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onSetData(false, error.networkResponse.statusCode, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onSetData(false, ErrorCode.HTTPCONN_TIMEOUT, errString);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }

            @Override
            public byte[] getBody() {
                JsonObject root = new JsonObject();
                Gson gson = new Gson();
                String troubleId = troubleBean.getId();
                if (troubleId != null && !troubleId.isEmpty()){
                    root.addProperty("id", troubleId);
                }
                List<PipeAttributesBean> pipeInfos = troubleBean.getPipeInfos();
                if (pipeInfos != null && !pipeInfos.isEmpty()) {
                    JsonArray jsonArray = new JsonArray();
                    for (PipeAttributesBean pipeInfo : pipeInfos) {
                        JsonElement pipe = gson.toJsonTree(pipeInfo);
                        jsonArray.add(pipe);
                    }
                    root.add("pipeList", jsonArray);
                }
                String pipeInfoDesc = troubleBean.getPipeInfoDesc();
                if (pipeInfoDesc != null && !pipeInfoDesc.isEmpty()) {
                    root.addProperty("pipeInfo", pipeInfoDesc);
                }
                List<DeviceAttributesBean> deviceInfos = troubleBean.getDeviceInfos();
                if (deviceInfos != null && !deviceInfos.isEmpty()) {
                    JsonArray jsonArray = new JsonArray();
                    for (DeviceAttributesBean deviceInfo : deviceInfos) {
                        JsonElement device = gson.toJsonTree(deviceInfo);
                        jsonArray.add(device);
                    }
                    root.add("deviceList", jsonArray);
                }
                String deviceInfoDesc = troubleBean.getDeviceInfoDesc();
                if (deviceInfoDesc != null && !deviceInfoDesc.isEmpty()) {
                    root.addProperty("deviceInfo", deviceInfoDesc);
                }
                String locationX = troubleBean.getLocationX();
                if (locationX != null && !locationX.isEmpty()) {
                    root.addProperty("locationX", locationX);
                }
                String locationY = troubleBean.getLocationY();
                if (locationY != null && !locationY.isEmpty()) {
                    root.addProperty("locationY", locationY);
                }
                String address = troubleBean.getAddress();
                if (address != null && !address.isEmpty()){
                    root.addProperty("address", address);
                }
                String pipeDevice = gson.toJson(root);
                return pipeDevice.getBytes();
            }

            @Override
            public String getBodyContentType() {
                return JsonRequestConstant.PROTOCOL_CONTENT_TYPE;
            }
        };
        BaseApp.addMultiStatckRequest(context.getClass().getName(), postRequest);
    }

    @Override
    public void getRestrictFileInfo(Context context, final TroubleCallBack troubleCallBack) {
        //Http post请求,获取隐患列表
        String url = newApi_dyrq.getRestrictFileUrl();
        StringRequest postRequest = new StringRequest(Request.Method.GET,
                url, response -> {
            URLResponse responseCode = new URLResponse(response);
            if (responseCode.getCode() == ErrorCode.SUCCESS){
                String rowsArray = responseCode.getResult();
                RestrictFileBean fileBean = null;
                int resCode = -1;
                boolean result = false;
                String parseErrMsg = "用户解析失败";
                if (rowsArray != null){
                    try {
                        Gson gson = new Gson();
                        RestrictFileBean file = gson.fromJson(rowsArray, new TypeToken<RestrictFileBean>(){}.getType());
                        if (file != null){
                            fileBean = file;
                            resCode = responseCode.getCode();
                            parseErrMsg = responseCode.getMessage();
                            result = true;
                        }
                    }catch (Exception e){
                        troubleCallBack.onGetRestrictFileInfo(false, resCode, parseErrMsg, null);
                    }
                }
                troubleCallBack.onGetRestrictFileInfo(result, resCode, parseErrMsg, fileBean);
            }else {
                troubleCallBack.onGetRestrictFileInfo(
                        false, responseCode.getCode(), responseCode.getMessage(), null);
            }
        }, error -> {
            //登录失败
            if (error.networkResponse != null) {
                try {
                    String errString = new String(error.networkResponse.data, "UTF-8");
                    troubleCallBack.onGetRestrictFileInfo(
                            false, error.networkResponse.statusCode, errString, null);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    troubleCallBack.onGetRestrictFileInfo(
                            false, error.networkResponse.statusCode, null, null);
                }
            }else {
                String errString = ErrorCode.getErrorMessage(ErrorCode.HTTPCONN_TIMEOUT);
                troubleCallBack.onGetRestrictFileInfo(
                        false, ErrorCode.HTTPCONN_TIMEOUT, errString, null);
            }
        }){
            @Override
            public Map<String, String> getHeaders(){
                //参数拼装:表单提交方式
                return newApi_dyrq.getHeaderParams();
            }
        };
        BaseApp.addRequest(context.getClass().getName(), postRequest);
    }
}
