wuxw7
2018-05-22 768a42166035e34360e92f90852f38301aab25ca
订单受理 同步 异步 逻辑处理完成待测试
13个文件已修改
1个文件已添加
610 ■■■■ 已修改文件
CenterService/src/main/java/com/java110/center/dao/ICenterServiceDAO.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CenterService/src/main/java/com/java110/center/dao/impl/CenterServiceDAOImpl.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CenterService/src/main/java/com/java110/center/smo/impl/CenterServiceSMOImpl.java 175 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserService/src/test/java/com/java110/user/AppTest.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-common/pom.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-common/src/main/java/com/java110/common/constant/StatusConstant.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-common/src/main/java/com/java110/common/exception/NoSupportException.java 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-common/src/main/java/com/java110/common/util/WebServiceAxisClient.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-config/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/src/main/java/com/java110/core/context/BusinessServiceDataFlow.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/src/main/java/com/java110/core/context/DataFlow.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/src/main/java/com/java110/core/factory/DataFlowFactory.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CenterService/src/main/java/com/java110/center/dao/ICenterServiceDAO.java
@@ -34,6 +34,12 @@
    public void saveBusiness(List<Map> businesses) throws DAOException;
    /**
     * 保存订单项信息
     * @param business 订单项信息
     */
    public void saveBusiness(Map business) throws DAOException;
    /**
     * 保存属性信息
     * @param businessAttrs
     * @return
@@ -70,6 +76,15 @@
    public void completeOrderByBId(String bId) throws DAOException;
    /**
     * 判断 business 过程是否完成 1 表示完成 0表示未完成
     * @param oId
     * @return
     * @throws DAOException
     */
    public int judgeAllBusinessCompleted(String oId,String statusCd) throws DAOException;
    /**
     * 根据bId查询订单信息
     * @param bId
     * @return
@@ -78,12 +93,28 @@
    public Map getOrderInfoByBId(String bId)throws DAOException;
    /**
     * 根据oId查询订单信息
     * @param oId
     * @return
     * @throws DAOException
     */
    public Map getDeleteOrderBusinessByOId(String oId)throws DAOException;
    /**
     * 获取同个订单中已经完成的订单项
     * @param bId
     * @return
     * @throws DAOException
     */
    public List<Map> getCommonOrderCompledBusinessByBId(String bId) throws DAOException;
    /**
     * 根据oId 查询Business
     * @param info
     * @return
     * @throws DAOException
     */
    public List<Map> getBusinessByOId(Map info) throws DAOException;
    /**
     * 查询所有组件
@@ -97,4 +128,6 @@
     */
    public List<Mapping> getMappingInfoAll();
}
CenterService/src/main/java/com/java110/center/dao/impl/CenterServiceDAOImpl.java
@@ -10,6 +10,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -54,6 +55,20 @@
                throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"保存订单属性信息失败:"+ JSONObject.toJSONString(orderAttr));
            }
        }
    }
    /**
     * 保存订单项信息
     * @param business 订单项信息
     */
    @Override
    public void saveBusiness(Map business) throws DAOException {
        LoggerEngine.debug("----【CenterServiceDAOImpl.saveBusiness】保存数据入参 : " + JSONObject.toJSONString(business));
            int saveFlag = sqlSessionTemplate.insert("centerServiceDAOImpl.saveBusiness", business);
            if (saveFlag < 1) {
                throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR, "保存订单项信息失败:" + JSONObject.toJSONString(business));
            }
    }
    /**
@@ -150,6 +165,25 @@
    }
    /**
     * 判断 business 过程是否完成 1 表示完成 0表示未完成
     * @param oId
     * @return
     * @throws DAOException
     */
    public int judgeAllBusinessCompleted(String oId,String statusCd) throws DAOException{
        LoggerEngine.debug("----【CenterServiceDAOImpl.judgeAllBusinessCompleted】数据入参 :oId= " + oId + ",statusCd = " + statusCd);
        Map paramIn = new HashMap();
        paramIn.put("oId",oId);
        paramIn.put("statusCd",statusCd);
        Map paramOut = sqlSessionTemplate.selectOne("centerServiceDAOImpl.judgeAllBusinessCompleted",paramIn);
        if(paramOut == null || paramOut.isEmpty()){
            return 0;
        }
        return 1;
    }
    /**
     * 根据bId查询订单信息
     * @param bId
     * @return
@@ -162,6 +196,21 @@
        }
        return null;
    }
    /**
     * 根据oId查询订单信息
     * @param oId
     * @return
     * @throws DAOException
     */
    public Map getDeleteOrderBusinessByOId(String oId)throws DAOException{
        List<Map> orders = sqlSessionTemplate.selectList("centerServiceDAOImpl.getDeleteOrderBusinessByOId",oId);
        if(orders !=null){
            return orders.get(0);
        }
        return null;
    }
    /**
     * 获取同个订单中已经完成的订单项
     * @param bId
@@ -188,5 +237,17 @@
        return sqlSessionTemplate.selectList("centerServiceDAOImpl.getMappingInfoAll");
    }
    /**
     * 根据oId 查询Business
     * @param info
     * @return
     * @throws DAOException
     */
    public List<Map> getBusinessByOId(Map info) throws DAOException{
        LoggerEngine.debug("----【CenterServiceDAOImpl.getBusinessByOId】保存数据入参 : " + JSONObject.toJSONString(info));
        return sqlSessionTemplate.selectList("centerServiceDAOImpl.getBusinessByOId",info);
    }
}
CenterService/src/main/java/com/java110/center/smo/impl/CenterServiceSMOImpl.java
@@ -379,7 +379,7 @@
    /**
     * 7.0 作废订单和业务项
     * 7.0 作废订单和业务项 插入撤单记录 等待撤单
     *
     * @param dataFlow
     */
@@ -392,12 +392,25 @@
            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(DataFlowFactory.getNeedInvalidOrder(dataFlow));
        //作废订单项
        centerServiceDaoImpl.updateBusiness(DataFlowFactory.getNeedInvalidOrder(dataFlow));
        //将当前订单项改为 撤单状态
        centerServiceDaoImpl.updateBusinessByBId(DataFlowFactory.getNeedDeleteBusiness(dataFlow));
        //插入撤单记录
        doAddDeleteOrderBusinessData(dataFlow);
        DataFlowFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "作废订单和业务项耗时", startDate);
    }
@@ -409,14 +422,28 @@
     * @param dataFlow
     */
    private void invalidCompletedBusinessSystem(DataFlow dataFlow) throws Exception{
        if(!StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
            return ;
        }
        //判断 订单instance 是否都变成了撤单状态
        if(centerServiceDaoImpl.judgeAllBusinessCompleted(dataFlow.getoId(),StatusConstant.STATUS_CD_DELETE_ORDER) < 1){
            return ;
        }
        // 根据 c_business 表中的字段business_type_cd 找到对应的消息队列名称
        List<Map> completedBusinesses = centerServiceDaoImpl.getCommonOrderCompledBusinessByBId(dataFlow.getBusinesses().get(0).getbId());
        Map paramIn = new HashMap();
        paramIn.put("oId",dataFlow.getoId());
        paramIn.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);
        List<Map> completedBusinesses = centerServiceDaoImpl.getBusinessByOId(paramIn);
        for(AppRoute appRoute :dataFlow.getAppRoutes()){
            for(Map completedBusiness : completedBusinesses){
                if(completedBusiness.get("business_type_cd").equals(appRoute.getAppService().getBusinessTypeCd())){
                    //发起撤单
                    KafkaFactory.sendKafkaMessage(appRoute.getAppService().getMessageQueueName(),"",
                            DataFlowFactory.getCompletedBusinessErrorJson(dataFlow,completedBusiness,appRoute.getAppService()));
                    saveLogMessage(DataFlowFactory.getCompletedBusinessErrorJson(dataFlow,completedBusiness,appRoute.getAppService()),null);
                            DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()));
                    saveLogMessage(DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()),null);
                }
            }
        }
@@ -456,12 +483,29 @@
        centerServiceDaoImpl.updateOrder(DataFlowFactory.getNeedInvalidOrder(dataFlow));
        //作废订单项
        centerServiceDaoImpl.updateBusiness(DataFlowFactory.getNeedInvalidOrder(dataFlow));
        centerServiceDaoImpl.updateBusiness(DataFlowFactory.getNeedDeleteBusiness(dataFlow));
        //加入撤单记录
        //doAddDeleteOrderBusinessData(dataFlow);
        DataFlowFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "订单状态改为失败耗时", startDate);
    }
    /**
     * 加入撤单记录
     * @param dataFlow
     */
    private void doAddDeleteOrderBusinessData(DataFlow 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(DataFlowFactory.getDeleteOrderBusiness(dataFlow,"订单失败,加入撤单"));
    }
@@ -485,22 +529,39 @@
                return ;
            }
            //如果不是 business 和instance 过程 则直接跳出
            judgeBusinessOrInstance(dataFlow);
            //2.0加载数据,没有找到appId 及配置信息 则抛出InitConfigDataException
            reloadOrderInfoAndConfigData(dataFlow);
            //3.0 判断是否成功,失败会抛出BusinessStatusException异常
            judgeBusinessStatus(dataFlow);
            judgeBusinessStatusAndCompleteBusiness(dataFlow);
            //4.0 修改业务为成功,如果发现业务项已经是作废或失败状态(D或E)则抛出BusinessException异常
            completeBusiness(dataFlow);
            //5.0当所有业务动作是否都是C,将订单信息改为 C 并且发布竣工消息,这里在广播之前确认
            completeOrderAndNotifyBusinessSystem(dataFlow);
            //completeBusiness(dataFlow);
            //5.0 判断 发起 Instance 条件是否满足,如果满足 发起 Instance过程
            judgeSendToInstance(dataFlow);
            //7.0 判断撤单条件是否满足,如果满足发起撤单
            invalidCompletedBusinessSystem(dataFlow);
        }catch (BusinessStatusException e){
            logger.error("订单失败:" ,e);
            //8.0 将订单状态改为失败,人工处理。
            updateOrderAndBusinessError(dataFlow);
        }catch (BusinessException e) {
            //9.0说明这个订单已经失败了,再不需要
            //想法,这里广播当前失败业务
            logger.error("修改业务数据失败",e);
        }catch (InitConfigDataException e){ //这种一般不会出现,除非人工改了数据
            LoggerEngine.error("加载配置数据出错", e);
            try {
                //6.0 作废订单和所有业务项
                invalidOrderAndBusiness(dataFlow);
                //7.0 广播作废业务系统订单信息,这里只有 Instance 失败后才发起 撤单
                if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
                    invalidCompletedBusinessSystem(dataFlow);
@@ -510,28 +571,9 @@
                //8.0 将订单状态改为失败,人工处理。
                updateOrderAndBusinessError(dataFlow);
            }
        }catch (BusinessException e) {
            //9.0说明这个订单已经失败了,再不需要
            //想法,这里广播当前失败业务
            try {
                notifyBusinessSystemErrorMessage(dataFlow);
            }catch (Exception e1){
                //这里记录日志
            }
        }catch (InitConfigDataException e){ //这种一般不会出现,除非人工改了数据
            LoggerEngine.error("加载配置数据出错", e);
            try {
                //6.0 作废订单和所有业务项
                invalidOrderAndBusiness(dataFlow);
                //7.0 广播作废业务系统订单信息
                //想法,这里只广播已经完成的订单项
                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 成功的情况下通知下游系统失败将状态改为NE,人工处理。
@@ -540,6 +582,38 @@
            DataFlowFactory.addCostTime(dataFlow, "receiveBusinessSystemNotifyMessage", "接受业务系统通知消息耗时", startDate);
            saveLogMessage(dataFlow.getReqJson(),null);
        }
    }
    /**
     * Instance过程
     * @param dataFlow
     */
    private void doSendInstance(DataFlow dataFlow) {
        if(dataFlow == null || !StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())){
            return ;
        }
        try {
            KafkaFactory.sendKafkaMessage(DataFlowFactory.getService(dataFlow, dataFlow.getCurrentBusiness().getServiceCode()).getMessageQueueName(), "",
                    DataFlowFactory.getBusinessTableDataInfoToInstanceTableJson(dataFlow, dataFlow.getCurrentBusiness()).toJSONString());
        }catch (Exception e){
        }
    }
    /**
     * 判断是否是 business 或者 instance过程
     * @param dataFlow
     * @throws NoSupportException
     */
    private void judgeBusinessOrInstance(DataFlow 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过程");
    }
@@ -579,14 +653,26 @@
     * 判断是否都成功了
     * @param dataFlow
     */
    private void judgeBusinessStatus(DataFlow dataFlow) throws BusinessStatusException{
    private void judgeBusinessStatusAndCompleteBusiness(DataFlow dataFlow) throws BusinessStatusException{
        List<Business> businesses = dataFlow.getBusinesses();
        for(Business business: businesses){
            if(!ResponseConstant.RESULT_CODE_SUCCESS.equals(business.getCode())){
                throw new BusinessStatusException(business.getCode(),"业务bId= "+business.getbId() + " 处理失败,需要作废订单");
        //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(DataFlowFactory.getNeedDeleteBusiness(dataFlow));
                return ;
            }
        }
        Business business = dataFlow.getCurrentBusiness();
        if(!ResponseConstant.RESULT_CODE_SUCCESS.equals(business.getCode())){
            //throw new BusinessStatusException(business.getCode(),"业务bId= "+business.getbId() + " 处理失败,需要作废订单");
            //作废订单和业务项 插入撤单记录 等待撤单
            invalidOrderAndBusiness(dataFlow);
        }else{
            completeBusiness(dataFlow);
        }
    }
@@ -598,8 +684,14 @@
     */
    private void completeBusiness(DataFlow dataFlow) throws BusinessException{
        try {
            //完成订单项
            centerServiceDaoImpl.updateBusinessByBId(DataFlowFactory.getNeedCompleteBusiness(dataFlow));
            if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) {
                //完成订单项
                centerServiceDaoImpl.updateBusinessByBId(DataFlowFactory.getNeedCompleteBusiness(dataFlow));
            }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())) {
                centerServiceDaoImpl.updateBusinessByBId(DataFlowFactory.getNeedBusinessComplete(dataFlow));
            }else{ //这里到不了,前面做了校验
                throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,"当前不支持 业务类型为 businessType" +dataFlow.getBusinessType());
            }
        }catch (DAOException e){
            throw new BusinessException(e.getResult(),e);
@@ -610,11 +702,12 @@
     * //4.0当所有业务动作是否都是C,将订单信息改为 C 并且发布竣工消息,这里在广播之前确认
     * @param dataFlow
     */
    private void completeOrderAndNotifyBusinessSystem(DataFlow dataFlow) throws Exception{
    private void judgeSendToInstance(DataFlow dataFlow) throws Exception{
        try {
            centerServiceDaoImpl.completeOrderByBId(DataFlowFactory.getMoreBId(dataFlow));
            //通知成功消息
            notifyBusinessSystemSuccessMessage(dataFlow);
            if(centerServiceDaoImpl.judgeAllBusinessCompleted(dataFlow.getoId(),StatusConstant.STATUS_CD_BUSINESS_COMPLETE) > 0) {
                //通知成功消息
                doSendInstance(dataFlow);
            }
        }catch (DAOException e){
            //这里什么都不做,说明订单没有完成
        }
UserService/src/test/java/com/java110/user/AppTest.java
@@ -1,5 +1,6 @@
package com.java110.user;
import com.java110.common.util.WebServiceAxisClient;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -33,6 +34,24 @@
     */
    public void testApp()
    {
        assertTrue( true );
        String url = "http://135.192.70.67:9084/serviceAgent/http/FactorageManager_ForAgent?AppKey=2017082401";
        String function = "queryOrderInfo";
        String xml  = "<QueryOrderInfoRequest>\n" +
                "\t<accNbr>18009706604</accNbr>\n" +
                "\t<accNbrType>1</accNbrType> \n" +
                "\t<areaCode>0971</areaCode>\n" +
                "\t<channelId></channelId>\n" +
                "\t<staffCode></staffCode> \t\n" +
                "</QueryOrderInfoRequest>";
        try {
            Object retObj = WebServiceAxisClient.callWebService(url, function, new Object[]{xml});
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
java110-common/pom.xml
@@ -54,6 +54,8 @@
            <artifactId>commons-httpclient</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
java110-common/src/main/java/com/java110/common/constant/StatusConstant.java
@@ -18,7 +18,10 @@
    public final static String STATUS_CD_NOTIFY_ERROR = "NE";//通知错误订单
    public final static String STATUS_CD_COMPLETE = "C";//错误订单
    public final static String STATUS_CD_BUSINESS = "B";//BUSINESS过程
    public final static String STATUS_CD_BUSINESS_COMPLETE = "BC";//BUSINESS过程 完成
    public final static String STATUS_CD_INSTANCE = "I";//INSTANCE过程
    public final static String STATUS_CD_DELETE_ORDER = "DO";// 撤单
    public final static String OPERATE_ADD = "ADD";
    public final static String OPERATE_MOD = "MOD";
java110-common/src/main/java/com/java110/common/exception/NoSupportException.java
New file
@@ -0,0 +1,189 @@
package com.java110.common.exception;
import com.alibaba.fastjson.JSONObject;
import java.io.PrintStream;
import java.io.PrintWriter;
/**
 * 系统不支持异常
 * Created by wuxw on 2018/4/14.
 */
public class NoSupportException extends RuntimeException {
    private Result result;
    private Throwable cause = this;
    public NoSupportException(){}
    /**
     * 构造方法
     * @param result 返回值
     * @param cause  异常堆栈
     */
    public NoSupportException(Result result, Throwable cause) {
        super(result.getMsg(), cause);
        this.result = result;
    }
    /**
     * 构造方法
     * @param code 返回码
     * @param msg  错误消息
     */
    public NoSupportException(int code, String msg) {
        super(msg);
        this.result = new Result(code, msg);
    }
    public NoSupportException(String code, String msg) {
        super(msg);
        this.result = new Result(code, msg);
    }
    /**
     * 构造方法
     * @param result 返回值
     * @param detail 具体的返回消息
     */
    public NoSupportException(Result result, String detail) {
        super(result.getMsg() + "," + detail);
        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
    }
    /**
     * 构造方法
     * @param result 返回值
     * @param detail 具体的返回消息
     * @param cause  异常堆栈
     */
    public NoSupportException(Result result, String detail, Throwable cause) {
        super(result.getMsg() + "," + detail, cause);
        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
    }
    /**
     * 构造方法
     * @param code    返回码
     * @param msg    返回消息
     * @param cause 异常堆栈
     */
    public NoSupportException(int code, String msg, Throwable cause) {
        super(msg, cause);
        if(cause != null) {
            if(cause.getCause() != null) {
                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
            }
            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
        }
        this.result = new Result(code, msg);
    }
    /**
     * 构造方法
     * @param code    返回码
     * @param cause    异常堆栈
     */
    public NoSupportException(int code, Throwable cause) {
        super(cause);
        String msg = "";
        if(cause != null) {
            if(cause.getCause() != null) {
                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
            }
            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
        }
        this.result = new Result(code, msg);
    }
    /**
     *
     * TODO 简单描述该方法的实现功能(可选).
     * @see Throwable#getCause()
     */
    public synchronized Throwable getCause() {
        return (cause==this ? super.getCause() : cause);
    }
    /**
     * 返回异常消息
     * @return 异常消息
     */
    @Override
    public String getMessage() {
        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
    }
    /**
     * 异常
     * @return
     */
    public String toJsonString() {
        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
        if (getResult() != null)
            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
        exceptionJsonObj.put("exceptionTrace",getMessage());
        return exceptionJsonObj.toString();
    }
    @Override
    public void printStackTrace(PrintStream ps) {
        ps.print("<exception>");
        if (getResult() != null) {
            ps.print(result.toString());
        }
        ps.append("<exceptionTrace>");
        Throwable cause = getCause();
        if (cause == null) {
            super.printStackTrace(ps);
        } else {
            ps.println(this);
            ps.print("Caused by: ");
            cause.printStackTrace(ps);
        }
        ps.append("</exceptionTrace>");
        ps.println("</exception>");
    }
    @Override
    public void printStackTrace(PrintWriter pw) {
        pw.print("<exception>");
        if (getResult() != null) {
            pw.print(result.toString());
        }
        pw.append("<exceptionTrace>");
        Throwable cause = getCause();
        if (cause == null) {
            super.printStackTrace(pw);
        } else {
            pw.println(this);
            pw.print("Caused by: ");
            cause.printStackTrace(pw);
        }
        pw.append("</exceptionTrace>");
        pw.println("</exception>");
    }
    /**
     * 返回异常值
     * @return    异常值对象
     */
    public Result getResult() {
        return result;
    }
    public void setResult(Result result) {
        this.result = result;
    }
}
java110-common/src/main/java/com/java110/common/util/WebServiceAxisClient.java
@@ -16,16 +16,21 @@
public class WebServiceAxisClient extends LoggerEngine {
    public static void main(String[] args) {
        String url = "http://135.192.100.2:9001/QH10000Web/WebTelecom10000";
        String function = "getBalance";
        String url = "http://135.192.70.67:9084/serviceAgent/http/FactorageManager_ForAgent?AppKey=2017082401";
        String function = "queryOrderInfo";
        String areaCode = "0971";
        String accNbr = "18997240042";
        String type = "2";
        Object[] obj = new Object[]{areaCode, accNbr, type};
        String xml  = "<QueryOrderInfoRequest>\n" +
                "\t<accNbr>18009706604</accNbr>\n" +
                "\t<accNbrType>1</accNbrType> \n" +
                "\t<areaCode>0971</areaCode>\n" +
                "\t<channelId></channelId>\n" +
                "\t<staffCode></staffCode> \t\n" +
                "</QueryOrderInfoRequest>";
        try {
            Object retObj = WebServiceAxisClient.callWebService(url, function, obj);
            Object retObj = WebServiceAxisClient.callWebService(url, function, new Object[]{xml});
        } catch (Exception e) {
            e.printStackTrace();
        }
java110-config/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml
@@ -81,6 +81,26 @@
        )
    ]]>
    </select>
    <!-- 根据 OID 查询 business -->
    <select id="getBusinessByOId" parameterType="map" resultType="map">
        SELECT co.`o_id`,co.`app_id`,co.`order_type_cd`,co.`user_id`,cb.`business_type_cd`,cb.`b_id`,cb.`status_cd`
        FROM c_orders co,c_business cb
        WHERE co.`o_id` = cb.`o_id`
        AND cb.`business_type_cd` NOT IN ('DO')
        <if test="statusCd != null and statusCd != ''">
        AND cb.`status_cd` = #{statusCd}
        </if>
        <if test="oId != null and oId != ''">
        AND co.`o_id` = #{oId}
        </if>
    </select>
    <select id="getDeleteOrderBusinessByOId" parameterType="String" resultType="Map">
        <![CDATA[
           select cb.b_id,cb.o_id,cb.business_type_cd,cb.status_cd from c_orders co,c_business cb where co.o_id = cb.o_id and cb.business_type_cd = 'DO' and cb.status_cd = 'DO'
           and co.o_id = #{oId}
        ]]>
    </select>
    <!-- 获取同个订单中已经完成的订单项-->
    <select id="getCommonOrderCompledBusinessByBId" parameterType="String" resultType="Map">
@@ -113,4 +133,16 @@
        ]]>
    </select>
    <select id="judgeAllBusinessCompleted" parameterType="map" resultType="map">
        SELECT co.* FROM c_orders co WHERE co.`o_id` = #{oId} and not exists (
        SELECT 1 FROM c_business cb WHERE cb.`o_id` = co.`o_id`
        AND cb.`status_cd` NOT IN (#{statusCd})
        )
        AND NOT EXISTS (
        SELECT 1 FROM c_business cbs WHERE cbs.`o_id` =co.`o_id`
        AND cbs.`business_type_cd` = 'DO'
        )
        AND co.`status_cd` NOT IN ('D','C')
    </select>
</mapper>
java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java
@@ -16,6 +16,8 @@
    private String dataFlowId;
    private String businessType;
    //交易流水
    private String transactionId;
@@ -220,7 +222,11 @@
    public JSONArray getAttrs(){return null;};
    public String getBusinessType() {
        return null;
        return businessType;
    }
    public void setBusinessType(String businessType) {
        this.businessType = businessType;
    }
    public Map<String, Object> getParamOut() {
java110-core/src/main/java/com/java110/core/context/BusinessServiceDataFlow.java
@@ -18,7 +18,7 @@
public class BusinessServiceDataFlow extends AbstractDataFlowContext {
    private String businessType;
    private String bId;
@@ -29,13 +29,6 @@
        return this;
    }
    public String getBusinessType() {
        return businessType;
    }
    public void setBusinessType(String businessType) {
        this.businessType = businessType;
    }
    public BusinessServiceDataFlow(Date startDate, String code) {
        super(startDate, code);
java110-core/src/main/java/com/java110/core/context/DataFlow.java
@@ -186,6 +186,7 @@
            this.setTransactionId(reqInfoObj.getString("transactionId"));
            this.setOrderTypeCd(reqInfoObj.getString("orderTypeCd"));
            this.setRequestTime(reqInfoObj.getString("responseTime"));
            this.setBusinessType(reqInfoObj.getString("businessType"));
            //this.setReqOrders(orderObj);
            JSONObject businessObj = new JSONObject();
            businessObj.put("bId",reqInfoObj.getString("bId"));
java110-core/src/main/java/com/java110/core/factory/DataFlowFactory.java
@@ -199,7 +199,7 @@
        busiMap.put("oId",dataFlow.getoId());
        busiMap.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE);
        busiMap.put("remark",message);
        busiMap.put("statusCd",StatusConstant.STATUS_CD_DELETE);
        busiMap.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);
        busiMap.put("bId",SequenceUtil.getBId());
        business.add(busiMap);
        return business;
@@ -267,6 +267,40 @@
        business.put("bId",bId.substring(0,bId.length()-1));
        business.put("finishTime",DateUtil.getCurrentDate());
        business.put("statusCd",StatusConstant.STATUS_CD_COMPLETE);
        return business;
    }
    /**
     * Business 过程完成
     * @param dataFlow
     * @return
     */
    public static Map getNeedBusinessComplete(DataFlow dataFlow){
        Map business = new HashMap();
        String bId = "";
        for(Business busi:dataFlow.getBusinesses()){
            bId += "'"+busi.getbId()+"',";
        }
        business.put("bId",bId.substring(0,bId.length()-1));
        business.put("finishTime",DateUtil.getCurrentDate());
        business.put("statusCd",StatusConstant.STATUS_CD_BUSINESS_COMPLETE);
        return business;
    }
    /**
     * Business 过程完成
     * @param dataFlow
     * @return
     */
    public static Map getNeedDeleteBusiness(DataFlow dataFlow){
        Map business = new HashMap();
        String bId = "";
        for(Business busi:dataFlow.getBusinesses()){
            bId += "'"+busi.getbId()+"',";
        }
        business.put("bId",bId.substring(0,bId.length()-1));
        business.put("finishTime",DateUtil.getCurrentDate());
        business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);
        return business;
    }
@@ -374,6 +408,8 @@
    }
    /**
     * 获取失败消息的报文(订单失败后通知业务系统)
     * @param business
@@ -387,8 +423,8 @@
            busi.put("bId",business.getbId());
            busi.put("serviceCode",business.getServiceCode());
            busi.put("serviceName",business.getServiceName());
            busi.put("isInstance",CommonConstant.INSTANCE_Y);
        busi.put("datas",business.getDatas());
            //busi.put("isInstance",CommonConstant.INSTANCE_Y);
        //busi.put("datas",business.getDatas());
        requestMessage.put("business",busi);
        return requestMessage;
    }
@@ -407,11 +443,23 @@
        busi.put("bId",business.getbId());
        busi.put("serviceCode",business.getServiceCode());
        busi.put("serviceName",business.getServiceName());
        busi.put("datas",business.getDatas());
        //busi.put("datas",business.getDatas());
        requestMessage.put("business",busi);
        return requestMessage;
    }
    public static JSONObject getDeleteInstanceTableJson(DataFlow dataFlow,Map business,AppService appService){
        JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_DELETE);
        JSONObject busi = null;
        busi = new JSONObject();
        busi.put("bId",business.get("b_id"));
        busi.put("serviceCode",appService.getServiceCode());
        //busi.put("datas",business.getDatas());
        requestMessage.put("business",busi);
        return requestMessage;
    }
    /**
     * 获取失败消息的报文(订单失败后通知业务系统)
     * @param business
pom.xml
@@ -293,6 +293,7 @@
                <version>${httpclient.verion}</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2 -->
            <dependency>
                <groupId>org.apache.axis</groupId>