DataFlow.java 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. package com.java110.entity.center;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import java.util.*;
  5. /**
  6. * 主要用于离散成对象 httpApi service 请求过程消息记录和返回记录
  7. * Created by wuxw on 2018/4/13.
  8. */
  9. public class DataFlow {
  10. private String dataFlowId;
  11. private String oId;
  12. //交易流水
  13. private String transactionId;
  14. private String appId;
  15. private String userId;
  16. private String ip;
  17. private String orderTypeCd;
  18. private String requestTime;
  19. private String remark;
  20. private String reqSign;
  21. private JSONObject reqOrders;
  22. private JSONArray reqBusiness;
  23. private String responseTime;
  24. private String resSign;
  25. private String code;
  26. private String message;
  27. private JSONObject resOrders;
  28. private JSONArray resBusiness;
  29. //请求开始时间
  30. private Date startDate;
  31. //请求完成时间
  32. private Date endDate;
  33. private JSONObject reqJson;
  34. private JSONObject resJson;
  35. private List<Business> businesses;
  36. private String requestURL;
  37. private List<DataFlowLinksCost> linksCostDates = new ArrayList<DataFlowLinksCost>();
  38. private Map<String,String> headers = new HashMap<String,String>();
  39. /*private AppRoute appRoute;*/
  40. private List<AppRoute> appRoutes = new ArrayList<AppRoute>();
  41. //请求业务系统报文
  42. private JSONObject requestBusinessJson;
  43. //业务系统返回报文
  44. private JSONObject responseBusinessJson;
  45. public String getoId() {
  46. return oId;
  47. }
  48. public void setoId(String oId) {
  49. this.oId = oId;
  50. }
  51. public List<Business> getBusinesses() {
  52. return businesses;
  53. }
  54. public String getDataFlowId() {
  55. return dataFlowId;
  56. }
  57. public void setDataFlowId(String dataFlowId) {
  58. this.dataFlowId = dataFlowId;
  59. }
  60. public void setBusinesses(List<Business> businesses) {
  61. this.businesses = businesses;
  62. }
  63. //public DataFlow(){}
  64. public DataFlow(Date startDate,String code){
  65. this.setStartDate(startDate);
  66. this.setCode(code);
  67. }
  68. public void setTransactionId(String transactionId) {
  69. this.transactionId = transactionId;
  70. }
  71. public void setAppId(String appId) {
  72. this.appId = appId;
  73. }
  74. public void setUserId(String userId) {
  75. this.userId = userId;
  76. }
  77. public void setOrderTypeCd(String orderTypeCd) {
  78. this.orderTypeCd = orderTypeCd;
  79. }
  80. public void setRequestTime(String requestTime) {
  81. this.requestTime = requestTime;
  82. }
  83. public void setRemark(String remark) {
  84. this.remark = remark;
  85. }
  86. public void setReqSign(String reqSign) {
  87. this.reqSign = reqSign;
  88. }
  89. public void setReqOrders(JSONObject reqOrders) {
  90. this.reqOrders = reqOrders;
  91. }
  92. public void setReqBusiness(JSONArray reqBusiness) {
  93. this.reqBusiness = reqBusiness;
  94. }
  95. public void setResponseTime(String responseTime) {
  96. this.responseTime = responseTime;
  97. }
  98. public void setResSign(String resSign) {
  99. this.resSign = resSign;
  100. }
  101. public void setCode(String code) {
  102. this.code = code;
  103. }
  104. public void setMessage(String message) {
  105. this.message = message;
  106. }
  107. public void setResOrders(JSONObject resOrders) {
  108. this.resOrders = resOrders;
  109. }
  110. public void setResBusiness(JSONArray resBusiness) {
  111. this.resBusiness = resBusiness;
  112. }
  113. public String getTransactionId() {
  114. return transactionId;
  115. }
  116. public String getAppId() {
  117. return appId;
  118. }
  119. public String getUserId() {
  120. return userId;
  121. }
  122. public String getOrderTypeCd() {
  123. return orderTypeCd;
  124. }
  125. public String getRequestTime() {
  126. return requestTime;
  127. }
  128. public String getRemark() {
  129. return remark;
  130. }
  131. public String getReqSign() {
  132. return reqSign;
  133. }
  134. public JSONObject getReqOrders() {
  135. return reqOrders;
  136. }
  137. public JSONArray getReqBusiness() {
  138. return reqBusiness;
  139. }
  140. public String getResponseTime() {
  141. return responseTime;
  142. }
  143. public String getResSign() {
  144. return resSign;
  145. }
  146. public String getCode() {
  147. return code;
  148. }
  149. public String getMessage() {
  150. return message;
  151. }
  152. public JSONObject getResOrders() {
  153. return resOrders;
  154. }
  155. public JSONArray getResBusiness() {
  156. return resBusiness;
  157. }
  158. public Date getStartDate() {
  159. return startDate;
  160. }
  161. public void setStartDate(Date startDate) {
  162. this.startDate = startDate;
  163. }
  164. public Date getEndDate() {
  165. return endDate;
  166. }
  167. public void setEndDate(Date endDate) {
  168. this.endDate = endDate;
  169. }
  170. public String getRequestURL() {
  171. return requestURL;
  172. }
  173. public void setRequestURL(String requestURL) {
  174. this.requestURL = requestURL;
  175. }
  176. public Map<String, String> getHeaders() {
  177. return headers;
  178. }
  179. /*public AppRoute getAppRoute() {
  180. return appRoute;
  181. }
  182. public void setAppRoute(AppRoute appRoute) {
  183. this.appRoute = appRoute;
  184. }*/
  185. public List<AppRoute> getAppRoutes() {
  186. return appRoutes;
  187. }
  188. public void addAppRoutes(AppRoute appRoute) {
  189. this.appRoutes.add(appRoute);
  190. }
  191. public String getIp() {
  192. return ip;
  193. }
  194. public void setIp(String ip) {
  195. this.ip = ip;
  196. }
  197. public JSONObject getRequestBusinessJson() {
  198. return requestBusinessJson;
  199. }
  200. public void setRequestBusinessJson(JSONObject requestBusinessJson) {
  201. this.requestBusinessJson = requestBusinessJson;
  202. }
  203. public JSONObject getResponseBusinessJson() {
  204. return responseBusinessJson;
  205. }
  206. public void setResponseBusinessJson(JSONObject responseBusinessJson) {
  207. this.responseBusinessJson = responseBusinessJson;
  208. }
  209. public JSONObject getReqJson() {
  210. return reqJson;
  211. }
  212. public void setReqJson(JSONObject reqJson) {
  213. this.reqJson = reqJson;
  214. }
  215. public JSONObject getResJson() {
  216. return resJson;
  217. }
  218. public void setResJson(JSONObject resJson) {
  219. this.resJson = resJson;
  220. }
  221. public List<DataFlowLinksCost> getLinksCostDates() {
  222. return linksCostDates;
  223. }
  224. /**
  225. * 添加各个环节的耗时
  226. * @param dataFlowLinksCost
  227. */
  228. public void addLinksCostDates(DataFlowLinksCost dataFlowLinksCost){
  229. this.linksCostDates.add(dataFlowLinksCost);
  230. }
  231. public DataFlow builder(String reqInfo, Map<String,String> headerAll) throws Exception{
  232. try{
  233. Business business = null;
  234. JSONObject reqInfoObj = JSONObject.parseObject(reqInfo);
  235. JSONObject orderObj = reqInfoObj.getJSONObject("orders");
  236. JSONArray businessArray = reqInfoObj.getJSONArray("business");
  237. this.setReqJson(reqInfoObj);
  238. this.setDataFlowId(orderObj.containsKey("dataFlowId")?orderObj.getString("dataFlowId"):"-1");
  239. this.setAppId(orderObj.getString("appId"));
  240. this.setTransactionId(orderObj.getString("transactionId"));
  241. this.setUserId(orderObj.getString("userId"));
  242. this.setOrderTypeCd(orderObj.getString("orderTypeCd"));
  243. this.setRemark(orderObj.getString("remark"));
  244. this.setReqSign(orderObj.getString("sign"));
  245. this.setRequestTime(orderObj.getString("requestTime"));
  246. this.setReqOrders(orderObj);
  247. this.setReqBusiness(businessArray);
  248. this.businesses = new ArrayList<Business>();
  249. if(businessArray != null && businessArray.size() > 0){
  250. for(int businessIndex = 0;businessIndex < businessArray.size();businessIndex++) {
  251. business = new Business().builder(businessArray.getJSONObject(businessIndex));
  252. businesses.add(business);
  253. }
  254. }
  255. if (headerAll != null){
  256. this.headers.putAll(headerAll);
  257. this.setRequestURL(headers.get("REQUEST_URL"));
  258. this.setIp(headers.get("IP"));
  259. }
  260. }catch (Exception e){
  261. throw e;
  262. }
  263. return this;
  264. }
  265. }