Преглед на файлове

Merge branch 'master' of chenweida/esb into master

esb преди 9 години
родител
ревизия
a6281fce63

+ 6 - 4
Hos-Resource-Rest/src/main/java/com/yihu/hos/gateway/control/GatewayControl.java

@ -19,7 +19,6 @@ import javax.servlet.http.HttpServletRequest;
/**
 * Created by chenweida on 2016/1/27.
 * EHR平台应用 REST请求
 *
 */
@RestController
@RequestMapping("/gateway")
@ -46,6 +45,7 @@ public class GatewayControl {
    public RestResponseResult transfer(HttpServletRequest request) {
        String resultData = null;
        RestRequsetResult restRequsetResult = new RestRequsetResult();
        RestResponseResult restResponseResult = new RestResponseResult();
        try {
            BeanUtils.populate(restRequsetResult, request.getParameterMap());
@ -55,7 +55,8 @@ public class GatewayControl {
            ResourceRestDetailModel resourceRestDetailModel = gatewayService.getResourceRestDetailModelByCode(restRequsetResult.getApi());
            //根据资源对象的信息还有访问的参数通过httpclient得到数据
            resultData = getResultData(resourceRestDetailModel, restRequsetResult.getParam());
            restResponseResult = (RestResponseResult) JSONObject.toBean(JSONObject.fromObject(resultData), RestResponseResult.class);
            restResponseResult.setRequestId(restRequsetResult.getRequestId());
        } catch (Exception e) {
            e.printStackTrace();
            if (e instanceof EHRException) {
@ -68,11 +69,12 @@ public class GatewayControl {
            }
        }
        return RestResponseResult.getSuccess(resultData, restRequsetResult.getRequestId());
        return restResponseResult;
    }
    /**
     * 根据资源对象的信息还有访问的参数通过httpclient得到数据
     *
     * @param resourceRestDetailModel
     * @param param
     * @return
@ -82,7 +84,7 @@ public class GatewayControl {
        String returnData = null;
        //拼凑出URL
        String url = resourceRestDetailModel.getUrl() + resourceRestDetailModel.getNamespace().replace(".","/");
        String url = resourceRestDetailModel.getUrl() + resourceRestDetailModel.getNamespace().replace(".", "/");
        String userNamre = resourceRestDetailModel.getUsername();
        String password = resourceRestDetailModel.getPassword();
        try {

+ 0 - 45
Hos-Resource-Rest/src/main/java/com/yihu/hos/gateway/model/RestRequsetResult.java

@ -1,45 +0,0 @@
package com.yihu.hos.gateway.model;
import com.yihu.hos.gateway.exception.EHRExceptionConstant;
/**
 * Created by chenweida on 2016/1/27.
 */
public class RestRequsetResult {
    private String api;
    private String param;
    private String requestId;
    public String getApi() {
        return api;
    }
    public void setApi(String api) {
        this.api = api;
    }
    public String getParam() {
        return param;
    }
    public void setParam(String param) {
        this.param = param;
    }
    public String getRequestId() {
        return requestId;
    }
    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }
    @Override
    public String toString() {
        return "{" +
                "api:'" + api + '\'' +
                ", param:'" + param + '\'' +
                ", requestId:'" + requestId + '\'' +
                '}';
    }
}

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

@ -1,73 +0,0 @@
package com.yihu.hos.gateway.model;
import com.yihu.hos.gateway.exception.EHRExceptionConstant;
/**
 * Created by chenweida on 2016/1/27.
 */
public class RestResponseResult {
    private String responseCode = EHRExceptionConstant.EHREXCEPTION_SUCCESS;
    private String responseMessage = EHRExceptionConstant.EHREXCEPTION_SUCCESS_MESSAGE;
    private String responseParams;
    private String requestId;
    public String getResponseCode() {
        return responseCode;
    }
    public void setResponseCode(String responseCode) {
        this.responseCode = responseCode;
    }
    public String getResponseMessage() {
        return responseMessage;
    }
    public void setResponseMessage(String responseMessage) {
        this.responseMessage = responseMessage;
    }
    public String getResponseParams() {
        return responseParams;
    }
    public void setResponseParams(String responseParams) {
        this.responseParams = responseParams;
    }
    public String getRequestId() {
        return requestId;
    }
    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }
    public static RestResponseResult getSuccess(String responseParams, String requestId) {
        RestResponseResult responseModel = new RestResponseResult();
        responseModel.setRequestId(requestId);
        responseModel.setResponseParams(responseParams);
        return responseModel;
    }
    public static RestResponseResult getSuccess(String responseParams) {
        RestResponseResult responseModel = new RestResponseResult();
        responseModel.setResponseParams(responseParams);
        return responseModel;
    }
    public static RestResponseResult getError(String respCode, String respMessage) {
        RestResponseResult responseModel = new RestResponseResult();
        responseModel.setResponseCode(respCode);
        responseModel.setResponseMessage(respMessage);
        return responseModel;
    }
    @Override
    public String toString() {
        return "{" +
                "responseCode:'" + responseCode + '\'' +
                ", responseMessage:'" + responseMessage + '\'' +
                ", responseParams:'" + responseParams + '\'' +
                ", requestId:'" + requestId + '\'' +
                '}';
    }
}

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

@ -7,11 +7,12 @@ import java.io.Serializable;
/**
 * Created by chenweida on 2016/1/27.
 */
public class RestResponseResult implements Serializable{
public class RestResponseResult implements Serializable {
    private String responseCode = EHRExceptionConstant.EHREXCEPTION_SUCCESS;
    private String responseMessage = "";
    private String responseParams;
    private String requestId;
    private Object responseResult;
    public String getResponseCode() {
        return responseCode;
@ -51,11 +52,13 @@ public class RestResponseResult implements Serializable{
        responseModel.setResponseParams(responseParams);
        return responseModel;
    }
    public static RestResponseResult getSuccess(String responseParams) {
        RestResponseResult responseModel = new RestResponseResult();
        responseModel.setResponseParams(responseParams);
        return responseModel;
    }
    public static RestResponseResult getError(String respCode, String respMessage) {
        RestResponseResult responseModel = new RestResponseResult();
        responseModel.setResponseCode(respCode);
@ -72,4 +75,12 @@ public class RestResponseResult implements Serializable{
                ", requestId:'" + requestId + '\'' +
                '}';
    }
    public Object getResponseResult() {
        return responseResult;
    }
    public void setResponseResult(Object responseResult) {
        this.responseResult = responseResult;
    }
}

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

@ -2,6 +2,7 @@ package com.yihu.hos.qlc.controller;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.hos.config.Config;
import com.yihu.hos.gateway.model.rest.RestResponseResult;
import com.yihu.hos.gateway.util.RPCUtil;
import com.yihu.hos.resource.util.httpclient.HttpClientUtil;
import io.swagger.annotations.Api;
@ -47,14 +48,15 @@ public class QLCController {
     */
    @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) {
        String returnMessage = "成功";
    public RestResponseResult 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) {
        RestResponseResult restResponseResult = new RestResponseResult();
        try {
            String param = "<Req><TransactionCode>5001</TransactionCode><Data><CardType>" + CardType + "</CardType><CardNo>" + CardNo + "</CardNo><PatientId>" + PatientId + "</PatientId></Data></Req>";
            String apiparam = "{\"ChannelId\"=\"" + Config.channelId + "\"," +
@ -89,32 +91,32 @@ public class QLCController {
                params.put("eventNo", PatientId);
                httpClientUtil.doPost(Config.startCollect, params, null, null);
            } else {
                returnMessage = "RPC返回RespCode:" + root.element("RespCode").getText();
                throw new Exception("RPC返回RespCode:" + root.element("RespCode").getText());
            }
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
        }
        return returnMessage;
        return restResponseResult;
    }
    /**
     * 院方_检查/检验报告单推送---数据说明
     * localhost:8890/gateway/transfer?api=patientInformationPush&param={CardType:"",CardNo:"",ReportType:"",ReportId:"",State:"",HospitalId:""}&requestId="目前没用随便写"
     * localhost:8890/gateway/transfer?api=patientInformationPush&param={CardType:"",CardNo:"000021341249",ReportType:"0",ReportId:"201405228-A-110B",State:"2",HospitalId:"1026333"}&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) {
        String returnMessage = "成功";
    public RestResponseResult 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) {
        RestResponseResult restResponseResult = new RestResponseResult();
        try {
            if ("1".equals(State)) {
                return "报告未出,结束 ";
                throw new Exception("报告未出,结束" );
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
            String data =
@ -166,13 +168,13 @@ public class QLCController {
                }
            } else {
                returnMessage = "RPC返回RespCode:" + root.element("RespCode").getText();
                throw new Exception("RPC返回RespCode:" + root.element("RespCode").getText());
            }
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
        }
        return returnMessage;
        return restResponseResult;
    }
    /**

+ 55 - 32
Hos-Resource-Rest/src/main/java/com/yihu/hos/resource/control/ResourceControl.java

@ -1,5 +1,6 @@
package com.yihu.hos.resource.control;
import com.yihu.hos.gateway.model.rest.RestResponseResult;
import com.yihu.hos.resource.service.intf.IResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -47,10 +48,11 @@ public class ResourceControl {
     */
    @RequestMapping(value = "/getAuthorizedResource", method = RequestMethod.GET)
    @ApiOperation(value = "授权资源清单接口", response = Object.class, produces = "application/json", notes = "查询授权资源清单")
    public Object getAuthorizedResource(@ApiParam(value = "当前页", required = true) @RequestParam(value = "page") String page,
                                        @ApiParam(value = "每页显示条数", required = true) @RequestParam(value = "rows") String rows,
                                        @ApiParam(value = "参数", required = true) @RequestParam(value = "condition") String condition,
                                        HttpServletRequest request) {
    public RestResponseResult getAuthorizedResource(@ApiParam(value = "当前页", required = true) @RequestParam(value = "page") String page,
                                                    @ApiParam(value = "每页显示条数", required = true) @RequestParam(value = "rows") String rows,
                                                    @ApiParam(value = "参数", required = true) @RequestParam(value = "condition") String condition,
                                                    HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            //String sys_id = request.getParameter("sys_id");//渠道ID
@ -61,11 +63,13 @@ public class ResourceControl {
                rows = "10";
            }
            returnDate = resourceService.getAuthorizedResource(String.valueOf(page), String.valueOf(rows), condition);
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    /**
@ -108,6 +112,7 @@ public class ResourceControl {
                              @ApiParam(value = "每页显示条数", required = true) @RequestParam(value = "rows") String rows,
                              @ApiParam(value = "参数", required = true) @RequestParam(value = "condition") String condition,
                              HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            if (StringUtils.isEmpty(page)) {
@ -118,17 +123,18 @@ public class ResourceControl {
            }
            returnDate = resourceService.getResource(String.valueOf(page), String.valueOf(rows), condition);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {  restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    /**
     * 数据字典查询接口
     * <p/>
     * <p>
     * code     字典代码
     * page     当前页
     * pageSize 每页大小
@ -159,6 +165,7 @@ public class ResourceControl {
    public Object getDictionary(@ApiParam(value = "当前页", required = true) @RequestParam(value = "page") String page,
                                @ApiParam(value = "每页显示条数", required = true) @RequestParam(value = "rows") String rows,
                                @ApiParam(value = "参数", required = true) @RequestParam(value = "condition") String condition, HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            if (StringUtils.isEmpty(page)) {
@ -169,16 +176,18 @@ public class ResourceControl {
            }
            returnDate = resourceService.getDictionary(String.valueOf(page), String.valueOf(rows), condition);
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    /**
     * 资源元数据查询接口
     * <p/>
     * <p>
     * code 数据集代码
     *
     * @return {
@ -202,6 +211,7 @@ public class ResourceControl {
    public Object getResourceMetadata(@ApiParam(value = "当前页", required = true) @RequestParam(value = "page") String page,
                                      @ApiParam(value = "每页显示条数", required = true) @RequestParam(value = "rows") String rows,
                                      @ApiParam(value = "参数", required = true) @RequestParam(value = "condition") String condition, HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            if (StringUtils.isEmpty(page)) {
@ -211,12 +221,13 @@ public class ResourceControl {
                rows = "10";
            }
            returnDate = resourceService.getResourceMetadata(String.valueOf(page), String.valueOf(rows), condition);
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    @RequestMapping(value = "/getMongoDBData", method = RequestMethod.GET)
@ -226,6 +237,7 @@ public class ResourceControl {
                                 @ApiParam(value = "参数", required = true) @RequestParam(value = "condition") String condition,
                                 @ApiParam(value = "mongo表名", required = true) @RequestParam(value = "tableCode") String tableCode,
                                 HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            //String sys_id = request.getParameter("sys_id");//渠道ID
@ -239,11 +251,13 @@ public class ResourceControl {
            }
            returnDate = resourceService.getMongoDBData(String.valueOf(page), String.valueOf(rows), tableCode, condition);
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    @RequestMapping(value = "/collectionData", method = RequestMethod.GET)
@ -252,6 +266,7 @@ public class ResourceControl {
            @ApiParam(value = "mongo表名", required = true) @RequestParam(value = "tableCode") String tableCode,
            @ApiParam(value = "参数", required = true) @RequestParam(value = "condition") String condition,
            HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            //String sys_id = request.getParameter("sys_id");//渠道ID
@ -261,26 +276,31 @@ public class ResourceControl {
                throw new Exception("condition参数格式错误");
            }
            returnDate = resourceService.collectionData(tableCode, condition);
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    @RequestMapping(value = "/getCurrentTime", method = RequestMethod.GET)
    @ApiOperation(value = "得到系统时间", response = Object.class, produces = "application/json", notes = "得到系统时间")
    public Object collectionData(
            HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            returnDate = Calendar.getInstance().getTimeInMillis() + "";
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    @RequestMapping(value = "/executeSQL", method = RequestMethod.GET)
@ -288,14 +308,17 @@ public class ResourceControl {
    public Object executeSQL(
            @ApiParam(value = "SQL语句", required = true) @RequestParam(value = "sql") String sql,
            HttpServletRequest request) {
        RestResponseResult restResponseResult = new RestResponseResult();
        String returnDate = "";
        try {
            returnDate = resourceService.executeSQL(sql);
            restResponseResult.setResponseResult(returnDate);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
            restResponseResult.setResponseCode("20000");
            restResponseResult.setResponseMessage(e.getMessage());
            return restResponseResult;
        }
        return returnDate;
        return restResponseResult;
    }
    /* 文件上传的例子

+ 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://172.19.103.56:8181/datapush/datapush
http.startCollect=http://172.19.103.56:8181/crawler/patient
http.monogourl=http://localhost:8080/datapush/datapush
http.startCollect=http://localhost:8080/crawler/patient

+ 2 - 2
Hos-resource/src/main/java/com/yihu/ehr/crawler/service/EsbHttp.java

@ -135,7 +135,7 @@ public class EsbHttp {
                return "";
            }
            String rootStr = responseNode.path("responseParams").asText();
            String rootStr = responseNode.path("responseResult").asText();
            if ("".equals(rootStr)) {
                LogService.getLogger().error("获取病人列表错误,集成平台获取病人列表失败.");
                return "";
@ -162,7 +162,7 @@ public class EsbHttp {
                return "";
            }
            String rootStr = responseNode.path("responseParams").asText();
            String rootStr = responseNode.path("responseResult").asText();
            if ("".equals(rootStr)) {
                LogService.getLogger().info("获取病人数据错误,集成平台获取病人数据失败.");
                return "";

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/resource/controller/RsResourceController.java

@ -308,7 +308,7 @@ public class RsResourceController extends BaseController {
                result.setPageSize(count);
                result.setSuccessFlg(true);
            } else if (response_params.startsWith("{")) {
                Integer count = (Integer) JSONObject.fromObject(response_params).get("totalCount");//得到总数
                Integer count = (Integer) JSONObject.fromObject(response_params).get("count");//得到总数
                //访问服务得到元数据
                //设置动态datagrid值
                String s = JSONObject.fromObject(response_params).get("detailModelList").toString().replace(":null", ":\"\"");

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/resource/service/impl/RsResourceServiceImpl.java

@ -158,7 +158,7 @@ public class RsResourceServiceImpl implements IRsResourceService {
    public String searchRomoteResourceList(String code, Map<String, Object> params) throws Exception {
        String result = HttpHelper.getByGateway(code, params).getBody();
        JSONObject jsonobject = JSONObject.fromObject(result);
        String response_params = (String) jsonobject.get("responseParams");
        String response_params = (String) jsonobject.get("responseResult");
        return response_params;
    }

+ 1 - 1
Hos-resource/src/main/resources/config/http.properties

@ -9,5 +9,5 @@ sslPassword = 123456
clientId = 1FtXTrSL8D
clientKey = MUZ0WFRyU0w4RDp1c3ZOeWxWc0ZvdFVlQ2tE
httpGateway=http://172.19.103.56:8890/gateway/transfer
httpGateway=http://localhost:8890/gateway/transfer