Commit 635bd1a0 by wubh

包活干V2.3.0-修改命名

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@30384 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent b114d76f
package com.glsx.ordercenter.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.StringUtils;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.req.*;
import com.glsx.ordercenter.dto.req.DaSouCheDevice;
import com.glsx.ordercenter.dto.req.DaSouCheRemoveDevice;
import com.glsx.ordercenter.dto.req.DaSouCheRemoveOrderReq;
import com.glsx.ordercenter.dto.req.DaSouCheRepairOrderReq;
import com.glsx.ordercenter.dto.req.MsBaseReq;
import com.glsx.ordercenter.dto.req.MsFeedbackReq;
import com.glsx.ordercenter.dto.req.MsInstallOrderReq;
import com.glsx.ordercenter.exception.MsBusinessException;
import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.plat.common.utils.HttpUtils;
......@@ -14,13 +26,9 @@ import com.souche.api.SoucheApiException;
import com.souche.api.util.SoucheSignature;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
@Component
@Slf4j
public class MsSignUtil {
......@@ -36,26 +44,23 @@ public class MsSignUtil {
*/
private static final long BUNDLED_ORDER_TIME_DIFF = 20 * 1000;
@PostConstruct
public void initialize() {
MsSignUtil.serverUrl = PropertiesUtil.getProperty("msyz.serverUrl");
MsSignUtil.appKey = PropertiesUtil.getProperty("msyz.appKey");
MsSignUtil.appSecret = PropertiesUtil.getProperty("msyz.appSecret");
public MsSignUtil(@Value("${msyz.serverUrl}") String serverUrl,
@Value("${msyz.appKey}") String appKey,
@Value("${msyz.appSecret}") String appSecret) {
MsSignUtil.serverUrl = serverUrl;
MsSignUtil.appKey = appKey;
MsSignUtil.appSecret = appSecret;
}
/**
* 传送数据生成sign
* @param msReq
* @param appSecret
* @return
* @throws SoucheApiException
*/
public static MsFeedbackReq fillSign(MsFeedbackReq msReq, String appSecret)
throws SoucheApiException {
Map<String, String> signMap = objectToMap(msReq);
String sign = SoucheSignature.sign(signMap, appSecret);
msReq.setSign(sign);
return msReq;
public static JSONObject postForObject(String api, Object data) throws SoucheApiException {
MsFeedbackReq msReq = new MsFeedbackReq(api, appKey, data);
fillSign(msReq, appSecret);
log.info("==== 请求民生易租接口地址 url = {}, api = {}", serverUrl, api);
log.info("==== 请求民生易租反馈参数:{}", JSON.toJSONString(msReq));
String respJson = HttpUtils.post(serverUrl, JSON.toJSONString(msReq));
log.info("==== 民生易租反馈接口返回:{}", respJson);
JSONObject msResp = JSON.parseObject(JSON.parseObject(respJson, String.class));
return msResp;
}
/**
......@@ -88,15 +93,19 @@ public class MsSignUtil {
return devType;
}
public static JSONObject postForObject(String api, Object data) throws SoucheApiException {
MsFeedbackReq msReq = new MsFeedbackReq(api, appKey, data);
fillSign(msReq, appSecret);
log.info("==== 请求民生易租接口地址 url = {}, api = {}", serverUrl, api);
log.info("==== 请求民生易租反馈参数:{}", JSON.toJSONString(msReq));
String respJson = HttpUtils.post(serverUrl, JSON.toJSONString(msReq));
log.info("==== 民生易租反馈接口返回:{}", respJson);
JSONObject msResp = JSON.parseObject(JSON.parseObject(respJson, String.class));
return msResp;
/**
* 传送数据生成sign
* @param msReq
* @param appSecret
* @return
* @throws SoucheApiException
*/
private static MsFeedbackReq fillSign(MsFeedbackReq msReq, String appSecret)
throws SoucheApiException {
Map<String, String> signMap = objectToMap(msReq);
String sign = SoucheSignature.sign(signMap, appSecret);
msReq.setSign(sign);
return msReq;
}
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!