将Gson改为使用fastjson,与若依保持一致。

This commit is contained in:
Bo 2021-08-14 21:13:54 +08:00
parent 8f458c61d8
commit 24ce46c525
9 changed files with 1 additions and 35 deletions

View File

@ -9,7 +9,6 @@ import com.alibaba.fastjson.JSONObject;
import com.ruoyi.bps.service.IExpressService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
//import com.google.gson.Gson;
import com.kuaidi100.sdk.request.QueryTrackParam;
import com.kuaidi100.sdk.response.QueryTrackResp;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -63,7 +62,6 @@ public class QueryExpressController extends BaseController {
System.out.println("快递公司:" + queryTrackParam.getCom());
System.out.println("电话:" + queryTrackParam.getPhone());
String info=expressService.QueryTrackExpress(queryTrackParam);
//QueryTrackResp queryTrackResp = new Gson().fromJson(info,QueryTrackResp.class);
QueryTrackResp queryTrackResp= JSONObject.parseObject(info,QueryTrackResp.class);
result = new HashMap<>();
result.put("code", "1");

View File

@ -1,7 +1,6 @@
package com.ruoyi.bps.service.impl;
import com.alibaba.fastjson.JSONObject;
//import com.google.gson.Gson;
import com.kuaidi100.sdk.api.Subscribe;
import com.kuaidi100.sdk.contant.ApiInfoConstant;
import com.kuaidi100.sdk.core.IBaseClient;
@ -102,14 +101,12 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
SubscribeReq subscribeReq = new SubscribeReq();
subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA);
//subscribeReq.setParam(new Gson().toJson(subscribeParam));
subscribeReq.setParam(JSONObject.toJSONString(subscribeParam));
IBaseClient subscribe = new Subscribe();
try{
//推送订阅并获得快递100响应结果
HttpResult httpResult= subscribe.execute(subscribeReq);
//subscribeResp= new Gson().fromJson(httpResult.getBody(),SubscribeResp.class);
subscribeResp = JSONObject.parseObject(httpResult.getBody(),SubscribeResp.class);
}catch (Exception e)
{
@ -278,7 +275,6 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
//加密相等继续处理业务逻辑
subscribeResp.setMessage("接受成功!加密验证通过【sign】"+sign+"【ourSign】"+ourSign);
//SubscribePushParamResp subscribePushParamResp = new Gson().fromJson(param, SubscribePushParamResp.class);
SubscribePushParamResp subscribePushParamResp=JSONObject.parseObject(param,SubscribePushParamResp.class);
SubscribePushResult subscribePushResult = subscribePushParamResp.getLastResult();
//快递单号

View File

@ -10,7 +10,6 @@ import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
//import com.google.gson.Gson;
import com.kuaidi100.sdk.api.AutoNum;
import com.kuaidi100.sdk.api.QueryTrack;
import com.kuaidi100.sdk.core.IBaseClient;
@ -161,7 +160,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService
queryTrackParam.setPhone(expressInfo.getPhone());
//获取快递信息
//String param = new Gson().toJson(queryTrackParam);
String param= JSONObject.toJSONString(queryTrackParam);
QueryTrackReq queryTrackReq=new QueryTrackReq();
queryTrackReq.setParam(param);
@ -178,7 +176,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService
}
//将快递信息转化为QueryTrackResp对象
//QueryTrackResp queryTrackResp = new Gson().fromJson(msg,QueryTrackResp.class);
QueryTrackResp queryTrackResp= JSONObject.parseObject(msg,QueryTrackResp.class);
//如果没有查到物流信息则返回错误信息

View File

@ -3,7 +3,6 @@ package com.ruoyi.bps.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
//import com.google.gson.Gson;
import com.kuaidi100.sdk.api.QueryTrack;
import com.kuaidi100.sdk.api.Subscribe;
import com.kuaidi100.sdk.contant.ApiInfoConstant;
@ -42,7 +41,6 @@ public class ExpressServiceImpl implements IExpressService {
for(QueryTrackParam queryTrackParam:list)
{
//QueryTrackResp queryTrackResp = new Gson().fromJson(expressService.QueryTrackExpress(queryTrackParam),QueryTrackResp.class);
QueryTrackResp queryTrackResp= JSONObject.parseObject(expressService.QueryTrackExpress(queryTrackParam),QueryTrackResp.class);
qtList.add(queryTrackResp);
}
@ -68,7 +66,6 @@ public class ExpressServiceImpl implements IExpressService {
public String QueryTrackExpress(QueryTrackParam queryTrackParam) {
String str="";
QueryTrackReq queryTrackReq = new QueryTrackReq();
//String param = new Gson().toJson(queryTrackParam);
String param = JSONObject.toJSONString(queryTrackParam);
queryTrackReq.setParam(param);
@ -88,11 +85,9 @@ public class ExpressServiceImpl implements IExpressService {
JSONObject jsonObject = JSON.parseObject(msg);
if (jsonObject.containsKey("returnCode")){
//QueryTrackResp queryTrackResp= new Gson().fromJson(msg,QueryTrackResp.class);
QueryTrackResp queryTrackResp= JSONObject.parseObject(msg,QueryTrackResp.class);
queryTrackResp.setStatus(queryTrackResp.getReturnCode());
queryTrackResp.setNu(queryTrackParam.getNum());
//msg= new Gson().toJson(queryTrackResp);
msg= JSONObject.toJSONString(queryTrackResp);
}
return msg;
@ -114,7 +109,6 @@ public class ExpressServiceImpl implements IExpressService {
SubscribeReq subscribeReq = new SubscribeReq();
subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA); //返回的数据格式必须
//subscribeReq.setParam(new Gson().toJson(subscribeParam));
subscribeReq.setParam(JSONObject.toJSONString(subscribeParam));
IBaseClient subscribe = new Subscribe();

View File

@ -35,10 +35,6 @@
<version>20160810</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-system</artifactId>

View File

@ -22,10 +22,6 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>

View File

@ -368,10 +368,6 @@ public class SysDeptServiceImpl implements ISysDeptService
Map<String,Object> dataMap= (Map<String, Object>) map.get("data");
JSONArray json = (JSONArray) dataMap.get("dataList");
List<EcologyDept> deptList = JSONArray.parseArray(json.toJSONString(), EcologyDept.class);
/*Map<String,Object> map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class);
Map<String,Object> dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class);
List<EcologyDept> deptList= new Gson().fromJson(new Gson().toJson(dataMap.get("dataList")), new TypeToken<List<EcologyDept>>(){}.getType());*/
//清空部门表
deptMapper.truncateDept();

View File

@ -2,8 +2,6 @@ package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.AjaxResult;
@ -585,10 +583,6 @@ public class SysUserServiceImpl implements ISysUserService
Map<String,Object> dataMap= (Map<String, Object>) map.get("data");
JSONArray json = (JSONArray) dataMap.get("dataList");
List<EcologyUser> ecologyUserList = JSONArray.parseArray(json.toJSONString(), EcologyUser.class);
/*Map<String,Object> map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class);
Map<String,Object> dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class);
List<EcologyUser> ecologyUserList= new Gson().fromJson(dataMap.get("dataList").toString(), new TypeToken<List<EcologyUser>>(){}.getType());
*/
//获取原同步的用户
SysUser oldSysUser=new SysUser();

View File

@ -1,7 +1,6 @@
package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.CacheUtils;
import com.ruoyi.common.utils.DateUtils;
@ -145,7 +144,7 @@ public class WechatApiServiceImpl implements IWechatApiService {
private WechatAccessToken getAccessTokenFromWechat(String corpId,String secret, String agentId){
String param ="corpid=" + corpId + "&corpsecret=" + secret;
String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
WechatAccessToken wechatAccessToken= new Gson().fromJson(HttpUtils.sendGet(url,param),WechatAccessToken.class);
WechatAccessToken wechatAccessToken = JSONObject.parseObject(HttpUtils.sendGet(url,param),WechatAccessToken.class);
wechatAccessToken.setCorpId(corpId);
wechatAccessToken.setSecret(secret);
wechatAccessToken.setAgentId(agentId);