Преглед на файлове

同步人员到北森 代码提交

qingwu преди 4 месеца
родител
ревизия
442094ab95

+ 130 - 60
src/com/kingdee/eas/custom/beisen/syncperson/SyncPersonToBeisenFacadeControllerBean.java

@@ -50,6 +50,7 @@ import com.kingdee.eas.common.EASBizException;
 
 import java.lang.String;
 import java.sql.SQLException;
+import java.text.ParseException;
 import java.util.*;
 
 /**
@@ -148,8 +149,6 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
             BeisenParamByPropertiesUtil beisenParamByProperties = new BeisenParamByPropertiesUtil("/server/properties/beisen/BeiSenConfig.properties");
             Map<String, String> config = beisenParamByProperties.getConfig();
             logger.error("config---" + config.size());
-            // 员工
-            IPerson iPerson = PersonFactory.getLocalInstance(ctx);
             // 查询所有人的user用户
             IUser iUser = UserFactory.getLocalInstance(ctx);
             UserCollection userCollection = iUser.getUserCollection();
@@ -177,17 +176,19 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
                 PersonInfo person = personPositionInfo.getPerson();
                 // 入职ID
                 Object bsUserId = person.get("bsUserId");
+                Object beisenId = person.get("beisenId");
                 logger.error("bsUserId--" + bsUserId);
+                logger.error("beisenId--" + beisenId);
                 String originalId = URLEncoder.encode(person.getId().toString(), StandardCharsets.UTF_8.name());
                 String nCell = person.getNCell();
                 String name = person.getName();
                 msgMap.put("number", person.getNumber());
                 msgMap.put("name", name);
                 msgMap.put("originalId", originalId);
+                msgMap.put("bsUserId", bsUserId);
+                msgMap.put("beisenId", beisenId);
                 EmployeeTypeInfo employeeType = person.getEmployeeType();
-                // 调用新增接口---禁用系统用户账号 状态1:在职 3:离职
                 EmployeeTypeEnum inServiceEnum = employeeType.getInService();
-                Object beisenId = person.get("beisenId");
                 String email = person.getEmail();
                 if (StringUtils.isEmpty(email)) {
                     // throw new BOSException(person.getName() + "同步失败:邮箱不能为空,请维护!!");
@@ -211,12 +212,11 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
                 PositionInfo primaryPosition = personPositionInfo.getPrimaryPosition();
                 personJson.put(config.get("positionNumber"), primaryPosition.getNumber());//  岗位编码
                 personJson.put(config.get("positionName"), primaryPosition.getName());//  岗位名称
-
                 // 判断是否在北森存在 如果beisenId为空并且是在职状态需要再北森创建员工
                 if (beisenId == null) {
                     // 判断是否在职
                     if (inServiceEnum.getValue() == 2) {
-                        msgMap.put("message",person.getName() + "已离职无需同步北森!!");
+                        msgMap.put("message", person.getName() + "已离职无需同步北森!!");
                         jsonArray.add(msgMap);
                         continue;
                     }
@@ -225,17 +225,62 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
                     logger.error("personJson--" + personJson);
                     JSONObject staffs = beisenApiClient.callApi(staffsPost, personJson);
                     if (!"200".equals(staffs.getString("code"))) {
-                        msgMap.put("message","创建员工信息失败,原因:" + staffs.get("message"));
+                        msgMap.put("message", "创建员工信息失败,原因:" + staffs.get("message"));
                         jsonArray.add(msgMap);
                         continue;
                     }
                     String data = staffs.getString("data");
-                    person.put("beisenId", data);
-                    SelectorItemCollection personUpdSic = new SelectorItemCollection();
-                    personUpdSic.add("beisenId");
-                    iPerson.updatePartial(person, personUpdSic);
-                    msgMap.put("staffsMessage:", staffs.get("message"));
+                    // 更新bsUserId
+                    updatePersonBensenId(ctx, person, data);
+                    msgMap.put("bsUserId", data);
+                    msgMap.put("创建员工信息:", staffs.get("message"));
                 } else {
+                    // 查询待入职人员信息 通过beisenId 入职员工ID获取入职记录guid和userId
+                    Map<String, String> result = getGuid(config, beisenId);
+                    logger.error("result--" + result);
+                    if (result == null || result.isEmpty()) {
+                        msgMap.put("message", "入职ID[" + beisenId + "]未查询到入职信息!");
+                        jsonArray.add(msgMap);
+                        continue;
+                    }
+                    String userId = result.get("userID");
+                    // 判断userid是否等于shr员工信息维护的北森id,如果不等于通过bsUserId修改北森用户管理的外部Id
+                    logger.error("bsUserId == null" + bsUserId == null);
+                    if (bsUserId == null) {
+                        bsUserId = userId;
+                    }
+                    logger.error(person.getName() + ":" + userId + "--" + bsUserId);
+                    msgMap.put("userID", userId);
+                    if (userId != bsUserId) {
+                        updateBeisenOriginalIdByUserId(msgMap, config, bsUserId);
+                        // 更新bsUserId
+                        updatePersonBensenId(ctx, person, (String) bsUserId);
+                    }
+                    // 通过OriginalId更新员工信息
+                    JSONObject udpatePersonJson = personJson;
+                    // 删除用户名,不修改用户名
+                    udpatePersonJson.remove("userName");
+                    String putbyuserid = config.get("PUTBYUSERID") + "?userId=" + userId;
+                    logger.error("putbyuserid--" + putbyuserid);
+                    logger.error("udpatePersonJson--" + udpatePersonJson);
+                    JSONObject updateStaffs = beisenApiClient.callPutApi(putbyuserid, udpatePersonJson);
+                    msgMap.put("通过userId更新员工信息:", updateStaffs.get("message"));
+                    // 更新bsUserId
+                    updatePersonBensenId(ctx, person, userId);
+                    // 更新待入职人员信息
+                    if (beisenId != null) {
+                        JSONObject updateStaffInfo = new JSONObject();
+                        JSONObject staffInfos = new JSONObject();
+                        staffInfos.put("id", beisenId);
+                        staffInfos.put("name", name);
+                        // staffInfos.put("email", email);
+                        staffInfos.put("mobilePhone", nCell);
+                        staffInfos.put("staffStatus", 1);
+                        updateStaffInfo.put("staffInfos", staffInfos);
+                        logger.error("updateStaffInfo--" + updateStaffInfo);
+                        JSONObject updateStaffRet = beisenApiClient.callApi(config.get("UPDATESTAFFURL"), updateStaffInfo);
+                        msgMap.put("更新待入职人员信息:", updateStaffRet.get("code"));
+                    }
                     // 通过userId更新员工信息
                     if (inServiceEnum.getValue() == 2 || inServiceEnum.getValue() == 0) {
                         // 通过OriginalId设置员工离职
@@ -243,11 +288,8 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
                         logger.error("putSetdimission--" + putSetdimission);
                         JSONObject setdimission = beisenApiClient.callPutApi(putSetdimission, new JSONObject());
                         msgMap.put("通过OriginalId设置员工离职:", setdimission.get("message"));
-                        // 查询待入职人员信息 通过bsUserId 入职员工ID获取入职记录guid
-                        String guid = getGuid(config, bsUserId);
-                        logger.error("guid--" + guid);
                         // 入职管理设置离职
-                        String recruitOnBoardingPost = config.get("RECRUITONBOARDINGPOST") + "?entryId=" + guid;
+                        String recruitOnBoardingPost = config.get("RECRUITONBOARDINGPOST") + "?entryId=" + result.get("guid");
                         logger.error("recruitOnBoardingPost--" + recruitOnBoardingPost);
                         JSONObject recruitOnBoarding = beisenApiClient.callApi(recruitOnBoardingPost, new JSONObject());
                         msgMap.put("入职单设置离职:", recruitOnBoarding.get("message"));
@@ -259,29 +301,6 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
                         JSONObject setinduction = beisenApiClient.callPutApi(putSetinduction, new JSONObject());
                         msgMap.put("设置员工在职:", setinduction.get("message"));
                     }
-                    // 通过OriginalId更新员工信息
-                    JSONObject udpatePersonJson = personJson;
-                    // 删除用户名,不修改用户名
-                    udpatePersonJson.remove("userName");
-                    String putByOriginalId = config.get("PUTBYORIGINALID") + "?originalId=" + originalId;
-                    logger.error("putByOriginalId--" + putByOriginalId);
-                    logger.error("udpatePersonJson--" + udpatePersonJson);
-                    JSONObject updateStaffs = beisenApiClient.callPutApi(putByOriginalId, udpatePersonJson);
-                    msgMap.put("通过OriginalId更新员工信息:", updateStaffs.get("message"));
-                    // 更新待入职人员信息
-                    if (bsUserId != null) {
-                        JSONObject updateStaffInfo = new JSONObject();
-                        JSONObject staffInfos = new JSONObject();
-                        staffInfos.put("id", bsUserId);
-                        staffInfos.put("name", name);
-                        staffInfos.put("email", email);
-                        staffInfos.put("mobilePhone", nCell);
-                        staffInfos.put("staffStatus", 1);
-                        updateStaffInfo.put("staffInfos", staffInfos);
-                        logger.error("updateStaffInfo--" + updateStaffInfo);
-                        JSONObject updateStaffRet = beisenApiClient.callApi(config.get("UPDATESTAFFURL"), updateStaffInfo);
-                        msgMap.put("更新待入职人员信息:", updateStaffRet.get("code"));
-                    }
                 }
                 jsonArray.add(msgMap);
             }
@@ -295,31 +314,83 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
     }
 
     /**
-     * 查询待入职人员信息 通过bsUserId 入职员工ID获取入职记录guid
+     * 通过bsUserId修改北森用户管理的外部Id
      *
-     * @param config
      * @param bsUserId
+     */
+    public void updateBeisenOriginalIdByUserId(Map map, Map config, Object bsUserId) throws IOException {
+        String putbyuserid = config.get("PUTBYUSERID") + "?userId=" + bsUserId;
+        JSONObject udpatePersonJson = new JSONObject();
+        udpatePersonJson.put("originalId", "");
+        udpatePersonJson.put("email", "");
+        JSONObject json = beisenApiClient.callPutApi(putbyuserid, udpatePersonJson);
+        map.put("修改北森用户管理的外部Id:", json.get("message"));
+    }
+
+    /**
+     * @param person
+     * @throws BOSException
+     * @throws EASBizException
+     */
+    private static void updatePersonBensenId(Context ctx, PersonInfo person, String bsUserId) throws BOSException, EASBizException {
+        // 员工
+        IPerson iPerson = PersonFactory.getLocalInstance(ctx);
+        person.put("bsUserId", bsUserId);
+        SelectorItemCollection personUpdSic = new SelectorItemCollection();
+        personUpdSic.add("bsUserId");
+        iPerson.updatePartial(person, personUpdSic);
+    }
+
+    /**
+     * 查询待入职人员信息 通过beisenId 入职员工ID获取入职记录guid
+     *
+     * @param config
+     * @param beisenId
      * @return
      */
-    public String getGuid(Map<String, String> config, Object bsUserId) throws IOException {
-        String guid = null;
-        JSONArray jsonArray = new JSONArray();
-        jsonArray.add(bsUserId);
-        JSONObject staffInfos = beisenApiClient.callApi(config.get("GETSTAFFINFOS"), jsonArray);
-        logger.error("staffInfos--" + staffInfos);
-        if (staffInfos.getInteger("code") == 200) {
-            JSONArray data = staffInfos.getJSONArray("data");
-            for (int i = 0; i < data.size(); i++) {
-                JSONObject dataJson = data.getJSONObject(i);
-                logger.error("dataJson--" + dataJson);
-                JSONArray entryRecord = dataJson.getJSONArray("entryRecord");
-                for (int j = 0; j < entryRecord.size(); j++) {
-                    JSONObject entry = entryRecord.getJSONObject(j);
-                    guid = entry.getString("id");
+    public Map getGuid(Map<String, String> config, Object beisenId) {
+        Map<String, String> result = null;
+        try {
+            result = new HashMap<>();
+            String guid = null;
+            JSONArray jsonArray = new JSONArray();
+            jsonArray.add(beisenId);
+            JSONObject staffInfos = beisenApiClient.callApi(config.get("GETSTAFFINFOS"), jsonArray);
+            logger.error("staffInfos--" + staffInfos);
+            if (staffInfos.getInteger("code") == 200) {
+                JSONArray data = staffInfos.getJSONArray("data");
+                for (int i = 0; i < data.size(); i++) {
+                    JSONObject dataJson = data.getJSONObject(i);
+                    logger.error("dataJson--" + dataJson);
+                    // entryRecord 入职记录
+                    JSONArray entryRecord = dataJson.getJSONArray("entryRecord");
+                    for (int j = 0; j < entryRecord.size(); j++) {
+                        JSONObject entry = entryRecord.getJSONObject(j);
+                        if (entry.getInteger("status") == 1 || entry.getInteger("status") == 0) {
+                            guid = entry.getString("id");
+                            result.put("guid", guid);
+                        }
+                    }
+                    // 任职记录
+                    Long dataTime = 0l;
+                    JSONArray employmentRecord = dataJson.getJSONArray("employmentRecord");
+                    for (int q = 0; q < employmentRecord.size(); q++) {
+                        JSONObject employment = employmentRecord.getJSONObject(q);
+                        String entryDate = employment.getString("entryDate");
+                        logger.debug("entryDate--" + entryDate);
+                        // 处理entryDate为空的数据必须要保存一条数据,如果不为空则保存最新的一条数据
+                        result.put("userID", employment.getString("userID"));
+                        if (!StringUtils.isEmpty(entryDate) && DateTimeUtils.parseDate(entryDate).getTime() > dataTime) {
+                            result.put("userID", employment.getString("userID"));
+                        }
+                    }
                 }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
         }
-        return guid;
+        return result;
     }
 
     /**
@@ -386,9 +457,8 @@ public class SyncPersonToBeisenFacadeControllerBean extends AbstractSyncPersonTo
         sic.add("personDep.number");
         sic.add("personDep.id");
         sic.add("personDep.parent.id");
-        sic.add("personDep.primaryPosition.name");
-        sic.add("personDep.primaryPosition.number");
+        sic.add("primaryPosition.name");
+        sic.add("primaryPosition.number");
         return sic;
     }
-
 }

+ 30 - 0
src/com/kingdee/eas/custom/beisen/utils/BeisenTokenManager.java

@@ -6,6 +6,7 @@ import okhttp3.*;
 import org.apache.log4j.Logger;
 
 import java.io.IOException;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -179,8 +180,37 @@ public class BeisenTokenManager {
     }
 
     public static class Config {
+
+        // public static String APP_KEY = "FFEC5C62AB444567AFC11E8D394CC072";
+        // public static String APP_SECRET = "74FE75BEE476496EAF531C2219EC10E57EDCE01D74F64557BADEEC78FBFF3B26";
+        // public static String TOKEN_URL = "https://openapi.italent.cn/token";
         public static String APP_KEY = "FFEC5C62AB444567AFC11E8D394CC072";
         public static String APP_SECRET = "74FE75BEE476496EAF531C2219EC10E57EDCE01D74F64557BADEEC78FBFF3B26";
         public static String TOKEN_URL = "https://openapi.italent.cn/token";
+
+        static {
+            // 从配置文件中读取配置
+            try {
+                BeisenParamByPropertiesUtil beisenParamByProperties = new BeisenParamByPropertiesUtil();
+                Map<String, String> config = beisenParamByProperties.getConfig();
+                // 如果配置文件中存在配置,则覆盖默认配置
+                if (config != null) {
+                    // 如果配置文件中存在appKey,则覆盖默认appKey
+                    if (config.containsKey("APP_KEY")) {
+                        APP_KEY = config.get("APP_KEY");
+                    }
+                    // 如果配置文件中存在appSecret,则覆盖默认appSecret
+                    if (config.containsKey("APP_SECRET")) {
+                        APP_SECRET = config.get("APP_SECRET");
+                    }
+                    // 如果配置文件中存在tokenUrl,则覆盖默认tokenUrl
+                    if (config.containsKey("ACCESSTOKEN_URL")) {
+                        TOKEN_URL = config.get("ACCESSTOKEN_URL");
+                    }
+                }
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
     }
 }

+ 175 - 0
websrc/com/kingdee/eas/custom/beisen/syncperson/handler/EmployeeListHandlerEx.java

@@ -1,15 +1,40 @@
 package com.kingdee.eas.custom.beisen.syncperson.handler;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.IObjectCollection;
+import com.kingdee.bos.dao.IObjectValue;
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.dao.query.BizEnumValueDTO;
+import com.kingdee.bos.util.BOSUuid;
+import com.kingdee.eas.basedata.org.OrgUnitInfo;
+import com.kingdee.eas.basedata.person.PersonFactory;
+import com.kingdee.eas.basedata.person.PersonInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.beisen.synchronousorg.SynchronousEmpBillFactory;
 import com.kingdee.eas.custom.beisen.syncperson.SyncPersonToBeisenFacadeFactory;
 import com.kingdee.eas.hr.emp.web.handler.EmployeeListHandler;
+import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsBody;
+import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsHeader;
 import com.kingdee.shr.base.syssetting.context.SHRContext;
 import com.kingdee.shr.base.syssetting.exception.SHRWebException;
 import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
+import com.kingdee.shr.base.syssetting.json.adapter.*;
+import com.kingdee.shr.base.syssetting.web.json.adapter.BOSUuidTypeAdapter;
+import com.kingdee.util.StringUtils;
+import com.kingdee.util.enums.Enum;
 import org.springframework.ui.ModelMap;
 
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Timestamp;
+import java.util.Date;
 
 /**
  * @author 青梧
@@ -36,4 +61,154 @@ public class EmployeeListHandlerEx extends EmployeeListHandler {
             throw new ShrWebBizException(e);
         }
     }
+
+    /**
+     * 同步北森人员信息
+     *
+     * @param request
+     * @param response
+     * @param modelMap
+     * @return
+     * @throws SHRWebException
+     */
+    public String synBeiSenPersonAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        Context ctx = SHRContext.getInstance().getContext();
+        BatchMessageTipsHeader batchMessageTipsHeader = new BatchMessageTipsHeader();
+        String ids = request.getParameter("ids");
+        System.out.println("==========ids:"+ids);
+        int sucess = 0;
+        int failure = 0;
+        if (ids != null && ids.length() > 0) {
+            String[] personArray = ids.split(",");
+            for (int i = 0; i < personArray.length; i++) {
+                BatchMessageTipsBody body = new BatchMessageTipsBody();
+                try {
+                    PersonInfo personInfo = PersonFactory.getLocalInstance(ctx).getPersonInfo(new ObjectUuidPK(personArray[i]));
+                    String beisenid = personInfo.getString("beisenid");
+                    System.out.println("==========beisenid:"+beisenid);
+                    if (beisenid!=null&&beisenid.length()>0){
+                        try {
+                            String string = personInfo.getString("IsSync");
+                            if (string==null||string.equals("0")){
+                                String s = SynchronousEmpBillFactory.getLocalInstance(ctx).empBill(beisenid, "002", "asdasdasdasdasdasd");
+                                System.out.println("==========s:"+s);
+                                body.setId(personArray[i]);
+                                body.setMuitTipsState(true);
+                                body.setMuitTipsMessage("同步成功【" +personInfo.getName() + "】");
+                                batchMessageTipsHeader.addResult(body);
+                                sucess++;
+                            }else {
+                                body.setId(personArray[i]);
+                                body.setMuitTipsState(true);
+                                body.setMuitTipsMessage("已经同步过该数据【" + personInfo.getName() + "】");
+                                batchMessageTipsHeader.addResult(body);
+                                sucess++;
+                            }
+
+                        }catch (Exception e){
+                            System.out.println("==========personArray[i]1:"+personArray[i]);
+                            body.setId(personArray[i]);
+                            body.setMuitTipsState(false);
+                            body.setMuitTipsMessage("后台事务执行失败【" + personArray[i] + "】");
+                            batchMessageTipsHeader.addResult(body);
+                            e.printStackTrace();
+                            failure++;
+                        }
+                    }else {
+                        failure++;
+                        System.out.println("==========personArray[i]2:"+personArray[i]);
+                        body.setId(personArray[i]);
+                        body.setMuitTipsState(false);
+                        body.setMuitTipsMessage("未查询到北森入职单id【" +personInfo.getName() + "】");
+                        batchMessageTipsHeader.addResult(body);
+                    }
+                } catch (BOSException e) {
+                    System.out.println("==========personArray[i]3:"+personArray[i]);
+                    body.setId(personArray[i]);
+                    body.setMuitTipsState(false);
+                    body.setMuitTipsMessage("同步失败查询员工失败【" + personArray[i] + "】");
+                    batchMessageTipsHeader.addResult(body);
+                    e.printStackTrace();
+                } catch (EASBizException e) {
+                    System.out.println("==========personArray[i]4:"+personArray[i]);
+                    body.setId(personArray[i]);
+                    body.setMuitTipsState(false);
+                    body.setMuitTipsMessage("同步失败查询员工失败【" + personArray[i] + "】");
+                    batchMessageTipsHeader.addResult(body);
+                    e.printStackTrace();
+                }
+            }
+        }
+        batchMessageTipsHeader.setBillId(ids);
+        batchMessageTipsHeader.setFailureCount(failure);
+        batchMessageTipsHeader.setSuccessCount(sucess);
+        System.out.println("=========batchMessageTipsHeader:"+batchMessageTipsHeader.toString());
+        SUCCESS(batchMessageTipsHeader,request,response,"application/json;charset=UTF-8",ctx);
+        return null;
+    }
+    public static void SUCCESS(Object object,ServletRequest request, ServletResponse response, String contentType,Context context) throws SHRWebException {
+        response.setContentType(contentType);
+
+        PrintWriter pw;
+        try {
+            pw = response.getWriter();
+        } catch (IOException var7) {
+            throw new SHRWebException("can't open the output stream!");
+        }
+
+        StringBuilder strSuccessJson = new StringBuilder();
+        strSuccessJson.append("{");
+        strSuccessJson.append("\"result\":\"");
+        strSuccessJson.append("success");
+        strSuccessJson.append("\",\"data\":");
+        strSuccessJson.append(convertObjectToJson(context, object).toString());
+        String successMessage = (String)request.getAttribute("successMessage");
+        if (!StringUtils.isEmpty(successMessage)) {
+            strSuccessJson.append(",\"successMessage\":\"");
+            strSuccessJson.append(successMessage);
+            strSuccessJson.append("\"");
+        }
+
+        strSuccessJson.append("}");
+        pw.flush();
+        pw.write(strSuccessJson.toString());
+        pw.flush();
+    }
+    public static String convertObjectToJson(Context ctx, Object object) {
+        if (object != null && !object.equals("")) {
+            Gson gson = getGson(ctx);
+            String result = gson.toJson(object);
+            if (result == null) {
+                return "\"\"";
+            } else {
+                result = processJsonResult(result);
+                return result;
+            }
+        } else {
+            return "\"\"";
+        }
+    }
+    public static Gson getGson(Context ctx) {
+        GsonBuilder builder = new GsonBuilder();
+        builder.serializeNulls();
+        builder.disableHtmlEscaping();
+        builder.serializeSpecialFloatingPointValues();
+        builder.registerTypeHierarchyAdapter(Date.class, new DateTypeAdapter());
+        builder.registerTypeHierarchyAdapter(Timestamp.class, new DateTypeAdapter());
+        builder.registerTypeHierarchyAdapter(BOSUuid.class, new BOSUuidTypeAdapter());
+        builder.registerTypeHierarchyAdapter(IObjectValue.class, new BosObjectTypeAdapter(ctx));
+        builder.registerTypeHierarchyAdapter(IObjectCollection.class, new BosObjectCollectionTypeAdapter(ctx));
+        builder.registerTypeHierarchyAdapter(OrgUnitInfo.class, new BosObjectTypeAdapter(ctx));
+        builder.registerTypeHierarchyAdapter(BizEnumValueDTO.class, new BizEnumAdapter());
+        builder.registerTypeHierarchyAdapter(Enum.class, new EnumTypeAdapter());
+        return builder.create();
+    }
+    public static String processJsonResult(String result) {
+        result = result.replace("${quote_2312415321232}", "\"");
+        result = result.replace("\"${leftbracket_2312415321232}", "{");
+        result = result.replace("${leftbracket_2312415321232}", "{");
+        result = result.replace("${rightbracket_2312415321232}\"", "}");
+        result = result.replace("${rightbracket_2312415321232}", "}");
+        return result;
+    }
 }