!24 增加TOPGP签收后返回接口

Merge pull request !24 from Bo/bo_dev
This commit is contained in:
Bo 2021-08-15 12:02:23 +00:00 committed by Gitee
commit 5e1ea95c8f
18 changed files with 271 additions and 174 deletions

View File

@ -13,6 +13,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@ -35,14 +36,15 @@ public class ExpSubsPushApiController extends BaseController {
@Autowired
IExpSubsPushApiService expSubsPushApiService;
//推送
//快递100推送
@CrossOrigin
@PostMapping("anon/subscribeCallBackUrl")
@PostMapping("anon/subscribeCallBackUrl/{salt}")
@ApiOperation("快递信息订阅推送接受")
public SubscribeResp SubscribeCallBackUrl(HttpServletRequest request) {
return expSubsPushApiService.ExpressSubscribeCallBackUrl(request);
public SubscribeResp SubscribeCallBackUrl(@PathVariable("salt") String salt, HttpServletRequest request) {
return expSubsPushApiService.ExpressSubscribeCallBackUrl(request,salt);
}
//订阅
@CrossOrigin
@PostMapping("anon/subscribe")
@ -53,17 +55,34 @@ public class ExpSubsPushApiController extends BaseController {
//接受topgp订阅
@Log(title = "快递订阅", businessType = BusinessType.OTHER)
@CrossOrigin
@ApiOperation(value="topgp订阅快递",notes = "request body格式 {\"requestId\":\"1628584040740\",\"deliveryNo\":\"S301-2108020001\",\"expressNo\":\"300444235610\",\"company\":\"annengwuliu\",\"phone\":\"13800138000\"}")
@ApiOperation(value="topgp订阅快递",notes = "request body格式 {\"requestId\":\"1628584040740\",\"deliveryNum\":\"S301-2108020001\",\"expressNum\":\"300444235610\",\"company\":\"annengwuliu\",\"phone\":\"13800138000\"}")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "requestJson", value = "请求json",required = true, paramType = "body", dataType = "String", dataTypeClass = String.class)
})
@PostMapping("api/express/topgpSubscribe")
public String topgpSubscribe(HttpServletRequest request, HttpServletResponse response) throws IOException {
return expSubsPushApiService.ExpressSubscribeFromTopgp(request);
}
//接受topgp转签收单完成后的消息推送
@Log(title = "TOPGP出货已转签收", businessType = BusinessType.OTHER)
@CrossOrigin
@ApiOperation(value="接受TOPGP已转签收消息推送",notes = "request body格式 {\"requestId\":\"topgpSign1628584040740\"," +
"\"signedInfoList\":[{\"deliveryNum\":\"S301-2108020001\",\"signNo\":\"S501-2108020001\"},{\"deliveryNum\":\"S301-2108020002\",\"signNo\":\"S501-2108020002\"}]," +
"\"expressNum\":\"300444235610\",\"company\":\"annengwuliu\",\"phone\":\"13800138000\",\"status\":\"0\"}"
)
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "requestJson", value = "请求json",required = true, paramType = "body", dataType = "String", dataTypeClass = String.class)
})
@PostMapping("api/express/topgpSigned")
public String topgpSigned(HttpServletRequest request, HttpServletResponse response) throws IOException {
// return expSubsPushApiService.ExpressSubscribeFromTopgp(request);
return expSubsPushApiService.TopgpDeliverySigned(request);
}
}

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

@ -28,11 +28,11 @@ public class ExpTopgpLog extends BaseEntity
/** 快递单 */
@Excel(name = "快递单")
private String expressNumber;
private String expressNum;
/** 出货单号 */
@Excel(name = "出货单号")
private String deliveryNumber;
private String deliveryNum;
/** 请求报文 */
@Excel(name = "请求报文")
@ -77,23 +77,23 @@ public class ExpTopgpLog extends BaseEntity
{
return requestType;
}
public void setExpressNumber(String expressNumber)
public void setExpressNum(String expressNum)
{
this.expressNumber = expressNumber;
this.expressNum = expressNum;
}
public String getExpressNumber()
public String getExpressNum()
{
return expressNumber;
return expressNum;
}
public void setDeliveryNumber(String deliveryNumber)
public void setDeliveryNum(String deliveryNum)
{
this.deliveryNumber = deliveryNumber;
this.deliveryNum = deliveryNum;
}
public String getDeliveryNumber()
public String getDeliveryNum()
{
return deliveryNumber;
return deliveryNum;
}
public void setRequestStr(String requestStr)
{
@ -138,8 +138,8 @@ public class ExpTopgpLog extends BaseEntity
.append("sid", getSid())
.append("requestId", getRequestId())
.append("requestType", getRequestType())
.append("expressNumber", getExpressNumber())
.append("deliveryNumber", getDeliveryNumber())
.append("expressNum", getExpressNum())
.append("deliveryNum", getDeliveryNum())
.append("requestStr", getRequestStr())
.append("requestTime", getRequestTime())
.append("responseCode", getResponseCode())

View File

@ -25,7 +25,7 @@ public interface IExpSubsPushApiService {
* 成功结果返回例子 {"result":true,"returnCode":"200","message":"提交成功"}
*
*/
public SubscribeResp ExpressSubscribeCallBackUrl(HttpServletRequest request);
public SubscribeResp ExpressSubscribeCallBackUrl(HttpServletRequest request,String salt);
/**
* 获取Topgp推送的快递信息向快递100推送订阅请求
@ -33,4 +33,11 @@ public interface IExpSubsPushApiService {
* @return
*/
public String ExpressSubscribeFromTopgp(HttpServletRequest request) throws IOException;
/**
* Topgp将出货单转为签收单后的信息推送处理
* @param request
* @return
*/
public String TopgpDeliverySigned(HttpServletRequest request) throws IOException;
}

View File

@ -1,7 +1,7 @@
package com.ruoyi.bps.service.impl;
import com.alibaba.fastjson.JSONArray;
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;
@ -41,14 +41,7 @@ import java.util.Map;
@Service
public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
/*String key = PropertiesReader.get("key");
String customer = PropertiesReader.get("customer");
String secret = PropertiesReader.get("secret");
String siid = PropertiesReader.get("siid");
String userid = PropertiesReader.get("userid");
String tid = PropertiesReader.get("tid");
String secret_key = PropertiesReader.get("secret_key");
String secret_secret = PropertiesReader.get("secret_secret"); */
/*String key = PropertiesReader.get("key");*/
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
@Value("${express.key}")
private String key;
@ -78,22 +71,26 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
if(StringUtils.isEmpty(expSubscribe.getRequestFrom())){
expSubscribe.setRequestFrom("local");
}
//如果订阅来源是topgp则取TOPGP的时间戳,否则自己生成时间戳
if( StringUtils.isEmpty(expSubscribe.getRequestId())) {
//expSubscribe.setRequestId("local"+System.currentTimeMillis()); //获取时间戳,生成本地请求的requestId
expSubscribe.setRequestId("local"+ LocalDateTime.now());
}
//如果订阅来源是topgp则取TOPGP的订阅时间,否则自己生成订阅时间
if(StringUtils.isEmpty(expSubscribe.getSubscribeTime())){
expSubscribe.setSubscribeTime(DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"));
}
String salt="bpsemi"; //定义salt字符串
//如果订阅来源是topgp则取TOPGP传来的salt值topgp,否则使用bpsemi
if(StringUtils.isEmpty(expSubscribe.getSalt())) {
expSubscribe.setSalt("bpsemi");//定义salt字符串
}
//组合订阅参数
SubscribeParameters subscribeParameters = new SubscribeParameters();
SubscribeResp subscribeResp = new SubscribeResp();
subscribeParameters.setCallbackurl("http://report.bpsemi.cn:8081/it_war/anon/subscribeCallBackUrl");
subscribeParameters.setCallbackurl("http://report.bpsemi.cn:8081/it_war/anon/subscribeCallBackUrl/"+expSubscribe.getSalt().trim());
subscribeParameters.setPhone(expSubscribe.getPhone());
subscribeParameters.setSalt(salt);
subscribeParameters.setSalt(expSubscribe.getSalt());
SubscribeParam subscribeParam = new SubscribeParam();
subscribeParam.setParameters(subscribeParameters);
subscribeParam.setCompany(expSubscribe.getCompany());
@ -102,14 +99,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)
{
@ -121,14 +116,13 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
return subscribeResp;
}
//订阅记录写入数据库
ExpSubscribe newExpSubscribe = new ExpSubscribe();
newExpSubscribe.setSid(expSubscribe.getSid()); //将时间戳设为Sid 210810 yangbo
newExpSubscribe.setCompany(expSubscribe.getCompany());
newExpSubscribe.setNumber(expSubscribe.getNumber());
newExpSubscribe.setPhone(expSubscribe.getPhone());
newExpSubscribe.setSalt(salt);
newExpSubscribe.setSalt(expSubscribe.getSalt());
newExpSubscribe.setSubscribeTime(expSubscribe.getSubscribeTime());
newExpSubscribe.setResult((subscribeResp.isResult())?"true":"false");
newExpSubscribe.setReturnCode(subscribeResp.getReturnCode());
@ -170,7 +164,7 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
@Override
public String ExpressSubscribeFromTopgp(HttpServletRequest request) throws IOException {
//定义Return变量
String retrunStr;
String returnStr;
//获取httpServletRequest传过来的Json字符串并进行解析
JSONObject contentJson= JSONObject.parseObject(ServletUtils.getRequestContent(request));
@ -178,15 +172,15 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
return "貌似没有接受到任何参数!";
}
String requestId=contentJson.getString("requestId"); //TOPGP请求ID年月日时分稍毫秒
String deliveryNo= contentJson.getString("deliveryNo"); //TOPGP出货单号
String expressNo = contentJson.getString("expressNo"); //TOPGP快递单号
String deliveryNum= contentJson.getString("deliveryNum"); //TOPGP出货单号
String expressNum = contentJson.getString("expressNum"); //TOPGP快递单号
String company = contentJson.getString("company"); //TOPGP物流公司编号
String phone = contentJson.getString("phone"); //TOPGP出货单号
//Long timeStamp = System.currentTimeMillis(); //获取时间戳
String subscribeTime= DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"); //获取订阅时间
SubscribeResp subscribeResp=new SubscribeResp();
//如果请求ID出货单号或者快递单号为空,则不向快递100请求订阅自己组合返回信息
if(StringUtils.isEmpty(deliveryNo) || StringUtils.isEmpty(expressNo) || StringUtils.isEmpty(requestId)){
if(StringUtils.isEmpty(deliveryNum) || StringUtils.isEmpty(expressNum) || StringUtils.isEmpty(requestId)){
subscribeResp.setMessage("请求ID、快递单号或出货单号不可为空");
subscribeResp.setResult(false);
subscribeResp.setReturnCode("700");
@ -194,7 +188,7 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
//组合向快递100推送订阅请求的参数
ExpSubscribe expSubscribe=new ExpSubscribe();
expSubscribe.setSid(Long.getLong(requestId)); //时间戳
expSubscribe.setNumber(expressNo);
expSubscribe.setNumber(expressNum);
expSubscribe.setCompany(company);
expSubscribe.setPhone(phone);
expSubscribe.setSubscribeTime(subscribeTime); //订阅时间
@ -207,42 +201,75 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
//根据快递100的订阅返回结果组合返回Topgp的JSON字符串
Map<String,Object> map= new HashMap<>();
map.put("requestId",requestId); //从TOPGP传过来的requestId 时间戳
map.put("deliveryNo",deliveryNo); //出货单号
map.put("expressNo",expressNo); //快递单号
map.put("deliveryNum",deliveryNum); //出货单号
map.put("expressNum",expressNum); //快递单号
map.put("responseStr",subscribeResp.getMessage()); //返回消息
map.put("responseCode",subscribeResp.getReturnCode()); //返回码
map.put("result",subscribeResp.isResult()); //订阅结果
//返回Json字符串给TOPGP
retrunStr= JSONObject.toJSONString(map);
returnStr= JSONObject.toJSONString(map);
//记录本次TOPGP订阅请求的Log
ExpTopgpLog expTopgpLog=new ExpTopgpLog();
expTopgpLog.setRequestId(requestId);
expTopgpLog.setRequestType("fromTopgp");
expTopgpLog.setExpressNumber(expressNo);
expTopgpLog.setDeliveryNumber(deliveryNo);
expTopgpLog.setExpressNum(expressNum);
expTopgpLog.setDeliveryNum(deliveryNum);
expTopgpLog.setRequestStr(contentJson.toString());
expTopgpLog.setRequestTime(subscribeTime);
expTopgpLog.setResponseCode(subscribeResp.getReturnCode());
expTopgpLog.setResponseStr(retrunStr);
expTopgpLog.setResponseStr(returnStr);
//插入TOPGPLOG数据库
expTopgpLogService.insertExpTopgpLog(expTopgpLog);
//返回TOPGP json字符串
return returnStr;
}
/**
* Topgp将出货单转为签收单后的信息推送处理
*
* @param request
* @return
*/
@Override
public String TopgpDeliverySigned(HttpServletRequest request) throws IOException {
//获取httpServletRequest传过来的Json字符串并进行解析
String returnStr;
JSONObject contentJson= JSONObject.parseObject(ServletUtils.getRequestContent(request));
Map<String,Object> map=new HashMap<>();
map.put("requestId",contentJson.getString("requestId"));
map.put("responseCode","200");
map.put("expressNum",contentJson.getString("expressNum"));
returnStr= JSONObject.toJSONString(map);
//写入TOPGP记录档
String deliveryNum="";
JSONArray jsonArray = JSONArray.parseArray(contentJson.getString("signedList"));
for(Object object :jsonArray){
JSONObject jsonObject= JSONObject.parseObject(object.toString());
deliveryNum += jsonObject.getString("deliveryNum");
if(jsonArray.indexOf(object)<jsonArray.size()-1){
deliveryNum+="";
}
}
ExpTopgpLog expTopgpLog=new ExpTopgpLog();
expTopgpLog.setRequestId(contentJson.getString("requestId"));
expTopgpLog.setRequestType("topgpSigned");
expTopgpLog.setExpressNum(contentJson.getString("expressNum"));
expTopgpLog.setRequestStr(contentJson.toString());
expTopgpLog.setDeliveryNum(deliveryNum);
expTopgpLog.setRequestTime(DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"));
expTopgpLog.setResponseCode("200");
expTopgpLog.setResponseStr(returnStr);
expTopgpLogService.insertExpTopgpLog(expTopgpLog);
//返回TOPGP json字符串
return retrunStr;
//返回处理结果给Topgp
return returnStr;
}
public JSONObject SendRequestToTopgp( String url,String tip,Map<String,Object> map) {
String param = TopgpXmlUtils.GetTopgpRequestXml(tip, map);
String returnXml = HttpUtils.sendXmlPost(url, param);
return TopgpXmlUtils.GetStatusFromTopgpResponse(returnXml);
}
/**
* 处理快递100订阅的快递推送信息并返回响应结果
*
@ -250,7 +277,7 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
* @return 结果
*/
@Override
public SubscribeResp ExpressSubscribeCallBackUrl(HttpServletRequest request) {
public SubscribeResp ExpressSubscribeCallBackUrl(HttpServletRequest request,String salt) {
//如果推送信息中没有包含
if(StringUtils.isEmpty(request.getParameter("param"))
|| StringUtils.isEmpty(request.getParameter("sign"))) {
@ -263,9 +290,7 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
String param= request.getParameter("param");
String sign = request.getParameter("sign");
//log.debug("快递100订阅推送回调结果|{}|{}",param,sign);
//订阅时传的salt
String salt = "bpsemi";
String ourSign = SignUtils.sign(param + salt);
SubscribeResp subscribeResp = new SubscribeResp();
subscribeResp.setResult(Boolean.TRUE);
@ -278,59 +303,21 @@ 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();
//快递单号
String nu = subscribePushResult.getNu();
//监控状态 (polling:监控中shutdown:结束abort:中止updateall重新推送其中当快递单为已签收时status=shutdown)
String status= subscribePushParamResp.getStatus();
if(status.equals("abort")){
if(subscribePushParamResp.getStatus().equals("abort")){
//todo
//当message为3天查询无记录60天无变化时status= abort 对于status=abort的状态的处理逻辑
//将Abort信息存档然后预警
}
//如果是快递100推送的快递单状态为签收state=3,并且为TOPGP订阅
//快递单当前状态 0在途1揽收2疑难3签收4退签5派件6退回7转单10待清关11清关中12已清关13清关异常14收件人拒签)
String state = subscribePushResult.getState();
//处理签收逻辑
//如果是快递100推送的快递单状态为签收state=3,并且TOPGP未反馈该快递单已被签收
if(state.equals("3")) {
//如果该快递信息没有推送给TOPGP且TOPGP已反馈生成签收单成功记录则推送给TOPGP
ExpTopgpLog expTopgpLog=new ExpTopgpLog();
expTopgpLog.setExpressNumber(subscribePushResult.getNu());
expTopgpLog.setRequestType("toTopgp");
expTopgpLog.setResponseCode("200");
List<ExpTopgpLog> expTopgpLogList= expTopgpLogService.selectExpTopgpLogList(expTopgpLog);
if(null==expTopgpLogList || expTopgpLogList.size()<1){
Map<String, Object> requestMap = new HashMap<>();
requestMap.put("expressNum", subscribePushResult.getNu());
requestMap.put("expressCom", subscribePushResult.getCom());
requestMap.put("expressState", subscribePushResult.getState());
//一个快递单号对应多个出货单请求
//调用topgp Webservice接口
//topgp返回的
JSONObject jsonObject= SendRequestToTopgp(webserviceUrl, "express_testRequest",requestMap);
log.info(jsonObject.toJSONString());
if(jsonObject.getString("returnCode").equals("200")){
//一个快递单号对应多个出货单号怎么处理如果有多个出货单号部分已签收部分未签收又怎么处理 如果推送到ERP时ERP已经人工生成签收单了又该怎么处理
if(subscribePushResult.getState().equals("3") && salt.equals("topgp")) {
pushExpressInfoToTopgp(subscribePushResult);
}
}
}
//将快递流转状态存入数据库
expSubsPushRespService.insertExpSubsPushResp(ToExpSubsPushResp(subscribePushParamResp)); //无论数据库中存在快递单号+快递公司编码都更新数据库 210809 yangbo 修正
@ -350,11 +337,40 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService {
//如果数据库中没有快递单号+快递公司编码则更插入新记录
expSubsPushRespService.insertExpSubsPushResp(ToExpSubsPushResp(subscribePushParamResp));
}*/
return subscribeResp;
}
//根据快递100推送的快递信息推送给TOPGP并将TOPGP返回信息记录到exp_topgp_log表
private void pushExpressInfoToTopgp(SubscribePushResult subscribePushResult){
Map<String, Object> requestMap = new HashMap<>();
requestMap.put("requestId","toTopgp"+LocalDateTime.now()); //生成推送requestId
requestMap.put("expressNum", subscribePushResult.getNu());
requestMap.put("expressCom", subscribePushResult.getCom());
requestMap.put("expressState", subscribePushResult.getState());
//将签收信息推送给TOPGP让TOPGP处理签收
String returnXml = HttpUtils.sendXmlPost(webserviceUrl, TopgpXmlUtils.GetTopgpRequestXml("express_testRequest", requestMap));
JSONObject jsonObject = TopgpXmlUtils.TopgpResponseXmlToJson(returnXml);
log.info(jsonObject.toJSONString());
//记录本次TOPGP订阅请求的Log
ExpTopgpLog expTopgpLog=new ExpTopgpLog();
expTopgpLog.setRequestId(requestMap.get("requestId").toString());
expTopgpLog.setRequestType("toTopgp");
expTopgpLog.setExpressNum(requestMap.get("expressNum").toString());
expTopgpLog.setRequestStr(JSONObject.toJSONString(requestMap));
expTopgpLog.setRequestTime(DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"));
JSONObject object = jsonObject.getJSONObject("execution");
expTopgpLog.setResponseCode(object.getString("code"));
expTopgpLog.setResponseStr(returnXml);
//插入TOPGPLOG数据库
expTopgpLogService.insertExpTopgpLog(expTopgpLog);
}
/**
* 将快递100推送的信息转换为ExpSubsPushResp
* @param subscribePushParamResp

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

@ -8,8 +8,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="sid" column="sid" />
<result property="requestId" column="requestId" />
<result property="requestType" column="requestType" />
<result property="expressNumber" column="expressNumber" />
<result property="deliveryNumber" column="deliveryNumber" />
<result property="expressNum" column="expressNum" />
<result property="deliveryNum" column="deliveryNum" />
<result property="requestStr" column="requestStr" />
<result property="requestTime" column="requestTime" />
<result property="responseCode" column="responseCode" />
@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectExpTopgpLogVo">
select sid, requestId, requestType, expressNumber, deliveryNumber, requestStr, requestTime, responseCode, responseStr from exp_topgp_log
select sid, requestId, requestType, expressNum, deliveryNum, requestStr, requestTime, responseCode, responseStr from exp_topgp_log
</sql>
<select id="selectExpTopgpLogList" parameterType="ExpTopgpLog" resultMap="ExpTopgpLogResult">
@ -25,8 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="requestId != null and requestId != ''"> and requestId = #{requestId}</if>
<if test="requestType != null and requestType != ''"> and requestType = #{requestType}</if>
<if test="expressNumber != null and expressNumber != ''"> and expressNumber = #{expressNumber}</if>
<if test="deliveryNumber != null and deliveryNumber != ''"> and deliveryNumber = #{deliveryNumber}</if>
<if test="expressNum != null and expressNum != ''"> and expressNum = #{expressNum}</if>
<if test="deliveryNum != null and deliveryNum != ''"> and deliveryNum = #{deliveryNum}</if>
<if test="requestStr != null and requestStr != ''"> and requestStr = #{requestStr}</if>
<if test="requestTime != null and requestTime != ''"> and requestTime = #{requestTime}</if>
<if test="responseCode != null and responseCode != ''"> and responseCode = #{responseCode}</if>
@ -44,8 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="requestId != null">requestId,</if>
<if test="requestType != null">requestType,</if>
<if test="expressNumber != null">expressNumber,</if>
<if test="deliveryNumber != null">deliveryNumber,</if>
<if test="expressNum != null">expressNum,</if>
<if test="deliveryNum != null">deliveryNum,</if>
<if test="requestStr != null">requestStr,</if>
<if test="requestTime != null">requestTime,</if>
<if test="responseCode != null">responseCode,</if>
@ -54,8 +54,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="requestId != null">#{requestId},</if>
<if test="requestType != null">#{requestType},</if>
<if test="expressNumber != null">#{expressNumber},</if>
<if test="deliveryNumber != null">#{deliveryNumber},</if>
<if test="expressNum != null">#{expressNum},</if>
<if test="deliveryNum != null">#{deliveryNum},</if>
<if test="requestStr != null">#{requestStr},</if>
<if test="requestTime != null">#{requestTime},</if>
<if test="responseCode != null">#{responseCode},</if>
@ -68,8 +68,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="requestId != null">requestId = #{requestId},</if>
<if test="requestType != null">requestType = #{requestType},</if>
<if test="expressNumber != null">expressNumber = #{expressNumber},</if>
<if test="deliveryNumber != null">deliveryNumber = #{deliveryNumber},</if>
<if test="expressNum != null">expressNum = #{expressNum},</if>
<if test="deliveryNum != null">deliveryNum = #{deliveryNum},</if>
<if test="requestStr != null">requestStr = #{requestStr},</if>
<if test="requestTime != null">requestTime = #{requestTime},</if>
<if test="responseCode != null">responseCode = #{responseCode},</if>

View File

@ -21,13 +21,13 @@
<div class="form-group">
<label class="col-sm-3 control-label">快递单:</label>
<div class="col-sm-8">
<input name="expressNumber" class="form-control" type="text">
<input name="expressNum" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">出货单号:</label>
<div class="col-sm-8">
<input name="deliveryNumber" class="form-control" type="text">
<input name="deliveryNum" class="form-control" type="text">
</div>
</div>
<div class="form-group">

View File

@ -22,13 +22,13 @@
<div class="form-group">
<label class="col-sm-3 control-label">快递单:</label>
<div class="col-sm-8">
<input name="expressNumber" th:field="*{expressNumber}" class="form-control" type="text">
<input name="expressNum" th:field="*{expressNum}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">出货单号:</label>
<div class="col-sm-8">
<input name="deliveryNumber" th:field="*{deliveryNumber}" class="form-control" type="text">
<input name="deliveryNum" th:field="*{deliveryNum}" class="form-control" type="text">
</div>
</div>
<div class="form-group">

View File

@ -20,11 +20,11 @@
</li>
<li>
<label>快递单:</label>
<input type="text" name="expressNumber"/>
<input type="text" name="expressNum"/>
</li>
<li>
<label>出货单号:</label>
<input type="text" name="deliveryNumber"/>
<input type="text" name="deliveryNum"/>
</li>
<li>
<label>请求时间:</label>
@ -78,6 +78,7 @@
sortName: "requesttime", //不要用驼峰式变量requestTimemybatis会转换成request_time
sortOrder: "desc",
modalName: "ERP订阅推送日志",
escape: true,
columns: [{
checkbox: true
},
@ -95,11 +96,11 @@
title: '请求类型'
},
{
field: 'expressNumber',
field: 'expressNum',
title: '快递单'
},
{
field: 'deliveryNumber',
field: 'deliveryNum',
title: '出货单号'
},
{

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

@ -20,7 +20,7 @@ public class XmlWebserviceController {
String param = TopgpXmlUtils.GetTopgpRequestXml("express_testRequest", map);
String url = "http://192.168.2.81:85/web/ws/r/aws_ttsrv2_toptest";
String returnXml = HttpUtils.sendXmlPost(url,param);
return TopgpXmlUtils.GetStatusFromTopgpResponse(returnXml).toString();
return TopgpXmlUtils.TopgpResponseXmlToJson(returnXml).toString();
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.common.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.http.HttpUtils;
import org.json.XML;
@ -44,7 +45,7 @@ public class TopgpXmlUtils {
" &lt;/RequestContent>\n" +
" &lt;/Request>\n" +
" </tip:request>\n" +
" </tip:express_testRequest>\n" +
" </tip:"+tip+">\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>");
log.info("=======生成xml结束======");
@ -52,19 +53,102 @@ public class TopgpXmlUtils {
}
/**
* 将TOPGP返回的XML转化为Json,并提出返回Status
* @param TopgpResponseXml 调用TOPGP的Webservice的方法名 express_testRequest
* 将TOPGP返回的XML转化为Json
* @param topgpResponseXml
* @return Status JsonObject
*/
public static JSONObject GetStatusFromTopgpResponse(String TopgpResponseXml) {
JSONObject jsonObject = JSONObject.parseObject(XML.toJSONObject(TopgpResponseXml).toString());
JSONObject envelope = jsonObject.getJSONObject("SOAP-ENV:Envelope");
JSONObject body = envelope.getJSONObject("SOAP-ENV:Body");
JSONObject express_testResponse = body.getJSONObject("fjs1:express_testResponse");
JSONObject fjs1Response = express_testResponse.getJSONObject("fjs1:response");
JSONObject response = fjs1Response.getJSONObject("Response");
JSONObject execution = response.getJSONObject("Execution");
return execution.getJSONObject("Status");
public static JSONObject TopgpResponseXmlToJson(String topgpResponseXml) {
//String xmlString= TopgpResponseTestXml(); //开发测试用xml
String xmlString =XML.toJSONObject(topgpResponseXml).toString();
JSONObject xmlJson = JSONObject.parseObject(xmlString);
JSONObject response = xmlJson.getJSONObject("SOAP-ENV:Envelope")
.getJSONObject("SOAP-ENV:Body").getJSONObject("fjs1:express_testResponse")
.getJSONObject("fjs1:response").getJSONObject("Response");
JSONObject returnJsonObject=new JSONObject();
if(StringUtils.isNotEmpty(response.getString("ResponseContent"))){
JSONObject responseContent = response.getJSONObject("ResponseContent");
if(StringUtils.isNotEmpty(responseContent.getString("Parameter"))){
JSONObject parameter=responseContent.getJSONObject("Parameter");
if(StringUtils.isNotEmpty(parameter.getString("Record"))){
JSONObject record= parameter.getJSONObject("Record");
if(StringUtils.isNotEmpty(record.getString("Field"))){
returnJsonObject.put("Parameter",parameter.getJSONObject("Record").getJSONObject("Field")); //回传参数资料
}
}
}else {
returnJsonObject.put("Parameter",""); //回传参数资料
}
if(StringUtils.isNotEmpty(responseContent.getString("Document"))){
JSONObject document= responseContent.getJSONObject("Document");
if(StringUtils.isNotEmpty(document)){
returnJsonObject.put("document",document.getJSONObject("RecordSet")); //回传单据的单头单身资料
}
}else {
returnJsonObject.put("document","");
}
}
if(StringUtils.isNotEmpty(response.getJSONObject("Execution"))){
if(response.getJSONObject("Execution").containsKey("Status")){
returnJsonObject.put("execution",response.getJSONObject("Execution").getJSONObject("Status")); //服务执行结果
}else {
returnJsonObject.put("execution","");
}
}
return returnJsonObject;
}
//TOPGP返回XML的标准格式开发时可使用该XML进行测试
private static String TopgpResponseTestXml(){
return "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <SOAP-ENV:Body>\n" +
" <fjs1:express_testResponse xmlns:fjs1=\"http://www.dsc.com.tw/tiptop/TIPTOPServiceGateWay\">\n" +
" <fjs1:response>\n" +
"<Response>\n" +
" <Execution>\t<!-- 服务执行结果 -->\n" +
" <Status code=\"0\" sqlcode=\"0\" description=\"\"/>\n" +
" </Execution> \n" +
" <ResponseContent>\n" +
" <Parameter>\t<!-- 参数资料回传 -->\n" +
" <Record>\n" +
" <Field name=\"my_parameter\" value=\"my_value\"/>\n" +
" </Record>\n" +
" </Parameter> \n" +
" <Document>\t<!—单据资料回传(单头单身) -->\n" +
" <RecordSet id=\"1\">\n" +
" <Master name=\"my_name\"> \n" +
" <Record>\n" +
" <Field name=\"my_column\" value=\"my_value\"/>\n" +
" </Record>\n" +
" </Master>\n" +
" <Detail name=\"my_name\">\n" +
" <Record>\n" +
" <Field name=\"my_column\" value=\"my_value\"/>\n" +
" <Field name=\"my_column1\" value=\"my_value1\"/>\n" +
" </Record>\n" +
" </Detail>\n" +
" </RecordSet> \n" +
" <RecordSet id=\"2\">\n" +
" <Master name=”my_name”> \n" +
" <Record>\n" +
" <Field name=\"my_column\" value=\"my_value\"/>\n" +
" </Record>\n" +
" </Master>\n" +
" <Detail name=”my_name”>\n" +
" <Record>\n" +
" <Field name=\"my_column\" value=\"my_value\"/>\n" +
" <Field name=\"my_column1\" value=\"my_value1\"/>\n" +
" </Record>\n" +
" </Detail>\n" +
" </RecordSet>\n" +
" </Document>\n" +
" </ResponseContent>\n" +
"</Response>\n" +
"</fjs1:response>\n" +
" </fjs1:express_testResponse>\n" +
" </SOAP-ENV:Body>\n" +
"</SOAP-ENV:Envelope>";
}

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);