wuxw7
2018-04-18 ea3bded6c8659fbc0f2c1cb604bfe466c00ed32a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
package com.java110.entity.center;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
 
import java.util.*;
 
/**
 * 主要用于离散成对象 httpApi service 请求过程消息记录和返回记录
 * Created by wuxw on 2018/4/13.
 */
public class DataFlow {
 
 
    private String dataFlowId;
 
    private String oId;
 
    //交易流水
    private String transactionId;
 
    private String appId;
 
    private String userId;
 
    private String ip;
 
    private String orderTypeCd;
 
    private String requestTime;
 
    private String remark;
 
    private String reqSign;
 
    private JSONObject reqOrders;
 
    private JSONArray reqBusiness;
 
    private String responseTime;
 
    private String resSign;
 
    private String code;
 
    private String message;
 
    private JSONObject resOrders;
 
    private JSONArray resBusiness;
 
    //请求开始时间
    private Date startDate;
 
    //请求完成时间
    private Date endDate;
 
    private JSONObject reqJson;
 
    private JSONObject resJson;
 
    private List<Business> businesses;
 
    private String requestURL;
 
    private List<DataFlowLinksCost> linksCostDates = new ArrayList<DataFlowLinksCost>();
 
    private Map<String,String> headers = new HashMap<String,String>();
 
    /*private AppRoute appRoute;*/
 
    private List<AppRoute> appRoutes = new ArrayList<AppRoute>();
    //请求业务系统报文
    private JSONObject requestBusinessJson;
 
    //业务系统返回报文
    private JSONObject responseBusinessJson;
 
    public String getoId() {
        return oId;
    }
 
    public void setoId(String oId) {
        this.oId = oId;
    }
 
    public List<Business> getBusinesses() {
        return businesses;
    }
 
    public String getDataFlowId() {
        return dataFlowId;
    }
 
    public void setDataFlowId(String dataFlowId) {
        this.dataFlowId = dataFlowId;
    }
 
    public void setBusinesses(List<Business> businesses) {
        this.businesses = businesses;
    }
 
 
    //public DataFlow(){}
 
    public DataFlow(Date startDate,String code){
        this.setStartDate(startDate);
        this.setCode(code);
    }
 
 
    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }
 
    public void setAppId(String appId) {
        this.appId = appId;
    }
 
    public void setUserId(String userId) {
        this.userId = userId;
    }
 
    public void setOrderTypeCd(String orderTypeCd) {
        this.orderTypeCd = orderTypeCd;
    }
 
    public void setRequestTime(String requestTime) {
        this.requestTime = requestTime;
    }
 
    public void setRemark(String remark) {
        this.remark = remark;
    }
 
    public void setReqSign(String reqSign) {
        this.reqSign = reqSign;
    }
 
    public void setReqOrders(JSONObject reqOrders) {
        this.reqOrders = reqOrders;
    }
 
    public void setReqBusiness(JSONArray reqBusiness) {
        this.reqBusiness = reqBusiness;
    }
 
    public void setResponseTime(String responseTime) {
        this.responseTime = responseTime;
    }
 
    public void setResSign(String resSign) {
        this.resSign = resSign;
    }
 
    public void setCode(String code) {
        this.code = code;
    }
 
    public void setMessage(String message) {
        this.message = message;
    }
 
    public void setResOrders(JSONObject resOrders) {
        this.resOrders = resOrders;
    }
 
    public void setResBusiness(JSONArray resBusiness) {
        this.resBusiness = resBusiness;
    }
 
    public String getTransactionId() {
        return transactionId;
    }
 
    public String getAppId() {
        return appId;
    }
 
    public String getUserId() {
        return userId;
    }
 
    public String getOrderTypeCd() {
        return orderTypeCd;
    }
 
    public String getRequestTime() {
        return requestTime;
    }
 
    public String getRemark() {
        return remark;
    }
 
    public String getReqSign() {
        return reqSign;
    }
 
    public JSONObject getReqOrders() {
        return reqOrders;
    }
 
    public JSONArray getReqBusiness() {
        return reqBusiness;
    }
 
    public String getResponseTime() {
        return responseTime;
    }
 
    public String getResSign() {
        return resSign;
    }
 
    public String getCode() {
        return code;
    }
 
    public String getMessage() {
        return message;
    }
 
    public JSONObject getResOrders() {
        return resOrders;
    }
 
    public JSONArray getResBusiness() {
        return resBusiness;
    }
 
 
    public Date getStartDate() {
        return startDate;
    }
 
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }
 
    public Date getEndDate() {
        return endDate;
    }
 
    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }
 
 
 
    public String getRequestURL() {
        return requestURL;
    }
 
    public void setRequestURL(String requestURL) {
        this.requestURL = requestURL;
    }
 
    public Map<String, String> getHeaders() {
        return headers;
    }
 
    /*public AppRoute getAppRoute() {
        return appRoute;
    }
 
    public void setAppRoute(AppRoute appRoute) {
        this.appRoute = appRoute;
    }*/
 
    public List<AppRoute> getAppRoutes() {
        return appRoutes;
    }
 
    public void addAppRoutes(AppRoute appRoute) {
        this.appRoutes.add(appRoute);
    }
 
    public String getIp() {
        return ip;
    }
 
    public void setIp(String ip) {
        this.ip = ip;
    }
 
 
    public JSONObject getRequestBusinessJson() {
        return requestBusinessJson;
    }
 
    public void setRequestBusinessJson(JSONObject requestBusinessJson) {
        this.requestBusinessJson = requestBusinessJson;
    }
 
    public JSONObject getResponseBusinessJson() {
        return responseBusinessJson;
    }
 
    public void setResponseBusinessJson(JSONObject responseBusinessJson) {
        this.responseBusinessJson = responseBusinessJson;
    }
 
    public JSONObject getReqJson() {
        return reqJson;
    }
 
    public void setReqJson(JSONObject reqJson) {
        this.reqJson = reqJson;
    }
 
    public JSONObject getResJson() {
        return resJson;
    }
 
    public void setResJson(JSONObject resJson) {
        this.resJson = resJson;
    }
 
    public List<DataFlowLinksCost> getLinksCostDates() {
        return linksCostDates;
    }
 
    /**
     * 添加各个环节的耗时
     * @param dataFlowLinksCost
     */
    public void addLinksCostDates(DataFlowLinksCost dataFlowLinksCost){
        this.linksCostDates.add(dataFlowLinksCost);
    }
 
    public DataFlow builder(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");
            this.setReqJson(reqInfoObj);
            this.setDataFlowId(orderObj.containsKey("dataFlowId")?orderObj.getString("dataFlowId"):"-1");
            this.setAppId(orderObj.getString("appId"));
            this.setAppId(orderObj.getString("transactionId"));
            this.setUserId(orderObj.getString("userId"));
            this.setOrderTypeCd(orderObj.getString("orderTypeCd"));
            this.setRemark(orderObj.getString("remark"));
            this.setReqSign(orderObj.getString("sign"));
            this.setRequestTime(orderObj.getString("requestTime"));
            this.setReqOrders(orderObj);
            this.setReqBusiness(businessArray);
            this.businesses = new ArrayList<Business>();
            if(businessArray != null && businessArray.size() > 0){
                for(int businessIndex = 0;businessIndex < businessArray.size();businessIndex++) {
                    business = new Business().builder(businessArray.getJSONObject(businessIndex));
                    businesses.add(business);
                }
            }
 
            if (headerAll != null){
                this.headers.putAll(headerAll);
                this.setRequestURL(headers.get("REQUEST_URL"));
                this.setIp(headers.get("IP"));
            }
 
 
        }catch (Exception e){
            throw e;
        }
        return this;
    }
 
 
 
}