From e64197421cf28099935f71f193989a3394d47fe0 Mon Sep 17 00:00:00 2001
From: mrzcc <121184950@qq.com>
Date: 星期一, 17 二月 2020 18:12:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java | 717 ++++++++++++++++-------------------------------------------
1 files changed, 196 insertions(+), 521 deletions(-)
diff --git a/OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java b/OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java
index d289b06..8183d6e 100644
--- a/OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java
+++ b/OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java
@@ -2,20 +2,41 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.java110.common.cache.AppRouteCache;
-import com.java110.common.cache.MappingCache;
-import com.java110.common.constant.*;
-import com.java110.common.exception.*;
-import com.java110.common.factory.ApplicationContextFactory;
-import com.java110.common.kafka.KafkaFactory;
-import com.java110.common.log.LoggerEngine;
-import com.java110.common.util.*;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.constant.KafkaConstant;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.ServiceBusinessConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.BusinessException;
+import com.java110.utils.exception.BusinessStatusException;
+import com.java110.utils.exception.ConfigDataException;
+import com.java110.utils.exception.DAOException;
+import com.java110.utils.exception.DecryptException;
+import com.java110.utils.exception.InitConfigDataException;
+import com.java110.utils.exception.NoAuthorityException;
+import com.java110.utils.exception.NoSupportException;
+import com.java110.utils.exception.OrdersException;
+import com.java110.utils.exception.RuleException;
+import com.java110.utils.exception.SMOException;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.kafka.KafkaFactory;
+import com.java110.utils.log.LoggerEngine;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ServiceBusinessUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.utils.util.WebServiceAxisClient;
import com.java110.core.client.RestTemplate;
-import com.java110.core.context.*;
+import com.java110.core.context.DataFlow;
+import com.java110.core.context.IOrderDataFlowContext;
+import com.java110.core.context.IOrderNotifyDataFlowContext;
+import com.java110.core.context.IOrderResponse;
+import com.java110.core.context.OrderDataFlow;
+import com.java110.core.context.OrderNotifyDataFlow;
import com.java110.core.factory.AuthenticationFactory;
import com.java110.core.factory.OrderDataFlowContextFactory;
-import com.java110.core.factory.GenerateCodeFactory;
-import com.java110.entity.center.AppRoute;
import com.java110.entity.center.AppService;
import com.java110.entity.center.DataFlowLinksCost;
import com.java110.entity.order.Business;
@@ -36,7 +57,11 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
@@ -45,19 +70,12 @@
*/
@Service("orderServiceSMOImpl")
//@Transactional
-public class OrderServiceSMOImpl implements IOrderServiceSMO {
+public class OrderServiceSMOImpl extends AbstractOrderServiceSMOImpl implements IOrderServiceSMO {
- private final static Logger logger = LoggerFactory.getLogger(OrderServiceSMOImpl.class);
+ private static Logger logger = LoggerFactory.getLogger(OrderServiceSMOImpl.class);
- @Autowired
- ICenterServiceDAO centerServiceDaoImpl;
- @Autowired
- private RestTemplate restTemplate;
-
- @Autowired
- private RestTemplate restTemplateNoLoadBalanced;
@Autowired
private IQueryServiceSMO queryServiceSMOImpl;
@@ -65,10 +83,11 @@
/**
* 涓氬姟缁熶竴澶勭悊鏈嶅姟鏂规硶
+ *
* @param reqJson 璇锋眰鎶ユ枃json
* @return
*/
- public ResponseEntity<String> service(String reqJson, Map<String,String> headers) throws SMOException{
+ public ResponseEntity<String> service(String reqJson, Map<String, String> headers) throws SMOException {
IOrderDataFlowContext dataFlow = null;
JSONObject responseJson = null;
@@ -76,7 +95,7 @@
ResponseEntity<String> responseEntity = null;
try {
- DataFlowEventPublishing.preValidateData(reqJson,headers);
+ DataFlowEventPublishing.preValidateData(reqJson, headers);
//1.0 鍒涘缓鏁版嵁娴�
dataFlow = OrderDataFlowContextFactory.newInstance(OrderDataFlow.class).builder(reqJson, headers);
DataFlowEventPublishing.initDataFlowComplete(dataFlow);
@@ -95,25 +114,25 @@
//鑳藉鎵ц鍒拌繖涓�姝� 璁や负鏄兘鎴愬姛浜�
refreshOrderDataFlowResJson(dataFlow);
- }catch (BusinessException e) {
- responseEntity = new ResponseEntity<String>(e.getMessage() , OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR);
+ } catch (BusinessException e) {
+ responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.INTERNAL_SERVER_ERROR);
} catch (OrdersException e) {
- responseEntity = new ResponseEntity<String>(e.getMessage() , OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR);
+ responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.INTERNAL_SERVER_ERROR);
} catch (RuleException e) {
- responseEntity = new ResponseEntity<String>(e.getMessage(),OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.NETWORK_AUTHENTICATION_REQUIRED);
+ responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.NETWORK_AUTHENTICATION_REQUIRED);
} catch (NoAuthorityException e) {
- responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.UNAUTHORIZED);
- } catch (InitConfigDataException e){
- responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR);
- }catch (Exception e) {
- logger.error("鍐呴儴寮傚父浜嗭細",e);
- responseEntity = new ResponseEntity<String>("鍐呴儴寮傚父浜嗭細"+e.getMessage() + e.getLocalizedMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR);
+ responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.UNAUTHORIZED);
+ } catch (InitConfigDataException e) {
+ responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.INTERNAL_SERVER_ERROR);
+ } catch (Exception e) {
+ logger.error("鍐呴儴寮傚父浜嗭細", e);
+ responseEntity = new ResponseEntity<String>("鍐呴儴寮傚父浜嗭細" + e.getMessage() + e.getLocalizedMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.INTERNAL_SERVER_ERROR);
} finally {
- if(responseEntity == null){
- responseEntity = new ResponseEntity<String>(dataFlow.getResJson().getString("msg"),OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.OK);
+ if (responseEntity == null) {
+ responseEntity = new ResponseEntity<String>(dataFlow.getResJson().getJSONArray("msg").toJSONString(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.OK);
}
- if(dataFlow != null) {
+ if (dataFlow != null) {
//娣诲姞鑰楁椂
//OrderDataFlowContextFactory.addCostTime(dataFlow, "service", "涓氬姟澶勭悊鎬昏�楁椂", dataFlow.getStartDate(), dataFlow.getEndDate());
//淇濆瓨鑰楁椂
@@ -125,50 +144,39 @@
//杩欓噷淇濆瓨鑰楁椂锛屼互鍙婃棩蹇�
- return responseEntity ;
+ return responseEntity;
}
}
- /**
- * 鍒疯繑鍥炲��
- * @param dataFlow
- */
- private void refreshOrderDataFlowResJson(IOrderDataFlowContext dataFlow){
-
- if(dataFlow.getResJson() == null || dataFlow.getResJson().isEmpty()){
- JSONObject resJson = new JSONObject();
- resJson.put("msg","鎴愬姛");
- dataFlow.setResJson(resJson);
- }
-
- }
/**
* 鎶掑啓杩斿洖澶翠俊鎭�
+ *
* @param dataFlow
*/
- private void putResponseHeader(DataFlow dataFlow,Map<String,String> headers) {
+ private void putResponseHeader(DataFlow dataFlow, Map<String, String> headers) {
headers.put("responseTime", DateUtil.getDefaultFormateTimeString(new Date()));
- headers.put("transactionId",dataFlow.getTransactionId());
+ headers.put("transactionId", dataFlow.getTransactionId());
}
/**
* 瑙e瘑
+ *
* @param reqJson
* @return
*/
- private String decrypt(String reqJson,Map<String,String> headers) throws DecryptException{
+ private String decrypt(String reqJson, Map<String, String> headers) throws DecryptException {
try {
if (MappingConstant.VALUE_ON.equals(headers.get(CommonConstant.ENCRYPT))) {
logger.debug("瑙e瘑鍓嶅瓧绗︼細" + reqJson);
reqJson = new String(AuthenticationFactory.decrypt(reqJson.getBytes("UTF-8"), AuthenticationFactory.loadPrivateKey(MappingConstant.KEY_PRIVATE_STRING)
, NumberUtils.isNumber(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) ? Integer.parseInt(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) :
- Integer.parseInt(MappingCache.getValue(MappingConstant.KEY_DEFAULT_DECRYPT_KEY_SIZE))),"UTF-8");
+ Integer.parseInt(MappingCache.getValue(MappingConstant.KEY_DEFAULT_DECRYPT_KEY_SIZE))), "UTF-8");
logger.debug("瑙e瘑鍚庡瓧绗︼細" + reqJson);
}
- }catch (Exception e){
- throw new DecryptException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"瑙e瘑澶辫触");
+ } catch (Exception e) {
+ throw new DecryptException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "瑙e瘑澶辫触");
}
return reqJson;
@@ -176,25 +184,25 @@
/**
* 鍔犲瘑
+ *
* @param resJson
* @param headers
* @return
*/
- private String encrypt(String resJson,Map<String,String> headers){
+ private String encrypt(String resJson, Map<String, String> headers) {
try {
if (MappingConstant.VALUE_ON.equals(headers.get(CommonConstant.ENCRYPT))) {
logger.debug("鍔犲瘑鍓嶅瓧绗︼細" + resJson);
resJson = new String(AuthenticationFactory.encrypt(resJson.getBytes("UTF-8"), AuthenticationFactory.loadPubKey(MappingConstant.KEY_PUBLIC_STRING)
, NumberUtils.isNumber(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) ? Integer.parseInt(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) :
- Integer.parseInt(MappingCache.getValue(MappingConstant.KEY_DEFAULT_DECRYPT_KEY_SIZE))),"UTF-8");
+ Integer.parseInt(MappingCache.getValue(MappingConstant.KEY_DEFAULT_DECRYPT_KEY_SIZE))), "UTF-8");
logger.debug("鍔犲瘑鍚庡瓧绗︼細" + resJson);
}
- }catch (Exception e){
- logger.error("鍔犲瘑澶辫触锛�",e);
+ } catch (Exception e) {
+ logger.error("鍔犲瘑澶辫触锛�", e);
}
return resJson;
}
-
/**
@@ -206,87 +214,6 @@
}
- /**
- * 4.0瑙勫垯鏍¢獙
- *
- * @param dataFlow
- * @throws RuleException
- */
- private void ruleValidate(IOrderDataFlowContext dataFlow) throws RuleException {
- Date startDate = DateUtil.getCurrentDate();
- try {
-
- if (MappingConstant.VALUE_OFF.equals(MappingCache.getValue(MappingConstant.KEY_RULE_ON_OFF))
- || (MappingCache.getValue(MappingConstant.KEY_NO_NEED_RULE_VALDATE_ORDER) != null
- && MappingCache.getValue(MappingConstant.KEY_NO_NEED_RULE_VALDATE_ORDER).contains(dataFlow.getOrders().getOrderTypeCd()))) {
- //涓嶅仛鏍¢獙
- //娣诲姞鑰楁椂
- OrderDataFlowContextFactory.addCostTime(dataFlow, "ruleValidate", "瑙勫垯鏍¢獙鑰楁椂", startDate);
- return ;
- }
-
- //璋冪敤瑙勫垯
-
- } catch (Exception e) {
- //娣诲姞鑰楁椂
- OrderDataFlowContextFactory.addCostTime(dataFlow, "ruleValidate", "瑙勫垯鏍¢獙鑰楁椂", startDate);
- throw new RuleException(ResponseConstant.RESULT_CODE_RULE_ERROR, "瑙勫垯鏍¢獙寮傚父澶辫触锛�" + e.getMessage());
- }
-
- OrderDataFlowContextFactory.addCostTime(dataFlow, "ruleValidate", "瑙勫垯鏍¢獙鑰楁椂", startDate);
-
- }
-
- /**
- * 5.0 淇濆瓨璁㈠崟鍜屼笟鍔¢」 c_orders c_order_attrs c_business c_business_attrs
- *
- * @param dataFlow
- * @throws OrdersException
- */
- private void saveOrdersAndBusiness(IOrderDataFlowContext dataFlow) throws OrdersException {
- Date startDate = DateUtil.getCurrentDate();
- if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
- &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrders().getOrderTypeCd())){
- //涓嶄繚瀛樿鍗曚俊鎭�
- OrderDataFlowContextFactory.addCostTime(dataFlow, "saveOrdersAndBusiness", "淇濆瓨璁㈠崟鍜屼笟鍔¢」鑰楁椂", startDate);
- return ;
- }
-
-
- //1.0 淇濆瓨 orders淇℃伅
- centerServiceDaoImpl.saveOrder(OrderDataFlowContextFactory.getOrder(dataFlow.getOrders()));
-
-
- centerServiceDaoImpl.saveOrderAttrs(OrderDataFlowContextFactory.getOrderAttrs(dataFlow.getOrders()));
-
- //2.0 淇濆瓨 business淇℃伅
-
- centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getBusiness(dataFlow));
-
- centerServiceDaoImpl.saveBusinessAttrs(OrderDataFlowContextFactory.getBusinessAttrs(dataFlow));
-
- OrderDataFlowContextFactory.addCostTime(dataFlow, "saveOrdersAndBusiness", "淇濆瓨璁㈠崟鍜屼笟鍔¢」鑰楁椂", startDate);
- }
-
- /**
- * 6.0 璋冪敤涓嬫父绯荤粺
- *
- * @param dataFlow
- * @throws BusinessException
- */
- private void invokeBusinessSystem(IOrderDataFlowContext dataFlow) throws BusinessException {
- Date startDate = DateUtil.getCurrentDate();
- //6.1 鍏堝鐞嗗悓姝ユ柟寮忕殑鏈嶅姟锛屾瘡涓�鍚屾鍚庡彂甯冧簨浠跺箍鎾�
-
- doSynchronousBusinesses(dataFlow);
-
- //6.2 澶勭悊寮傛鏈嶅姟
- doAsynchronousBusinesses(dataFlow);
-
-
- OrderDataFlowContextFactory.addCostTime(dataFlow, "invokeBusinessSystem", "璋冪敤涓嬫父绯荤粺鑰楁椂", startDate);
- }
-
/**
* 7.0 浣滃簾璁㈠崟鍜屼笟鍔¢」 鎻掑叆鎾ゅ崟璁板綍 绛夊緟鎾ゅ崟
@@ -295,20 +222,20 @@
*/
private void invalidOrderAndBusiness(IOrderNotifyDataFlowContext dataFlow) {
Date startDate = DateUtil.getCurrentDate();
- if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
- &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())){
+ if (MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
+ && MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())) {
//涓嶇敤浣滃簾璁㈠崟淇℃伅
- // OrderDataFlowContextFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "浣滃簾璁㈠崟鍜屼笟鍔¢」鑰楁椂", startDate);
- return ;
+ // OrderDataFlowContextFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "浣滃簾璁㈠崟鍜屼笟鍔¢」鑰楁椂", startDate);
+ return;
}
//濡傛灉宸茬粡浣滃簾 涓嶅瓨鍦� 鎴栧け璐ワ紝鍒欎笉鍋氬鐞�
Map order = centerServiceDaoImpl.getOrderInfoByBId(dataFlow.getbId());
- if(order == null || !order.containsKey("status_cd") || StatusConstant.STATUS_CD_DELETE.equals(order.get("status_cd"))
- || StatusConstant.STATUS_CD_ERROR.equals(order.get("status_cd"))){
- return ;
+ if (order == null || !order.containsKey("status_cd") || StatusConstant.STATUS_CD_DELETE.equals(order.get("status_cd"))
+ || StatusConstant.STATUS_CD_ERROR.equals(order.get("status_cd"))) {
+ return;
}
//浣滃簾 璁㈠崟
@@ -331,30 +258,30 @@
*
* @param dataFlow
*/
- private void invalidCompletedBusinessSystem(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+ private void invalidCompletedBusinessSystem(IOrderNotifyDataFlowContext dataFlow) throws Exception {
- if(!StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
- return ;
+ if (!StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
+ return;
}
//鍒ゆ柇 璁㈠崟instance 鏄惁閮藉彉鎴愪簡鎾ゅ崟鐘舵��
- if(centerServiceDaoImpl.judgeAllBusinessDeleteOrder(dataFlow.getoId(),StatusConstant.STATUS_CD_DELETE_ORDER) < 1){
- return ;
+ if (centerServiceDaoImpl.judgeAllBusinessDeleteOrder(dataFlow.getoId(), StatusConstant.STATUS_CD_DELETE_ORDER) < 1) {
+ return;
}
// 鏍规嵁 c_business 琛ㄤ腑鐨勫瓧娈礲usiness_type_cd 鎵惧埌瀵瑰簲鐨勬秷鎭槦鍒楀悕绉�
Map paramIn = new HashMap();
- paramIn.put("oId",dataFlow.getoId());
- paramIn.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);
+ paramIn.put("oId", dataFlow.getoId());
+ paramIn.put("statusCd", StatusConstant.STATUS_CD_DELETE_ORDER);
List<Map> completedBusinesses = centerServiceDaoImpl.getBusinessByOId(paramIn);
- for(Map completedBusiness : completedBusinesses){
- ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(completedBusiness.get("business_type_cd").toString());
- long startTime = DateUtil.getCurrentDate().getTime();
- //鍙戣捣鎾ゅ崟
- KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(),"",
- OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness).toJSONString());
- //saveLogMessage(OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()),null);
- }
+ for (Map completedBusiness : completedBusinesses) {
+ ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(completedBusiness.get("business_type_cd").toString());
+ long startTime = DateUtil.getCurrentDate().getTime();
+ //鍙戣捣鎾ゅ崟
+ KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(), "",
+ OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow, completedBusiness).toJSONString());
+ //saveLogMessage(OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()),null);
+ }
}
/**
@@ -397,77 +324,58 @@
//OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "璁㈠崟鐘舵�佹敼涓哄け璐ヨ�楁椂", startDate);
}
+
+
+
/**
- * 灏嗚鍗曠姸鎬佹敼涓轰綔搴熺姸鎬併��
+ * 鍔犲叆鎾ゅ崟璁板綍
*
* @param dataFlow
*/
- private void updateOrderAndBusinessDelete(IOrderDataFlowContext dataFlow) {
-
- Date startDate = DateUtil.getCurrentDate();
-
- //浣滃簾 璁㈠崟
- centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedInvalidOrder(dataFlow));
-
- //浣滃簾璁㈠崟椤�
- centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedDeleteBusiness(dataFlow));
-
- //鍔犲叆鎾ゅ崟璁板綍
- //doAddDeleteOrderBusinessData(dataFlow);
-
-
-
- OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "璁㈠崟鐘舵�佹敼涓哄け璐ヨ�楁椂", startDate);
-
- }
-
- /**
- * 鍔犲叆鎾ゅ崟璁板綍
- * @param dataFlow
- */
- private void doAddDeleteOrderBusinessData(IOrderDataFlowContext dataFlow){
+ private void doAddDeleteOrderBusinessData(IOrderDataFlowContext dataFlow) {
/* Map business = new HashMap();
business.put("bId",SequenceUtil.getBId());
business.put("oId",dataFlow.getoId());
business.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE);
business.put("remark","鍙戣捣鎾ゅ崟");
business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);*/
- centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow,"璁㈠崟澶辫触锛屽姞鍏ユ挙鍗�"));
+ centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow, "璁㈠崟澶辫触锛屽姞鍏ユ挙鍗�"));
}
/**
* 鍔犲叆鎾ゅ崟璁板綍
+ *
* @param dataFlow
*/
- private void doAddDeleteOrderBusinessData(IOrderNotifyDataFlowContext dataFlow){
+ private void doAddDeleteOrderBusinessData(IOrderNotifyDataFlowContext dataFlow) {
/* Map business = new HashMap();
business.put("bId",SequenceUtil.getBId());
business.put("oId",dataFlow.getoId());
business.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE);
business.put("remark","鍙戣捣鎾ゅ崟");
business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);*/
- centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow,"璁㈠崟澶辫触锛屽姞鍏ユ挙鍗�"));
+ centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow, "璁㈠崟澶辫触锛屽姞鍏ユ挙鍗�"));
}
-
/**
* 鎺ュ彈涓氬姟绯荤粺閫氱煡娑堟伅
+ *
* @param receiveJson 鎺ュ彈鎶ユ枃
* @throws SMOException
*/
@Override
- public void receiveBusinessSystemNotifyMessage(String receiveJson) throws SMOException{
+ public void receiveBusinessSystemNotifyMessage(String receiveJson) throws SMOException {
Date startDate = DateUtil.getCurrentDate();
IOrderNotifyDataFlowContext dataFlow = null;
try {
//1.0 鍒涘缓鏁版嵁娴�
- dataFlow = OrderDataFlowContextFactory.newInstance(OrderNotifyDataFlow.class).builder(receiveJson,null);
+ dataFlow = OrderDataFlowContextFactory.newInstance(OrderNotifyDataFlow.class).builder(receiveJson, null);
//濡傛灉璁㈠崟閮芥病鏈変繚瀛橈紝鍒欏啀涓嶈澶勭悊
- if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
- &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())){
+ if (MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
+ && MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())) {
//涓嶄繚瀛樿鍗曚俊鎭�
- return ;
+ return;
}
//濡傛灉涓嶆槸 business 鍜宨nstance 杩囩▼ 鍒欑洿鎺ヨ烦鍑�
@@ -488,16 +396,16 @@
//7.0 鍒ゆ柇鎾ゅ崟鏉′欢鏄惁婊¤冻锛屽鏋滄弧瓒冲彂璧锋挙鍗�
invalidCompletedBusinessSystem(dataFlow);
- }catch (BusinessStatusException e){
+ } catch (BusinessStatusException e) {
- logger.error("璁㈠崟澶辫触:" ,e);
+ logger.error("璁㈠崟澶辫触:", e);
//8.0 灏嗚鍗曠姸鎬佹敼涓哄け璐ワ紝浜哄伐澶勭悊銆�
updateOrderAndBusinessError(dataFlow);
- }catch (BusinessException e) {
+ } catch (BusinessException e) {
//9.0璇存槑杩欎釜璁㈠崟宸茬粡澶辫触浜嗭紝鍐嶄笉闇�瑕�
//鎯虫硶锛岃繖閲屽箍鎾綋鍓嶅け璐ヤ笟鍔�
- logger.error("淇敼涓氬姟鏁版嵁澶辫触",e);
+ logger.error("淇敼涓氬姟鏁版嵁澶辫触", e);
}/*catch (InitConfigDataException e){ //杩欑涓�鑸笉浼氬嚭鐜帮紝闄ら潪浜哄伐鏀逛簡鏁版嵁
LoggerEngine.error("鍔犺浇閰嶇疆鏁版嵁鍑洪敊", e);
try {
@@ -513,13 +421,13 @@
updateOrderAndBusinessError(dataFlow);
}
- }*/catch (NoSupportException e){
+ }*/ catch (NoSupportException e) {
LoggerEngine.error("褰撳墠涓氬姟涓嶆敮鎸�", e);
- }catch (Exception e){
+ } catch (Exception e) {
LoggerEngine.error("浣滃簾璁㈠崟澶辫触", e);
//10.0 鎴愬姛鐨勬儏鍐典笅閫氱煡涓嬫父绯荤粺澶辫触灏嗙姸鎬佹敼涓篘E锛屼汉宸ュ鐞嗐��
updateBusinessNotifyError(dataFlow);
- }finally{
+ } finally {
/*OrderDataFlowContextFactory.addCostTime(dataFlow, "receiveBusinessSystemNotifyMessage", "鎺ュ彈涓氬姟绯荤粺閫氱煡娑堟伅鑰楁椂", startDate);
saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getReqJson().toJSONString()),
LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS),
@@ -529,17 +437,18 @@
/**
* Instance杩囩▼
+ *
* @param dataFlow
*/
private void doSendInstance(IOrderNotifyDataFlowContext dataFlow) {
- if(dataFlow == null || !StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())){
- return ;
+ if (dataFlow == null || !StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())) {
+ return;
}
try {
ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd());
KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(), "",
OrderDataFlowContextFactory.getBusinessTableDataInfoToInstanceTableJson(dataFlow).toJSONString());
- }catch (Exception e){
+ } catch (Exception e) {
}
@@ -547,17 +456,18 @@
/**
* 鍒ゆ柇鏄惁鏄� business 鎴栬�� instance杩囩▼
+ *
* @param dataFlow
* @throws NoSupportException
*/
- private void judgeBusinessOrInstance(IOrderNotifyDataFlowContext dataFlow) throws NoSupportException{
+ private void judgeBusinessOrInstance(IOrderNotifyDataFlowContext dataFlow) throws NoSupportException {
- if(dataFlow == null || StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType()) ||
- StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())){
- return ;
+ if (dataFlow == null || StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType()) ||
+ StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
+ return;
}
- throw new NoSupportException(ResponseConstant.RESULT_PARAM_ERROR,"褰撳墠鍙敮鎸� Business 鍜� Instance杩囩▼");
+ throw new NoSupportException(ResponseConstant.RESULT_PARAM_ERROR, "褰撳墠鍙敮鎸� Business 鍜� Instance杩囩▼");
}
@@ -571,13 +481,13 @@
Map order = centerServiceDaoImpl.getOrderInfoByBId(dataFlow.getBusinesses().get(0).getbId());
dataFlow.setoId(order.get("o_id").toString());
dataFlow.setAppId(order.get("app_id").toString());
- if("-1".equals(dataFlow.getDataFlowId()) || StringUtil.isNullOrNone(dataFlow.getDataFlowId())){
- throw new InitConfigDataException(ResponseConstant.RESULT_CODE_ERROR,"璇锋眰鎶ユ枃涓病鏈夊寘鍚� dataFlowId 鑺傜偣");
+ if ("-1".equals(dataFlow.getDataFlowId()) || StringUtil.isNullOrNone(dataFlow.getDataFlowId())) {
+ throw new InitConfigDataException(ResponseConstant.RESULT_CODE_ERROR, "璇锋眰鎶ユ枃涓病鏈夊寘鍚� dataFlowId 鑺傜偣");
}
//閲嶆柊鍒风鍙d俊鎭�
- ServiceInfoListener serviceInfoListener = ApplicationContextFactory.getBean("serviceInfoListener",ServiceInfoListener.class);
- if(serviceInfoListener != null){
- dataFlow.setPort(serviceInfoListener.getServerPort()+"");
+ ServiceInfoListener serviceInfoListener = ApplicationContextFactory.getBean("serviceInfoListener", ServiceInfoListener.class);
+ if (serviceInfoListener != null) {
+ dataFlow.setPort(serviceInfoListener.getServerPort() + "");
}
//閲嶆柊鍔犺浇閰嶇疆
//initConfigData(dataFlow);
@@ -593,8 +503,8 @@
Map order = centerServiceDaoImpl.getOrderInfoByBId(dataFlow.getbId());
dataFlow.setoId(order.get("o_id").toString());
- if("-1".equals(dataFlow.getDataFlowId()) || StringUtil.isNullOrNone(dataFlow.getDataFlowId())){
- throw new InitConfigDataException(ResponseConstant.RESULT_CODE_ERROR,"璇锋眰鎶ユ枃涓病鏈夊寘鍚� dataFlowId 鑺傜偣");
+ if ("-1".equals(dataFlow.getDataFlowId()) || StringUtil.isNullOrNone(dataFlow.getDataFlowId())) {
+ throw new InitConfigDataException(ResponseConstant.RESULT_CODE_ERROR, "璇锋眰鎶ユ枃涓病鏈夊寘鍚� dataFlowId 鑺傜偣");
}
}
@@ -606,36 +516,37 @@
private void updateBusinessNotifyError(IOrderNotifyDataFlowContext dataFlow) {
Date startDate = DateUtil.getCurrentDate();
- //瀹屾垚璁㈠崟椤�
+ //瀹屾垚璁㈠崟椤�
centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedNotifyErrorBusiness(dataFlow));
- // OrderDataFlowContextFactory.addCostTime(dataFlow, "updateBusinessNotifyError", "璁㈠崟鐘舵�佹敼涓哄け璐ヨ�楁椂", startDate);
+ // OrderDataFlowContextFactory.addCostTime(dataFlow, "updateBusinessNotifyError", "璁㈠崟鐘舵�佹敼涓哄け璐ヨ�楁椂", startDate);
}
/**
* 鍒ゆ柇鏄惁閮芥垚鍔熶簡
+ *
* @param dataFlow
*/
- private void judgeBusinessStatusAndCompleteBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessStatusException{
+ private void judgeBusinessStatusAndCompleteBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessStatusException {
//List<Business> businesses = dataFlow.getBusinesses();
//1.0 鍒ゆ柇鏄惁瀛樺湪鎾ゅ崟锛屽鏋滄槸鎾ゅ崟鍒欏皢褰撳墠 bId 鏍囪涓烘挙鍗曠姸鎬�
- if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
+ if (StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
Map businessMap = centerServiceDaoImpl.getDeleteOrderBusinessByOId(dataFlow.getoId());
- if(businessMap != null && !businessMap.isEmpty()){
+ if (businessMap != null && !businessMap.isEmpty()) {
centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedDeleteBusiness(dataFlow));
- return ;
+ return;
}
}
//Business business = dataFlow.getCurrentBusiness();
- if(!ResponseConstant.RESULT_CODE_SUCCESS.equals(((IOrderResponse)dataFlow).getCode())){
+ if (!ResponseConstant.RESULT_CODE_SUCCESS.equals(((IOrderResponse) dataFlow).getCode())) {
//throw new BusinessStatusException(business.getCode(),"涓氬姟bId= "+business.getbId() + " 澶勭悊澶辫触锛岄渶瑕佷綔搴熻鍗�");
//浣滃簾璁㈠崟鍜屼笟鍔¢」 鎻掑叆鎾ゅ崟璁板綍 绛夊緟鎾ゅ崟
invalidOrderAndBusiness(dataFlow);
- }else{
+ } else {
completeBusiness(dataFlow);
}
@@ -646,36 +557,37 @@
*
* @param dataFlow
*/
- private void completeBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessException{
+ private void completeBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessException {
try {
- if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
+ if (StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
//瀹屾垚璁㈠崟椤�
centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedCompleteBusiness(dataFlow));
//濡傛灉涓氬姟閮藉畬鎴愶紝鍒欏皢 璁㈠崟鏀逛负瀹屾垚鐘舵��
centerServiceDaoImpl.completeOrderByBId(dataFlow.getbId());
- }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())) {
+ } else if (StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())) {
centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedBusinessComplete(dataFlow));
- }else{ //杩欓噷鍒颁笉浜嗭紝鍓嶉潰鍋氫簡鏍¢獙
- throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,"褰撳墠涓嶆敮鎸� 涓氬姟绫诲瀷涓� businessType" +dataFlow.getBusinessType());
+ } else { //杩欓噷鍒颁笉浜嗭紝鍓嶉潰鍋氫簡鏍¢獙
+ throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR, "褰撳墠涓嶆敮鎸� 涓氬姟绫诲瀷涓� businessType" + dataFlow.getBusinessType());
}
- }catch (DAOException e){
- throw new BusinessException(e.getResult(),e);
+ } catch (DAOException e) {
+ throw new BusinessException(e.getResult(), e);
}
}
/**
* //4.0褰撴墍鏈変笟鍔″姩浣滄槸鍚﹂兘鏄疌锛屽皢璁㈠崟淇℃伅鏀逛负 C 骞朵笖鍙戝竷绔e伐娑堟伅锛岃繖閲屽湪骞挎挱涔嬪墠纭
+ *
* @param dataFlow
*/
- private void judgeSendToInstance(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+ private void judgeSendToInstance(IOrderNotifyDataFlowContext dataFlow) throws Exception {
try {
- if(centerServiceDaoImpl.judgeAllBusinessCompleted(dataFlow.getoId(),StatusConstant.STATUS_CD_BUSINESS_COMPLETE) > 0) {
+ if (centerServiceDaoImpl.judgeAllBusinessCompleted(dataFlow.getoId(), StatusConstant.STATUS_CD_BUSINESS_COMPLETE) > 0) {
//閫氱煡鎴愬姛娑堟伅
doSendInstance(dataFlow);
}
- }catch (DAOException e){
+ } catch (DAOException e) {
//杩欓噷浠�涔堥兘涓嶅仛锛岃鏄庤鍗曟病鏈夊畬鎴�
}
@@ -684,15 +596,16 @@
/**
* 閫氱煡 璁㈠崟宸茬粡瀹屾垚锛屽悗绔渶瑕佸畬鎴愭暟鎹�
+ *
* @param dataFlow
*/
- private void notifyBusinessSystemSuccessMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+ private void notifyBusinessSystemSuccessMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception {
long startTime = DateUtil.getCurrentDate().getTime();
ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd());
//鎷艰鎶ユ枃閫氱煡涓氬姟绯荤粺
- KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(),"",
+ KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(), "",
OrderDataFlowContextFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString());
/*saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),OrderDataFlowContextFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString()),
@@ -705,292 +618,63 @@
*
* @param dataFlow
*/
- private void notifyBusinessSystemErrorMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+ private void notifyBusinessSystemErrorMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception {
long startTime = DateUtil.getCurrentDate().getTime();
ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd());
//鎷艰鎶ユ枃閫氱煡涓氬姟绯荤粺
- KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(),"",
+ KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(), "",
OrderDataFlowContextFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString());
/*saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),OrderDataFlowContextFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString()),
LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_ERROR),
DateUtil.getCurrentDate().getTime() - startTime);*/
}
- /**
- * 澶勭悊鍚屾涓氬姟
- * @param dataFlow
- */
- private void doSynchronousBusinesses(IOrderDataFlowContext dataFlow) throws BusinessException{
- Date startDate = DateUtil.getCurrentDate();
- List<Business> synchronousBusinesses = OrderDataFlowContextFactory.getSynchronousBusinesses(dataFlow);
-
- List<Business> deleteBusinesses = new ArrayList<Business>();
-
- if(synchronousBusinesses == null || synchronousBusinesses.size() == 0){
- return ;
- }
- JSONArray responseBusinesses = new JSONArray();
-
- //6.1澶勭悊鍚屾鏈嶅姟 鍙戣捣Business
- doSaveDataInfoToBusinessTable(dataFlow, synchronousBusinesses, responseBusinesses);
-
- try {
- //6.2鍙戣捣Instance
- doBusinessTableDataInfoToInstanceTable(dataFlow, synchronousBusinesses,deleteBusinesses);
- }catch (Exception e){
- try {
- //杩欓噷鍙戣捣鎾ゅ崟閫昏緫
- doDeleteOrderAndInstanceData(dataFlow, deleteBusinesses);
- }catch (Exception e1){
- logger.error("鎾ゅ崟澶辫触",e1);
- //杩欓噷璁板綍鎾ゅ崟澶辫触鐨勪俊鎭�
- }
- throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,e.getMessage());
- }
- //6.3 c_business 鏁版嵁淇敼涓哄畬鎴�
- /*List<Business> asynchronousBusinesses = OrderDataFlowContextFactory.getAsynchronousBusinesses(dataFlow);
- if(asynchronousBusinesses == null || asynchronousBusinesses.size() == 0){
- doComplateOrderAndBusiness(dataFlow,synchronousBusinesses);
- }*/
- OrderDataFlowContextFactory.addCostTime(dataFlow, "doSynchronousBusinesses", "鍚屾璋冪敤涓氬姟绯荤粺鎬昏�楁椂", startDate);
-}
-
- /**
- * 鍙戣捣鎾ゅ崟涓氬姟
- * @param dataFlow
- * @param deleteBusinesses
- */
- private void doDeleteOrderAndInstanceData(IOrderDataFlowContext dataFlow, List<Business> deleteBusinesses) {
-
- if(deleteBusinesses == null || deleteBusinesses.size() == 0){
- return ;
- }
-
- //1.0 鍦╟_business 琛ㄤ腑鍔犲叆 鎾ゅ崟璁板綍
- centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow,"涓氬姟绯荤粺瀹炰緥澶辫触锛屽彂璧锋挙鍗�"));
- //2.0 浣滃簾 c_orders 鍜� c_business 鏁版嵁
- updateOrderAndBusinessDelete(dataFlow);
- //3.0 鍙戣捣 鎾ゅ崟涓氬姟
- doDeleteBusinessSystemInstanceData(dataFlow,deleteBusinesses);
- }
-
- /**
- * 瀹屾垚璁㈠崟鐘舵��
- * @param synchronousBusinesses
- */
- /*private void doComplateOrderAndBusiness(DataFlow dataFlow,List<Business> synchronousBusinesses) {
-
- //Complete Order and business
- Map order = new HashMap();
- order.put("oId",dataFlow.getoId());
- order.put("statusCd", StatusConstant.STATUS_CD_COMPLETE);
- order.put("finishTime",DateUtil.getCurrentDate());
- centerServiceDaoImpl.updateOrder(order);
- centerServiceDaoImpl.updateBusiness(order);
- Date businessStartDate;
- AppService service;
- JSONObject requestBusinessJson;
- for(Business business : synchronousBusinesses){
- businessStartDate = DateUtil.getCurrentDate();
- service = OrderDataFlowContextFactory.getService(dataFlow,business.getServiceCode());
- if(!CommonConstant.INSTANCE_Y.equals(service.getIsInstance())){
- continue;
- }
- requestBusinessJson = OrderDataFlowContextFactory.getCompleteInstanceDataJson(dataFlow,business);
- JSONObject responseJson = doRequestBusinessSystem(dataFlow, service, requestBusinessJson);
-
- OrderDataFlowContextFactory.addCostTime(dataFlow, business.getServiceCode(), "璋冪敤"+business.getServiceName()+"-doComplete鑰楁椂", businessStartDate);
- saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
- LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()),
- DateUtil.getCurrentDate().getTime() - businessStartDate.getTime());
- }
-
- }*/
-
- /**
- * 灏咮usinessTable 涓殑鏁版嵁淇濆瓨鍒� InstanceTable
- * @param dataFlow
- * @param synchronousBusinesses
- */
- private void doBusinessTableDataInfoToInstanceTable(IOrderDataFlowContext dataFlow, List<Business> synchronousBusinesses,List<Business> deleteBusinesses) {
- Date businessStartDate;
- ServiceBusiness serviceBusiness;
- JSONObject requestBusinessJson;
- for(Business business : synchronousBusinesses){
- businessStartDate = DateUtil.getCurrentDate();
- serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd());
- //娣诲姞闇�瑕佹挙鍗曠殑涓氬姟淇℃伅
- deleteBusinesses.add(business);
-
- requestBusinessJson = OrderDataFlowContextFactory.getBusinessTableDataInfoToInstanceTableJson(dataFlow,business);
- JSONObject responseJson = doRequestBusinessSystem(dataFlow, serviceBusiness, requestBusinessJson);
- //鍙戝竷浜嬩欢
- DataFlowEventPublishing.invokeBusinessISuccess(dataFlow,business);
- updateBusinessStatusCdByBId(business.getbId(),StatusConstant.STATUS_CD_COMPLETE);
- OrderDataFlowContextFactory.addCostTime(dataFlow, business.getBusinessTypeCd(), "璋冪敤"+business.getBusinessTypeCd()+"鑰楁椂", businessStartDate);
- /* saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
- LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()),
- DateUtil.getCurrentDate().getTime() - businessStartDate.getTime());*/
- }
-
- /* if(dataFlow.getCurrentBusiness() == null){
- return ;
- }*/
-
- //鍒ゆ柇涓氬姟鍔ㄤ綔鏄惁閮界宸ワ紝涓昏鑰冭檻 璇锋眰鎶ユ枃涓� 鏈夊紓姝ヤ篃鏈夊悓姝ョ殑鎯呭喌
- //濡傛灉涓氬姟閮藉畬鎴愶紝鍒欏皢 璁㈠崟鏀逛负瀹屾垚鐘舵��
- centerServiceDaoImpl.completeOrderByOId(dataFlow.getOrders().getoId());
- }
-
- /**
- * 涓氬姟绯荤粺鎾ゅ崟
- * @param dataFlow
- * @param deleteBusinesses
- */
- private void doDeleteBusinessSystemInstanceData(IOrderDataFlowContext dataFlow, List<Business> deleteBusinesses) {
- Date businessStartDate;
- JSONObject requestBusinessJson;
- ServiceBusiness serviceBusiness;
- for(Business business : deleteBusinesses){
- businessStartDate = DateUtil.getCurrentDate();
- requestBusinessJson = OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow,business);
- serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd());
- JSONObject responseJson = doRequestBusinessSystem(dataFlow, serviceBusiness, requestBusinessJson);
- OrderDataFlowContextFactory.addCostTime(dataFlow, business.getBusinessTypeCd(), "璋冪敤"+business.getBusinessTypeCd()+"-鎾ゅ崟 鑰楁椂", businessStartDate);
-// saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
-// LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()),
-// DateUtil.getCurrentDate().getTime() - businessStartDate.getTime());
- }
- }
-
- /**
- * 璋冪敤涓嬫父绯荤粺
- * @param dataFlow
- * @param serviceBusiness
- * @param requestBusinessJson 璇锋眰鎶ユ枃
- * @return
- */
- private JSONObject doRequestBusinessSystem(IOrderDataFlowContext dataFlow, ServiceBusiness serviceBusiness, JSONObject requestBusinessJson) {
- String responseMessage;
-
- Assert.hasLength(serviceBusiness.getInvokeType(),"c_service_business琛ㄩ厤缃嚭閿欙紝invoke_type 涓嶈兘涓虹┖"+ serviceBusiness.getBusinessTypeCd());
- if(ServiceBusinessConstant.INVOKE_TYPE_WEBSERVICE.equals(serviceBusiness.getInvokeType())) {//webservice鏂瑰紡
- String url = serviceBusiness.getUrl();
- String[] urls = url.split("#");
-
- if(urls.length != 2){
- throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"閰嶇疆閿欒锛歝_service_business閰嶇疆url瀛楁閿欒"+serviceBusiness.getBusinessTypeCd());
- }
- String webserviceUrl = MappingCache.getValue(urls[0]);
- String method = MappingCache.getValue(urls[1]);
- responseMessage = (String) WebServiceAxisClient.callWebService(webserviceUrl,method,
- new Object[]{requestBusinessJson.toJSONString()},
- serviceBusiness.getTimeout());
- }else if(ServiceBusinessConstant.INVOKE_TYPE_HTTP_POST.equals(serviceBusiness.getInvokeType())){
- //http://user-service/test/sayHello
- String httpPostUrl = MappingCache.getValue(serviceBusiness.getUrl());
- responseMessage = restTemplate.postForObject(httpPostUrl,requestBusinessJson.toJSONString(),String.class);
- }else if(ServiceBusinessConstant.INVOKE_TYPE_OUT_HTTP_POST.equals(serviceBusiness.getInvokeType())){
- String httpPostUrl = MappingCache.getValue(serviceBusiness.getUrl());
- responseMessage = restTemplateNoLoadBalanced.postForObject(httpPostUrl,requestBusinessJson.toJSONString(),String.class);
- }
- else {//post鏂瑰紡
- throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"閰嶇疆閿欒锛歝_service_business閰嶇疆url瀛楁閿欒,褰撳墠鏃犳硶璇嗗埆"+serviceBusiness.getBusinessTypeCd());
- }
-
-
- logger.debug("璁㈠崟鏈嶅姟璋冪敤涓嬫父鏈嶅姟璇锋眰鎶ユ枃锛歿}锛岃繑鍥炴姤鏂囷細{}",requestBusinessJson,responseMessage);
-
- if(StringUtil.isNullOrNone(responseMessage) || !Assert.isJsonObject(responseMessage)){
- throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"涓嬫父绯荤粺杩斿洖鏍煎紡涓嶆纭紝璇锋寜鍗忚瑙勮寖澶勭悊");
- }
- JSONObject responseJson = JSONObject.parseObject(responseMessage);
-
- Assert.jsonObjectHaveKey(responseJson,"response","涓嬫父杩斿洖鎶ユ枃鏍煎紡閿欒锛屾病鏈夊寘鍚玶esponseJson鑺傜偣銆�"+serviceBusiness.getBusinessTypeCd()+"銆�");
-
- JSONObject responseInfo = responseJson.getJSONObject("response");
-
- Assert.jsonObjectHaveKey(responseInfo,"code","涓嬫父杩斿洖鎶ユ枃鏍煎紡閿欒锛宺esponse 鑺傜偣涓病鏈夊寘鍚玞ode鑺傜偣銆�"+serviceBusiness.getBusinessTypeCd()+"銆�");
-
- if(!ResponseConstant.RESULT_CODE_SUCCESS.equals(responseInfo.getString("code"))){
- throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,"涓氬姟绯荤粺澶勭悊澶辫触锛�"+responseInfo.getString("message"));
- }
- return responseJson;
- }
private String doTransferRequestBusinessSystem(DataFlow dataFlow, AppService service, String reqData) {
String responseMessage;
- if(service.getMethod() == null || "".equals(service.getMethod())) {//post鏂瑰紡
+ if (service.getMethod() == null || "".equals(service.getMethod())) {//post鏂瑰紡
//http://user-service/test/sayHello
HttpHeaders header = new HttpHeaders();
- for(String key : dataFlow.getRequestCurrentHeaders().keySet()){
- header.add(key,dataFlow.getRequestCurrentHeaders().get(key));
+ for (String key : dataFlow.getRequestCurrentHeaders().keySet()) {
+ header.add(key, dataFlow.getRequestCurrentHeaders().get(key));
}
HttpEntity<String> httpEntity = new HttpEntity<String>(reqData, header);
- responseMessage = restTemplateNoLoadBalanced.postForObject(service.getUrl(),httpEntity,String.class);
- }else{//webservice鏂瑰紡
- responseMessage = (String) WebServiceAxisClient.callWebService(service.getUrl(),service.getMethod(),
+ responseMessage = restTemplateNoLoadBalanced.postForObject(service.getUrl(), httpEntity, String.class);
+ } else {//webservice鏂瑰紡
+ responseMessage = (String) WebServiceAxisClient.callWebService(service.getUrl(), service.getMethod(),
new Object[]{dataFlow.getRequestBusinessJson().toJSONString()},
service.getTimeOut());
}
return responseMessage;
}
- /**
- * 鏁版嵁淇濆瓨鍒癇usinessTable 涓�
- * @param dataFlow
- * @param synchronousBusinesses
- * @param responseBusinesses
- */
- private void doSaveDataInfoToBusinessTable(IOrderDataFlowContext dataFlow, List<Business> synchronousBusinesses, JSONArray responseBusinesses) {
- Date businessStartDate;
- ServiceBusiness serviceBusiness;
- JSONObject requestBusinessJson;
- for(Business business : synchronousBusinesses) {
- businessStartDate = DateUtil.getCurrentDate();
- //鍙戣捣Business杩囩▼
- updateBusinessStatusCdByBId(business.getbId(),StatusConstant.STATUS_CD_BUSINESS);
- serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd());
- requestBusinessJson = OrderDataFlowContextFactory.getRequestBusinessJson(dataFlow,business);
-
- JSONObject responseJson = doRequestBusinessSystem(dataFlow, serviceBusiness, requestBusinessJson);
-
- //鍙戝竷浜嬩欢
- DataFlowEventPublishing.invokeBusinessBSuccess(dataFlow,business);
-
- responseBusinesses.add(responseJson);
-
- OrderDataFlowContextFactory.addCostTime(dataFlow, business.getBusinessTypeCd(), "璋冪敤"+business.getBusinessTypeCd()+"鑰楁椂", businessStartDate);
- /* saveLogMessage(null,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
- LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()),
- DateUtil.getCurrentDate().getTime()-businessStartDate.getTime());*/
- }
- }
/**
* 澶勭悊寮傛涓氬姟
+ *
* @param
*/
- private void doAsynchronousBusinesses(IOrderDataFlowContext dataFlow) throws BusinessException{
+ @Override
+ protected void doAsynchronousBusinesses(IOrderDataFlowContext dataFlow) throws BusinessException {
Date startDate = DateUtil.getCurrentDate();
//6.3 澶勭悊寮傛锛屾寜娑堟伅闃熼噷澶勭悊
List<Business> asynchronousBusinesses = OrderDataFlowContextFactory.getAsynchronousBusinesses(dataFlow);
- if(asynchronousBusinesses == null || asynchronousBusinesses.size() == 0){
- return ;
+ if (asynchronousBusinesses == null || asynchronousBusinesses.size() == 0) {
+ return;
}
ServiceBusiness serviceBusiness;
try {
for (Business business : asynchronousBusinesses) {
serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd());
KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(), "",
- OrderDataFlowContextFactory.getRequestBusinessJson(dataFlow,business).toJSONString());
+ OrderDataFlowContextFactory.getRequestBusinessJson(dataFlow, business).toJSONString());
}
- }catch (Exception e){
- throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,e.getMessage());
+ } catch (Exception e) {
+ throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR, e.getMessage());
}
OrderDataFlowContextFactory.addCostTime(dataFlow, "doSynchronousBusinesses", "寮傛璋冪敤涓氬姟绯荤粺鎬昏�楁椂", startDate);
@@ -1002,77 +686,68 @@
/**
* 淇濆瓨鏃ュ織淇℃伅
- * @param dataFlow 鏁版嵁娴佸璞� 灏佽鐢ㄦ埛璇锋眰鐨勪俊鎭�
*
- * @param requestJson 璇锋眰鎶ユ枃 鏍煎紡涓�
- * {"headers":"",
+ * @param dataFlow 鏁版嵁娴佸璞� 灏佽鐢ㄦ埛璇锋眰鐨勪俊鎭�
+ * @param requestJson 璇锋眰鎶ユ枃 鏍煎紡涓�
+ * {"headers":"",
* "body":""
* }
* @param responseJson 璇锋眰鎶ユ枃 鏍煎紡涓�
- * {"headers":"",
+ * {"headers":"",
* "body":""
* }
*/
- private void saveLogMessage(DataFlow dataFlow,JSONObject requestJson,JSONObject responseJson,long costTime){
- LogAgent.sendLog(dataFlow,requestJson,responseJson,costTime);
+ private void saveLogMessage(DataFlow dataFlow, JSONObject requestJson, JSONObject responseJson, long costTime) {
+ LogAgent.sendLog(dataFlow, requestJson, responseJson, costTime);
}
/**
* 淇濆瓨鏃ュ織淇℃伅
+ *
* @param requestJson
*/
- private void saveLogMessage(String requestJson,String responseJson){
+ private void saveLogMessage(String requestJson, String responseJson) {
- try{
- if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_LOG_ON_OFF))){
+ try {
+ if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_LOG_ON_OFF))) {
JSONObject log = new JSONObject();
- log.put("request",requestJson);
- log.put("response",responseJson);
- KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_LOG_NAME,"",log.toJSONString());
+ log.put("request", requestJson);
+ log.put("response", responseJson);
+ KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_LOG_NAME, "", log.toJSONString());
}
- }catch (Exception e){
- logger.error("鎶ラ敊鏃ュ織鍑洪敊浜嗭紝",e);
+ } catch (Exception e) {
+ logger.error("鎶ラ敊鏃ュ織鍑洪敊浜嗭紝", e);
}
}
/**
* 淇濆瓨鑰楁椂淇℃伅
+ *
* @param dataFlow
*/
- private void saveCostTimeLogMessage(DataFlow dataFlow){
- try{
- if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))){
+ private void saveCostTimeLogMessage(DataFlow dataFlow) {
+ try {
+ if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))) {
List<DataFlowLinksCost> dataFlowLinksCosts = dataFlow.getLinksCostDates();
JSONObject costDate = new JSONObject();
JSONArray costDates = new JSONArray();
JSONObject newObj = null;
- for(DataFlowLinksCost dataFlowLinksCost : dataFlowLinksCosts){
+ for (DataFlowLinksCost dataFlowLinksCost : dataFlowLinksCosts) {
newObj = JSONObject.parseObject(JSONObject.toJSONString(dataFlowLinksCost));
- newObj.put("dataFlowId",dataFlow.getDataFlowId());
- newObj.put("transactionId",dataFlow.getTransactionId());
+ newObj.put("dataFlowId", dataFlow.getDataFlowId());
+ newObj.put("transactionId", dataFlow.getTransactionId());
costDates.add(newObj);
}
- costDate.put("costDates",costDates);
+ costDate.put("costDates", costDates);
- KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_COST_TIME_LOG_NAME,"",costDate.toJSONString());
+ KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_COST_TIME_LOG_NAME, "", costDate.toJSONString());
}
- }catch (Exception e){
- logger.error("鎶ラ敊鏃ュ織鍑洪敊浜嗭紝",e);
+ } catch (Exception e) {
+ logger.error("鎶ラ敊鏃ュ織鍑洪敊浜嗭紝", e);
}
}
- /**
- * 淇敼c_business鐘舵��
- * @param bId
- * @param statusCd
- */
- private void updateBusinessStatusCdByBId(String bId,String statusCd){
- Map business = new HashMap();
- business.put("bId",bId);
- business.put("statusCd",statusCd);
- business.put("finishTime",DateUtil.getCurrentDate());
- centerServiceDaoImpl.updateBusinessByBId(business);
- }
+
public ICenterServiceDAO getCenterServiceDaoImpl() {
return centerServiceDaoImpl;
--
Gitblit v1.8.0