Parcourir la source

RPC代码更新提交

chenweida il y a 9 ans
Parent
commit
7804037c70

+ 17 - 1
Hos-Resource-Rest/pom.xml

@ -158,8 +158,24 @@
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>core-rpc</artifactId>
            <version>2.0.0</version>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>api-config</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>core-db</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.3.6</version>
        </dependency>
        <dependency>
            <groupId>xom</groupId>
            <artifactId>xom</artifactId>

+ 1 - 1
Hos-Resource-Rest/src/main/java/com/yihu/hos/config/Config.java

@ -11,7 +11,7 @@ import java.util.Properties;
 */
public class Config {
    public static String url;
    public static String namespace;
    public static String appId;
    public static String monogoUrl;
    public static String startCollect;

+ 26 - 21
Hos-Resource-Rest/src/main/java/com/yihu/hos/gateway/control/rpc/impl/ResourceRpcImpl.java

@ -17,10 +17,8 @@ import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by Administrator on 2016/4/12.
@ -67,19 +65,21 @@ public class ResourceRpcImpl implements IResourceRpc {
    //查询病人基本信息
    private void patientInformation(String cardNo, String cardType, String patientId) throws Exception {
        String data =
                "<Req>" +
                        "<TransactionCode></TransactionCode>" +
                        "<Data>" +
                        "<CardType>" + cardType + "</CardType>" +
                        "<CardNo>" + cardNo + "</CardNo>" +
                        "<PatientId>" + patientId + "</PatientId>" +
                        "</Data>" +
                        "</Req>";
        Class[] classes = new Class[]{String.class};
        Object[] v = new Object[1];
        v[0] = data;
        Object s = RPCUtil.getRPCData("report.ReportWs.GetReportInfo", classes, v);
        String param = "<Req><TransactionCode>1001</TransactionCode>" +
                "<Data>" +
                "<CardType>"+cardType+"</CardType>" +
                "<CardNo>"+cardNo+"</CardNo>" +
                "<PatientName>zhengmy" +"</PatientName>" +
                "</Data>" +
                "</Req>";
        String apiparam = "{\"ChannelId\"=\"100123\"," +
                "\"ParamType\"=1," +
                "\"Params\"=\"" + param + "\"," +
                "\"Guid\"=\"" + "00000001111111" + "\"," +
                "\"V\"=\"3.0.0\"," +
                "\"OutType\"=0n ," +
                "\"HospitalId\"=\"1026333\"}";
        Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.QueryUserInfo", apiparam);
        //解析xml
        SAXReader saxReader = new SAXReader();
        Document document = saxReader.read(s.toString());
@ -104,6 +104,7 @@ public class ResourceRpcImpl implements IResourceRpc {
    //检查检验报告
    private void pushreport(String reportType, String reportId) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String data =
                "<Req>" +
                        "<TransactionCode></TransactionCode>" +
@ -112,10 +113,14 @@ public class ResourceRpcImpl implements IResourceRpc {
                        "<ReportType>" + reportType + "</ReportType>" +
                        "</Data>" +
                        "</Req>";
        Class[] classes = new Class[]{String.class};
        Object[] v = new Object[1];
        v[0] = data;
        Object s = RPCUtil.getRPCData("report.ReportWs.GetReportInfo", classes, v);
        String apiparam = "{\"ChannelId\"=\"100123\"," +
                "\"ParamType\"=1," +
                "\"Params\"=\"" + data + "\"," +
                "\"Guid\"=\"" + "00000001111111" + "\"," +
                "\"V\"=\"3.0.0\"," +
                "\"OutType\"=0," +
                "\"HospitalId\"=\"1026333\"}";
        Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.GetReportInfo", apiparam);
        //解析xml
        SAXReader saxReader = new SAXReader();
        Document document = saxReader.read(s.toString());

+ 82 - 10
Hos-Resource-Rest/src/main/java/com/yihu/hos/gateway/util/RPCUtil.java

@ -2,6 +2,7 @@ package com.yihu.hos.gateway.util;
import com.yihu.hos.config.Config;
import com.yihu.wsgw.api.ServiceBus;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
@ -14,13 +15,24 @@ import java.util.Date;
 * Created by Administrator on 2016/4/18.
 */
public class RPCUtil {
    public static String getRPCData(String methos, Class[] classes, Object[] v) {
    public static String getRPCData(String apiName, String apiparam) {
        String SERVER_URL = Config.url;
        String namespace = Config.namespace;
        String xml = getObjectByAxis2CallClient(SERVER_URL, namespace, methos, v, classes);
        return xml;
        String appId = Config.appId;
        return ServiceBus.getInstance(
                "172.18.20.123:8085",
                "EsbCloud").call(apiName, apiparam);
    }
    /**
     * webservice调用
     *
     * @param webServiceAddr
     * @param webserviceNamespace
     * @param webServiceMethod
     * @param inputValues
     * @param inputValuetype
     * @return
     */
    public static String getObjectByAxis2CallClient(String webServiceAddr, String webserviceNamespace, String webServiceMethod,
                                                    Object[] inputValues, Class[] inputValuetype) {
@ -42,13 +54,73 @@ public class RPCUtil {
        return "";
    }
    public static void main(String[] args) throws Exception {
        String apiName = "ZEUS.HosHOPWs.GetReportList";
      String  param = "<Req><TransactionCode>1001</TransactionCode>" +
                "<Data>" +
                "<CardType>1</CardType>" +
                "<CardNo>123</CardNo>" +
                "<StartDate>2016-04-19</StartDate>" +
                "<EndDate>2016-08-19</EndDate>" +
                "<Mobile>18559991897</Mobile>" +
                "<PatientName>zhengmy" +
                "</PatientName>" +
                "<ReportType>1</ReportType>" +
                "</Data>" +
                "</Req>";
        String apiparam = "{\"ChannelId\"=\"100123\"," +
                "\"ParamType\"=1," +
                "\"Params\"=\"" + param + "\"," +
                "\"Guid\"=\"" + "00000001111111" + "\"," +
                "\"V\"=\"3.0.0\"," +
                "\"OutType\"=1," +
                "\"HospitalId\"=\"1026333\"}";
        String result = null;
        result = ServiceBus.getInstance(
                "172.18.20.123:8085",
                "EsbCloud").call(apiName, apiparam);
    }
    /*
    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String data =
                "<Req>" +
                        "<TransactionCode>yy.yygh.QueryNumbers</TransactionCode>" +
                        "<Data>" +
                        "<CardType>123</CardType>" +
                        "<CardNo>333</CardNo>" +
                        "<PatientId>333</PatientId>" +
                        "</Data>" +
                        "</Req>";
        String SERVER_URL = "http://service.yihu.com:8080/WSGW/services/ServiceGateWay";
        String namespace = "http://com.yihu.wsgw/ServiceGateWay";
        String methos = "yy.yygh.QueryNumbers";
        Class[] classes = new Class[]{String.class};
        Object[] v = new Object[1];
        v[0] = "";
        String xml = getObjectByAxis2CallClient(SERVER_URL, namespace, methos, v, classes);
    }
        String methos = "service";
        Class[] classes = new Class[]{String.class, String.class, String.class, String.class, Integer.class, Integer.class, String.class};
        Object[] v = new Object[7];
        v[0] = "{ClientVersion:1,ClientId:'EsbCloud',Sign:'Sign',SessionKey:''}";//authInfo
        v[1] = sdf.format(new Date());//sequenceNo
        v[2] = "report.ReportWs.GetReportInfo";//api
        v[3] = data;
        v[4] = 1;//paramType(0: json  1: Xml)
        v[5] = 1;//outType(0: json  1: Xml)
        v[6] = "1.0";//API版本号
        Object s = RPCUtil.getRPCData( classes, v);
        try {
            //新建RPC服务客户端
            RPCServiceClient serviceClient = new RPCServiceClient();
            Options options = serviceClient.getOptions();
            //设置URL
            EndpointReference targetEPR = new EndpointReference(SERVER_URL);
            options.setTo(targetEPR);
            //设置参数的类型
            //设置namespace和方法名
            QName opAddEntry = new QName(namespace, methos);
            //数组的第一个值为返回值
            String xml = (String) (serviceClient.invokeBlocking(opAddEntry, v, classes))[0];
            System.out.println(xml);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/
}

+ 1 - 1
Hos-Resource-Rest/src/main/java/com/yihu/hos/resource/base/App.java

@ -80,7 +80,7 @@ public class App {
    }
    private static void readpop(){
        Config.url= prop.getProperty("rpc.url");
        Config.namespace = prop.getProperty("rpc.namespace");
        Config.appId = prop.getProperty("rpc.appId");
        Config.monogoUrl = prop.getProperty("http.monogourl");
        Config.startCollect = prop.getProperty("http.startCollect");
    }

+ 2 - 2
Hos-Resource-Rest/src/main/resources/rpc.properties

@ -1,5 +1,5 @@
rpc.url=http://service.yihu.com:8080/WSGW/services/ServiceGateWay
rpc.namespace=http://com.yihu.wsgw/ServiceGateWay
rpc.url=172.18.20.123:8085
rpc.appId=EsbCloud
http.monogourl=http://localhost:8080/datapush/datapush
http.startCollect=http://localhost:8080/datapush/datapush