esb 9 年之前
父节点
当前提交
58e15e6580

+ 65 - 106
Hos-Resource-WS/src/main/java/com.yihu.ehr/ws/ExcuteService.java

@ -6,6 +6,12 @@ import com.yihu.ehr.model.WSReturnModel;
import com.yihu.ehr.util.operator.StringUtil;
import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.ResourceUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
/**
@ -108,36 +114,7 @@ public class ExcuteService {
            //wsReturnModel.setData(jdbcTemplate.queryForList(sb.toString()));
            // return WSReturnModel.toXml(wsReturnModel);
            return "<Resp> \n" +
                    "<TransactionCode></TransactionCode> \n" +
                    "<RespMessage>成功</RespMessage>\n" +
                    "<Data>\n" +
                    "<ReportId>8F5F14C2-FAB8-4CB5-BB91-AECF0EC64E69</ReportId>\n" +
                    "<ReportType>1</ReportType>\n" +
                    "<SubmissionTime>2015-03-12 09:52:47.0</SubmissionTime>\n" +
                    "<PatientName>张三</PatientName>\n" +
                    "<ItemName>测试报告1</ItemName>\n" +
                    "<State>1</ State >\n" +
                    "<EventNo>事件号</EventNo>\n" +
                    "<EventType>就诊类型</EventType>\n" +
                    "<EventTime>就诊时间</EventTime>\n" +
                    "<LocalCardNo>就诊卡号</LocalCardNo>\n" +
                    "<IdCardNo>身份证号</IdCardNo>\n" +
                    "</Data> \n" +
                    "<Data>\n" +
                    "<ReportId>8F5F14C2-FAB8-4CB5-BB91-AECF0EC64E69</ReportId>\n" +
                    "<ReportType>1</ReportType>\n" +
                    "<SubmissionTime>2015-03-12 09:52:47.0</SubmissionTime>\n" +
                    "<PatientName>张三</PatientName>\n" +
                    "<ItemName>测试报告1</ItemName>\n" +
                    "<State>1</State>\n" +
                    "<EventNo>事件号</EventNo>\n" +
                    "<EventType>就诊类型</EventType>\n" +
                    "<EventTime>就诊时间</EventTime>\n" +
                    "<LocalCardNo>就诊卡号</LocalCardNo>\n" +
                    "<IdCardNo>身份证号</IdCardNo>\n" +
                    "</Data>\n" +
                    "</Resp>";
            return getFileByPath("C:\\Documents and Settings\\Administrator\\桌面\\data\\GetReportList.xml");
        } catch (Exception e) {
            wsReturnModel.setTransactionCode("-30000");
            wsReturnModel.setRespMessage(e.getMessage());
@ -152,13 +129,14 @@ public class ExcuteService {
     * @param reportType
     * @return
     */
    public String getReportInfo(
    public String GetReportInfo(
            String TransactionCode,
            String reportId,
            String reportType) {
        WSReturnModel wsReturnModel = new WSReturnModel();
        wsReturnModel.setTransactionCode(TransactionCode);
        try {
            /*
            initJDBC();
            StringBuffer sb = new StringBuffer("select * from HDSD01_01 where 1=1 ");
            if (!StringUtil.isEmpty(reportId)) {
@ -166,60 +144,10 @@ public class ExcuteService {
            }
            if (!StringUtil.isEmpty(reportType)) {
                sb.append(" and HDSD00_01_001 > '" + reportType + "'");
            }
            }*/
            //  wsReturnModel.setData(jdbcTemplate.queryForList(sb.toString()));
            return "<Resp> \n" +
                    "<TransactionCode></TransactionCode> \n" +
                    "<RespMessage>成功</RespMessage>\n" +
                    "<Data>\n" +
                    "\t<ReportTitle>报告单2</ReportTitle>\n" +
                    "\t<ClinicCard>K5698012</ClinicCard>\n" +
                    "\t<UserType>0</UserType>\n" +
                    "\t<HosBedNo>6</HosBedNo>\n" +
                    "\t<SigningTime>2015-03-09 09:52:47.0</SigningTime>\n" +
                    "\t<Checker>审核人2</Checker>\n" +
                    "\t<BarCode>456456456</BarCode>\n" +
                    "\t<Sex>2</Sex>\n" +
                    "\t<PatientName>李四</PatientName>\n" +
                    "\t<SampleNumber>Yao77822</SampleNumber>\n" +
                    "\t<SampleType>2</SampleType>\n" +
                    "\t<ApplicationDepartment>口腔科</ApplicationDepartment>\n" +
                    "\t<SubmissionTime>2015-03-10 09:52:47.0</SubmissionTime>\n" +
                    "\t<Rmark>牙齿蛀牙</Rmark>\n" +
                    "\t<ReportTime>2015-03-12 09:52:47.0</ReportTime>\n" +
                    "\t<Inspector>检验员2</Inspector>\n" +
                    "\t<ItemNum>2</ItemNum>\n" +
                    "\t<ClinicNo>门诊号</ClinicNo>\n" +
                    "\t<HosUserNo>住院号</HosUserNo>\n" +
                    "\t<Data_1>\n" +
                    "\t\t\t<ItemDetailsName>xxx1</ItemDetailsName>\n" +
                    "\t\t\t<ResultValue>xxx1</ResultValue>\n" +
                    "\t\t\t<Unit>分</Unit>\n" +
                    "\t\t\t<ReferenceValues>100~250</ReferenceValues>\n" +
                    "\t\t\t<IsNormal></IsNormal>\n" +
                    "<ExFlag></ExFlag>\n" +
                    "<Range></Range>\n" +
                    "<SeFlag></SeFlag>\n" +
                    "<Words></Words>\n" +
                    "<GermName></GermName>\n" +
                    "<GrowStatus></GrowStatus>\n" +
                    "\t</Data_1>\n" +
                    "\t<Data_1>\n" +
                    "\t\t\t<ItemDetailsName>xxx2</ItemDetailsName>\n" +
                    "\t\t\t<ResultValue>xxx2</ResultValue>\n" +
                    "\t\t\t<Unit>分</Unit>\n" +
                    "\t\t\t<ReferenceValues>100~250</ReferenceValues>\n" +
                    "\t\t\t<IsNormal></IsNormal>\n" +
                    "<ExFlag></ExFlag>\n" +
                    "<Range></Range>\n" +
                    "<SeFlag></SeFlag>\n" +
                    "<Words></Words>\n" +
                    "<GermName></GermName>\n" +
                    "<GrowStatus></GrowStatus>\n" +
                    "\t</Data_1>\n" +
                    " </Data>\n" +
                    "</Resp>";
            return getFileByPath("C:\\Documents and Settings\\Administrator\\桌面\\data\\GetReportInfo.xml");
        } catch (Exception e) {
            wsReturnModel.setTransactionCode("-30000");
            wsReturnModel.setRespMessage(e.getMessage());
@ -228,29 +156,26 @@ public class ExcuteService {
    }
    public String QueryUserInfo(String TransactionCode, String CardType, String CardNo, String Mobile, String PatientId) {
        return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
                "<Resp>\n" +
                "<TransactionCode></TransactionCode>\n" +
                "<RespMessage>成功</RespMessage>\n" +
                "<RespCode>10000</RespCode>\n" +
                "<Data>\n" +
                "<PatientId>病人id</PatientId>\n" +
                "<ClinicCard>就诊卡号</ClinicCard>\n" +
                "<Name>用户姓名</Name>\n" +
                "<Mobile>手机号码</Mobile>\n" +
                "<McardNo>医保卡</McardNo>\n" +
                "<Address>家庭住址</Address>\n" +
                "<Sex>性别</Sex>\n" +
                "<Fee>就诊卡余额</Fee>\n" +
                "<BirthDay>出生日期</BirthDay>\n" +
                "<Country>国籍</Country>\n" +
                "<Nation>民族</Nation>\n" +
                "<BloodCode1>血型代码:ABO</BloodCode1>\n" +
                "<BloodCode2>HR血型代码</BloodCode2>\n" +
                "<Allergens>过敏源</Allergens>\n" +
                "<IdCardId>身份证</IdCardId>\n" +
                "</Data>\n" +
                "</Resp>";
        WSReturnModel wsReturnModel = new WSReturnModel();
        wsReturnModel.setTransactionCode(TransactionCode);
        try {
            /*
            initJDBC();
            StringBuffer sb = new StringBuffer("select * from HDSD01_01 where 1=1 ");
            if (!StringUtil.isEmpty(reportId)) {
                sb.append(" and HDSD00_05_026 < '" + reportId + "'");
            }
            if (!StringUtil.isEmpty(reportType)) {
                sb.append(" and HDSD00_01_001 > '" + reportType + "'");
            }*/
            //  wsReturnModel.setData(jdbcTemplate.queryForList(sb.toString()));
            return getFileByPath("C:\\Documents and Settings\\Administrator\\桌面\\data\\QueryUserInfo.xml");
        } catch (Exception e) {
            wsReturnModel.setTransactionCode("-30000");
            wsReturnModel.setRespMessage(e.getMessage());
            return WSReturnModel.toXml(wsReturnModel);
        }
    }
@ -267,6 +192,40 @@ public class ExcuteService {
        } catch (Exception e) {
            e.printStackTrace();
        }*/
        System.out.println(getFileByPath("C:\\Users\\Administrator\\Desktop\\getReportInfo.xml"));
    }
    public static String getFileByPath(String path) {
        BufferedReader reader = null;
        FileReader fileReader = null;
        try {
            File cfgFile = ResourceUtils.getFile(path);
            fileReader=new FileReader(cfgFile);
            reader = new BufferedReader(fileReader);
            String line;
            String strContent = "";
            while ((line = reader.readLine()) != null) {
                strContent += line;
            }
            return strContent;
        } catch (Exception e) {
            return "";
        } finally {
            if(reader!=null){
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(fileReader!=null){
                try {
                    fileReader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

+ 19 - 4
Hos-Resource-WS/src/main/java/com/yihu/wsgw/webservice/ServiceGateWay.java

@ -7,6 +7,10 @@ import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import javax.xml.namespace.QName;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * Created by Administrator on 2016/5/19.
@ -26,10 +30,21 @@ public class ServiceGateWay implements ServiceGateWayPortType {
     */
    public String excuteSQL(String TransactionCode,
                            String sql) {
        return excuteService.excuteSQL(TransactionCode, sql);
    }
    public static String replaceBlank(String str) {
        String dest = "";
        if (str != null) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(str);
            dest = m.replaceAll("");
        }
        return dest;
    }
    public String service(String authInfo, String sequenceNo, String api, String param, int paramType, int outType, String v) {
        System.out.println("authInfo:" + authInfo);
        System.out.println("sequenceNo:" + sequenceNo);
@ -42,8 +57,8 @@ public class ServiceGateWay implements ServiceGateWayPortType {
        String xml = "";
        try {
            switch (api) {
                case "user.UserApi.QueryUserInfo": {
                    Document document = DocumentHelper.parseText(param.toString());
                case "basic.BasicApi.QueryUserInfo": {
                    Document document = DocumentHelper.parseText(param.trim());
                    Element root = document.getRootElement();
                    Element data = root.element("Data");
                    xml = excuteService.QueryUserInfo(
@ -58,7 +73,7 @@ public class ServiceGateWay implements ServiceGateWayPortType {
                    Document document = DocumentHelper.parseText(param.toString());
                    Element root = document.getRootElement();
                    Element data = root.element("Data");
                    xml = excuteService.getReportInfo(
                    xml = excuteService.GetReportInfo(
                            StringUtil.isEmpty(root.element("TransactionCode").getText()) ? "" : root.element("TransactionCode").getText(),
                            StringUtil.isEmpty(data.element("ReportId").getText()) ? "" : data.element("ReportId").getText(),
                            StringUtil.isEmpty(data.element("ReportType").getText()) ? "" : data.element("ReportType").getText()
@ -94,7 +109,7 @@ public class ServiceGateWay implements ServiceGateWayPortType {
            return "<Resp> \n" +
                    "<TransactionCode>" + api + "</TransactionCode> \n" +
                    "<RespCode>-10000</RespCode>\n" +
                    "<RespMessage>" + e.getMessage() + "</RespMessage>\n" +
                    "<RespMessage>参数错误:" + e.getMessage() + "</RespMessage>\n" +
                    "</Resp>";
        }
        return xml;

+ 3 - 2
Hos-Resource-WS/src/main/resources/spring/spring-cxf.xml

@ -10,6 +10,7 @@
    <import resource="classpath:META-INF/cxf/cxf.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
    <jaxws:endpoint id="/ServiceGateWay" implementor="com.yihu.wsgw.webservice.ServiceGateWay" address="/ServiceGateWay"/>
    <jaxws:endpoint id="/ServiceGateWay"
                    implementor="com.yihu.wsgw.webservice.ServiceGateWay"
                    address="/ServiceGateWay"  publishedEndpointUrl="http://27.154.56.142:8082/service/ServiceGateWay" /><!---->
</beans>