Browse Source

ESB系统改动
MINI系统文件丢失

hzp 9 years ago
parent
commit
c556fd1095
30 changed files with 1436 additions and 337 deletions
  1. 275 0
      Hos-Framework/src/main/java/com/yihu/ehr/framework/util/http/HttpClientUtil.java
  2. 200 159
      Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpClientUtil.java
  3. 269 0
      Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpHelper.java
  4. 36 0
      Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpResponse.java
  5. 15 4
      Hos-Resource-Mini/Hos-Resource-Mini.iml
  6. 87 0
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/ThreadStart.java
  7. 189 0
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/standard/StandardService.java
  8. 1 1
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/HttpHelper.java
  9. 1 2
      Hos-Resource-Mini/src/main/webapp/WEB-INF/jsp/common/indexJs.jsp
  10. 32 0
      Hos-resource/src/main/java/com/yihu/ehr/common/CommonPageController.java
  11. 3 1
      Hos-resource/src/main/java/com/yihu/ehr/common/Services.java
  12. 1 1
      Hos-resource/src/main/java/com/yihu/ehr/datacollect/controller/DataCollectController.java
  13. 18 21
      Hos-resource/src/main/java/com/yihu/ehr/std/controller/StdController.java
  14. 1 1
      Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/DatacollectManager.java
  15. 1 1
      Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/DatacollectService.java
  16. 169 0
      Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/DatapushService.java
  17. 20 0
      Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/intf/IDatapushService.java
  18. 45 0
      Hos-resource/src/main/java/com/yihu/ehr/resource/controller/StdController.java
  19. 1 1
      Hos-resource/src/main/java/com/yihu/ehr/resource/service/IRsResourceService.java
  20. 1 1
      Hos-resource/src/main/java/com/yihu/ehr/std/service/intf/IStdService.java
  21. 8 5
      Hos-resource/src/main/java/com/yihu/ehr/resource/service/impl/RsResourceServiceImpl.java
  22. 29 56
      Hos-resource/src/main/java/com/yihu/ehr/std/service/StdService.java
  23. 0 60
      Hos-resource/src/main/java/com/yihu/ehr/std/service/BaseHttpService.java
  24. 1 1
      Hos-resource/src/main/java/com/yihu/ehr/system/controller/BaseDictController.java
  25. 4 4
      Hos-resource/src/main/resources/config/dbhelper.properties
  26. 13 0
      Hos-resource/src/main/resources/config/http.properties
  27. 3 3
      Hos-resource/src/main/resources/config/quartz.properties
  28. 9 9
      Hos-resource/src/main/resources/resource.properties
  29. 3 5
      Hos-resource/src/main/resources/spring/applicationContext.xml
  30. 1 1
      Hos-resource/src/main/webapp/WEB-INF/ehr/jsp/resource/resourceregister/resourceBrowseJs.jsp

+ 275 - 0
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/http/HttpClientUtil.java

@ -0,0 +1,275 @@
package com.yihu.ehr.framework.util.http;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * HTTP 请求工具类
 *
 * @author : cwd
 * @version : 1.0.0
 * @date : 2016/1/14
 * @see : TODO
 */
public class HttpClientUtil {
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url) throws Exception {
        return doGet(url, new HashMap<String, Object>(), "", "");
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, Map<String, Object> params) throws Exception {
        return doGet(url, params, "", "");
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, String username, String password) throws Exception {
        return doGet(url, new HashMap<String, Object>(), username, password);
    }
    /**
     * httpClient的get请求方式
     *
     * @return
     * @throws Exception
     */
    public static String doGet(String url, Map<String, Object> params, String username, String password)
            throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        //设置请求信息
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpGet httpget = new HttpGet(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
            } else {
                response1 = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的post请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPost(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            //流转字符串
            responString = EntityUtils.toString(httpEntity);
        } catch (Exception e){
            e.printStackTrace();
        }finally {
            response.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的put请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPut(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpPut httpPut = new HttpPut(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpPut.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpPut, context);
            } else {
                response1 = httpclient.execute(httpPut);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的delete请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doDelete(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpDelete httpget = new HttpDelete(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
            } else {
                response1 = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    public static void main(String[] args) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("standard", "{\n" +
//                "    \"id\": 4,\n" +
//                "    \"name\": \"电子健康档案标准bbb\",\n" +
//                "    \"code\": \"YY20160114\",\n" +
//                "    \"publisher\": \"健康之路2\",\n" +
//                "    \"publisherOrgCode\": \"jkzl\",\n" +
//                "    \"summary\": \"string\",\n" +
//                "    \"refStandard\": \"WS2012\",\n" +
//                "    \"refStandardVersion\": \"V1.0\",\n" +
//                "    \"versionStatus\": 0\n" +
//                "}");
        params.put("versionId", "5694696eb80d");
        params.put("publisher", "lfq");
        System.out.println(HttpClientUtil.doPost("http://192.168.131.17:6020/api/v1.0/standard_center/version/publish", params, "user", "standard"));
    }
}

+ 200 - 159
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpClientUtil.java

@ -1,6 +1,6 @@
package com.yihu.ehr.framework.util.httpclient;
import com.yihu.ehr.framework.util.encode.Base64;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
@ -10,133 +10,171 @@ import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.springframework.util.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * HTTP 请求工具类
 *
 * @author : cwd
 * @version : 1.0.0
 * @date : 2016/1/14
 * @see : TODO
 * Created by hzp on 2016/4/14.
 */
public class HttpClientUtil {
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url) throws Exception {
        return doGet(url, new HashMap<String, Object>(), "", "");
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, Map<String, Object> params) throws Exception {
        return doGet(url, params, "", "");
    /**************************** 私有方法 *****************************************/
    private static CloseableHttpClient getCloseableHttpClient(SSLConnectionSocketFactory ssl) {
        if(ssl == null)
        {
            return HttpClients.createDefault();
        }
        else{
            CloseableHttpClient httpClient = HttpClients.custom()
                    .setSSLSocketFactory(ssl)
                    .build();
            return httpClient;
        }
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, String username, String password) throws Exception {
        return doGet(url, new HashMap<String, Object>(), username, password);
    private static void close(CloseableHttpClient httpClient, CloseableHttpResponse response) {
        try {
            if (httpClient != null) {
                httpClient.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            if (response != null) {
                response.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private static HttpRequestBase getRequest(String method,String url,Map<String,Object> params,Map<String,Object> header) throws Exception
    {
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        //配置参数
        if(params!=null) {
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
        }
        HttpRequestBase request;
        if(method.equals("POST"))
        {
            request = new HttpPost(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
        }
        else if(method.equals("PUT"))
        {
            request = new HttpPut(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
        }
        else if(method.equals("DELETE"))
        {
            request = new HttpDelete(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
        }
        else
        {
            request = new HttpGet(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
        }
        //配置头部信息
        if(header!=null)
        {
            for (String key : header.keySet()) {
                request.addHeader(key, header.get(key).toString());
            }
        }
        return request;
    }
    /****************************** 公用方法 *******************************************/
    /**
     * httpClient的get请求方式
     *
     * @return
     * @throws Exception
     * get请求
     */
    public static String doGet(String url, Map<String, Object> params, String username, String password)
            throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        //设置请求信息
    public static HttpResponse request(String method,String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl,String user,String password) {
        HttpResponse re = new HttpResponse();
        CloseableHttpResponse response = null;
        CloseableHttpClient httpclient = getCloseableHttpClient(ssl);
        //设置请求信息
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            HttpRequestBase request = getRequest(method,url,params,header);
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpGet httpget = new HttpGet(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
            request.setConfig(requestConfig);
            //需要验证
            if (!StringUtils.isEmpty(user) && !StringUtils.isEmpty(password)) {
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),new org.apache.http.auth.UsernamePasswordCredentials(user, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
                response = httpclient.execute(request, context);
            } else {
                response1 = httpclient.execute(httpget);
                response = httpclient.execute(request);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
            re.setStatusCode(response.getStatusLine().getStatusCode());
            re.setBody(EntityUtils.toString(response.getEntity(), "UTF-8"));
        } catch (Exception e) {
            re.setStatusCode(201);
            re.setBody(e.getMessage());
            e.printStackTrace();
        } finally {
            response1.close();
            httpclient.close();
            close(httpclient, response);
        }
        return responString;
        return re;
    }
    /**
     * httpClient的post请求方式
     * 发送文件
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @param url        路径
     * @param formParams 参数
     * @return
     * @throws Exception
     */
    public static String doPost(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
    public static HttpResponse postFile(String url,
                                    File file, List<NameValuePair> formParams,SSLConnectionSocketFactory ssl, String username, String password) {
        HttpResponse re = new HttpResponse();
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        CloseableHttpClient httpClient = getCloseableHttpClient(ssl);
        try{
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            //创建httppost请求
            HttpPost httpPost = new HttpPost(url);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            //新建文件对象并且设置文件
            FileBody bin = new FileBody(file);
            MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
            reqEntity.addPart("file", bin);
            //设置参数
            if (formParams != null && formParams.size() > 0) {
                for (NameValuePair nv : formParams) {
                    reqEntity.addTextBody(nv.getName(), nv.getValue(), ContentType.create("text/plain", Charset.forName(HTTP.UTF_8)));
                }
            }
            httpPost.setEntity(reqEntity.build());
            //设置验证
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
@ -145,48 +183,44 @@ public class HttpClientUtil {
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
                response = httpClient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
                response = httpClient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            //流转字符串
            responString = EntityUtils.toString(httpEntity);
        } catch (Exception e){
            re.setStatusCode(response.getStatusLine().getStatusCode());
            re.setBody(EntityUtils.toString(response.getEntity(), "UTF-8"));;
        } catch (Exception e) {
            re.setStatusCode(201);
            re.setBody(e.getMessage());
            e.printStackTrace();
        }finally {
            response.close();
            httpclient.close();
        } finally {
            close(httpClient, response);
        }
        return responString;
        return re;
    }
    /**
     * httpClient的put请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     * 发送File
     */
    public static String doPut(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
    public static File downLoadFileByBase64(String filePath, Map<String, Object> params, String url, String username, String password) {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        CloseableHttpClient httpclient = getCloseableHttpClient(null);
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            HttpPut httpPut = new HttpPut(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpPut.setConfig(requestConfig);
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
@ -195,45 +229,51 @@ public class HttpClientUtil {
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpPut, context);
                response = httpclient.execute(httpPost, context);
            } else {
                response1 = httpclient.execute(httpPut);
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            String responString = EntityUtils.toString(httpEntity, "UTF-8");
            file = new File(filePath);
            file.getParentFile().mkdirs();
            InputStream i = new ByteArrayInputStream(Base64.decode(responString));
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = i.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
            i.close();
            fileout.flush();
            fileout.close();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            response1.close();
            httpclient.close();
            close(httpclient, response);
        }
        return responString;
        return file;
    }
    /**
     * httpClient的delete请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     * 下载文件
     */
    public static String doDelete(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
    public static File downLoadFile(String filePath, String url, String username, String password) {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        CloseableHttpClient httpclient = getCloseableHttpClient(null);
        try {
            HttpGet httpGet = new HttpGet(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpDelete httpget = new HttpDelete(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
@ -242,34 +282,35 @@ public class HttpClientUtil {
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
                response = httpclient.execute(httpGet, context);
            } else {
                response1 = httpclient.execute(httpget);
                response = httpclient.execute(httpGet);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
            HttpEntity httpEntity = response.getEntity();
            InputStream is = httpEntity.getContent();
            file = new File(filePath);
            file.getParentFile().mkdirs();
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = is.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            is.close();
            fileout.flush();
            fileout.close();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            response1.close();
            httpclient.close();
            close(httpclient, response);
        }
        return responString;
        return file;
    }
    public static void main(String[] args) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("standard", "{\n" +
//                "    \"id\": 4,\n" +
//                "    \"name\": \"电子健康档案标准bbb\",\n" +
//                "    \"code\": \"YY20160114\",\n" +
//                "    \"publisher\": \"健康之路2\",\n" +
//                "    \"publisherOrgCode\": \"jkzl\",\n" +
//                "    \"summary\": \"string\",\n" +
//                "    \"refStandard\": \"WS2012\",\n" +
//                "    \"refStandardVersion\": \"V1.0\",\n" +
//                "    \"versionStatus\": 0\n" +
//                "}");
        params.put("versionId", "5694696eb80d");
        params.put("publisher", "lfq");
        System.out.println(HttpClientUtil.doPost("http://192.168.131.17:6020/api/v1.0/standard_center/version/publish", params, "user", "standard"));
    }
}
}

+ 269 - 0
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpHelper.java

@ -0,0 +1,269 @@
package com.yihu.ehr.framework.util.httpclient;
import org.apache.http.NameValuePair;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContexts;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
public class HttpHelper {
    private static String defaultPropertiesPath = "config/http.properties";
    private static SSLConnectionSocketFactory defaultSSL;
    private static String defaultHttpUser;
    private static String defaultHttpPassword;
    public static String defaultHttpUrl;
    public static String clientId;
    public static String clientKey;
    public static String httpGateway;
    static {
        //默认配置
        try {
            Resource resource = new ClassPathResource(defaultPropertiesPath);
            EncodedResource encRes = new EncodedResource(resource,"UTF-8");
            Properties props = PropertiesLoaderUtils.loadProperties(encRes);
            defaultHttpUrl= props.getProperty("httpUrl");
            defaultHttpUser= props.getProperty("httpUser");
            defaultHttpPassword= props.getProperty("httpPassword");
            clientId = props.getProperty("clientId");
            clientKey = props.getProperty("clientKey");
            httpGateway = props.getProperty("httpGateway");
            String sslKeystore = props.getProperty("sslKeystore");
            String sslPassword = props.getProperty("sslPassword");
            if(sslKeystore!=null && sslKeystore.length()>0 && sslPassword!=null &&sslPassword.length()>0)
            {
                SSLContext sslContext = SSLContexts.custom()
                        .loadTrustMaterial(new File(sslKeystore), sslPassword.toCharArray(),
                                new TrustSelfSignedStrategy())
                        .build();
                defaultSSL = new SSLConnectionSocketFactory(
                        sslContext,
                        new String[]{"TLSv1"},
                        null,
                        null);
            }
        }
        catch (Exception e) {
            System.out.print(e.getMessage());
        }
    }
    /************************** Get方法 ******************************************/
    public static HttpResponse get(String url)
    {
        return get(url,null,null);
    }
    public static HttpResponse get(String url,Map<String,Object> params)
    {
        return get(url,params,null);
    }
    public static HttpResponse get(String url,Map<String,Object> params,Map<String,Object> header)
    {
        if(url.startsWith("https"))
        {
            return get(url,params,header,defaultSSL);
        }
        else{
            //默认http不走ssl和用户密码
            return get(url, params, header, null, null, null);
        }
    }
    public static HttpResponse get(String url,Map<String,Object> params,Map<String,Object> header,Boolean isCheck)
    {
        if(isCheck)
        {
            return get(url, params, header,defaultSSL, defaultHttpUser, defaultHttpPassword);
        }
        else{
            return get(url, params, header, null, null, null);
        }
    }
    public static HttpResponse get(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl)
    {
        return get(url, params, header, ssl, defaultHttpUser, defaultHttpPassword);
    }
    public static HttpResponse get(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl,String user,String password)
    {
        return HttpClientUtil.request("GET", url, params, header, ssl, user, password);
    }
    /************************** Post方法 ******************************************/
    public static HttpResponse post(String url)
    {
        return post(url, null, null);
    }
    public static HttpResponse post(String url,Map<String,Object> params)
    {
        return post(url, params, null);
    }
    public static HttpResponse post(String url,Map<String,Object> params,Map<String,Object> header)
    {
        if(url.startsWith("https"))
        {
            return post(url, params, header, defaultSSL);
        }
        else{
            //默认http不走ssl和用户密码
            return post(url, params, header, null, null, null);
        }
    }
    public static HttpResponse post(String url,Map<String,Object> params,Map<String,Object> header,Boolean isCheck)
    {
        if(isCheck)
        {
            return post(url, params, header, defaultSSL, defaultHttpUser, defaultHttpPassword);
        }
        else{
            return post(url, params, header, null, null, null);
        }
    }
    public static HttpResponse post(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl)
    {
        return post(url, params, header, ssl, defaultHttpUser, defaultHttpPassword);
    }
    public static HttpResponse post(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl,String user,String password)
    {
        return HttpClientUtil.request("POST",url,params,header,ssl,user,password);
    }
    public static HttpResponse postFile(String url, List<NameValuePair> formParams, String filePath)
    {
        File file = new File(filePath);
        if(url.startsWith("https"))
        {
            return HttpClientUtil.postFile(url, file, formParams, defaultSSL,defaultHttpUser,defaultHttpPassword);
        }
        else{
        //默认http不走ssl和用户密码
        return HttpClientUtil.postFile(url, file, formParams, null,defaultHttpUser,defaultHttpPassword);
    }
    }
    public static HttpResponse postFile(String url, List<NameValuePair> formParams, File file)
    {
        if(url.startsWith("https"))
        {
            return HttpClientUtil.postFile(url, file, formParams, defaultSSL,defaultHttpUser,defaultHttpPassword);
        }
        else{
            //默认http不走ssl和用户密码
            return HttpClientUtil.postFile(url, file, formParams, null,defaultHttpUser,defaultHttpPassword);
        }
    }
    /************************** Put方法 ******************************************/
    public static HttpResponse put(String url)
    {
        return put(url, null, null);
    }
    public static HttpResponse put(String url,Map<String,Object> params)
    {
        return put(url, params, null);
    }
    public static HttpResponse put(String url,Map<String,Object> params,Map<String,Object> header)
    {
        if(url.startsWith("https"))
        {
            return put(url, params, header, defaultSSL);
        }
        else{
            //默认http不走ssl和用户密码
            return put(url, params, header, null, null, null);
        }
    }
    public static HttpResponse put(String url,Map<String,Object> params,Map<String,Object> header,Boolean isCheck)
    {
        if(isCheck)
        {
            return put(url, params, header, defaultSSL, defaultHttpUser, defaultHttpPassword);
        }
        else{
            return put(url, params, header, null, null, null);
        }
    }
    public static HttpResponse put(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl)
    {
        return put(url, params, header, ssl, defaultHttpUser, defaultHttpPassword);
    }
    public static HttpResponse put(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl,String user,String password)
    {
        return HttpClientUtil.request("PUT",url,params,header,ssl,user,password);
    }
    /************************** Delete方法 **************************************/
    public static HttpResponse delete(String url)
    {
        return delete(url, null, null);
    }
    public static HttpResponse delete(String url,Map<String,Object> params)
    {
        return delete(url, params, null);
    }
    public static HttpResponse delete(String url,Map<String,Object> params,Map<String,Object> header)
    {
        if(url.startsWith("https"))
        {
            return delete(url, params, header, defaultSSL);
        }
        else{
            //默认http不走ssl和用户密码
            return delete(url, params, header, null, null, null);
        }
    }
    public static HttpResponse delete(String url,Map<String,Object> params,Map<String,Object> header,Boolean isCheck)
    {
        if(isCheck)
        {
            return delete(url, params, header, defaultSSL, defaultHttpUser, defaultHttpPassword);
        }
        else{
            return delete(url, params, header, null, null, null);
        }
    }
    public static HttpResponse delete(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl)
    {
        return delete(url, params, header, ssl, defaultHttpUser, defaultHttpPassword);
    }
    public static HttpResponse delete(String url,Map<String,Object> params,Map<String,Object> header,SSLConnectionSocketFactory ssl,String user,String password)
    {
        return HttpClientUtil.request("DELETE",url,params,header,ssl,user,password);
    }
    /**************************** 通过网关获取数据 ***************************************/
    /**
     * 通过网关获取数据
     */
    public static HttpResponse getByGateway(String code)
    {
        Map<String,Object> params=new HashMap<String,Object>();
        params.put("api",code);
        params.put("param", "{}");
        return HttpClientUtil.request("GET",httpGateway,params,null,null,null,null);
    }
    /**
     * 通过网关获取数据
     */
    public static HttpResponse getByGateway(String code,Map<String,Object> queryParams)
    {
        Map<String,Object> params=new HashMap<String,Object>();
        params.put("api",code);
        params.put("param", net.sf.json.JSONObject.fromObject(queryParams).toString());
        return HttpClientUtil.request("GET",httpGateway,params,null,null,null,null);
    }
}

+ 36 - 0
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpResponse.java

@ -0,0 +1,36 @@
package com.yihu.ehr.framework.util.httpclient;
/**
 * add by hzp at 2016-3-10
 */
public class HttpResponse {
    public HttpResponse()
    {
    }
    public HttpResponse(int statusCode, String body) {
        this.statusCode = statusCode;
        this.body = body;
    }
    private int statusCode;
    private String body;
    public int getStatusCode() {
        return statusCode;
    }
    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }
    public String getBody() {
        return body;
    }
    public void setBody(String body) {
        this.body = body;
    }
}

+ 15 - 4
Hos-Resource-Mini/Hos-Resource-Mini.iml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    <facet type="web" name="Web">
      <configuration>
@ -11,6 +11,14 @@
        </webroots>
      </configuration>
    </facet>
    <facet type="Spring" name="Spring">
      <configuration>
        <fileset id="fileset" name="Spring Application Context" removed="false">
          <file>file://$MODULE_DIR$/src/main/webapp/WEB-INF/dispatcher-servlet.xml</file>
          <file>file://$MODULE_DIR$/src/main/resources/spring/applicationContext.xml</file>
        </fileset>
      </configuration>
    </facet>
  </component>
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
    <output url="file://$MODULE_DIR$/target/classes" />
@ -22,8 +30,8 @@
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Maven: com.yihu.core:ehr-dbhelper:1.1.5" level="project" />
    <orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.37" level="project" />
    <orderEntry type="library" name="Maven: com.yihu.core:ehr-dbhelper:1.1.6" level="project" />
    <orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.38" level="project" />
    <orderEntry type="library" name="Maven: com.oracle:ojdbc6:11.2.0.3.0" level="project" />
    <orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.8.11.2" level="project" />
    <orderEntry type="library" name="Maven: net.sf.json-lib:json-lib:2.4" level="project" />
@ -32,6 +40,10 @@
    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
    <orderEntry type="library" name="Maven: net.sf.ezmorph:ezmorph:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.json:json:20151123" level="project" />
    <orderEntry type="library" name="Maven: xom:xom:1.2.5" level="project" />
    <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.3.03" level="project" />
    <orderEntry type="library" name="Maven: xerces:xercesImpl:2.8.0" level="project" />
    <orderEntry type="library" name="Maven: xalan:xalan:2.7.0" level="project" />
    <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.2" level="project" />
    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
    <orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.1" level="project" />
@ -39,7 +51,6 @@
    <orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.10" level="project" />
    <orderEntry type="library" name="Maven: commons-dbutils:commons-dbutils:1.6" level="project" />
    <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
    <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
    <orderEntry type="library" name="Maven: net.lingala.zip4j:zip4j:1.3.2" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />

+ 87 - 0
Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/ThreadStart.java

@ -0,0 +1,87 @@
package com.yihu.ehr.common;
import com.yihu.ehr.common.config.SysConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.service.thread.CrawlerSupplyThread;
import com.yihu.ehr.service.thread.CrawlerThread;
import com.yihu.ehr.service.thread.StandardUpdateThread;
import com.yihu.ehr.service.thread.ThreadManage;
import com.yihu.ehr.util.log.LogUtil;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
/**
 * 线程启动执行
 * add by hzp at 2016-03-17
 */
public class ThreadStart implements ServletContextListener {
    private static Properties prop = new Properties();
    private String log4jDirKey = "log4j";
    @Override
    public void contextInitialized(ServletContextEvent context) {
        try {
            String home = System.getProperty("catalina.home").replace('\\','/');
            String homeUrl = home.substring(0,home.lastIndexOf('/')+1);
            crawlerConfig(homeUrl);
            startThread();
        } catch (Exception e) {
            System.out.print(e.getStackTrace().toString());
        }
    }
    @Override
    public void contextDestroyed(ServletContextEvent context) {
    }
    /**
     * 采集配置
     * @param homeUrl
     * @throws Exception
     */
    private void crawlerConfig(String homeUrl) throws Exception {
        System.setProperty(log4jDirKey, homeUrl + "log4j");
        SysConfig.getInstance().setTempFile(homeUrl + "standard");
    }
    /**
     * 启动线程
     */
    private void startThread() {
        try {
            DBHelper db = new DBHelper();
            Object obj = db.scalar("select param_value from system_param where param_key='ORG_CODE'");
            if (obj != null) {
                SysConfig.getInstance().setOrgCode(obj.toString());
            }
            Thread crawlerThread = new Thread(new CrawlerThread());
            Thread crawlerSupplyThread = new Thread(new CrawlerSupplyThread());
            Thread standardUpdateThread = new Thread(new StandardUpdateThread());
            ThreadManage.add(ThreadManage.CRAWLER_THREAD, crawlerThread);
            ThreadManage.add(ThreadManage.CRAWLER_SUPPLY_THREAD, crawlerSupplyThread);
            ThreadManage.add(ThreadManage.STANDARD_UPDATE_THREAD, standardUpdateThread);
            ThreadManage.setCrawlerInterval();
            ThreadManage.setUpdateInterval();
            //启动线程
            crawlerThread.start();
            crawlerSupplyThread.start();
            standardUpdateThread.start();
        }
        catch (Exception e)
        {
            LogUtil.error(e.getStackTrace().toString());
        }
    }
}

+ 189 - 0
Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/standard/StandardService.java

@ -0,0 +1,189 @@
package com.yihu.ehr.service.standard;
import com.yihu.ehr.common.constants.Constants;
import com.yihu.ehr.dbhelper.jdbc.DBConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.CollectionUtil;
import com.yihu.ehr.util.operator.SqlCreate;
import com.yihu.ehr.util.operator.StringUtil;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.json.JSONObject;
import java.io.File;
import java.sql.Connection;
import java.util.*;
/**
 * 线程取数据,不走连接池
 */
public class StandardService {
    private DBHelper db = new DBHelper();
    /**
     * 获取当前自版本号
     */
    public synchronized String getCurrentVersion() {
        try {
            String localVersion = "";
            List<JSONObject> list = db.query("select code from std_inner_version order by code desc");
            if (!CollectionUtil.isEmpty(list)) {
                localVersion = list.get(0).getString("code");
            }
            return localVersion;
        }
        catch (Exception e)
        {
            LogUtil.error(e);
            return "";
        }
    }
    /**
     * 读取标准数据
     */
    public synchronized boolean genData(File[] zipFiles) {
        List<String> sqlList = new ArrayList<>();
        List<String> fileNameList = new ArrayList<>();
        List<String> deleteDataList = new ArrayList<>();
        for (File file : zipFiles) {
            if (!file.getName().contains("_cda")) {
                if (file.getName().contains("org_")||file.getName().contains("adapter_")
                        ||file.getName().contains("std_")) {
                    fileNameList.add(StringUtil.substring(file.getName(), 0, file.getName().indexOf(Constants.DOT)));
                }
                if (!file.getParentFile().getName().equals(Constants.CDA_FILE)) {
                    createData(file, sqlList);
                }
            }
        }
        SqlCreate sqlCreate = new SqlCreate();
        for (String fileName : fileNameList) {
            sqlCreate.setTableName(fileName);
            deleteDataList.add(sqlCreate.deleteData());
        }
        String[] deleteArray = new String[deleteDataList.size()];
        deleteDataList.toArray(deleteArray);
        String[] sqlArray = new String[sqlList.size()];
        sqlList.toArray(sqlArray);
        try {
            db.executeBatch(deleteArray);
            db = new DBHelper();
            db.executeBatch(sqlArray);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }
    private void createData(File file, List<String> sqlList) {
        try {
            SAXReader reader = new SAXReader();
            Document doc = reader.read(file);
            Element root = doc.getRootElement();
            String tableName = root.attributeValue("name");
            if (tableName == null) {
                throw new Exception("错误的标准格式,无表名信息.");
            }
            Element metadata = root.element("metadata");
            if (metadata == null) {
                throw new Exception("错误的标准格式,无表字段信息.");
            }
            HashMap<String, String> colMap = getColMetaData(metadata);
            for (Iterator rowIterator = root.elementIterator("row"); rowIterator.hasNext();) {
                SqlCreate sqlCreate = new SqlCreate();
                sqlCreate.setTableName(tableName);
                Element rowElement = (Element) rowIterator.next();
                createDataSql(rowElement, colMap, sqlList, sqlCreate);
            }
        } catch (Exception e) {
            LogUtil.fatal("生成标准表异常:");
            LogUtil.error(e);
        }
    }
    private HashMap<String, String> getColMetaData(Element rowElem) {
        HashMap<String, String> hashMap = new HashMap<>();
        for (Iterator colIterator = rowElem.elementIterator(); colIterator.hasNext(); ) {
            Element colElement = (Element) colIterator.next();
            String name = colElement.attributeValue("name");
            String type = colElement.attributeValue("type");
            hashMap.put(name, type);
        }
        return hashMap;
    }
    private void createDataSql(Element rowElement, HashMap<String, String> colMap, List<String> sqlList, SqlCreate sqlCreate) {
        if (rowElement == null) {
            return;
        }
        Map<String, String> keyValueMap = new HashMap<>();
        List<String> itemList = new ArrayList<>();
        List<String> itemValueList = new ArrayList<>();
        for (Iterator colIterator = rowElement.elementIterator(); colIterator.hasNext(); ) {
            Element colElement = (Element) colIterator.next();
            if (colElement.getText().equals("")) {
                continue;
            }
            String key = colElement.getName();
            itemList.add(key);
            String type = colMap.get(key);
            if (type == null) {
                LogUtil.fatal("createDataSql无效的类型.");
            }
            String value;
            switch (type) {
                case "N":
                    value = colElement.getText();
                    break;
                case "S":
                    value = "'" + colElement.getText().replace("'","''") + "'";
                    break;
                case "D":
                    value = "'" + colElement.getText() + "'";
                    break;
                default:
                    value = colElement.getText();
            }
            itemValueList.add(value);
            keyValueMap.put(key, value);
            if (key.equals(Constants.TABLE_KEY)) {
                sqlCreate.setTableKey(value);
            }
        }
        sqlCreate.setItemList(itemList);
        sqlCreate.setItemValueList(itemValueList);
        sqlCreate.setKeyValueMap(keyValueMap);
        if (Constants.ADD_TYPE.equals(rowElement.attributeValue("type"))) {
            sqlList.add(sqlCreate.insertData());
        } else if (Constants.UPDATE_TYPE.equals(rowElement.attributeValue("type"))) {
            sqlList.add(sqlCreate.updateDataByTableKey());
            if (sqlCreate.isToAdapter() && sqlCreate.isCodeOrValue()) {
                sqlList.add(sqlCreate.updateAdapterData());
            }
        } else if (Constants.DELETE_TYPE.equals(rowElement.attributeValue("type"))) {
            sqlList.add(sqlCreate.deleteDataByTableKey());
            if (sqlCreate.isToAdapter()) {
                sqlList.add(sqlCreate.deleteAdapterData());
            }
            if (sqlCreate.isToAdapterDataset()) {
                sqlList.add(sqlCreate.deleteAdapterOriginData());
            }
        }
    }
}

+ 1 - 1
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/HttpHelper.java

@ -49,7 +49,7 @@ public class HttpHelper {
                        sslContext,
                        new String[]{"TLSv1"},
                        null,
                        new HopHostnameVerifier());
                        null);
            }
        }

+ 1 - 2
Hos-Resource-Mini/src/main/webapp/WEB-INF/jsp/common/indexJs.jsp

@ -67,8 +67,7 @@
                {id: 2, text: '采集标准',icon:'${staticRoot}/images/index/menu2_icon.png', url: '${contextRoot}/datacollect/stdManager'},
                {id: 3, text: '任务跟踪',icon:'${staticRoot}/images/index/menu3_icon.png', url: '${contextRoot}/datacollect/trackJob'},
                {id: 4, text: '任务补采',icon:'${staticRoot}/images/index/menu4_icon.png', url: '${contextRoot}/datacollect/repeatJob'},
                {id: 5, text: '系统参数',icon:'${staticRoot}/images/index/menu5_icon.png', url: '${contextRoot}/system/paramManager'},
                {id: 6, text: '接口配置',icon:'${staticRoot}/images/index/menu5_icon.png', url: '${contextRoot}/dataAcquisition/dataAcquisitionManager'}
                {id: 5, text: '系统参数',icon:'${staticRoot}/images/index/menu5_icon.png', url: '${contextRoot}/system/paramManager'}
            ];
            me.menuTree = $('#ulTree').ligerTree({
                data: menu,

+ 32 - 0
Hos-resource/src/main/java/com/yihu/ehr/common/CommonPageController.java

@ -51,6 +51,38 @@ public class CommonPageController extends BaseController {
        HttpSession session = request.getSession();
        SystemUser user = (SystemUser) session.getAttribute("userInfo");
        model.addAttribute("userName", user.getUserName());
        //获取菜单
        String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" +
                "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" +
                "        {id: 12, pid: 1, text: '任务补采', url: '${contextRoot}/datacollect/repeatDatacollect'},\n" +
                "        {id: 13, pid: 1, text: '任务配置', url: '${contextRoot}/datacollect/configJob'},\n" +
                "        {id: 2, text: '标准管理',icon:'${staticRoot}/images/index/menu3_icon.png'},\n" +
                "        {id: 21, pid: 2, text: '集成标准', url: '${contextRoot}/integration/initial/standard'},\n" +
                "        {id: 22, pid: 2, text: '应用标准', url: '${contextRoot}/integration/initial/application'},\n" +
                "        {id: 23, pid: 2, text: '适配方案', url: '${contextRoot}/adapterPlan/initial'},\n" +
                "        {id: 3, text: '资源管理',icon:'${staticRoot}/images/index/menu4_icon.png'},\n" +
                "        {id: 31, pid: 3, text: '资源注册', url: '${contextRoot}/resource/resource/initial'},\n" +
                "        {id: 32, pid: 3, text: '资源浏览', url: '${contextRoot}/resource/resourcePage'},\n" +
                "        {id: 34, pid: 3, text: '资源分类', url: '${contextRoot}/resource/rsCategory/initial'},\n" +
                "        {id: 35, pid: 3, text: '业务资源', url: '${contextRoot}/resourceRest/initial'},\n" +
                "        {id: 4, text: '维度管理',icon:'${staticRoot}/images/index/menu5_icon.png'},\n" +
                "        {id: 41, pid: 4, text: '维度配置', url: '${contextRoot}/dimension/dimension'},\n" +
                "        {id: 42, pid: 4, text: '维度类别配置', url: '${contextRoot}/dimension/dimensioncatetory'},\n" +
                "        {id: 9, text: '系统配置',icon:'${staticRoot}/images/index/menu6_icon.png'},\n" +
                "        {id: 91, pid: 9, text: '机构配置', url: '${contextRoot}/org/initial'},\n" +
                "        {id: 92, pid: 9, text: '数据源配置', url: '${contextRoot}/datasource/configSources'},\n" +
                "        {id: 93, pid: 9, text: '菜单配置', url: '${contextRoot}/menu/initial'},\n" +
                "        {id: 100, pid: 9, text: '菜单按钮配置', url: '${contextRoot}/menu/menuAction/initial'},\n" +
                "        {id: 94, pid: 9, text: '用户管理', url: '${contextRoot}/user/initial'},\n" +
                "        {id: 95, pid: 9, text: '角色管理', url: '${contextRoot}/role/initial'},\n" +
                "        {id: 96, pid: 9, text: '权限管理', url: '${contextRoot}/authority/initial'},\n" +
                "        {id: 97, pid: 9, text: '字典管理', url: '${contextRoot}/dict/initial' },\n" +
                "        {id: 98, pid: 9, text: '系统参数', url: '${contextRoot}/param/initial'},\n" +
                "        {id: 99, pid: 9, text: '<spring:message code=\"title.app.manage\"/>', url: '${contextRoot}/app/initial'}]";
        model.addAttribute("menu", menu);
        model.addAttribute("contentPage","/common/index");
        return "pageView";
    }

+ 3 - 1
Hos-resource/src/main/java/com/yihu/ehr/common/Services.java

@ -111,9 +111,11 @@ public class Services {
    public final static String DatacollectService = "com.yihu.ehr.datacollect.service.DatacollectService";
    public final static String DatapushService = "com.yihu.ehr.datacollect.service.DatapushService";
    public final static String Datasource = "com.yihu.ehr.system.service.DatasourceManager";
    public final static String BaseDict = "com.yihu.ehr.system.service.BaseDictManager";
    public final static String StdService = "com.yihu.ehr.system.service.StdService";
    public final static String StdService = "com.yihu.ehr.resource.service.impl.StdService";
}

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

@ -10,7 +10,7 @@ import com.yihu.ehr.framework.model.ActionResult;
import com.yihu.ehr.framework.model.Result;
import com.yihu.ehr.framework.util.controller.BaseController;
import com.yihu.ehr.framework.util.operator.CollectionUtil;
import com.yihu.ehr.std.service.intf.IStdService;
import com.yihu.ehr.resource.service.IStdService;
import com.yihu.ehr.system.service.intf.IDatasourceManager;
import net.sf.json.JSONArray;
import org.apache.commons.beanutils.BeanUtils;

+ 18 - 21
Hos-resource/src/main/java/com/yihu/ehr/std/controller/StdController.java

@ -1,17 +1,20 @@
package com.yihu.ehr.std.controller;
package com.yihu.ehr.datacollect.controller;
import com.yihu.ehr.common.Services;
import com.yihu.ehr.datacollect.model.RsJobConfig;
import com.yihu.ehr.datacollect.service.intf.IDatacollectManager;
import com.yihu.ehr.datacollect.service.intf.IDatacollectService;
import com.yihu.ehr.datacollect.service.intf.IDatapushService;
import com.yihu.ehr.framework.constrant.DateConvert;
import com.yihu.ehr.framework.model.ActionResult;
import com.yihu.ehr.framework.model.Result;
import com.yihu.ehr.framework.util.controller.BaseController;
import com.yihu.ehr.framework.util.operator.CollectionUtil;
import com.yihu.ehr.std.service.intf.IStdService;
import com.yihu.ehr.system.service.intf.IDatasourceManager;
import net.sf.json.JSONObject;
import net.sf.json.JSONArray;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@ -19,35 +22,28 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
 * 数据采集配置页面
 * Created by hzp on 2015/8/12.
 */
@RequestMapping("/std")
@Controller("stdController")
public class StdController extends BaseController {
@RequestMapping("/datapush")
@Controller("dataPushController")
public class DataPushController extends BaseController {
    @Autowired
    IDatapushService datapushService;
    @Resource(name = Services.StdService)
    IStdService stdService;
    /**************************** 标准字典 ************************************************/
    /**
     * 通过字典ID获取字段
     * @return
    /**************************** 推送数据 ************************************************/
    /*
    推数据
     */
    @RequestMapping("getDictByScheme")
    @RequestMapping("pushData")
    @ResponseBody
    public Result getDictByScheme(String version, String dictId){
    public Result pushData(String dataset,String data,String orgCode) {
        try {
            return stdService.getDictResultByVersion(version, dictId);
            return datapushService.pushData(dataset, data, orgCode);
        }
        catch (Exception ex)
        {
@ -56,4 +52,5 @@ public class StdController extends BaseController {
    }
}

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/DatacollectManager.java

@ -10,9 +10,9 @@ import com.yihu.ehr.framework.model.DictItem;
import com.yihu.ehr.framework.model.SimpleChartItem;
import com.yihu.ehr.framework.util.quartz.QuartzManager;
import com.yihu.ehr.resource.model.RsDatasourceDataset;
import com.yihu.ehr.resource.service.IStdService;
import com.yihu.ehr.standard.model.adapter.AdapterDatasetModel;
import com.yihu.ehr.standard.model.standard.StdDataSetModel;
import com.yihu.ehr.std.service.intf.IStdService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.BeanUtils;

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/DatacollectService.java

@ -14,7 +14,7 @@ import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.dbhelper.mongodb.MongodbHelper;
import com.yihu.ehr.framework.constrant.DateConvert;
import com.yihu.ehr.framework.model.ActionResult;
import com.yihu.ehr.std.service.intf.IStdService;
import com.yihu.ehr.resource.service.IStdService;
import org.json.JSONObject;
import org.json.JSONArray;
import org.springframework.stereotype.Service;

+ 169 - 0
Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/DatapushService.java

@ -0,0 +1,169 @@
package com.yihu.ehr.datacollect.service;
import com.yihu.ehr.common.Services;
import com.yihu.ehr.datacollect.model.*;
import com.yihu.ehr.datacollect.service.intf.IDatacollectManager;
import com.yihu.ehr.datacollect.service.intf.IDatapushService;
import com.yihu.ehr.dbhelper.common.enums.DBType;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.dbhelper.mongodb.MongodbHelper;
import com.yihu.ehr.framework.constrant.DateConvert;
import com.yihu.ehr.framework.model.ActionResult;
import com.yihu.ehr.framework.model.Result;
import com.yihu.ehr.resource.service.IStdService;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 推数据服务
 */
@Service(Services.DatapushService)
public class DatapushService implements IDatapushService {
    @Resource(name = Services.Datacollect)
    private IDatacollectManager datacollect;
    @Resource(name = Services.StdService)
    private IStdService stdService;
    MongodbHelper mongo = new MongodbHelper();
    String dateFormat = "yyyy-MM-dd HH:mm:ss"; //默认时间字符串格式
    /**
     * 字典转换
     */
    private JSONObject translateDict(JSONObject data,JSONArray colList,String schemeVersion) throws Exception
    {
        //获取字典列表
        List<DtoDictCol> dictColList = new ArrayList<>();
        for(int i=0; i< colList.length();i++)
        {
            JSONObject col = colList.getJSONObject(i);
            String dictId = col.optString("adapterDictId");
            if(dictId!=null && dictId.length()>0)
            {
                String dictType = col.optString("adapterDataType");
                String stdMetadataCode = col.optString("stdMetadataCode");
                DtoDictCol dictCol = new DtoDictCol();
                dictCol.setStdMetadataCode(stdMetadataCode);
                dictCol.setAdapterDictId(dictId);
                dictCol.setAdapterDataType(dictType.length()>0?dictType:"1");//默认通过code转换字典
                //获取字典数据
                List dictString = stdService.getDictByScheme(schemeVersion,dictId);
                JSONArray dictAdapterArray = new JSONArray(dictString);
                dictCol.setDictList(dictAdapterArray);
                dictColList.add(dictCol);
            }
        }
        //遍历字典字段
        for (DtoDictCol col : dictColList) {
            String colNmae = col.getStdMetadataCode();
            String oldValue = data.optString(colNmae);
            String newValue = translateDictValue(oldValue,col.getAdapterDataType(),col.getDictList());
            if(newValue!=null && newValue.length()>0)
            {
                data.put(colNmae,newValue);
            }
        }
        return data;
    }
    /**
     * 转译字典
     */
    private String translateDictValue(String oldValue,String type,JSONArray dictAdapterList) throws Exception
    {
        //应用标准字段
        String colName = "adapterEntryCode";
        if(type!="1") //通过name转译
        {
            colName = "adapterEntryValue";
        }
        //遍历字典数据
        for(int i=0; i< dictAdapterList.length();i++)
        {
            JSONObject dictItem = dictAdapterList.getJSONObject(i);
            if(oldValue.equals(dictItem.getString(colName)))
            {
                String newValue = dictItem.getString("stdEntryCode");
                return newValue;
            }
        }
        return oldValue;
    }
    /**
     * 采集入库
     */
    private String intoMongodb(JSONObject data,String schemeVersion,String stdDatasetCode,JSONArray colList)
    {
        try{
            if(data!=null)
            {
                //字典转换
                data = translateDict(data, colList,schemeVersion);
                //采集到mongodb
                boolean b = mongo.insert(stdDatasetCode,data);
                if(!b)
                {
                    if(mongo.errorMessage!=null && mongo.errorMessage.length()>0)
                    {
                        System.out.print(mongo.errorMessage);
                        return mongo.errorMessage;
                    }
                    else {
                        return "Mongodb保存失败!(表:"+stdDatasetCode+")";
                    }
                }
            }
        }
        catch (Exception e)
        {
            return e.getMessage();
        }
        return "";
    }
    /*****************************************************************************************************/
    /**
     * 获取版本号
     */
    @Override
    public String getVersion(String orgCode) throws Exception
    {
        return "";
    }
    /**
     * 数据入库
     */
    @Override
    @Transactional
    public Result pushData(String dataset,String data,String orgCode) throws Exception
    {
        return ActionResult.success("");
    }
}

+ 20 - 0
Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/intf/IDatapushService.java

@ -0,0 +1,20 @@
package com.yihu.ehr.datacollect.service.intf;
import com.yihu.ehr.framework.model.Result;
/**
 * Created by hzp on 2016/4/14.
 */
public interface IDatapushService {
    /**
     * 获取版本号
     */
    String getVersion(String orgCode) throws Exception;
    /**
     * 数据入库
     */
    Result pushData(String dataset,String data,String orgCode) throws Exception;
}

+ 45 - 0
Hos-resource/src/main/java/com/yihu/ehr/resource/controller/StdController.java

@ -0,0 +1,45 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.common.Services;
import com.yihu.ehr.framework.model.Result;
import com.yihu.ehr.framework.util.controller.BaseController;
import com.yihu.ehr.resource.service.IStdService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
 * 数据采集配置页面
 * Created by hzp on 2015/8/12.
 */
@RequestMapping("/std")
@Controller("stdController")
public class StdController extends BaseController {
    @Resource(name = Services.StdService)
    IStdService stdService;
    /**************************** 标准字典 ************************************************/
    /**
     * 通过字典ID获取字段
     * @return
     */
    @RequestMapping("getDictByScheme")
    @ResponseBody
    public Result getDictByScheme(String version, String dictId){
        try {
            return stdService.getDictResultByVersion(version, dictId);
        }
        catch (Exception ex)
        {
            return Result.error(ex.getMessage());
        }
    }
}

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

@ -36,7 +36,7 @@ public interface IRsResourceService {
    List<TreeResult> resourceCategoryTreeList() throws Exception;
    String searchRomoteResourceList(String url, Map<String, Object> params) throws Exception;
    String searchRomoteResourceList(String code, Map<String, Object> params) throws Exception;
    Result getDataSet(Map<String, Object> params) throws Exception;

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/std/service/intf/IStdService.java

@ -1,4 +1,4 @@
package com.yihu.ehr.std.service.intf;
package com.yihu.ehr.resource.service;
import com.yihu.ehr.framework.model.DictionaryResult;

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

@ -5,14 +5,14 @@ import com.yihu.ehr.framework.model.DataGridResult;
import com.yihu.ehr.framework.model.Result;
import com.yihu.ehr.framework.model.TreeResult;
import com.yihu.ehr.framework.util.PKUtil;
import com.yihu.ehr.framework.util.httpclient.HttpHelper;
import com.yihu.ehr.resource.dao.*;
import com.yihu.ehr.resource.model.*;
import com.yihu.ehr.resource.service.IRsResourceService;
import com.yihu.ehr.resource.service.IStdService;
import com.yihu.ehr.resource.viewresult.ResourceAuthorizeDGModel;
import com.yihu.ehr.resource.viewresult.RsResourceDeatilModel;
import com.yihu.ehr.resource.viewresult.RsResourceDimensionModel;
import com.yihu.ehr.std.service.BaseHttpService;
import com.yihu.ehr.std.service.intf.IStdService;
import com.yihu.ehr.system.dao.intf.IAppDao;
import com.yihu.ehr.system.model.SystemApp;
import net.sf.json.JSONArray;
@ -30,7 +30,7 @@ import java.util.List;
import java.util.Map;
@Service("resourceService")
public class RsResourceServiceImpl extends BaseHttpService implements IRsResourceService {
public class RsResourceServiceImpl implements IRsResourceService {
    @Resource(name = "rsResourceCategoryDao")
    private IRsResourceCategoryDao rsResourceCategoryDao;
    @Resource(name = "rsResourceDao")
@ -151,9 +151,12 @@ public class RsResourceServiceImpl extends BaseHttpService implements IRsResourc
        return rsResourceDao.getResourceFiled(conditionMap, page, rows);
    }
    /**
     * 通过网关获取资源数据
     */
    @Override
    public String searchRomoteResourceList(String url, Map<String, Object> params) throws Exception {
        String result = super.doGetByResourceCode(url, params);
    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");
        return response_params;

+ 29 - 56
Hos-resource/src/main/java/com/yihu/ehr/std/service/StdService.java

@ -1,10 +1,11 @@
package com.yihu.ehr.std.service;
package com.yihu.ehr.resource.service.impl;
import com.yihu.ehr.common.Services;
import com.yihu.ehr.framework.constrant.ErrorCode;
import com.yihu.ehr.framework.model.DictItem;
import com.yihu.ehr.framework.model.DictionaryResult;
import com.yihu.ehr.framework.util.operator.CollectionUtil;
import com.yihu.ehr.resource.service.IStdService;
import com.yihu.ehr.standard.model.adapter.AdapterDatasetModel;
import com.yihu.ehr.standard.model.adapter.AdapterDictentryModel;
import com.yihu.ehr.standard.model.adapter.resultModel.AdapterMetadataResultDetailModel;
@ -18,10 +19,6 @@ import com.yihu.ehr.standard.service.adapter.AdapterSchemeVersionService;
import com.yihu.ehr.standard.service.bo.AdapterVersion;
import com.yihu.ehr.standard.service.standard.StdDatasetService;
import com.yihu.ehr.standard.service.standard.StdMetadataService;
import com.yihu.ehr.std.service.intf.IStdService;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -34,7 +31,7 @@ import java.util.Map;
 * Created by hzp on 2016/1/20.
 */
@Service(Services.StdService)
public class StdService extends BaseHttpService implements IStdService {
public class StdService implements IStdService {
    @Resource(name = StdDatasetService.BEAN_ID)
    private StdDatasetService stdDatasetService;
@ -48,55 +45,7 @@ public class StdService extends BaseHttpService implements IStdService {
    private AdapterDatasetService datasetService;
    @Resource(name = AdapterSchemeVersionService.BEAN_ID)
    private AdapterSchemeVersionService adapterSchemeVersion;
    /**
     * 获取网关数据
     * @return
     */
    private String getData(String resourcecCode, Map<String, Object> queryParams) throws Exception
    {
        String getString = "";
        if(queryParams==null)
        {
            getString = super.doGetByResourceCode(resourcecCode);
        }
        else{
            getString = super.doGetByResourceCode(resourcecCode, queryParams);
        }
        JSONObject obj = new JSONObject(getString);
        if(obj.getString("responseCode").equals("10000"))
        {
            return obj.getString("responseParams");
        }
        else{
            return "[]";
        }
    }
    /**
     * 通过适配方案获取字典列表
     */
    public DictionaryResult getDictResultByVersion(String schemeVersion, String dictId) throws Exception {
        DictionaryResult re = new DictionaryResult();
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("adapterDictId", dictId);
        AdapterVersion version = new AdapterVersion(schemeVersion);
        List<AdapterDictentryModel> dictentryList =  dictentryService.getList(AdapterDictentryModel.class, version.getDictEntryTableName(), net.sf.json.JSONObject.fromObject(map).toString(), null, null, null, ErrorCode.GetDictEntryListFailed);
        List<DictItem> list = new ArrayList<>();
        if(!CollectionUtil.isEmpty(dictentryList)) {
            for(AdapterDictentryModel adapterDictentryModel : dictentryList)
            {
                DictItem dict = new  DictItem();
                dict.setCode(adapterDictentryModel.getAdapterEntryCode());
                dict.setValue(adapterDictentryModel.getAdapterEntryValue());
                list.add(dict);
            }
        }
        re.setDetailModelList(list);
        return re;
    }
    /**************************** 适配方案 **************************************************/
@ -107,8 +56,6 @@ public class StdService extends BaseHttpService implements IStdService {
        return adapterSchemeVersion.getPublishedList();
    }
    /**
     * 通过适配方案获取数据集列表
     */
@ -147,6 +94,32 @@ public class StdService extends BaseHttpService implements IStdService {
        return dictentryService.getList(AdapterDictentryModel.class, version.getDictEntryTableName(), net.sf.json.JSONObject.fromObject(map).toString(), null, null, null, ErrorCode.GetDictEntryListFailed);
    }
    /**
     * 通过适配方案获取字典列表
     */
    public DictionaryResult getDictResultByVersion(String schemeVersion, String dictId) throws Exception {
        DictionaryResult re = new DictionaryResult();
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("adapterDictId", dictId);
        AdapterVersion version = new AdapterVersion(schemeVersion);
        List<AdapterDictentryModel> dictentryList =  dictentryService.getList(AdapterDictentryModel.class, version.getDictEntryTableName(), net.sf.json.JSONObject.fromObject(map).toString(), null, null, null, ErrorCode.GetDictEntryListFailed);
        List<DictItem> list = new ArrayList<>();
        if(!CollectionUtil.isEmpty(dictentryList)) {
            for(AdapterDictentryModel adapterDictentryModel : dictentryList)
            {
                DictItem dict = new  DictItem();
                dict.setCode(adapterDictentryModel.getAdapterEntryCode());
                dict.setValue(adapterDictentryModel.getAdapterEntryValue());
                list.add(dict);
            }
        }
        re.setDetailModelList(list);
        return re;
    }
    /******************************** 标准版本 *****************************************************/
    /**
     * 通过标准版本获取数据集列表

+ 0 - 60
Hos-resource/src/main/java/com/yihu/ehr/std/service/BaseHttpService.java

@ -1,60 +0,0 @@
package com.yihu.ehr.std.service;
import com.yihu.ehr.framework.util.httpclient.HttpClientUtil;
import org.codehaus.jettison.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by chenweida on 2016/1/20.
 */
@Service("BaseHttpService")
public class BaseHttpService {
    @Value("#{propertyConfigurer['http.url']}")
    private String url;
    @Value("#{propertyConfigurer['http.username']}")
    private String username;
    @Value("#{propertyConfigurer['http.password']}")
    private String password;
    @Value("#{propertyConfigurer['http.gateway']}")
    private String gateway;
    //http://192.168.131.103:6020/api/v1.0/standard_center/metadatas/allVersionList
    protected String doPost(String methodName, Map<String, Object> params) throws Exception {
        StringBuilder sb = new StringBuilder(url + methodName);
        return HttpClientUtil.doPost(sb.toString(), params, username, password);
    }
    protected String doPost(String methodName) throws Exception {
        StringBuilder sb = new StringBuilder(url + methodName);
        return HttpClientUtil.doPost(sb.toString(), new HashMap<>(), username, password);
    }
    protected String doGet(String methodName, Map<String, Object> params) throws Exception {
        StringBuilder sb = new StringBuilder(url + methodName);
        return HttpClientUtil.doGet(sb.toString(), params, username, password);
    }
    protected String doGet(String methodName) throws Exception {
        StringBuilder sb = new StringBuilder(url + methodName);
        return HttpClientUtil.doGet(sb.toString(), new HashMap<>(), username, password);
    }
    protected String doGetByResourceCode(String resourcecCode, Map<String, Object> queryParams) throws Exception {
        Map<String,Object> params=new HashMap<String,Object>();
        params.put("api",resourcecCode);
        params.put("param", net.sf.json.JSONObject.fromObject(queryParams).toString());
        return HttpClientUtil.doGet(gateway, params, null, null);
    }
    protected String doGetByResourceCode(String resourcecCode) throws Exception {
        Map<String,Object> params=new HashMap<String,Object>();
        params.put("api",resourcecCode);
        params.put("param", "{}");
        return HttpClientUtil.doGet(gateway, params, null, null);
    }
}

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

@ -6,7 +6,7 @@ import com.yihu.ehr.framework.model.DataGridResult;
import com.yihu.ehr.framework.model.DictionaryResult;
import com.yihu.ehr.framework.model.Result;
import com.yihu.ehr.framework.util.controller.BaseController;
import com.yihu.ehr.framework.util.httpclient.HttpClientUtil;
import com.yihu.ehr.framework.util.http.HttpClientUtil;
import com.yihu.ehr.system.model.SystemDict;
import com.yihu.ehr.system.model.SystemDictList;
import com.yihu.ehr.system.service.intf.IBaseDictManager;

+ 4 - 4
Hos-resource/src/main/resources/config/dbhelper.properties

@ -1,7 +1,7 @@
defaultName = hos-mysql
defaultUri = jdbc:mysql://192.168.1.220:3306/hos2_resource?useUnicode=true&characterEncoding=UTF-8
defaultUser = hos2
defaultPassword = hos2
defaultUri = jdbc:mysql://172.19.103.71:3306/esb?useUnicode=true&characterEncoding=UTF-8
defaultUser = hos
defaultPassword = hos
mongodbUri=mongodb://admin:admin@192.168.1.220/?authSource=admin
mongodbUri=mongodb://hos:hos@172.19.103.42/?authSource=admin
mongodbName=hos

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

@ -0,0 +1,13 @@
httpUrl = https://172.19.103.73:443/api/v1.0
#ÖÒhttps://192.168.131.15:4432/api/v1.0
  #https://172.19.103.73:443/api/v1.0
sslKeystore = I:/ssl/tomcat.keystore
sslPassword = 123456
clientId = kHAbVppx44
clientKey = a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P
httpGateway=http://172.19.103.56:8890/gateway/transfer

+ 3 - 3
Hos-resource/src/main/resources/config/quartz.properties

@ -35,9 +35,9 @@ org.quartz.jobStore.dataSource:qzDS
#============================================================================
#dataSource
org.quartz.dataSource.qzDS.driver:com.mysql.jdbc.Driver
org.quartz.dataSource.qzDS.URL:jdbc:mysql://192.168.1.220:3306/hos2_resource?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&autoReconnectForPools=true
org.quartz.dataSource.qzDS.user:hos2
org.quartz.dataSource.qzDS.password:hos2
org.quartz.dataSource.qzDS.URL:jdbc:mysql://172.19.103.71:3306/hos?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&autoReconnectForPools=true
org.quartz.dataSource.qzDS.user:hos
org.quartz.dataSource.qzDS.password:hos
org.quartz.dataSource.qzDS.maxConnection:100
org.quartz.dataSource.qzDS.validateOnCheckout:true
org.quartz.dataSource.qzDS.validationQuery:select 1

+ 9 - 9
Hos-resource/src/main/resources/resource.properties

@ -1,13 +1,13 @@
hopurl=http://172.19.103.56:8080/WSGW/services/ServiceGateWay
org_code=41872607-9
username=user
password=standard
serverip=172.19.103.56
port=6020
#hopurl=http://172.19.103.56:8080/WSGW/services/ServiceGateWay
#org_code=41872607-9
#username=user
#password=standard
#serverip=172.19.103.56
#port=6020
####################http\u914D\u7F6E\u4FE1\u606F####################
#http.url=http://192.168.131.103:6020/api/v1.0/
http.url=http://172.19.103.56:6020/api/v1.0/
http.username=user
http.password=standard
#http.url=http://172.19.103.56:6020/api/v1.0/
#http.username=user
#http.password=standard
http.gateway=http://172.19.103.56:8890/gateway/transfer

+ 3 - 5
Hos-resource/src/main/resources/spring/applicationContext.xml

@ -43,9 +43,9 @@
        <property name="password" value="fujian"/>
        -->
        <property name="url"
                  value="jdbc:mysql://192.168.1.220:3306/hos2_resource?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos2"/>
        <property name="password" value="hos2"/>
                  value="jdbc:mysql://172.19.103.71:3306/esb?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos"/>
        <property name="password" value="hos"/>
        <property name="initialSize" value="1"/>
        <property name="maxTotal" value="100"/>
        <property name="maxIdle" value="50"/>
@ -79,8 +79,6 @@
        </property>
    </bean>
    <!-- 将多个配置文件读取到容器中,交给Spring管理 -->
    <util:properties id="propertyConfigurer" location="classpath:/resource.properties"/>
    <!--Hibernate 事务配置-->
    <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>

+ 1 - 1
Hos-resource/src/main/webapp/WEB-INF/ehr/jsp/resource/resourceregister/resourceBrowseJs.jsp

@ -121,7 +121,7 @@
            $.ajax({
                type: "POST",
                url: "${contextRoot}/resource/resource/searchResourceDatagridColunm",
                data: {"rows": 10, "page": 1, "id": resourceBrowse.resourceId},
                data: {"id": resourceBrowse.resourceId},
                success: function (msg) {
                    msg = eval("(" + msg + ")");
                    var colunmName = msg.colunmName;