ソースを参照

同步方式bug修复,异步方式 未测试完成

wuxw7 7 年 前
コミット
1e01ddaf59

+ 2 - 1
CenterService/src/main/java/com/java110/center/dao/impl/CenterServiceDAOImpl.java

@@ -160,7 +160,8 @@ public class CenterServiceDAOImpl extends BaseServiceDao implements ICenterServi
         int updateFlag = sqlSessionTemplate.update("centerServiceDAOImpl.completeOrderByBId",bId);
 
         if(updateFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"当前业务还没有全完成(C):"+ bId);
+            //throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"当前业务还没有全完成(C):"+ bId);
+            logger.debug("当前业务还没有全完成(C):"+bId);
         }
     }
 

+ 16 - 3
CenterService/src/main/java/com/java110/center/smo/impl/CenterServiceSMOImpl.java

@@ -655,7 +655,7 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
      */
     private void judgeBusinessStatusAndCompleteBusiness(DataFlow dataFlow) throws BusinessStatusException{
 
-        List<Business> businesses = dataFlow.getBusinesses();
+        //List<Business> businesses = dataFlow.getBusinesses();
 
         //1.0 判断是否存在撤单,如果是撤单则将当前 bId 标记为撤单状态
         if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
@@ -687,6 +687,9 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
             if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
                 //完成订单项
                 centerServiceDaoImpl.updateBusinessByBId(DataFlowFactory.getNeedCompleteBusiness(dataFlow));
+
+                //如果业务都完成,则将 订单改为完成状态
+                centerServiceDaoImpl.completeOrderByBId(dataFlow.getCurrentBusiness().getbId());
             }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())) {
                 centerServiceDaoImpl.updateBusinessByBId(DataFlowFactory.getNeedBusinessComplete(dataFlow));
             }else{ //这里到不了,前面做了校验
@@ -847,15 +850,24 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
             if(!CommonConstant.INSTANCE_Y.equals(service.getIsInstance())){
                 continue;
             }
+            dataFlow.setCurrentBusiness(business);
+            //添加需要撤单的业务信息
+            deleteBusinesses.add(business);
 
             requestBusinessJson = DataFlowFactory.getBusinessTableDataInfoToInstanceTableJson(dataFlow,business);
             JSONObject responseJson = doRequestBusinessSystem(dataFlow, service, requestBusinessJson);
-            //添加需要撤单的业务信息
-            deleteBusinesses.add(business);
+
             updateBusinessStatusCdByBId(business.getbId(),StatusConstant.STATUS_CD_COMPLETE);
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"耗时", businessStartDate);
             saveLogMessage(requestBusinessJson,responseJson);
         }
+
+        service = DataFlowFactory.getService(dataFlow,dataFlow.getCurrentBusiness().getServiceCode());
+        if(CommonConstant.INSTANCE_Y.equals(service.getIsInstance())){
+            //判断业务动作是否都竣工,主要考虑 请求报文中 有异步也有同步的情况
+            //如果业务都完成,则将 订单改为完成状态
+            centerServiceDaoImpl.completeOrderByBId(dataFlow.getCurrentBusiness().getbId());
+        }
     }
 
     /**
@@ -954,6 +966,7 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
 
         try {
             for (Business business : asynchronousBusinesses) {
+                dataFlow.setCurrentBusiness(business);
                 KafkaFactory.sendKafkaMessage(DataFlowFactory.getService(dataFlow, business.getServiceCode()).getMessageQueueName(), "",
                         DataFlowFactory.getRequestBusinessJson(dataFlow,business).toJSONString());
             }

+ 16 - 0
UserService/src/main/java/com/java110/user/kafka/UserServiceBean.java

@@ -0,0 +1,16 @@
+package com.java110.user.kafka;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created by wuxw on 2018/4/15.
+ */
+@Configuration
+public class UserServiceBean {
+    @Bean
+    public UserServiceKafka listener() {
+        return new UserServiceKafka();
+    }
+
+}

+ 1 - 1
java110-config/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml

@@ -63,7 +63,7 @@
     <!-- 当所有业务动作是否都是C,将订单信息改为 C-->
     <update id="completeOrderByBId" parameterType="String" >
         <![CDATA[
-            update c_orders co set co.status_cd = 'C' where co.status='S'
+            update c_orders co set co.status_cd = 'C' where co.status_cd='S'
                 and not exists(
                         select 1 from c_business cb where cb.status_cd <> 'C'
                         and cb.o_id = co.o_id

+ 1 - 1
java110-core/src/main/java/com/java110/core/context/DataFlow.java

@@ -201,7 +201,7 @@ public class DataFlow extends AbstractDataFlowContext {
             this.businesses = new ArrayList<Business>();
             business = new Business().builder(businessObj);
             businesses.add(business);
-
+            this.setCurrentBusiness(business);
         }catch (Exception e){
 
             throw e;

+ 2 - 1
java110-core/src/main/java/com/java110/core/factory/DataFlowFactory.java

@@ -306,7 +306,7 @@ public class DataFlowFactory {
         Map business = new HashMap();
         String bId = getMoreBId(dataFlow);
         business.put("bId",bId.substring(0,bId.length()-1));
-        //business.put("finishTime",DateUtil.getCurrentDate());
+        business.put("finishTime",DateUtil.getCurrentDate());
         business.put("statusCd",StatusConstant.STATUS_CD_NOTIFY_ERROR);
         return business;
     }
@@ -506,6 +506,7 @@ public class DataFlowFactory {
         JSONObject orders = notifyMessage.getJSONObject("orders");
         orders.put("transactionId",SequenceUtil.getTransactionId());
         orders.put("dataFlowId",dataFlow.getDataFlowId());
+        orders.put("orderTypeCd",dataFlow.getOrderTypeCd());
         orders.put("requestTime",DateUtil.getyyyyMMddhhmmssDateString());
         orders.put("businessType",businessType);
         return notifyMessage;