From c5aac73ec29f74904b544a722037b39bbb85ab3e Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期四, 07 二月 2019 21:35:35 +0800
Subject: [PATCH] 去serviceCode 改为businessTypeCd 完成
---
OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java | 1322 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 1,020 insertions(+), 302 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 f58a7d3..81fbef4 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,386 +2,1104 @@
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.ProtocolUtil;
-import com.java110.config.properties.EventProperties;
-import com.java110.core.base.smo.BaseServiceSMO;
-import com.java110.core.context.AppContext;
-import com.java110.core.event.AppEventPublishing;
-import com.java110.entity.order.BusiOrder;
-import com.java110.entity.order.BusiOrderAttr;
-import com.java110.entity.order.OrderList;
-import com.java110.entity.order.OrderListAttr;
-import com.java110.feign.base.IPrimaryKeyService;
-import com.java110.order.dao.IOrderServiceDao;
+import com.java110.common.util.*;
+import com.java110.core.client.RestTemplate;
+import com.java110.core.context.*;
+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;
+import com.java110.entity.order.ServiceBusiness;
+import com.java110.event.center.DataFlowEventPublishing;
+import com.java110.log.agent.LogAgent;
+import com.java110.order.dao.ICenterServiceDAO;
import com.java110.order.smo.IOrderServiceSMO;
-import org.apache.commons.lang.math.NumberUtils;
-import org.apache.commons.lang3.StringUtils;
+import com.java110.service.init.ServiceInfoListener;
+import com.java110.service.smo.IQueryServiceSMO;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import com.java110.common.util.Assert;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
/**
- * 璁㈠崟鏈嶅姟涓氬姟閫昏緫澶勭悊瀹炵幇绫�
- * Created by wuxw on 2017/4/11.
+ * 璁㈠崟鏈嶅姟澶勭悊绫�
+ * Created by wuxw on 2018/4/13.
*/
@Service("orderServiceSMOImpl")
-@Transactional
-public class OrderServiceSMOImpl extends BaseServiceSMO implements IOrderServiceSMO {
+//@Transactional
+public class OrderServiceSMOImpl implements IOrderServiceSMO {
+
+ private final static Logger logger = LoggerFactory.getLogger(OrderServiceSMOImpl.class);
+
@Autowired
- IPrimaryKeyService iPrimaryKeyService;
+ ICenterServiceDAO centerServiceDaoImpl;
@Autowired
- IOrderServiceDao iOrderServiceDao;
+ private RestTemplate restTemplate;
@Autowired
- EventProperties eventProperties;
+ private RestTemplate restTemplateNoLoadBalanced;
+
+ @Autowired
+ private IQueryServiceSMO queryServiceSMOImpl;
+
/**
- * 鏍规嵁璐墿杞D 鎴栬�� 澶栭儴绯荤粺ID 鎴栬�� custId 鎴栬�� channelId 鏌ヨ璁㈠崟淇℃伅
- * @param orderList
+ * 涓氬姟缁熶竴澶勭悊鏈嶅姟鏂规硶
+ * @param reqJson 璇锋眰鎶ユ枃json
* @return
*/
- @Override
- public String queryOrderInfo(OrderList orderList) throws Exception{
+ public ResponseEntity<String> service(String reqJson, Map<String,String> headers) throws SMOException{
+ IOrderDataFlowContext dataFlow = null;
+
+ JSONObject responseJson = null;
+
+ ResponseEntity<String> responseEntity = null;
+
+ try {
+ DataFlowEventPublishing.preValidateData(reqJson,headers);
+ //1.0 鍒涘缓鏁版嵁娴�
+ dataFlow = OrderDataFlowContextFactory.newInstance(OrderDataFlow.class).builder(reqJson, headers);
+ DataFlowEventPublishing.initDataFlowComplete(dataFlow);
+
+ //2.0 璋冪敤瑙勫垯鏍¢獙
+ ruleValidate(dataFlow);
+ DataFlowEventPublishing.ruleValidateComplete(dataFlow);
+
+ //3.0 淇濆瓨璁㈠崟鍜屼笟鍔¢」 c_orders c_order_attrs c_business c_business_attrs
+ saveOrdersAndBusiness(dataFlow);
+
+ //6.0 璋冪敤涓嬫父绯荤粺
+ DataFlowEventPublishing.invokeBusinessSystem(dataFlow);
+ invokeBusinessSystem(dataFlow);
+
+ //鑳藉鎵ц鍒拌繖涓�姝� 璁や负鏄兘鎴愬姛浜�
+ refreshOrderDataFlowResJson(dataFlow);
+
+ }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);
+ } catch (RuleException e) {
+ 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);
+ } finally {
+
+ if(responseEntity == null){
+ responseEntity = new ResponseEntity<String>(dataFlow.getResJson().getString("msg"),OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.OK);
+ }
+ if(dataFlow != null) {
+ //娣诲姞鑰楁椂
+ //OrderDataFlowContextFactory.addCostTime(dataFlow, "service", "涓氬姟澶勭悊鎬昏�楁椂", dataFlow.getStartDate(), dataFlow.getEndDate());
+ //淇濆瓨鑰楁椂
+ //saveCostTimeLogMessage(dataFlow);
+// saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()),
+// LogAgent.createLogMessage(dataFlow.getResponseHeaders(),responseEntity.getBody()),endDate.getTime()-dataFlow.getStartDate().getTime());
+// DataFlowEventPublishing.dataResponse(dataFlow,reqJson,headers);
+ }
- List<OrderList> orderLists = iOrderServiceDao.queryOrderListAndAttr(orderList);
- //
- JSONArray orderListsArray = new JSONArray();
- for (OrderList orderListTmp : orderLists){
- //
- BusiOrder busiOrderTmp = new BusiOrder();
- busiOrderTmp.setBoId(orderListTmp.getOlId());
+ //杩欓噷淇濆瓨鑰楁椂锛屼互鍙婃棩蹇�
+ return responseEntity ;
- List<BusiOrder> busiOrders = iOrderServiceDao.queryBusiOrderAndAttr(busiOrderTmp);
-
- JSONObject orderListJSON = JSONObject.parseObject(JSONObject.toJSONString(orderListTmp));
-
- orderListJSON.put("busiOrders",JSONObject.parseArray(JSONObject.toJSONString(busiOrders)));
-
- orderListsArray.add(orderListJSON);
}
-
- JSONObject orderListTmpO = new JSONObject();
- orderListTmpO.put("orderLists",orderListsArray);
-
- return ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_SUCCESS,"鏌ヨ鎴愬姛",orderListTmpO);
}
/**
- * 璁㈠崟璋冨害
+ * 鍒疯繑鍥炲��
+ * @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) {
+ headers.put("responseTime", DateUtil.getDefaultFormateTimeString(new Date()));
+ headers.put("transactionId",dataFlow.getTransactionId());
+ }
+
+ /**
+ * 瑙e瘑
+ * @param reqJson
+ * @return
+ */
+ 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");
+ logger.debug("瑙e瘑鍚庡瓧绗︼細" + reqJson);
+ }
+ }catch (Exception e){
+ throw new DecryptException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"瑙e瘑澶辫触");
+ }
+
+ return reqJson;
+ }
+
+ /**
+ * 鍔犲瘑
+ * @param resJson
+ * @param headers
+ * @return
+ */
+ 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");
+ logger.debug("鍔犲瘑鍚庡瓧绗︼細" + resJson);
+ }
+ }catch (Exception e){
+ logger.error("鍔犲瘑澶辫触锛�",e);
+ }
+ return resJson;
+ }
+
+
+
+ /**
+ * 2.0鍒濆鍖栭厤缃俊鎭�
*
- * orderListInfo 涓瓧娈� asyn 濡傛灉涓� A 琛ㄧず 寮傛澶勭悊璁㈠崟锛屽叾浠栬〃鍚屾澶勭悊璁㈠崟
- * @param orderInfo 璁㈠崟淇℃伅
- * @return 璁㈠崟澶勭悊鎺ュ彛
- * @throws Exception
+ * @param dataFlow
+ */
+ private void initConfigData(IOrderDataFlowContext dataFlow) {
+
+ }
+
+ /**
+ * 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 浣滃簾璁㈠崟鍜屼笟鍔¢」 鎻掑叆鎾ゅ崟璁板綍 绛夊緟鎾ゅ崟
+ *
+ * @param dataFlow
+ */
+ 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())){
+ //涓嶇敤浣滃簾璁㈠崟淇℃伅
+ // 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 ;
+ }
+
+ //浣滃簾 璁㈠崟
+ centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedInvalidOrder(dataFlow));
+
+ //浣滃簾璁㈠崟椤�
+ centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedInvalidOrder(dataFlow));
+
+ //灏嗗綋鍓嶈鍗曢」鏀逛负 鎾ゅ崟鐘舵��
+ centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedDeleteBusiness(dataFlow));
+ //鎻掑叆鎾ゅ崟璁板綍
+ doAddDeleteOrderBusinessData(dataFlow);
+
+ //OrderDataFlowContextFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "浣滃簾璁㈠崟鍜屼笟鍔¢」鑰楁椂", startDate);
+ }
+
+
+ /**
+ * 8.0 骞挎挱浣滃簾宸茬粡瀹屾垚涓氬姟绯荤粺璁㈠崟淇℃伅
+ *
+ * @param dataFlow
+ */
+ private void invalidCompletedBusinessSystem(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+
+ if(!StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
+ return ;
+ }
+
+ //鍒ゆ柇 璁㈠崟instance 鏄惁閮藉彉鎴愪簡鎾ゅ崟鐘舵��
+ 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);
+ 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);
+ }
+ }
+
+ /**
+ * 9.0 灏嗚鍗曠姸鎬佹敼涓哄け璐ワ紝浜哄伐澶勭悊銆�
+ *
+ * @param dataFlow
+ */
+ private void updateOrderAndBusinessError(IOrderDataFlowContext dataFlow) {
+
+ Date startDate = DateUtil.getCurrentDate();
+
+ //浣滃簾 璁㈠崟
+ centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow));
+
+ //浣滃簾璁㈠崟椤�
+ centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow));
+
+
+ OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "璁㈠崟鐘舵�佹敼涓哄け璐ヨ�楁椂", startDate);
+
+ }
+
+
+ /**
+ * 9.0 灏嗚鍗曠姸鎬佹敼涓哄け璐ワ紝浜哄伐澶勭悊銆�
+ *
+ * @param dataFlow
+ */
+ private void updateOrderAndBusinessError(IOrderNotifyDataFlowContext dataFlow) {
+
+ Date startDate = DateUtil.getCurrentDate();
+
+ //浣滃簾 璁㈠崟
+ centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow));
+
+ //浣滃簾璁㈠崟椤�
+ centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow));
+
+
+ //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){
+ /* 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,"璁㈠崟澶辫触锛屽姞鍏ユ挙鍗�"));
+ }
+
+ /**
+ * 鍔犲叆鎾ゅ崟璁板綍
+ * @param 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,"璁㈠崟澶辫触锛屽姞鍏ユ挙鍗�"));
+ }
+
+
+
+ /**
+ * 鎺ュ彈涓氬姟绯荤粺閫氱煡娑堟伅
+ * @param receiveJson 鎺ュ彈鎶ユ枃
+ * @throws SMOException
*/
@Override
- public String orderDispatch(JSONObject orderInfo) throws Exception {
-
- //1.0 璐墿杞︿俊鎭牎楠屽鐞�,璧拌鍗曞彈鐞嗗繀椤昏鏈夎喘鐗╄溅淇℃伅鍜岃鍗曢」淇℃伅
- if(!orderInfo.containsKey("orderListInfo") || !orderInfo.containsKey("busiOrder")){
- throw new IllegalArgumentException("璇锋眰鎶ユ枃涓病鏈夎喘鐗╄溅鐩稿叧淇℃伅[orderListInfo]鎴栬鍗曢」鐩稿叧淇℃伅[busiOrder],璇锋鏌ユ姤鏂囷細"+orderInfo);
- }
-
- JSONObject orderListTmp = orderInfo.getJSONObject("orderListInfo");
-
- OrderList orderList = JSONObject.parseObject(orderListTmp.toJSONString(),OrderList.class);
-
- String olId = orderList.getOlId();
- //鐢熸垚olId
- if(StringUtils.isBlank(olId) || olId.startsWith("-") ){
- olId = this.queryPrimaryKey(iPrimaryKeyService,"OL_ID");
- orderList.setOlId(olId);
- }
-
- //杩欓噷淇濆瓨璐墿杞�
-
- int saveOrderListFlag = iOrderServiceDao.saveDataToBoOrderList(orderList);
- if (saveOrderListFlag < 1){
- throw new RuntimeException("淇濆瓨璐墿杞︿俊鎭け璐�"+orderListTmp);
- }
-
- //淇濆瓨璐墿杞﹀睘鎬�
-
- if(orderInfo.containsKey("orderListAttrs")){
- JSONArray orderListAttrs = orderInfo.getJSONArray("orderListAttrs");
-
- List<OrderListAttr> orderListAttrsTmp = JSONObject.parseArray(orderListAttrs.toJSONString(), OrderListAttr.class);
-
- for(OrderListAttr orderListAttr : orderListAttrsTmp){
- orderListAttr.setOlId(olId);
- saveOrderListFlag = iOrderServiceDao.saveDataToOrderListAttr(orderListAttr);
- if(saveOrderListFlag < 1){
- throw new RuntimeException("淇濆瓨璐墿杞﹀睘鎬т俊鎭け璐�"+JSONObject.toJSONString(orderListAttr));
- }
- }
- }
-
-
- //鑾峰彇 璁㈠崟椤�
- JSONArray busiOrderTmps = orderInfo.getJSONArray("busiOrder");
-
- //瀛樻斁busiOrder 鐨刣ata鑺傜偣
-
- Map<String,JSONArray> datasTmp = new HashMap<String, JSONArray>();
-
- for(int busiOrderTmpsIndex = 0 ; busiOrderTmpsIndex < busiOrderTmps.size() ; busiOrderTmpsIndex++){
- JSONObject busiOrderJson = busiOrderTmps.getJSONObject(busiOrderTmpsIndex);
- /*if (!busiOrderJson.containsKey("busiObj")){
- throw new IllegalArgumentException("璇锋眰鎶ユ枃涓璪usiOrder 鑺傜偣涓病鏈夊搴旂殑 busiObj 鑺傜偣锛岃妫�鏌�"+busiOrderJson);
- }*/
-
- Assert.isNull(busiOrderJson,"busiObj","璇锋眰鎶ユ枃涓璪usiOrder 鑺傜偣涓病鏈夊搴旂殑 busiObj 鑺傜偣锛岃妫�鏌�"+busiOrderJson);
-
- BusiOrder busiOrderObj = JSONObject.parseObject(busiOrderJson.getJSONObject("busiObj").toJSONString(),BusiOrder.class);
-
- String boId = busiOrderObj.getBoId();
- //鐢熸垚 璁㈠崟椤笽D
- if(StringUtils.isBlank(boId) || boId.startsWith("-")){
- boId = this.queryPrimaryKey(iPrimaryKeyService,"BO_ID");
- }
- busiOrderObj.setOlId(olId);
- //淇敼boId
- busiOrderObj.setBoId(boId);
-
- //杩欓噷淇濆瓨璁㈠崟椤� busiOrder
- int saveBusiOrderFlag = iOrderServiceDao.saveDataToBusiOrder(busiOrderObj);
- if(saveBusiOrderFlag < 1){
- throw new RuntimeException("淇濆瓨璁㈠崟椤逛俊鎭け璐�"+JSONObject.toJSONString(busiOrderObj));
+ 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);
+ //濡傛灉璁㈠崟閮芥病鏈変繚瀛橈紝鍒欏啀涓嶈澶勭悊
+ if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null
+ &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())){
+ //涓嶄繚瀛樿鍗曚俊鎭�
+ return ;
}
- //濡傛灉鏈塨usiOrderAttrs 鑺傜偣 姣忎釜鑺傜偣娣诲姞 boId
- if(busiOrderJson.containsKey("busiOrderAttrs")){
- List<BusiOrderAttr> busiOrderAttrsTmp = JSONObject.parseArray(busiOrderJson.getJSONArray("busiOrderAttrs").toJSONString(),
- BusiOrderAttr.class);
+ //濡傛灉涓嶆槸 business 鍜宨nstance 杩囩▼ 鍒欑洿鎺ヨ烦鍑�
+ judgeBusinessOrInstance(dataFlow);
- for (BusiOrderAttr busiOrderAttrTmp : busiOrderAttrsTmp){
- busiOrderAttrTmp.setBoId(boId);
- //杩欓噷淇濆瓨璁㈠崟椤瑰睘鎬�
- saveBusiOrderFlag = iOrderServiceDao.saveDataToBusiOrderAttr(busiOrderAttrTmp);
- if(saveBusiOrderFlag < 1){
- throw new RuntimeException("淇濆瓨璁㈠崟椤逛俊鎭睘鎬уけ璐�"+JSONObject.toJSONString(busiOrderAttrTmp));
- }
- }
- }
- //淇敼data鑺傜偣涓嬬殑boId锛屼竴鑸槸娌℃湁杩欎釜鍊硷紝鎵�浠ョ洿鎺ユ柊鍔犲氨琛屼簡锛屼笉璁稿垽鏂槸鍚﹀凡-寮�澶�
- /* if (!busiOrderJson.containsKey("data")){
- throw new IllegalArgumentException("璇锋眰鎶ユ枃涓璪usiOrder 鑺傜偣涓病鏈夊搴旂殑 data 鑺傜偣锛岃妫�鏌�"+busiOrderJson);
- }*/
+ //2.0鍔犺浇鏁版嵁锛屾病鏈夋壘鍒癮ppId 鍙婇厤缃俊鎭� 鍒欐姏鍑篒nitConfigDataException
+ reloadOrderInfo(dataFlow);
- Assert.isNull(busiOrderJson,"data","璇锋眰鎶ユ枃涓璪usiOrder 鑺傜偣涓病鏈夊搴旂殑 data 鑺傜偣锛岃妫�鏌�"+busiOrderJson);
+ //3.0 鍒ゆ柇鏄惁鎴愬姛,澶辫触浼氭姏鍑築usinessStatusException寮傚父
+ judgeBusinessStatusAndCompleteBusiness(dataFlow);
- //澶勭悊data 鑺傜偣
- JSONObject data = busiOrderJson.getJSONObject("data");
+ //4.0 淇敼涓氬姟涓烘垚鍔�,濡傛灉鍙戠幇涓氬姟椤瑰凡缁忔槸浣滃簾鎴栧け璐ョ姸鎬侊紙D鎴朎锛夊垯鎶涘嚭BusinessException寮傚父
+ //completeBusiness(dataFlow);
- for (Map.Entry<String, Object> entry : data.entrySet()) {
- Object valueObj = entry.getValue();
- if (valueObj instanceof JSONObject){
- ((JSONObject)valueObj).put("boId",boId);
- }else if(valueObj instanceof JSONArray){
- JSONArray valueArray = (JSONArray)valueObj;
- for(int valueIndex = 0 ; valueIndex < valueArray.size(); valueIndex++){
- valueArray.getJSONObject(valueIndex).put("boId",boId);
- }
- }
- }
+ //5.0 鍒ゆ柇 鍙戣捣 Instance 鏉′欢鏄惁婊¤冻锛屽鏋滄弧瓒� 鍙戣捣 Instance杩囩▼
+ judgeSendToInstance(dataFlow);
- LoggerEngine.debug("澶勭悊鍚庣殑data鑺傜偣 锛�" + data.toString());
+ //7.0 鍒ゆ柇鎾ゅ崟鏉′欢鏄惁婊¤冻锛屽鏋滄弧瓒冲彂璧锋挙鍗�
+ invalidCompletedBusinessSystem(dataFlow);
- //鏍规嵁busiOrder 鐨� actionTypeCd 娉ㄥ唽閭d釜鏈嶅姟鍘诲鐞�
- String actionTypeCd = busiOrderObj.getActionTypeCd();
+ }catch (BusinessStatusException e){
- JSONArray dataJsonTmp = null;
- if(!datasTmp.containsKey(actionTypeCd)){
- dataJsonTmp = new JSONArray();
- }else{
- dataJsonTmp = datasTmp.get(actionTypeCd);
- }
- data.put("actionTypeCd",actionTypeCd);
- dataJsonTmp.add(data);
+ logger.error("璁㈠崟澶辫触:" ,e);
+ //8.0 灏嗚鍗曠姸鎬佹敼涓哄け璐ワ紝浜哄伐澶勭悊銆�
+ updateOrderAndBusinessError(dataFlow);
- datasTmp.put(actionTypeCd,dataJsonTmp);
-
- /*
+ }catch (BusinessException e) {
+ //9.0璇存槑杩欎釜璁㈠崟宸茬粡澶辫触浜嗭紝鍐嶄笉闇�瑕�
+ //鎯虫硶锛岃繖閲屽箍鎾綋鍓嶅け璐ヤ笟鍔�
+ logger.error("淇敼涓氬姟鏁版嵁澶辫触",e);
+ }/*catch (InitConfigDataException e){ //杩欑涓�鑸笉浼氬嚭鐜帮紝闄ら潪浜哄伐鏀逛簡鏁版嵁
+ LoggerEngine.error("鍔犺浇閰嶇疆鏁版嵁鍑洪敊", e);
try {
- //鍙戝竷浜嬩欢
- AppEventPublishing.multicastEvent(actionTypeCd,orderInfo.toJSONString(), data.toJSONString(),orderListTmp.getString("asyn"));
- }catch (Exception e){
- //杩欓噷琛ュ伩浜嬬墿
- throw e;
- }*/
+ //6.0 浣滃簾璁㈠崟鍜屾墍鏈変笟鍔¢」
+ invalidOrderAndBusiness(dataFlow);
+ //7.0 骞挎挱浣滃簾涓氬姟绯荤粺璁㈠崟淇℃伅,杩欓噷鍙湁 Instance 澶辫触鍚庢墠鍙戣捣 鎾ゅ崟
+ if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
+ invalidCompletedBusinessSystem(dataFlow);
+ }
+ } catch (Exception e1) {
+ LoggerEngine.error("浣滃簾璁㈠崟澶辫触", e1);
+ //8.0 灏嗚鍗曠姸鎬佹敼涓哄け璐ワ紝浜哄伐澶勭悊銆�
+ updateOrderAndBusinessError(dataFlow);
+ }
+ }*/catch (NoSupportException e){
+ LoggerEngine.error("褰撳墠涓氬姟涓嶆敮鎸�", e);
+ }catch (Exception e){
+ LoggerEngine.error("浣滃簾璁㈠崟澶辫触", e);
+ //10.0 鎴愬姛鐨勬儏鍐典笅閫氱煡涓嬫父绯荤粺澶辫触灏嗙姸鎬佹敼涓篘E锛屼汉宸ュ鐞嗐��
+ updateBusinessNotifyError(dataFlow);
+ }finally{
+ /*OrderDataFlowContextFactory.addCostTime(dataFlow, "receiveBusinessSystemNotifyMessage", "鎺ュ彈涓氬姟绯荤粺閫氱煡娑堟伅鑰楁椂", startDate);
+ saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getReqJson().toJSONString()),
+ LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS),
+ DateUtil.getCurrentDate().getTime() - dataFlow.getStartDate().getTime());*/
}
-
- //鍒涘缓涓婁笅鏂囧璞�
- AppContext context = createApplicationContext();
-
- prepareContext(context, datasTmp);
-
- //鍙戝竷浜嬩欢
- AppEventPublishing.multicastEvent(context,datasTmp,orderListTmp.getString("asyn"));
-
- return ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_SUCCESS,"鎴愬姛",JSONObject.parseObject(JSONObject.toJSONString(orderList)));
}
/**
- * 浣滃簾璁㈠崟
- * 鏍规嵁涓氬姟鍔ㄤ綔浣滃簾
- * 璇锋眰鍗忚锛�
- * {
- * "orderList":{
- * "transactionId": "1000000200201704113137002690",
- "channelId": "700212896",
- "remarks": "",
- "custId": "701008023904",
- "statusCd": "S",
- "reqTime": "20170411163709",
- "extSystemId": "310013698777",
- "olTypeCd": "15",
- * "oldOlId":"123456789",
- * "asyn":"S"
- * },
- * "busiOrder":[{
- * "actionTypeCd":"ALL"
- * }]
- * }
+ * Instance杩囩▼
+ * @param dataFlow
+ */
+ private void doSendInstance(IOrderNotifyDataFlowContext dataFlow) {
+ 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){
+
+ }
+
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁鏄� business 鎴栬�� instance杩囩▼
+ * @param 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 ;
+ }
+
+ throw new NoSupportException(ResponseConstant.RESULT_PARAM_ERROR,"褰撳墠鍙敮鎸� Business 鍜� Instance杩囩▼");
+ }
+
+
+ /**
+ * 2.0閲嶆柊鍔犺浇璁㈠崟淇℃伅鍒癲ataFlow 涓�
*
- * 锛�
+ * @param dataFlow
+ */
+ private void reloadOrderInfoAndConfigData(DataFlow dataFlow) {
+
+ 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 鑺傜偣");
+ }
+ //閲嶆柊鍒风鍙d俊鎭�
+ ServiceInfoListener serviceInfoListener = ApplicationContextFactory.getBean("serviceInfoListener",ServiceInfoListener.class);
+ if(serviceInfoListener != null){
+ dataFlow.setPort(serviceInfoListener.getServerPort()+"");
+ }
+ //閲嶆柊鍔犺浇閰嶇疆
+ //initConfigData(dataFlow);
+ }
+
+
+ /**
+ * 2.0閲嶆柊鍔犺浇璁㈠崟淇℃伅鍒癲ataFlow 涓�
*
- * 鏍规嵁 璁㈠崟椤笽D浣滃簾
+ * @param dataFlow
+ */
+ private void reloadOrderInfo(IOrderNotifyDataFlowContext dataFlow) {
+
+ 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 鑺傜偣");
+ }
+ }
+
+ /**
+ * 9.0 鎴愬姛鐨勬儏鍐典笅閫氱煡涓嬫父绯荤粺澶辫触灏嗙姸鎬佹敼涓篘E锛屼汉宸ュ鐞嗐��
*
- * {
- * "orderList":{
- * "transactionId": "1000000200201704113137002690",
- "channelId": "700212896",
- "remarks": "",
- "custId": "701008023904",
- "statusCd": "S",
- "reqTime": "20170411163709",
- "extSystemId": "310013698777",
- "olTypeCd": "15",
- "asyn":"A"
- * },
- * "busiOrder":[{
- * "oldBoId":"123456789"
- * },
- * {
- * "oldBoId":"123456799"
- * }]
- * }
- * @param orderInfo
+ * @param dataFlow
+ */
+ private void updateBusinessNotifyError(IOrderNotifyDataFlowContext dataFlow) {
+
+ Date startDate = DateUtil.getCurrentDate();
+ //瀹屾垚璁㈠崟椤�
+ centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedNotifyErrorBusiness(dataFlow));
+
+ // OrderDataFlowContextFactory.addCostTime(dataFlow, "updateBusinessNotifyError", "璁㈠崟鐘舵�佹敼涓哄け璐ヨ�楁椂", startDate);
+
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁閮芥垚鍔熶簡
+ * @param dataFlow
+ */
+ private void judgeBusinessStatusAndCompleteBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessStatusException{
+
+ //List<Business> businesses = dataFlow.getBusinesses();
+
+ //1.0 鍒ゆ柇鏄惁瀛樺湪鎾ゅ崟锛屽鏋滄槸鎾ゅ崟鍒欏皢褰撳墠 bId 鏍囪涓烘挙鍗曠姸鎬�
+ if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
+ Map businessMap = centerServiceDaoImpl.getDeleteOrderBusinessByOId(dataFlow.getoId());
+ if(businessMap != null && !businessMap.isEmpty()){
+ centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedDeleteBusiness(dataFlow));
+ return ;
+ }
+ }
+
+ //Business business = dataFlow.getCurrentBusiness();
+ if(!ResponseConstant.RESULT_CODE_SUCCESS.equals(((IOrderResponse)dataFlow).getCode())){
+ //throw new BusinessStatusException(business.getCode(),"涓氬姟bId= "+business.getbId() + " 澶勭悊澶辫触锛岄渶瑕佷綔搴熻鍗�");
+ //浣滃簾璁㈠崟鍜屼笟鍔¢」 鎻掑叆鎾ゅ崟璁板綍 绛夊緟鎾ゅ崟
+ invalidOrderAndBusiness(dataFlow);
+ }else{
+ completeBusiness(dataFlow);
+ }
+
+ }
+
+ /**
+ * 3.0 淇敼涓氬姟涓烘垚鍔�,濡傛灉鍙戠幇涓氬姟椤瑰凡缁忔槸浣滃簾鎴栧け璐ョ姸鎬侊紙D鎴朎锛夊垯鎶涘嚭BusinessException寮傚父
+ *
+ * @param dataFlow
+ */
+ private void completeBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessException{
+ try {
+ 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())) {
+ centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedBusinessComplete(dataFlow));
+ }else{ //杩欓噷鍒颁笉浜嗭紝鍓嶉潰鍋氫簡鏍¢獙
+ throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,"褰撳墠涓嶆敮鎸� 涓氬姟绫诲瀷涓� businessType" +dataFlow.getBusinessType());
+ }
+
+ }catch (DAOException e){
+ throw new BusinessException(e.getResult(),e);
+ }
+ }
+
+ /**
+ * //4.0褰撴墍鏈変笟鍔″姩浣滄槸鍚﹂兘鏄疌锛屽皢璁㈠崟淇℃伅鏀逛负 C 骞朵笖鍙戝竷绔e伐娑堟伅锛岃繖閲屽湪骞挎挱涔嬪墠纭
+ * @param dataFlow
+ */
+ private void judgeSendToInstance(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+ try {
+ if(centerServiceDaoImpl.judgeAllBusinessCompleted(dataFlow.getoId(),StatusConstant.STATUS_CD_BUSINESS_COMPLETE) > 0) {
+ //閫氱煡鎴愬姛娑堟伅
+ doSendInstance(dataFlow);
+ }
+ }catch (DAOException e){
+ //杩欓噷浠�涔堥兘涓嶅仛锛岃鏄庤鍗曟病鏈夊畬鎴�
+ }
+
+
+ }
+
+ /**
+ * 閫氱煡 璁㈠崟宸茬粡瀹屾垚锛屽悗绔渶瑕佸畬鎴愭暟鎹�
+ * @param dataFlow
+ */
+ private void notifyBusinessSystemSuccessMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+
+ long startTime = DateUtil.getCurrentDate().getTime();
+
+ ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd());
+ //鎷艰鎶ユ枃閫氱煡涓氬姟绯荤粺
+ KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(),"",
+ OrderDataFlowContextFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString());
+
+ /*saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),OrderDataFlowContextFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString()),
+ LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS),
+ DateUtil.getCurrentDate().getTime() - startTime);*/
+ }
+
+ /**
+ * 8.0 骞挎挱浣滃簾涓氬姟绯荤粺璁㈠崟淇℃伅
+ *
+ * @param dataFlow
+ */
+ private void notifyBusinessSystemErrorMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception{
+ long startTime = DateUtil.getCurrentDate().getTime();
+
+ ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd());
+
+ //鎷艰鎶ユ枃閫氱煡涓氬姟绯荤粺
+ 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
- * @throws Exception
*/
- @Override
- public String deleteOrder(JSONObject orderInfo) throws Exception {
- //1.0 璐墿杞︿俊鎭牎楠屽鐞�,璧拌鍗曞彈鐞嗗繀椤昏鏈夎喘鐗╄溅淇℃伅鍜岃鍗曢」淇℃伅
- if(!orderInfo.containsKey("orderList") || !orderInfo.containsKey("busiOrder")){
- throw new IllegalArgumentException("璇锋眰鎶ユ枃涓病鏈夎喘鐗╄溅鐩稿叧淇℃伅[orderList]鎴栬鍗曢」鐩稿叧淇℃伅[busiOrder],璇锋鏌ユ姤鏂囷細"+orderInfo);
+ 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 = CodeMapUtil.getDynamicConstantValue(urls[0]);
+ String method = CodeMapUtil.getDynamicConstantValue(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 = CodeMapUtil.getDynamicConstantValue(serviceBusiness.getUrl());
+ responseMessage = restTemplate.postForObject(httpPostUrl,requestBusinessJson.toJSONString(),String.class);
+ }else if(ServiceBusinessConstant.INVOKE_TYPE_OUT_HTTP_POST.equals(serviceBusiness.getInvokeType())){
+ String httpPostUrl = CodeMapUtil.getDynamicConstantValue(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());
}
- JSONObject orderListTmp = orderInfo.getJSONObject("orderList");
- OrderList orderList = JSONObject.parseObject(orderListTmp.toJSONString(),OrderList.class);
-
- String olId = orderList.getOlId();
- //鐢熸垚olId
- if(StringUtils.isBlank(olId) || olId.startsWith("-") ){
- olId = this.queryPrimaryKey(iPrimaryKeyService,"OL_ID");
- orderList.setOlId(olId);
+ 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()+"銆�");
- int saveOrderListFlag = iOrderServiceDao.saveDataToBoOrderList(orderList);
- if (saveOrderListFlag < 1){
- throw new RuntimeException("浣滃簾璁㈠崟鏃朵繚瀛樿喘鐗╄溅淇℃伅澶辫触"+orderListTmp);
+ 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;
+ }
- JSONArray busiOrderTmps = orderInfo.getJSONArray("busiOrder");
-
- /**
- * 鏍规嵁actionTypeCd 浣滃簾
- */
- Assert.isNull(busiOrderTmps,"鍏ュ弬閿欒锛屾病鏈塨usiOrder 鑺傜偣锛屾垨娌℃湁瀛愯妭鐐�");
-
- if(!busiOrderTmps.getJSONObject(0).containsKey("oldBoId")){
- String actionTypeCds = busiOrderTmps.getJSONObject(0).getString("actionTypeCd");
- deleteOrderByActionTypeCd(orderListTmp.getString("oldOlId"),actionTypeCds.split(","));
- return ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_SUCCESS,"鎴愬姛",JSONObject.parseObject(JSONObject.toJSONString(orderList)));
+ private String doTransferRequestBusinessSystem(DataFlow dataFlow, AppService service, String reqData) {
+ String responseMessage;
+ 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));
+ }
+ 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(),
+ new Object[]{dataFlow.getRequestBusinessJson().toJSONString()},
+ service.getTimeOut());
}
-
-
-
- return null;
+ return responseMessage;
}
/**
- * 鏍规嵁 璁㈠崟鍔ㄤ綔 浣滃簾
- * @param oldOlId 浣滃簾鐨勮喘鐗╄溅
- * @param actionTypeCd busi_order action_type_cd 绫诲瀷鏉ヤ綔搴熻鍗�
- * @throws Exception
+ * 鏁版嵁淇濆瓨鍒癇usinessTable 涓�
+ * @param dataFlow
+ * @param synchronousBusinesses
+ * @param responseBusinesses
*/
- private void deleteOrderByActionTypeCd(String oldOlId,String ...actionTypeCd) throws Exception{
- //鏍规嵁oldOdId actionTypeCd 鑾峰彇璁㈠崟椤�
- BusiOrder busiOrderTmp = new BusiOrder();
- busiOrderTmp.setOlId(oldOlId);
- String actionTypeCds= "";
- // 'C1','A1','M1',
- for(String ac : actionTypeCd){
- actionTypeCds += ("'"+ac+"',");
+ 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{
+ Date startDate = DateUtil.getCurrentDate();
+ //6.3 澶勭悊寮傛锛屾寜娑堟伅闃熼噷澶勭悊
+ List<Business> asynchronousBusinesses = OrderDataFlowContextFactory.getAsynchronousBusinesses(dataFlow);
+
+ 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());
+ }
+ }catch (Exception e){
+ throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,e.getMessage());
}
- // 'C1','A1','M1'
- actionTypeCds = actionTypeCds.endsWith(",")?actionTypeCds.substring(0,actionTypeCds.length()-1):actionTypeCds;
-
- busiOrderTmp.setActionTypeCd(actionTypeCds);
-
- List<BusiOrder> busiOrders = iOrderServiceDao.queryBusiOrderAndAttr(busiOrderTmp);
-
- Assert.isNull(busiOrders,"娌℃湁鎵惧埌闇�瑕佷綔搴熺殑璁㈠崟锛孾oldOdId="+oldOlId+",actionTypeCd = "+actionTypeCd+"]");
-
-
+ OrderDataFlowContextFactory.addCostTime(dataFlow, "doSynchronousBusinesses", "寮傛璋冪敤涓氬姟绯荤粺鎬昏�楁椂", startDate);
+// saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getRequestBusinessJson().toJSONString()),
+// LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getResponseBusinessJson().toJSONString()),
+// DateUtil.getCurrentDate().getTime()-startDate.getTime());
}
- private void prepareContext(AppContext context,Map<String,JSONArray> datasTmp){
- Assert.isNull(context,"鍒涘缓涓婁笅瀵硅薄澶辫触");
- //杩欓噷灏嗘暣涓鍗曠殑data 淇℃伅瀛樺叆 涓婁笅鏂囧璞′腑锛屼互闃插悗鏈熶娇鐢ㄦ棤娉曡幏鍙�
-
- context.coverData(datasTmp);
-
+ /**
+ * 淇濆瓨鏃ュ織淇℃伅
+ * @param dataFlow 鏁版嵁娴佸璞� 灏佽鐢ㄦ埛璇锋眰鐨勪俊鎭�
+ *
+ * @param requestJson 璇锋眰鎶ユ枃 鏍煎紡涓�
+ * {"headers":"",
+ * "body":""
+ * }
+ * @param responseJson 璇锋眰鎶ユ枃 鏍煎紡涓�
+ * {"headers":"",
+ * "body":""
+ * }
+ */
+ private void saveLogMessage(DataFlow dataFlow,JSONObject requestJson,JSONObject responseJson,long costTime){
+ LogAgent.sendLog(dataFlow,requestJson,responseJson,costTime);
}
- public IPrimaryKeyService getiPrimaryKeyService() {
- return iPrimaryKeyService;
+ /**
+ * 淇濆瓨鏃ュ織淇℃伅
+ * @param requestJson
+ */
+ private void saveLogMessage(String requestJson,String responseJson){
+
+ 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());
+ }
+ }catch (Exception e){
+ logger.error("鎶ラ敊鏃ュ織鍑洪敊浜嗭紝",e);
+ }
}
- public void setiPrimaryKeyService(IPrimaryKeyService iPrimaryKeyService) {
- this.iPrimaryKeyService = iPrimaryKeyService;
+ /**
+ * 淇濆瓨鑰楁椂淇℃伅
+ * @param dataFlow
+ */
+ 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){
+ newObj = JSONObject.parseObject(JSONObject.toJSONString(dataFlowLinksCost));
+ newObj.put("dataFlowId",dataFlow.getDataFlowId());
+ newObj.put("transactionId",dataFlow.getTransactionId());
+ costDates.add(newObj);
+ }
+ costDate.put("costDates",costDates);
+
+ KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_COST_TIME_LOG_NAME,"",costDate.toJSONString());
+ }
+ }catch (Exception e){
+ logger.error("鎶ラ敊鏃ュ織鍑洪敊浜嗭紝",e);
+ }
}
- public IOrderServiceDao getiOrderServiceDao() {
- return iOrderServiceDao;
+ /**
+ * 淇敼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 void setiOrderServiceDao(IOrderServiceDao iOrderServiceDao) {
- this.iOrderServiceDao = iOrderServiceDao;
+ public ICenterServiceDAO getCenterServiceDaoImpl() {
+ return centerServiceDaoImpl;
}
- public EventProperties getEventProperties() {
- return eventProperties;
+ public void setCenterServiceDaoImpl(ICenterServiceDAO centerServiceDaoImpl) {
+ this.centerServiceDaoImpl = centerServiceDaoImpl;
}
- public void setEventProperties(EventProperties eventProperties) {
- this.eventProperties = eventProperties;
+ public RestTemplate getRestTemplate() {
+ return restTemplate;
+ }
+
+ public void setRestTemplate(RestTemplate restTemplate) {
+ this.restTemplate = restTemplate;
+ }
+
+ public IQueryServiceSMO getQueryServiceSMOImpl() {
+ return queryServiceSMOImpl;
+ }
+
+ public void setQueryServiceSMOImpl(IQueryServiceSMO queryServiceSMOImpl) {
+ this.queryServiceSMOImpl = queryServiceSMOImpl;
+ }
+
+ public RestTemplate getRestTemplateNoLoadBalanced() {
+ return restTemplateNoLoadBalanced;
+ }
+
+ public void setRestTemplateNoLoadBalanced(RestTemplate restTemplateNoLoadBalanced) {
+ this.restTemplateNoLoadBalanced = restTemplateNoLoadBalanced;
}
}
--
Gitblit v1.8.0