|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import com.weaver.common.cache.base.BaseCache;
|
|
|
|
import com.weaver.common.cache.base.BaseCache;
|
|
|
|
|
|
|
|
import com.weaver.seconddev.interfaces.htjt.util.TransUtil;
|
|
|
|
import com.weaver.seconddev.interfaces.prop.ConfigProp;
|
|
|
|
import com.weaver.seconddev.interfaces.prop.ConfigProp;
|
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
@ -45,7 +46,18 @@ public class CallDTtripService extends BaseBean {
|
|
|
|
jsonObject.put("isEncrypt", false);
|
|
|
|
jsonObject.put("isEncrypt", false);
|
|
|
|
jsonObject.put("random", UUID.randomUUID().toString());
|
|
|
|
jsonObject.put("random", UUID.randomUUID().toString());
|
|
|
|
jsonObject.put("timestamp", new Date().getTime());
|
|
|
|
jsonObject.put("timestamp", new Date().getTime());
|
|
|
|
String accessToken = getToken(jsonObject);
|
|
|
|
String outEmployeeId = String.valueOf(param.get("outEmployeeId"));
|
|
|
|
|
|
|
|
String account = Util.null2String(getPropValue("htsloasync", "dttrip_account")).trim();
|
|
|
|
|
|
|
|
String password = Util.null2String(getPropValue("htsloasync", "dttrip_password")).trim();
|
|
|
|
|
|
|
|
String secret = Util.null2String(getPropValue("htsloasync", "dttrip_secret")).trim();
|
|
|
|
|
|
|
|
TransUtil tu = new TransUtil();
|
|
|
|
|
|
|
|
Map<String,String> map = tu.getDTtripMt(outEmployeeId);
|
|
|
|
|
|
|
|
if(!"".equals(Util.null2String(map.get("account")))){
|
|
|
|
|
|
|
|
account = map.get("account");
|
|
|
|
|
|
|
|
password = map.get("password");
|
|
|
|
|
|
|
|
secret = map.get("secret");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String accessToken = getToken(jsonObject,account,password);
|
|
|
|
if ("E".equals(accessToken)) {
|
|
|
|
if ("E".equals(accessToken)) {
|
|
|
|
str[0] = "E";
|
|
|
|
str[0] = "E";
|
|
|
|
str[1] = "获取同程Token失败!";
|
|
|
|
str[1] = "获取同程Token失败!";
|
|
|
@ -55,7 +67,7 @@ public class CallDTtripService extends BaseBean {
|
|
|
|
jsonObject.put("accessToken", accessToken);
|
|
|
|
jsonObject.put("accessToken", accessToken);
|
|
|
|
jsonObject.put("param", param);
|
|
|
|
jsonObject.put("param", param);
|
|
|
|
logger_a99d9846.error("调用同程差旅单接口数据:" + jsonObject.toJSONString());
|
|
|
|
logger_a99d9846.error("调用同程差旅单接口数据:" + jsonObject.toJSONString());
|
|
|
|
httpPost = new HttpPost(url + "?sign=" + getSign(jsonObject.toJSONString()));
|
|
|
|
httpPost = new HttpPost(url + "?sign=" + getSign(jsonObject.toJSONString(),secret));
|
|
|
|
httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=UTF-8");
|
|
|
|
httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=UTF-8");
|
|
|
|
httpPost.setHeader("Accept", "application/json; charset=UTF-8");
|
|
|
|
httpPost.setHeader("Accept", "application/json; charset=UTF-8");
|
|
|
|
StringEntity entity = new StringEntity(jsonObject.toJSONString(), "UTF-8");
|
|
|
|
StringEntity entity = new StringEntity(jsonObject.toJSONString(), "UTF-8");
|
|
|
@ -90,7 +102,7 @@ public class CallDTtripService extends BaseBean {
|
|
|
|
return str;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getToken(JSONObject jsonObject) {
|
|
|
|
public String getToken(JSONObject jsonObject,String account,String password){
|
|
|
|
// String token = (String) Util_DataCache.getObjVal("DTtrip_token");
|
|
|
|
// String token = (String) Util_DataCache.getObjVal("DTtrip_token");
|
|
|
|
String token = "";
|
|
|
|
String token = "";
|
|
|
|
if (token == null) {
|
|
|
|
if (token == null) {
|
|
|
@ -99,8 +111,8 @@ public class CallDTtripService extends BaseBean {
|
|
|
|
// String account = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htsloasync.dttrip_account")).trim();
|
|
|
|
// String account = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htsloasync.dttrip_account")).trim();
|
|
|
|
// String password = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htsloasync.dttrip_password")).trim();
|
|
|
|
// String password = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htsloasync.dttrip_password")).trim();
|
|
|
|
String url = configProp.getDttrip_tokenUrl();
|
|
|
|
String url = configProp.getDttrip_tokenUrl();
|
|
|
|
String account = configProp.getDttrip_account();
|
|
|
|
// String account = configProp.getDttrip_account();
|
|
|
|
String password = configProp.getDttrip_password();
|
|
|
|
// String password = configProp.getDttrip_password();
|
|
|
|
httpPost = new HttpPost(url);
|
|
|
|
httpPost = new HttpPost(url);
|
|
|
|
httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=UTF-8");
|
|
|
|
httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=UTF-8");
|
|
|
|
httpPost.setHeader("Accept", "application/json; charset=UTF-8");
|
|
|
|
httpPost.setHeader("Accept", "application/json; charset=UTF-8");
|
|
|
@ -140,9 +152,9 @@ public class CallDTtripService extends BaseBean {
|
|
|
|
return token;
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getSign(String postJson) {
|
|
|
|
public String getSign(String postJson,String secret){
|
|
|
|
// String secret = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htsloasync.dttrip_secret")).trim();
|
|
|
|
// String secret = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htsloasync.dttrip_secret")).trim();
|
|
|
|
String secret = configProp.getDttrip_secret();
|
|
|
|
// String secret = configProp.getDttrip_secret();
|
|
|
|
String postData_md5 = SecureUtil.md5(postJson).toLowerCase();
|
|
|
|
String postData_md5 = SecureUtil.md5(postJson).toLowerCase();
|
|
|
|
String finallySign = SecureUtil.md5(postData_md5 + secret).toLowerCase();
|
|
|
|
String finallySign = SecureUtil.md5(postData_md5 + secret).toLowerCase();
|
|
|
|
return finallySign;
|
|
|
|
return finallySign;
|
|
|
|