Your Name
2023-08-11 cc8e103aed0cdaf681d813f7601a38d2dd134289
java110-core/src/main/java/com/java110/core/context/DataFlow.java
old mode 100644 new mode 100755
@@ -2,11 +2,12 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.common.util.DateUtil;
import com.java110.common.util.SequenceUtil;
import com.java110.common.util.StringUtil;
import com.java110.entity.center.AppRoute;
import com.java110.entity.center.Business;
import com.java110.dto.system.AppRoute;
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.dto.system.AppBusiness;
import java.util.*;
@@ -115,7 +116,7 @@
    }
    @Override
    public Orders getOrder() {
    public IOrders getOrder() {
        return this;
    }
@@ -181,7 +182,7 @@
    public DataFlow builderByBusiness(String businessInfo) throws Exception{
        try{
            Business business = null;
            AppBusiness business = null;
            JSONObject reqInfoObj = JSONObject.parseObject(businessInfo);
            this.setReqJson(reqInfoObj);
            this.setReqData(businessInfo);
@@ -202,8 +203,8 @@
            this.setCode(response.getString("code"));
            this.setMessage(response.getString("message"));
            businessObj.put("response",response);
            this.businesses = new ArrayList<Business>();
            business = new Business().builder(businessObj);
            this.businesses = new ArrayList<AppBusiness>();
            business = new AppBusiness().builder(businessObj);
            businesses.add(business);
            this.setCurrentBusiness(business);
        }catch (Exception e){
@@ -216,10 +217,20 @@
    public DataFlow doBuilder(String reqInfo, Map<String,String> headerAll) throws Exception{
        try{
            Business business = null;
            AppBusiness 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");
@@ -232,10 +243,10 @@
            this.setRequestTime(orderObj.getString("requestTime"));
            this.setReqOrders(orderObj);
            this.setReqBusiness(businessArray);
            this.businesses = new ArrayList<Business>();
            this.businesses = new ArrayList<AppBusiness>();
            if(businessArray != null && businessArray.size() > 0){
                for(int businessIndex = 0;businessIndex < businessArray.size();businessIndex++) {
                    business = new Business().builder(businessArray.getJSONObject(businessIndex));
                    business = new AppBusiness().builder(businessArray.getJSONObject(businessIndex));
                    businesses.add(business);
                }
            }
@@ -265,23 +276,23 @@
    public DataFlow builderTransfer(String reqInfo, Map<String,String> headerAll) throws Exception{
        try{
            Business business = null;
            AppBusiness business = null;
            this.setReqData(reqInfo);
            this.setDataFlowId("-1");
            this.setAppId(headerAll.get("appId"));
            this.setTransactionId(StringUtil.isNullOrNone(headerAll.get("transactionId"))? SequenceUtil.getTransactionId():headerAll.get("transactionId"));
            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>();
            this.businesses = new ArrayList<AppBusiness>();
            if(!StringUtil.isNullOrNone(serviceCode)){
                JSONObject bInfo = new JSONObject();
                bInfo.put("serviceCode",serviceCode);
                bInfo.put("transferData",reqInfo);
                    business = new Business().builder(bInfo);
                    business = new AppBusiness().builder(bInfo);
                    businesses.add(business);
                this.setCurrentBusiness(business);
            }
@@ -301,4 +312,23 @@
        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;
    }
}