wuxw
2019-04-26 b1825e0e308329210229b72e556a137dd56f88ed
OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java
@@ -65,6 +65,7 @@
    /**
     * 业务统一处理服务方法
     *
     * @param reqJson 请求报文json
     * @return
     */
@@ -132,6 +133,7 @@
    /**
     * 刷返回值
     *
     * @param dataFlow
     */
    private void refreshOrderDataFlowResJson(IOrderDataFlowContext dataFlow){
@@ -146,6 +148,7 @@
    /**
     * 抒写返回头信息
     *
     * @param dataFlow
     */
    private void putResponseHeader(DataFlow dataFlow,Map<String,String> headers) {
@@ -155,6 +158,7 @@
    /**
     * 解密
     *
     * @param reqJson
     * @return
     */
@@ -176,6 +180,7 @@
    /**
     * 加密
     *
     * @param resJson
     * @param headers
     * @return
@@ -194,7 +199,6 @@
        }
        return resJson;
    }
    /**
@@ -397,6 +401,7 @@
        //OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "订单状态改为失败耗时", startDate);
    }
    /**
     * 将订单状态改为作废状态。
     *
@@ -416,13 +421,13 @@
        //doAddDeleteOrderBusinessData(dataFlow);
        OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "订单状态改为失败耗时", startDate);
    }
    /**
     * 加入撤单记录
     *
     * @param dataFlow
     */
    private void doAddDeleteOrderBusinessData(IOrderDataFlowContext dataFlow){
@@ -437,6 +442,7 @@
    /**
     * 加入撤单记录
     *
     * @param dataFlow
     */
    private void doAddDeleteOrderBusinessData(IOrderNotifyDataFlowContext dataFlow){
@@ -450,9 +456,9 @@
    }
    /**
     * 接受业务系统通知消息
     *
     * @param receiveJson 接受报文
     * @throws SMOException
     */
@@ -529,6 +535,7 @@
    /**
     * Instance过程
     *
     * @param dataFlow
     */
    private void doSendInstance(IOrderNotifyDataFlowContext dataFlow) {
@@ -547,6 +554,7 @@
    /**
     * 判断是否是 business 或者 instance过程
     *
     * @param dataFlow
     * @throws NoSupportException
     */
@@ -615,6 +623,7 @@
    /**
     * 判断是否都成功了
     *
     * @param dataFlow
     */
    private void judgeBusinessStatusAndCompleteBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessStatusException{
@@ -667,6 +676,7 @@
    /**
     * //4.0当所有业务动作是否都是C,将订单信息改为 C 并且发布竣工消息,这里在广播之前确认
     *
     * @param dataFlow
     */
    private void judgeSendToInstance(IOrderNotifyDataFlowContext dataFlow) throws Exception{
@@ -684,6 +694,7 @@
    /**
     * 通知 订单已经完成,后端需要完成数据
     *
     * @param dataFlow
     */
    private void notifyBusinessSystemSuccessMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception{
@@ -720,6 +731,7 @@
    /**
     * 处理同步业务
     *
     * @param dataFlow
     */
    private void doSynchronousBusinesses(IOrderDataFlowContext dataFlow) throws BusinessException{
@@ -759,6 +771,7 @@
    /**
     * 发起撤单业务
     *
     * @param dataFlow
     * @param deleteBusinesses
     */
@@ -811,6 +824,7 @@
    /**
     * 将BusinessTable 中的数据保存到 InstanceTable
     *
     * @param dataFlow
     * @param synchronousBusinesses
     */
@@ -846,6 +860,7 @@
    /**
     * 业务系统撤单
     *
     * @param dataFlow
     * @param deleteBusinesses
     */
@@ -867,6 +882,7 @@
    /**
     * 调用下游系统
     *
     * @param dataFlow
     * @param serviceBusiness
     * @param requestBusinessJson 请求报文
@@ -876,6 +892,7 @@
        String responseMessage;
        Assert.hasLength(serviceBusiness.getInvokeType(),"c_service_business表配置出错,invoke_type 不能为空"+ serviceBusiness.getBusinessTypeCd());
        String httpUrl = "";
        if(ServiceBusinessConstant.INVOKE_TYPE_WEBSERVICE.equals(serviceBusiness.getInvokeType())) {//webservice方式
            String url = serviceBusiness.getUrl();
            String[] urls = url.split("#");
@@ -883,25 +900,24 @@
            if(urls.length != 2){
                throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"配置错误:c_service_business配置url字段错误"+serviceBusiness.getBusinessTypeCd());
            }
            String webserviceUrl = MappingCache.getValue(urls[0]);
            httpUrl = MappingCache.getValue(urls[0]);
            String method = MappingCache.getValue(urls[1]);
            responseMessage = (String) WebServiceAxisClient.callWebService(webserviceUrl,method,
            responseMessage = (String) WebServiceAxisClient.callWebService(httpUrl, 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);
            httpUrl = MappingCache.getValue(serviceBusiness.getUrl());
            responseMessage = restTemplate.postForObject(httpUrl, 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方式
            httpUrl = MappingCache.getValue(serviceBusiness.getUrl());
            responseMessage = restTemplateNoLoadBalanced.postForObject(httpUrl, requestBusinessJson.toJSONString(), String.class);
        } else {//post方式
            throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"配置错误:c_service_business配置url字段错误,当前无法识别"+serviceBusiness.getBusinessTypeCd());
        }
        logger.debug("订单服务调用下游服务请求报文:{},返回报文:{}",requestBusinessJson,responseMessage);
        logger.debug("调用地址:{}, 订单服务调用下游服务请求报文:{},返回报文:{}", httpUrl, requestBusinessJson, responseMessage);
        if(StringUtil.isNullOrNone(responseMessage) || !Assert.isJsonObject(responseMessage)){
            throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"下游系统返回格式不正确,请按协议规范处理");
@@ -940,6 +956,7 @@
    /**
     * 数据保存到BusinessTable 中
     *
     * @param dataFlow
     * @param synchronousBusinesses
     * @param responseBusinesses
@@ -972,6 +989,7 @@
    /**
     * 处理异步业务
     *
     * @param
     */
    private void doAsynchronousBusinesses(IOrderDataFlowContext dataFlow) throws BusinessException{
@@ -1002,8 +1020,8 @@
    /**
     * 保存日志信息
     * @param dataFlow 数据流对象 封装用户请求的信息
     *
     * @param dataFlow     数据流对象 封装用户请求的信息
     * @param requestJson 请求报文 格式为
     *                    {"headers":"",
     *                     "body":""
@@ -1019,6 +1037,7 @@
    /**
     * 保存日志信息
     *
     * @param requestJson
     */
    private void saveLogMessage(String requestJson,String responseJson){
@@ -1037,6 +1056,7 @@
    /**
     * 保存耗时信息
     *
     * @param dataFlow
     */
    private void saveCostTimeLogMessage(DataFlow dataFlow){
@@ -1063,6 +1083,7 @@
    /**
     * 修改c_business状态
     *
     * @param bId
     * @param statusCd
     */