Newer
Older
dxcgt / app / src / main / java / com / smartdot / cgt / request / Request.java
wangxitong on 6 Apr 2021 30 KB first commit
package com.smartdot.cgt.request;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;

import com.smartdot.cgt.model.CaseAttach;
import com.smartdot.cgt.model.CaseModel;
import com.smartdot.cgt.model.CaseTaskNum;
import com.smartdot.cgt.model.MessageModel;
import com.smartdot.cgt.model.ResponseResult;
import com.smartdot.cgt.model.UserModel;
import com.smartdot.cgt.util.ApplicationMain;
import com.smartdot.cgt.util.HttpRequestTools;
import com.smartdot.cgt.util.StringUtils;
import com.smartdot.cgt.util.config.CgtConfig;

import org.json.JSONArray;
import org.json.JSONObject;

public class Request {
    private IRequestFormat requestFormat;

    private static Request request;

    private static final Object INSTANCE_LOCK = new Object();

    public static Request getRequest() throws Exception {
        synchronized (INSTANCE_LOCK) {
            if (request == null) {
                request = new Request();
            }
            return request;
        }
    }

    public Request() throws Exception {
        try {
            requestFormat = (IRequestFormat) Class.forName(
                "com.smartdot.cgt.request." + ApplicationMain.getInstance().getCgtConfig().getNowRequestFormat())
                .newInstance();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            throw new Exception("无法访问到后台请求的类!");
        } catch (InstantiationException e) {
            e.printStackTrace();
            throw new Exception("无法实例化后台请求的类!");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            throw new Exception("找不到后台请求的类!");
        }

    }

    /**
     * 登录
     * 
     * @param userId
     * @param password
     * @return
     * @throws IOException
     */
    public ResponseResult<UserModel> login(String userId, String password,String deviceId) throws Exception {
        return requestFormat.login(userId, password,deviceId);
    }

    /**
     * 构造POST参数
     *
     * @param paramNames
     *            参数名
     * @param paramValues
     *            参数值
     * @return
     */
    private String formatReqParam(String[] paramNames, String... paramValues) {

        StringBuilder sb = new StringBuilder();

        String encodingType = ApplicationMain.getInstance().getCgtConfig().getUploadEncoding();
        if (paramValues != null)
            for (int i = 0, count = paramNames.length; i < count; i++) {
                if (sb.length() != 0) {
                    sb.append("&");
                }
                sb.append(paramNames[i]);
                sb.append("=");
                if (paramValues[i] != null && paramValues[i].length() > 0) {
                    try {
                        sb.append(URLEncoder.encode(paramValues[i], encodingType));
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                    }
                }
            }

        return sb.toString();
    }


    public ResponseResult<List<Map<String,String>>> nextNodes() throws IOException {
        ResponseResult<List<Map<String,String>>> responseResult = new ResponseResult<List<Map<String,String>>>();
        try{
            List<Map<String,String>> arr = new ArrayList<Map<String,String>>();
            String url = ApplicationMain.getInstance().getCgtConfig().getRequestUrl() +"/dict/code/commonApproval";
            String token = ApplicationMain.getInstance().getCgtConfig().gettokenStr();
            String typelistResultXml = HttpRequestTools.getwithToken(url,token, null, 0);
            if (!StringUtils.isNullOrEmpty(typelistResultXml)) {
                JSONObject jsonObject = new JSONObject(typelistResultXml);
                JSONArray jsonArray = jsonObject.getJSONArray("data");
                for (int i=0;i<jsonArray.length();i++){
                    Map<String,String> map = new HashMap<>();
                    JSONObject json = jsonArray.getJSONObject(i);
                    map.put("value",json.getString("value"));
                    map.put("name",json.getString("name"));
                    arr.add(map);
                }
                responseResult.setResultObj(arr);
                responseResult.setSuccess(true);
            }else {
                responseResult.setSuccess(false);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return responseResult;
    }

    public ResponseResult<List<Map<String,String>>> nextNodes(String caseState) throws IOException {
        ResponseResult<List<Map<String,String>>> responseResult = new ResponseResult<List<Map<String,String>>>();
        try{
            List<Map<String,String>> arr = new ArrayList<Map<String,String>>();
            String url = ApplicationMain.getInstance().getCgtConfig().getRequestUrl() +"/process/nextNodes/?caseState="+caseState;
            String token = ApplicationMain.getInstance().getCgtConfig().gettokenStr();
            String typelistResultXml = HttpRequestTools.getwithToken(url,token, null, 0);
            if (!StringUtils.isNullOrEmpty(typelistResultXml)) {
                JSONObject jsonObject = new JSONObject(typelistResultXml);
                JSONArray jsonArray = jsonObject.getJSONArray("data");
                for (int i=0;i<jsonArray.length();i++){
                    Map<String,String> map = new HashMap<>();
                    JSONObject json = jsonArray.getJSONObject(i);
                    map.put("nextState",json.getString("nextState"));
                    map.put("nextOperation",json.getString("nextOperation"));
                    map.put("approvalResult",json.getString("approvalResult"));
                    arr.add(map);
                }
                responseResult.setResultObj(arr);
                responseResult.setSuccess(true);
            }else {
                responseResult.setSuccess(false);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return responseResult;
    }

    public ResponseResult<List<Map<String,String>>> casestatelist() throws IOException {
        ResponseResult<List<Map<String,String>>> responseResult = new ResponseResult<List<Map<String,String>>>();
        try{
            List<Map<String,String>> arr = new ArrayList<Map<String,String>>();
            String url = ApplicationMain.getInstance().getCgtConfig().getRequestUrl() +"/dict/code/caseState";
            String token = ApplicationMain.getInstance().getCgtConfig().gettokenStr();
            String typelistResultXml = HttpRequestTools.getwithToken(url,token, null, 0);
            if (!StringUtils.isNullOrEmpty(typelistResultXml)) {
                JSONObject jsonObject = new JSONObject(typelistResultXml);
                JSONArray jsonArray = jsonObject.getJSONArray("data");
                for (int i=0;i<jsonArray.length();i++){
                    Map<String,String> map = new HashMap<>();
                    JSONObject json = jsonArray.getJSONObject(i);
                    map.put("name",json.getString("name"));
                    map.put("id",json.getString("id"));
                    map.put("value",json.getString("value"));
                    arr.add(map);
                }
                responseResult.setResultObj(arr);
                responseResult.setSuccess(true);
            }else {
                responseResult.setSuccess(false);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return responseResult;
    }

    public ResponseResult<List<Map<String,String>>> typelist(String eorc) throws IOException {
        ResponseResult<List<Map<String,String>>> responseResult = new ResponseResult<List<Map<String,String>>>();
        try{
            List<Map<String,String>> arr = new ArrayList<Map<String,String>>();
            String url = ApplicationMain.getInstance().getCgtConfig().getRequestUrl() +"/case/type/list/?eorc="+eorc;
            String token = ApplicationMain.getInstance().getCgtConfig().gettokenStr();
            String typelistResultXml = HttpRequestTools.getwithToken(url,token, null, 0);
            if (!StringUtils.isNullOrEmpty(typelistResultXml)) {
                JSONObject jsonObject = new JSONObject(typelistResultXml);
                JSONArray jsonArray = jsonObject.getJSONArray("data");
                for (int i=0;i<jsonArray.length();i++){
                    Map<String,String> map = new HashMap<>();
                    JSONObject json = jsonArray.getJSONObject(i);
                    map.put("typeName",json.getString("typeName"));
                    map.put("id",json.getString("id"));
                    map.put("typeCode",json.getString("typeCode"));
                    arr.add(map);
                }
                responseResult.setResultObj(arr);
                responseResult.setSuccess(true);
            }else {
                responseResult.setSuccess(false);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return responseResult;
    }

    public ResponseResult<List<Map<String,String>>> typelistdetail(String eorc,String typeID) throws IOException {
        ResponseResult<List<Map<String,String>>> responseResult = new ResponseResult<List<Map<String,String>>>();
        try{
            List<Map<String,String>> arr = new ArrayList<Map<String,String>>();
            String url = ApplicationMain.getInstance().getCgtConfig().getRequestUrl() +"/case/typeDetail/list/?eorc="+eorc+"&typeId="+typeID;
            String token = ApplicationMain.getInstance().getCgtConfig().gettokenStr();
            String typelistResultXml = HttpRequestTools.getwithToken(url,token, null, 0);
            if (!StringUtils.isNullOrEmpty(typelistResultXml)) {
                JSONObject jsonObject = new JSONObject(typelistResultXml);
                JSONArray jsonArray = jsonObject.getJSONArray("data");
                for (int i=0;i<jsonArray.length();i++){
                    Map<String,String> map = new HashMap<>();
                    JSONObject json = jsonArray.getJSONObject(i);
                    map.put("typeDetailName",json.getString("typeDetailName"));
                    map.put("id",json.getString("id"));
                    map.put("typeDetailCode",json.getString("typeDetailCode"));
                    arr.add(map);
                }
                responseResult.setResultObj(arr);
                responseResult.setSuccess(true);
            }else {
                responseResult.setSuccess(false);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return responseResult;
    }

    public ResponseResult<String> typelistdetail(String eorc,String typeID, String typeDetailCode) throws IOException {
        ResponseResult<String> responseResult = new ResponseResult<String>();
        try{
            String url = ApplicationMain.getInstance().getCgtConfig().getRequestUrl()
                    +"/case/typeDetail/listPage/?eorc="+eorc+"&typeId="+typeID+"&typeDetailCode="+typeDetailCode;
            String token = ApplicationMain.getInstance().getCgtConfig().gettokenStr();
            String typelistResultXml = HttpRequestTools.getwithToken(url,token, null, 0);
            if (!StringUtils.isNullOrEmpty(typelistResultXml)) {
                JSONObject jsonObject = new JSONObject(typelistResultXml);
                JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("rows");
                String typeDetailName = jsonArray.getJSONObject(0).getString("typeName");

                responseResult.setResultObj(typeDetailName);
                responseResult.setSuccess(true);
            }else {
                responseResult.setSuccess(false);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return responseResult;
    }


    public ResponseResult<CaseTaskNum> getMsgAndTask(String userId) throws Exception {
        return requestFormat.getMsgAndTask(userId);
    }

    /**
     * 下班打卡,
     * 
     * @param bgAdminId
     * @return
     * @throws IOException
     */
    public ResponseResult<String> logout(String bgAdminId) throws Exception {
        return requestFormat.logout(bgAdminId);
    }

    /**
     * 获取案卷核实列表
     * 
     * @param bgAdminId
     * @param pageNow
     * @param pageSize
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseModel>> getProblemCheckList(String bgAdminId, int pageNow, int pageSize)
        throws Exception {
        return requestFormat.getProblemCheckList(bgAdminId, pageNow, pageSize);
    }
    
    public void delMsgSjx(String msgId, int pageNow, int pageSize)
            throws IOException {
             requestFormat.delMsgSjx(msgId, pageNow, pageSize);
      }
    /**
     * 获取核查列表
     * 
     * @param bgAdminId
     * @param pageNow
     * @param pageSize
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseModel>> getSanBaoProblemReCheckList(String bgAdminId, int pageNow, int pageSize)
        throws Exception {
        return requestFormat.getSanBaoProblemReCheckList(bgAdminId, pageNow, pageSize);
    }
    
    
    /**
     * 获取核查列表
     * 
     * @param bgAdminId
     * @param pageNow
     * @param pageSize
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseModel>> getProblemReCheckList(String bgAdminId, int pageNow, int pageSize)
        throws Exception {
        return requestFormat.getProblemReCheckList(bgAdminId, pageNow, pageSize);
    }
    /**
     * 获取施工图列表
     * 
     * @param bgAdminId
     * @param pageNow
     * @param pageSize
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseModel>> shigongList(String bgAdminId, int pageNow, int pageSize)
        throws Exception {
        return requestFormat.shigongList(bgAdminId, pageNow, pageSize);
    }

    /**
     * 获取历史案卷列表
     * 
     * @param bgAdminId
     * @param statusId
     * @param caseTypeId
     * @param caseLClassId
     * @param caseSClassId
     * @param caseModuleId
     * @param uploadDate
     * @param endDate
     * @param pageNow
     * @param pageSize
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseModel>> getProblemHistoryList(String bgAdminId, String statusId, String caseTypeId,
            String caseLClassId, String caseSClassId, String caseModuleId, String uploadDate, String endDate,
            int pageNow, int pageSize) throws Exception {
        return requestFormat.getProblemHistoryList(bgAdminId, statusId, caseTypeId, caseLClassId, caseSClassId,
            caseModuleId, uploadDate, endDate, pageNow, pageSize);

    }

    /**
     * 获取消息列表
     * 
     * @param bgAdminId
     * @param pageNow
     * @param pageSize
     * @return
     * @throws IOException
     */
    public ResponseResult<List<MessageModel>> getMessageList(String bgAdminId, int pageNow, int pageSize,String isRead)
        throws Exception {
        return requestFormat.getMessageList(bgAdminId, pageNow, pageSize,isRead);
    }



    /**
     * 获取消息数
     * 
     * @param bgAdminId
     * @return
     * @throws IOException
     */
    public ResponseResult<List<MessageModel>> getMessageCountAndTop(String bgAdminId) throws Exception {
        return requestFormat.getMessageCountAndTop(bgAdminId);
    }

    /**
     * 获取任务数
     * 
     * @param bgAdminId
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseModel>> getTaskCountAndTop(String bgAdminId) throws Exception {
        return requestFormat.getTaskCountAndTop(bgAdminId);
    }
    /**
     * 获取任务数
     * 
     * @param bgAdminId
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseModel>> getTaskCountAndTop2(String bgAdminId) throws Exception {
        return requestFormat.getTaskCountAndTop2(bgAdminId);
    }
    /**
     * 上报案卷
     * 
     * @param bgAdminId
     * @param caseTypeId
     * @param caseLClassId
     * @param caseSClassId
     * @param caseModuleId
     * @param caseAddress
     * @param caseSituation
     * @param longitude
     * @param latitude
     * @param partNum
     * @param gridNum
     * @return
     * @throws Exception
     */
    public ResponseResult<String[]> inputNewCase(String bgAdminId, String caseTypeId, String caseLClassId,
                                                  String caseSClassId, String caseModuleId, String caseAddress, String caseSituation, String longitude,
                                                  String latitude, String partNum, String gridNum, String deptId,String iskssb,String dq,String jd,String sq) throws Exception {

        return requestFormat.inputNewCase(bgAdminId, caseTypeId, caseLClassId, caseSClassId, caseModuleId, caseAddress,
                caseSituation, longitude, latitude, partNum, gridNum, deptId,iskssb, dq, jd, sq);
    }
    public ResponseResult<String[]> updatePwd(String bgAdminId, String newPwd, String oldPwd) throws Exception {

        return requestFormat.updatePwd(bgAdminId, newPwd, oldPwd);
    }

    public ResponseResult<String[]> inputPosionMap(String bgAdminId,  String caseAddress,  String longitude,
            String latitude) throws Exception {

        return requestFormat.inputPosionMap(bgAdminId, caseAddress,longitude, latitude);
    }
    public ResponseResult<String[]> inputPosionMap2(String bgAdminId,  String caseAddress,  String longitude,
            String latitude) throws Exception {

        return requestFormat.inputPosionMap2(bgAdminId, caseAddress,longitude, latitude);
    }

    
    /**
     * 门前
     * 
     * @param bgAdminId
     * @param caseTypeId
     * @param caseLClassId
     * @param caseSClassId
     * @param caseModuleId
     * @param caseAddress
     * @param caseSituation
     * @param longitude
     * @param latitude
     * @param partNum
     * @param gridNum
     * @return
     * @throws Exception
     */
    public ResponseResult<String[]> inputSanBaoCase(String bgAdminId, String caseTypeId, String caseLClassId,
            String caseSClassId, String caseModuleId, String caseAddress, String caseSituation, String longitude,
            String latitude, String partNum, String gridNum, String deptId,String iskssb,String dq,String jd,String sq) throws Exception {

        return requestFormat.inputSanBaoCase(bgAdminId, caseTypeId, caseLClassId, caseSClassId, caseModuleId, caseAddress,
            caseSituation, longitude, latitude, partNum, gridNum, deptId,iskssb, dq, jd, sq);
    }
    /**
     * 核实案卷
     * 
     * @param bgAdminId
     * @param caseId
     * @param caseTypeId
     * @param caseLClassId
     * @param caseSClassId
     * @param caseModuleId
     * @param caseStatusId
     * @param caseAddress
     * @param caseSituation
     * @param caseLongitude
     * @param caseLatitude
     * @param gridNum
     * @return
     * @throws IOException
     */
    public ResponseResult<String[]> checkCase(String bgAdminId, String caseId, String caseTypeId, String caseLClassId,
            String caseSClassId, String caseModuleId, String caseStatusId, String caseAddress, String caseSituation,
            String caseLongitude, String caseLatitude, String gridNum) throws Exception {
        return requestFormat.checkCase(bgAdminId, caseId, caseTypeId, caseLClassId, caseSClassId, caseModuleId,
            caseStatusId, caseAddress, caseSituation, caseLongitude, caseLatitude, gridNum);
    }

    /**
     * 核查案卷
     * 
     * @param caseId
     * @param bgAdminId
     * @param caseStatusId
     * @param caseSituation
     * @param jbpmid
     * @return
     * @throws IOException
     */
    public ResponseResult<String[]> reCheckCase(String caseId, String bgAdminId, String caseStatusId,
            String caseSituation, String jbpmid) throws Exception {
        return requestFormat.reCheckCase(caseId, bgAdminId, caseStatusId, caseSituation, jbpmid);
    }
    
    /**
     * 核查案卷
     * 
     * @param caseId
     * @param bgAdminId
     * @param caseStatusId
     * @param caseSituation
     * @param jbpmid
     * @return
     * @throws IOException
     */
    public ResponseResult<String[]> reCheckSanBaoCase(String caseId, String bgAdminId, String caseStatusId,
            String caseSituation, String jbpmid) throws Exception {
        return requestFormat.reCheckSanBaoCase(caseId, bgAdminId, caseStatusId, caseSituation, jbpmid);
    }
    
    /**
     * 施工处理案卷
     * 
     * @param caseId
     * @param bgAdminId
     * @param caseStatusId
     * @param caseSituation
     * @param jbpmid
     * @return
     * @throws IOException
     */
    public ResponseResult<String[]> pdaSGCase(String caseId, String bgAdminId, String caseStatusId,
            String caseSituation, String jbpmid) throws Exception {
        return requestFormat.pdaSGCase(caseId, bgAdminId, caseStatusId, caseSituation, jbpmid);
    }
    
    public ResponseResult<String> queryAddressString(String gridid) throws Exception {
        return requestFormat.queryAddressString(gridid);
    }

    /**
     * 保存图片缓存
     * 
     * @param selectedImages
     * @param eventId
     * @param cacheRowId
     */
    public void saveImageCache(Bitmap[] selectedImages, String eventId, String cacheRowId) {
        String fileDirPath = ApplicationMain.getInstance().getConfigPath("imagecache/" + eventId);
        File fileDir = new File(fileDirPath);
        if (!StringUtils.isNullOrEmpty(cacheRowId)) {
            String cachePath = ApplicationMain.getInstance().getConfigPath("imagecache/" + cacheRowId);
            File localCacheCase = new File(cachePath);
            localCacheCase.renameTo(fileDir);

            String recordFilePath = ApplicationMain.getInstance().getAudioTempPath();
            File saveAudioFile = new File(fileDirPath, recordFilePath.substring(recordFilePath.indexOf("/")));
            if (saveAudioFile.exists()) {
                saveAudioFile.delete();
            }
        } else {
            if (!fileDir.exists()) {
                fileDir.mkdirs();
            }
            int i = 1;
            if (selectedImages != null) {
                for (Bitmap bitmap : selectedImages) {
                    File imageFile = new File(fileDirPath, Integer.toString(i) + ".jpg");
                    try {
                        imageFile.createNewFile();
                        OutputStream fileOutput = new FileOutputStream(imageFile);
                        bitmap.compress(CompressFormat.JPEG, 80, fileOutput);
                        fileOutput.flush();
                        fileOutput.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    i++;
                }
            }
        }
    }

    /**
     * 保存录音缓存
     * 
     * @param recordFilePath
     * @param eventId
     * @throws IOException
     */
    public void saveAudioCache(String recordFilePath, String eventId) throws Exception {
        String fileDirPath = ApplicationMain.getInstance().getConfigPath("imagecache/" + eventId);
        File fileDir = new File(fileDirPath);
        if (!fileDir.exists()) {
            fileDir.mkdirs();
        }
        File audioFile = new File(recordFilePath);
        if (audioFile.exists()) {
            File saveFile = new File(fileDirPath, recordFilePath.substring(recordFilePath.indexOf("/")));
            saveFile.createNewFile();
            InputStream in = new FileInputStream(audioFile);
            OutputStream out = new FileOutputStream(saveFile);
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
            in.close();
            out.close();
        }
    }

    /**
     * 获取缓存的案卷录音
     * 
     * @param rowId
     * @return
     */
    public String getCacheAudio(String rowId) {
        String cacheAudioPath = "";
        String fileDirPath = ApplicationMain.getInstance().getConfigPath("imagecache/" + rowId);
        String recordFilePath = ApplicationMain.getInstance().getAudioTempPath();
        File saveAudioFile = new File(fileDirPath, recordFilePath.substring(recordFilePath.indexOf("/")));
        if (saveAudioFile.exists()) {
            cacheAudioPath = saveAudioFile.getAbsolutePath();
        }
        return cacheAudioPath;
    }

    /**
     * 获取缓存的案卷图片
     * 
     * @param caseId
     * @return
     */
    public List<String> getCacheImage(String caseId) {
        List<String> cacheImagePathList = new ArrayList<String>();
        String fileDirPath = ApplicationMain.getInstance().getConfigPath("imagecache/" + caseId);
        File fileDir = new File(fileDirPath);
        if (fileDir.exists()) {
            for (int i = 1; i <= 3; i++) {
                File imageFile = new File(fileDirPath, Integer.toString(i) + ".jpg");
                if (imageFile.exists()) {
                    cacheImagePathList.add(imageFile.getAbsolutePath());
                }
            }
        }
        return cacheImagePathList;
    }

    /**
     * 删除缓存的案卷图片
     * 
     * @param caseId
     */
    public void deleteCacheImage(String caseId) {
        String fileDirPath = ApplicationMain.getInstance().getConfigPath("imagecache/" + caseId);
        File fileDir = new File(fileDirPath);
        if (fileDir.exists() && fileDir.isDirectory()) {
            if (fileDir.listFiles() != null) {
                for (File fileItem : fileDir.listFiles()) {
                    fileItem.delete();
                }
            }
            fileDir.delete();
        }
    }

    /**
     * 提交声音
     * 
     * @param audioFilePath
     * @param pictureId
     * @param eventId
     * @return
     * @throws IOException
     */
    public boolean submitAudio(String audioFilePath, String pictureId, String eventId) throws Exception {
        String imageUploadPath = ApplicationMain.getInstance().getCgtConfig().getPictureSubmitUrl();
        String requestUrl = ApplicationMain.getInstance().getCgtConfig().getRequestUrl();
        String imageUploadUrl = MessageFormat.format("{0}{1}?prochisid={2}&imagetype=audio&idcase={3}", requestUrl,
            imageUploadPath, pictureId, eventId);

        FileInputStream fileInputStream = new FileInputStream(audioFilePath);
        byte[] buffer = new byte[fileInputStream.available()];
        fileInputStream.read(buffer);
        fileInputStream.close();

        return requestFormat.SubmitBytes(0, imageUploadUrl, buffer);
    }

    /**
     * 提交图片
     * 
     * @param imagePath
     * @param pictureId
     * @param index
     * @param eventId
     * @return
     * @throws IOException
     */
    public boolean submitImage(String imagePath, String pictureId, int index, String eventId) throws Exception {
        String imageUploadPath = ApplicationMain.getInstance().getCgtConfig().getPictureSubmitUrl();
        String requestUrl = ApplicationMain.getInstance().getCgtConfig().getRequestUrl();
        String imageUploadUrl = MessageFormat.format("{0}{1}?prochisid={2}&imagetype=image&idcase={3}", requestUrl,
            imageUploadPath, pictureId, eventId);
        FileInputStream fileInputStream = new FileInputStream(imagePath);
        byte[] buffer = new byte[fileInputStream.available()];
        fileInputStream.read(buffer);
        fileInputStream.close();
        return requestFormat.SubmitBytes(index, imageUploadUrl, buffer);
    }

    /**
     * 提交图片
     * 
     * @param bitmap
     * @param pictureId
     * @param index
     * @param eventId
     * @return
     * @throws IOException
     */
    public boolean submitImage(Bitmap bitmap, String pictureId, int index, String eventId) throws Exception {
        String imageUploadPath = ApplicationMain.getInstance().getCgtConfig().getPictureSubmitUrl();
        String requestUrl = ApplicationMain.getInstance().getCgtConfig().getRequestUrl();
        String imageUploadUrl = MessageFormat.format("{0}{1}?prochisid={2}&imagetype=image&idcase={3}", requestUrl,
            imageUploadPath, pictureId, eventId);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream);
        return requestFormat.SubmitBytes(index, imageUploadUrl, stream.toByteArray());
    }

    /**
     * 回报GPS坐标
     * 
     * @param phoneNumber
     * @param longitude
     * @param latitude
     * @param bgAdminId
     * @param isInPost
     * @return
     * @throws IOException
     */
    public boolean reportGpsPosition(String phoneNumber, String longitude, String latitude, String bgAdminId,
            int isInPost) throws Exception {
        return requestFormat.reportGpsPosition(phoneNumber, longitude, latitude, bgAdminId, isInPost);
    }

    /**
     * 获取案卷附件
     * 
     * @param caseId
     * @return
     * @throws IOException
     */
    public ResponseResult<List<CaseAttach>> getCaseAttach(String caseId) throws Exception {
        return requestFormat.getCaseAttach(caseId);
    }

    /**
     * 获取今日完成的任务
     * 
     * @param bgAdminId
     * @return
     * @throws IOException
     */
    public ResponseResult<Map<String,Integer>> getTodayFinish(String bgAdminId) throws Exception {
        return requestFormat.getTodayFinish(bgAdminId);
    }

    /**
     * 更新未读状态为已读
     * 
     * @param messageId
     */
    public void updateMessageReadState(String messageId,String adminid) {
        requestFormat.updateMessageReadState(messageId,adminid);
    }

    /**
     * 检查新配置
     * 
     * @param nowConfigVersion
     * @return
     * @throws IOException
     */
    public ResponseResult<CgtConfig> checkAndGetNewConfig(int nowConfigVersion) throws Exception {
        return requestFormat.checkAndGetNewConfig(nowConfigVersion);
    }

    /**
     * 检查新版本
     * 
     * @param versionCode
     * @return
     * @throws IOException
     */
    public ResponseResult<String[]> checkAndGetNewPackage(int versionCode) throws Exception {
        return requestFormat.checkAndGetNewPackage(versionCode);
    }

}