From 8dc6389c6d65d49bfb2569a39ffa3494b5e7ff48 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期四, 12 五月 2022 12:28:25 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity
---
java110-core/src/main/java/com/java110/core/context/DataFlow.java | 96 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 89 insertions(+), 7 deletions(-)
diff --git a/java110-core/src/main/java/com/java110/core/context/DataFlow.java b/java110-core/src/main/java/com/java110/core/context/DataFlow.java
old mode 100644
new mode 100755
index d632ac6..1dfc41f
--- a/java110-core/src/main/java/com/java110/core/context/DataFlow.java
+++ b/java110-core/src/main/java/com/java110/core/context/DataFlow.java
@@ -2,6 +2,10 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.util.DateUtil;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.utils.util.StringUtil;
import com.java110.entity.center.AppRoute;
import com.java110.entity.center.Business;
@@ -112,7 +116,7 @@
}
@Override
- public Orders getOrder() {
+ public IOrders getOrder() {
return this;
}
@@ -181,6 +185,7 @@
Business business = null;
JSONObject reqInfoObj = JSONObject.parseObject(businessInfo);
this.setReqJson(reqInfoObj);
+ this.setReqData(businessInfo);
this.setDataFlowId(reqInfoObj.containsKey("dataFlowId")?reqInfoObj.getString("dataFlowId"):"-1");
//this.setAppId(orderObj.getString("appId"));
this.setTransactionId(reqInfoObj.getString("transactionId"));
@@ -209,13 +214,24 @@
return this;
}
- public DataFlow builder(String reqInfo, Map<String,String> headerAll) throws Exception{
+ public DataFlow doBuilder(String reqInfo, Map<String,String> headerAll) throws Exception{
try{
Business business = null;
JSONObject reqInfoObj = JSONObject.parseObject(reqInfo);
- JSONObject orderObj = reqInfoObj.getJSONObject("orders");
- JSONArray businessArray = reqInfoObj.getJSONArray("business");
+ JSONObject orderObj = refreshOrderObj(reqInfoObj,headerAll);
+ Object businessObj = reqInfoObj.get("business");
+ JSONArray businessArray = null;
+ if(businessObj instanceof JSONObject){
+ businessArray = new JSONArray();
+ businessArray.add(reqInfoObj.getJSONObject("business"));
+ }else if(businessObj instanceof JSONArray){
+ businessArray = reqInfoObj.getJSONArray("business");
+ }else{
+ // 涓嶅仛澶勭悊
+ }
+
+ this.setReqData(reqInfo);
this.setReqJson(reqInfoObj);
this.setDataFlowId(orderObj.containsKey("dataFlowId")?orderObj.getString("dataFlowId"):"-1");
this.setAppId(orderObj.getString("appId"));
@@ -236,9 +252,10 @@
}
if (headerAll != null){
- this.headers.putAll(headerAll);
- this.setRequestURL(headers.get("REQUEST_URL"));
- this.setIp(headers.get("IP"));
+ this.requestHeaders.putAll(headerAll);
+ this.requestCurrentHeaders.putAll(headerAll);
+ this.setRequestURL(requestHeaders.get("REQUEST_URL"));
+ this.setIp(requestHeaders.get("IP"));
}
@@ -249,4 +266,69 @@
return this;
}
+ /**
+ * 閫忎紶鏃舵瀯寤哄璞�
+ * @param reqInfo
+ * @param headerAll
+ * @return
+ * @throws Exception
+ */
+ public DataFlow builderTransfer(String reqInfo, Map<String,String> headerAll) throws Exception{
+
+ try{
+ Business business = null;
+ this.setReqData(reqInfo);
+ this.setDataFlowId("-1");
+ this.setAppId(headerAll.get("appId"));
+ this.setTransactionId(StringUtil.isNullOrNone(headerAll.get("transactionId"))? GenerateCodeFactory.getTransactionId():headerAll.get("transactionId"));
+ this.setUserId(StringUtil.isNullOrNone(headerAll.get("userId"))? "-1":headerAll.get("userId"));
+ this.setOrderTypeCd("T");
+ this.setRemark(StringUtil.isNullOrNone(headerAll.get("remark"))? "":headerAll.get("remark"));
+ this.setReqSign(StringUtil.isNullOrNone(headerAll.get("sign"))? "":headerAll.get("sign"));
+ this.setRequestTime(StringUtil.isNullOrNone(headerAll.get("requestTime"))? DateUtil.getyyyyMMddhhmmssDateString():headerAll.get("requestTime"));
+ String serviceCode = headerAll.get("serviceCode");
+ this.businesses = new ArrayList<Business>();
+ if(!StringUtil.isNullOrNone(serviceCode)){
+ JSONObject bInfo = new JSONObject();
+ bInfo.put("serviceCode",serviceCode);
+ bInfo.put("transferData",reqInfo);
+ business = new Business().builder(bInfo);
+ businesses.add(business);
+ this.setCurrentBusiness(business);
+ }
+
+ if (headerAll != null){
+ this.requestHeaders.putAll(headerAll);
+ this.requestCurrentHeaders.putAll(headerAll);
+ this.setRequestURL(requestHeaders.get("REQUEST_URL"));
+ this.setIp(requestHeaders.get("IP"));
+ }
+
+
+ }catch (Exception e){
+
+ throw e;
+ }
+ return this;
+ }
+
+ private JSONObject refreshOrderObj(JSONObject reqInfoObj,Map<String,String> headerAll){
+
+ JSONObject reqInfoOrder = reqInfoObj.getJSONObject("orders");
+
+ if(!reqInfoOrder.containsKey("appId")) {
+ reqInfoOrder.put("appId", headerAll.get(CommonConstant.HTTP_APP_ID));
+ }
+ if(!reqInfoOrder.containsKey("transactionId")) {
+ reqInfoOrder.put("transactionId", headerAll.get(CommonConstant.HTTP_TRANSACTION_ID));
+ }
+ if(!reqInfoOrder.containsKey("sign")) {
+ reqInfoOrder.put("sign", headerAll.get(CommonConstant.HTTP_SIGN));
+ }
+
+ if(!reqInfoOrder.containsKey("requestTime")) {
+ reqInfoOrder.put("requestTime", headerAll.get(CommonConstant.HTTP_REQ_TIME));
+ }
+ return reqInfoOrder;
+ }
}
--
Gitblit v1.8.0