瀏覽代碼

Merge branch 'master' of chenweida/esb into master

esb 9 年之前
父節點
當前提交
5948ca806b

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

@ -23,6 +23,7 @@ import java.util.*;
/**
 * Created by Administrator on 2016/4/12.
 * RPC网关 目前没有用 先留着 以备不时之需
 */
public class ResourceRpcImpl implements IResourceRpc {
    private DBHelper dbHelper = new DBHelper();

+ 1 - 1
Hos-Resource-Rest/src/main/java/com/yihu/hos/gateway/model/rest/RestResponseResult.java

@ -9,7 +9,7 @@ import java.io.Serializable;
 */
public class RestResponseResult implements Serializable{
    private String responseCode = EHRExceptionConstant.EHREXCEPTION_SUCCESS;
    private String responseMessage = EHRExceptionConstant.EHREXCEPTION_SUCCESS_MESSAGE;
    private String responseMessage = "";
    private String responseParams;
    private String requestId;

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

@ -87,7 +87,7 @@ public class RPCUtil {
        // TODO Auto-generated method stub
        String apiName = "ZEUS.HosHOPWs.GetReportInfo";
       // apiName = "ZEUS.HosHOPWs.QueryUserInfo";
        apiName = "ZEUS.HosHOPWs.QueryUserInfo";
        String param = "<Req><TransactionCode>5001</TransactionCode><Data><ReportId>201405228-A-110B</ReportId><ReportType>0</ReportType><CardNo>000021341249</CardNo></Data></Req>";
        String apiparam = "{\"ChannelId\"=\"" + Config.channelId + "\"," +
                "\"ParamType\"=1," +

+ 222 - 0
Hos-Resource-Rest/src/main/java/com/yihu/hos/qlc/controller/QLCController.java

@ -0,0 +1,222 @@
package com.yihu.hos.qlc.controller;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.hos.config.Config;
import com.yihu.hos.gateway.util.RPCUtil;
import com.yihu.hos.resource.util.httpclient.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2016/4/20.
 */
@RestController
@RequestMapping(value = "/api/v1.0/qlc", produces = {"application/json;charset=UTF-8"})//
@Api(protocols = "http", value = "resource", hidden = false, description = "全流程对接接口")
public class QLCController {
    private DBHelper dbHelper = new DBHelper();
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 院方_挂号事件推送
     * localhost:8890/gateway/transfer?api=registeredPush&param={EventType:"",EventNo:"",CardType:"",CardNo:"",PatientId:"",HospitalId:""}&requestId="目前没用随便写"
     */
    @RequestMapping(value = "/queryUserInfo", method = RequestMethod.POST)
    @ApiOperation(value = "挂号事件推送", response = Object.class, produces = "application/json", notes = "院方挂号事件推送")
    public Object queryUserInfo(@ApiParam(value = "事件类型:门诊、住院", required = true) @RequestParam(value = "EventType") String EventType,
                                @ApiParam(value = "事件编码:门诊号、住院号", required = true) @RequestParam(value = "EventNo") String EventNo,
                                @ApiParam(value = "卡类型", required = true) @RequestParam(value = "CardType") String CardType,
                                @ApiParam(value = "卡号", required = true) @RequestParam(value = "CardNo") String CardNo,
                                @ApiParam(value = "PatientId", required = true) @RequestParam(value = "PatientId") String PatientId,
                                @ApiParam(value = "医院ID", required = true) @RequestParam(value = "HospitalId") String HospitalId,
                                HttpServletRequest request) {
        try {
            String param = "<Req><TransactionCode>5001</TransactionCode><Data><CardType>" + CardType + "</CardType><CardNo>" + CardNo + "</CardNo><PatientId>" + PatientId + "</PatientId></Data></Req>";
            String apiparam = "{\"ChannelId\"=\"\"+Config.channelId+\"\"," +
                    "\"ParamType\"=1," +
                    "\"Params\"=\"" + param + "\"," +
                    "\"Guid\"=\"" + "00000001111111" + "\"," +
                    "\"V\"=\"3.0.0\"," +
                    "\"OutType\"=0n ," +
                    "\"HospitalId\"=\"" + HospitalId + "\"}";
            Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.QueryUserInfo", apiparam);
            //解析xml
            SAXReader saxReader = new SAXReader();
            Document document = saxReader.read(s.toString());
            Element root = document.getRootElement();
            if ("10000".equals(root.element("RespCode"))) {
                //xml轉json
                Element dataXML = root.element("Data");
                JSONObject obj = xml2json(root.element("Data"));
                obj.put("CardType", CardType);
                obj.put("CardNo", CardNo);
                obj.put("PatientId", PatientId);
                obj.put("OrgCode", HospitalId);
                //調用接口存入mongo
                Map<String, Object> params = new HashMap<String, Object>();
                params.put("dataset", "HDSA00_01");
                params.put("data", obj.toString());
                httpClientUtil.doPost(Config.monogoUrl, params, null, null);
                //出發採集上傳
                params = new HashMap<String, Object>();
                params.put("orgCode", HospitalId);
                params.put("cardNo", CardNo);
                params.put("eventNo", PatientId);
                httpClientUtil.doPost(Config.startCollect, params, null, null);
            }
        } catch (Exception e) {
            return e.getMessage();
        }
        return "成功";
    }
    /**
     * 院方_检查/检验报告单推送---数据说明
     *  localhost:8890/gateway/transfer?api=patientInformationPush&param={CardType:"",CardNo:"",ReportType:"",ReportId:"",State:"",HospitalId:""}&requestId="目前没用随便写"
     */
    @RequestMapping(value = "/patientInformation", method = RequestMethod.POST)
    @ApiOperation(value = "检查/检验报告单推送-", response = Object.class, produces = "application/json", notes = "检查/检验报告单推送-")
    public Object patientInformation(@ApiParam(value = "卡类型", required = true) @RequestParam(value = "CardType") String CardType,
                                     @ApiParam(value = "卡号", required = true) @RequestParam(value = "CardNo") String CardNo,
                                     @ApiParam(value = "报告单类型1检验报告2检查报告", required = true) @RequestParam(value = "ReportType") String ReportType,
                                     @ApiParam(value = "报告单号", required = true) @RequestParam(value = "ReportId") String ReportId,
                                     @ApiParam(value = "报告单状态1 报告未出 2报告已出", required = true) @RequestParam(value = "State") String State,
                                     @ApiParam(value = "医院ID", required = true) @RequestParam(value = "HospitalId") String HospitalId,
                                     HttpServletRequest request) {
        try {
            if ("1".equals(State)) {
                return "报告未出,结束 ";
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
            String data =
                    "<Req><TransactionCode>5001</TransactionCode><Data><CardNo>" + CardNo + "</CardNo><ReportId>" + ReportId + "</ReportId><ReportType>" + ReportType + "</ReportType></Data></Req>";
            String apiparam = "{\"ChannelId\"=\"\"+Config.channelId+\"\"," +
                    "\"ParamType\"=1," +
                    "\"Params\"=\"" + data + "\"," +
                    "\"Guid\"=\"" + "00000001111111" + "\"," +
                    "\"V\"=\"3.0.0\"," +
                    "\"OutType\"=0," +
                    "\"HospitalId\"=\"" + HospitalId + "\"}";
            Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.GetReportInfo", apiparam);
            //解析xml
            SAXReader saxReader = new SAXReader();
            Document document = saxReader.read(s.toString());
            Element root = document.getRootElement();
            if ("10000".equals(root.element("RespCode"))) {
                //xml轉json
                JSONObject obj = new JSONObject();
                //得到Data节点
                Element dataXml = root.element("Data");
                //判断data节点是否有从表
                List elements = root.elements("Data_1");
                if (elements != null && elements.size() > 0) {
                    for (Object obj1 : elements) {
                        Element data1XML = (Element) obj1;
                        //从表节点
                        JSONObject objData = xml2json(data1XML);
                        objData.put("CardType", CardType);
                        objData.put("CardNo", CardNo);
                        objData.put("ReportId", ReportId);
                        objData.put("ReportType", ReportType);
                        objData.put("OrgCode", HospitalId);
                        //添加主表的所有信息
                        objData.putAll(xml2json(dataXml));
                        //調用接口存入mongo
                        Map<String, Object> params = new HashMap<String, Object>();
                        params.put("dataset", "HDSD01_01");
                        params.put("data", objData.toString());
                        httpClientUtil.doPost(Config.monogoUrl, params, null, null);
                        //出發採集上傳
                        params = new HashMap<String, Object>();
                        params.put("orgCode", HospitalId);
                        params.put("cardNo", CardNo);
                        params.put("eventNo", StringUtils.isEmpty(objData.get("ClinicNo")) ? objData.get("HosUserNo") : objData.get("ClinicNo"));
                        httpClientUtil.doPost(Config.startCollect, params, null, null);
                    }
                }
            }
        } catch (Exception e) {
            return e.getMessage();
        }
        return "成功";
    }
    /**
     * xml轉map
     *
     * @param element
     * @return
     */
    private static Map iterateElement(Element element) {
        List jiedian = element.elements();
        Element et = null;
        Map obj = new HashMap();
        List list = null;
        for (int i = 0; i < jiedian.size(); i++) {
            list = new LinkedList();
            et = (Element) jiedian.get(i);
            if (et.getTextTrim().equals("")) {
                if (et.elements().size() == 0)
                    continue;
                if (obj.containsKey(et.getName())) {
                    list = (List) obj.get(et.getName());
                }
                list.add(iterateElement(et));
                obj.put(et.getName(), list);
            } else {
                if (obj.containsKey(et.getName())) {
                    list = (List) obj.get(et.getName());
                }
                list.add(et.getTextTrim());
                obj.put(et.getName(), list);
            }
        }
        return obj;
    }
    private String getOrgCodeBy(String orgCode) {
        List<org.json.JSONObject> listSYSTEM = dbHelper.query("select * from system_organization where qlc_org_code='" + orgCode + "'");
        return listSYSTEM.get(0).get("code").toString();
    }
    /**
     * xml轉json
     *
     * @param xml
     * @return
     */
    private static String XML2Json(String xml) {
        XMLSerializer xmlSerializer = new XMLSerializer();
        JSON json = xmlSerializer.read(xml);
        return json.toString();
    }
    private JSONObject xml2json(Element root) {
        JSONObject obj = new JSONObject();
        obj.put(root.getName(), iterateElement(root));
        return obj;
    }
}

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

@ -10,6 +10,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.util.StringUtils;
import javax.servlet.MultipartConfigElement;
import java.io.FileOutputStream;
@ -68,13 +69,11 @@ public class App {
        readpop();
        Server server = Server.getInstance(Integer.valueOf(Config.port));
        server.start();
    }
    private static void initConfig() {
        try {
            InputStream in = App.class.getResourceAsStream("/config/dbhelper.properties");
            InputStream in = App.class.getResourceAsStream("/rpc.properties");
            prop.load(in);
            in.close();
        } catch (Exception e) {
@ -82,14 +81,17 @@ public class App {
        }
    }
    private static void readpop() {
    private static void readpop() throws Exception {
        Config.url = prop.getProperty("rpc.url");
        Config.appId = prop.getProperty("rpc.appId");
        Config.port = prop.getProperty("rpc.port");
        Config.port = prop.getProperty("rpc.channelId");
        Config.channelId = prop.getProperty("rpc.channelId");
        Config.monogoUrl = prop.getProperty("http.monogourl");
        Config.startCollect = prop.getProperty("http.startCollect");
        // Server server = Server.getInstance(Integer.valueOf(StringUtils.isEmpty(Config.port) ? "8081" : Config.port));
        // server.start();
    }
    /**
     * spring boot 定时任务

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

@ -3,5 +3,5 @@ rpc.appId=EsbCloud
rpc.channelId=100123
rpc.port=8081
http.monogourl=http://localhost:8181/datapush/datapush
http.startCollect=http://localhost:8181/crawler/patient
http.monogourl=http://172.19.103.56:8181/datapush/datapush
http.startCollect=http://172.19.103.56:8181/crawler/patient

+ 1 - 1
Hos-resource/src/main/webapp/WEB-INF/ehr/jsp/resource/resourcerest/resourceRestDetailDialogJs.jsp

@ -54,7 +54,7 @@
                if (!$("#div_info_form").ligerAutoForm("validate")) {
                    return;
                }
                var data = !$("#div_info_form").ligerAutoForm("getData")
                var data = $("#div_info_form").ligerAutoForm("getData")
                $.ajax({ //ajax处理
                    type: "POST",
                    url: me.actionUrl,