Bläddra i källkod

Merge branch 'master' of huangzhanpeng/esb_huangzhanpeng into master

esb 9 år sedan
förälder
incheckning
a51cdcba92
30 ändrade filer med 609 tillägg och 1689 borttagningar
  1. 1 34
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/ApplicationStart.java
  2. 87 0
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/ThreadStart.java
  3. 9 224
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/config/SysConfig.java
  4. 1 0
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/config/ThreadConfig.java
  5. 30 0
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/controller/SystemController.java
  6. 80 69
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/SystemManager.java
  7. 11 1
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/crawler/CrawlerManager.java
  8. 8 52
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/crawler/DataCollectDispatcher.java
  9. 5 50
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/patient/PatientCDAUpload.java
  10. 44 102
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/standard/StandardManager.java
  11. 0 58
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HAHttpClient.java
  12. 0 172
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HAHttpClientImpl.java
  13. 0 71
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HAHttpsClient.java
  14. 0 241
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HOPClient.java
  15. 0 408
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HttpClientUtil.java
  16. 0 56
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HttpsInitialise.java
  17. 0 20
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/IHAHttpClient.java
  18. 0 20
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/Response.java
  19. 258 37
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/EsbHttp.java
  20. 1 1
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HopHostnameVerifier.java
  21. 30 34
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/HttpClientUtil.java
  22. 6 6
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/HttpHelper.java
  23. 2 2
      Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/Response.java
  24. 5 7
      Hos-Resource-Mini/src/main/resources/config/crawler.properties
  25. 1 1
      Hos-Resource-Mini/src/main/resources/config/http.properties
  26. 0 8
      Hos-Resource-Mini/src/main/resources/config/sys.config.xml
  27. 14 10
      Hos-Resource-Mini/src/main/webapp/WEB-INF/web.xml
  28. 10 2
      Hos-resource/Hos-Resource.iml
  29. 0 1
      Hos-resource/src/main/webapp/WEB-INF/ehr/jsp/datacollect/editorJob.jsp
  30. 6 2
      Hos-resource/src/main/webapp/WEB-INF/ehr/jsp/datacollect/editorJobJs.jsp

+ 1 - 34
Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/ApplicationStart.java

@ -29,16 +29,14 @@ public class ApplicationStart implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent context) {
        try {
            String home = System.getProperty("catalina.home").replace('\\','/');
            String homeUrl = home.substring(0,home.lastIndexOf('/')+1);
            dbConfig(homeUrl);
            sslConfig(homeUrl);
            crawlerConfig(homeUrl);
            startThread();
        } catch (Exception e) {
            System.out.print(e.getStackTrace().toString());
            LogUtil.error(e.getStackTrace().toString());
        }
    }
@ -76,37 +74,6 @@ public class ApplicationStart implements ServletContextListener {
        fos.close();
    }
    /**
     * 采集配置
     * @param homeUrl
     * @throws Exception
     */
    private void crawlerConfig(String homeUrl) throws Exception {
        System.setProperty(log4jDirKey, homeUrl + "log4j");
        SysConfig.getInstance().setTempFile(homeUrl + "standard");
        SysConfig.getInstance().setTrustStorePath(homeUrl + "ssl/tomcat.keystore");
        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());
        }
    }
    private void startThread() {
        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();
    }
    @Override
    public void contextDestroyed(ServletContextEvent context) {

+ 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());
        }
    }
}

+ 9 - 224
Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/config/SysConfig.java

@ -1,13 +1,7 @@
package com.yihu.ehr.common.config;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.model.PatientIdentity;
import com.yihu.ehr.util.encrypt.RSA;
import com.yihu.ehr.util.http.HOPClient;
import com.yihu.ehr.util.http.Response;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.ConfigureUtil;
import com.yihu.ehr.util.operator.StringUtil;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@ -20,28 +14,13 @@ import java.util.List;
public class SysConfig {
    public static final String HOS_RESOURCES_CONFIG = "/config/sys.config.xml";
    public static String publicKeyMethod;
    public static String tokenMethod;
    private static volatile SysConfig instance = null;
    public static String publicKey;
    public static String orgCode;
    private String platformUrl;
    private boolean debugMode;
    private String tempFile;
    private String publicKey;
    public static String tempFile;
    public static String registerDataSet;
    public static String registerIdCardNo;
    private static volatile SysConfig instance = null;
    private HashMap<String, PatientIdentity> patientIdentityHashMap;
    private String trustStorePath;
    private String trustStorePwd;
    private String registerDataSet;
    private String registerIdCardNo;
    private String platformUserName;
    private String platformUserPass;
    private String platformAppId;
    private String platformAppSecret;
    private String accessToken;
    private String refreshToken;
    private String platformUser;
    private String basciAuthPwd;
    private String basciAuthUser;
    private SysConfig() {
        patientIdentityHashMap = new HashMap<>();
@ -69,10 +48,6 @@ public class SysConfig {
    }
    public Boolean isDebugMode() {
        return debugMode;
    }
    public String getTempFile() {
        return this.tempFile;
    }
@ -81,65 +56,12 @@ public class SysConfig {
        this.tempFile = tempFile;
    }
    public void setTrustStorePath(String trustStorePath) {
        this.trustStorePath = trustStorePath;
        HOPCLientInit();
    }
    public String getPlatformUrl() {
        return platformUrl;
    public String getPublicKey() {
        return publicKey;
    }
    /**
     * @return String
     * @throws Exception
     * @modify 2015.09.15 airhead 修订日志信息不对问题
     */
    public String getPublicKey() throws Exception {
        if (publicKey != null) {
            return publicKey;
        }
        if (publicKeyMethod == null) {
            publicKeyMethod = ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.security.publicKey.get");
        }
        HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
        hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
        hopClient.setUrl(SysConfig.getInstance().getPlatformUrl());
        hopClient.setMethod(publicKeyMethod + platformUserName);
        Response response = hopClient.get();
        if (response == null) {
            LogUtil.fatal("获取公钥失败.");
            return null;
        }
        if (response.statusCode != 200) {
            LogUtil.fatal("获取公钥失败,错误代码:" + response.statusCode);
            return null;
        }
        try {
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readValue(response.body, JsonNode.class);
            String code = rootNode.path("code").asText();
            if ("ehr.invalid.user".equals(code)) {
                LogUtil.fatal("获取公钥失败:无效用户,请检查 Sys.config.xml文件中 <user>节点值是否正确");
                return null;
            }
            JsonNode publicNode = rootNode.path("result").path("public_key");
            if (publicNode.isMissingNode()) {
                LogUtil.fatal("获取公钥失败,返回数据格式不正确.");
                return null;
            }
            publicKey = publicNode.asText();
        } catch (Exception e) {
            LogUtil.fatal("获取公钥失败,返回数据格式不正确.");
            return null;
        }
        return publicKey;
    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }
    public PatientIdentity getPatientIdentity(String dataSetCode) {
@ -158,105 +80,6 @@ public class SysConfig {
        return registerIdCardNo;
    }
    /**
     * @return String
     * @modify 2015.09.15 airhead 修订日志信息不对问题
     */
    public String getAccessToken() {
        try {
            if (tokenMethod == null) {
                tokenMethod = ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.security.token.get");
            }
            HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
            hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
            hopClient.setUrl(SysConfig.getInstance().getPlatformUrl());
            hopClient.setMethod(tokenMethod);
//            hopClient.setParam("grant_type", "password");
            hopClient.setParam("user_name", getPlatformUserName());
            hopClient.setParam("app_secret", SysConfig.getInstance().getPlatformAppSecret());
            String publicKey = getPublicKey();
            String encryptPwd = RSA.encrypt(platformUserPass, RSA.genPublicKey(publicKey));
            hopClient.setParam("rsa_pw", encryptPwd);
            Response response = hopClient.get();
            if (response == null) {
                LogUtil.fatal("获取令牌失败.");
                return null;
            }
            if (response.statusCode != 200) {
                LogUtil.fatal("获取令牌失败,错误代码:" + response.statusCode);
                return null;
            }
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readValue(response.body, JsonNode.class);
            String code = rootNode.path("code").asText();
            if (code.equals("ehr.invalid.username.or.pwd")) {
                LogUtil.fatal("无效用户名或密码,请检查Sys.config.xml文件中 <user>节点值是否正确");
                return null;
            }
            if (code.equals("ehr.app.register.invalid")) {
                LogUtil.fatal("该app应用在系统中不存在,请检查Sys.config.xml文件中 <app>节点值是否正确");
                return null;
            }
            if (code.equals("ehr.security.token.expired") && !StringUtil.isEmpty(refreshToken)) {
                hopClient.reset();
                hopClient.setMethod(tokenMethod);
                hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
                hopClient.setParam("grant_type", "password");
                hopClient.setParam("refresh_token", refreshToken);
                hopClient.setParam("user_id", getPlatformUserName());
                response = hopClient.get();
                if (response == null) {
                    LogUtil.fatal("刷新令牌失败.");
                    return null;
                }
                if (response.statusCode != 200) {
                    LogUtil.fatal("刷新令牌失败,错误代码:" + response.statusCode);
                    return null;
                }
                rootNode = mapper.readValue(response.body, JsonNode.class);
                code = rootNode.path("code").asText();
                if (StringUtil.isEmpty(code) || !code.equals("0")) {
                    LogUtil.fatal("刷新令牌失败,错误代码:" + code);
                    return null;
                }
            }
            accessToken = rootNode.path("result").get("access_token").asText();
            refreshToken = rootNode.path("result").path("refresh_token").asText();
            return accessToken;
        } catch (Exception e) {
            LogUtil.error(e);
        }
        return null;
    }
    public String getPlatformUser() {
        return platformUser;
    }
    public String getPlatformUserName() {
        return platformUserName;
    }
    public String getPlatformAppId() {
        return platformAppId;
    }
    private String getPlatformAppSecret() {
        return platformAppSecret;
    }
    private Document getDocument() throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = null;
@ -282,43 +105,13 @@ public class SysConfig {
                return;
            }
            this.initPlatForm(rootElement);
            this.initCrawler(rootElement);
            this.initEventNo(rootElement);
            String debug = rootElement.elementTextTrim("debug");
            if (StringUtil.isEmpty(debug) || debug.equals("false")) {
                debugMode = false;
            }
        } catch (Exception e) {
            LogUtil.error(e);
        }
    }
    private void initPlatForm(Element rootElement) throws Exception {
        Element platform = rootElement.element("platform");
        String platformUrl = platform.elementTextTrim("url");
        if (!StringUtil.isEmpty(platformUrl)) {
            this.platformUrl = platformUrl;
        }
        Element trustStore = platform.element("trust_store");
        trustStorePwd = trustStore.attributeValue("pwd");
        Element platformUserElem = platform.element("user");
        platformUserName = platformUserElem.getTextTrim();
        platformUserPass = platformUserElem.attributeValue("pwd");
        Element platformAppElem = platform.element("app");
        platformAppId = platformAppElem.getTextTrim();
        platformAppSecret = platformAppElem.attributeValue("secret");
        Element basciAuthElem = platform.element("basic_auth");
        basciAuthUser = basciAuthElem.getTextTrim();
        basciAuthPwd = basciAuthElem.attributeValue("pwd");
        HOPClient.initBasciAuth(basciAuthUser, basciAuthPwd);
    }
    private void initCrawler(Element rootElement) {
        List queueDataSets = rootElement.element("patient_queue").elements("dataset");
        for (Object obj : queueDataSets) {
@ -349,14 +142,6 @@ public class SysConfig {
        }
    }
    private void HOPCLientInit () {
        try {
            HOPClient.initHttps(trustStorePath, trustStorePwd);
        } catch (Exception e) {
            LogUtil.error(e);
        }
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }

+ 1 - 0
Hos-Resource-Mini/src/main/java/com.yihu.ehr/common/config/ThreadConfig.java

@ -6,4 +6,5 @@ public class ThreadConfig {
    public static int UPDATE_THREAD_SLEEP_TIME = 60;
    public static int CRAWLER_SUPPLY_THREAD_SLEEP_TIME = 60;
}

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 30 - 0
Hos-Resource-Mini/src/main/java/com.yihu.ehr/controller/SystemController.java


+ 80 - 69
Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/SystemManager.java

@ -10,10 +10,8 @@ import com.yihu.ehr.model.UserInfo;
import com.yihu.ehr.service.intf.ISystemManager;
import com.yihu.ehr.service.thread.StandardUpdateThread;
import com.yihu.ehr.service.thread.ThreadManage;
import com.yihu.ehr.util.http.HOPClient;
import com.yihu.ehr.util.httpclient.EsbHttp;
import com.yihu.ehr.util.httpclient.Response;
import com.yihu.ehr.util.operator.ConfigureUtil;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -164,85 +162,98 @@ public class SystemManager implements ISystemManager {
    登录操作
    */
    @Override
    public Result loginAction(HttpSession session, String user, String password) throws Exception {
        //特殊用户
        if (user.equals("admin") && password.equals("JKZL")) {
            UserInfo obj = new UserInfo();
            obj.setLoginCode("admin");
            obj.setRealName("管理员");
            obj.setOrgCode("JKZL");
            obj.setOrgName("健康之路");
            session.setAttribute("userInfo", obj);
            return Result.success("登录成功!");
        }
    public Result loginAction(HttpSession session, String user, String password) {
        try {
            //特殊用户
            if (user.equals("admin") && password.equals("JKZL")) {
                UserInfo obj = new UserInfo();
                obj.setLoginCode("admin");
                obj.setRealName("管理员");
                obj.setOrgCode("JKZL");
                obj.setOrgName("健康之路");
                session.setAttribute("userInfo", obj);
                return Result.success("登录成功!");
            }
        //根据用户名/密码到总平台校验
        Response response = EsbHttp.loginAction(user, password);
            //根据用户名/密码到总平台校验
            Response response = EsbHttp.loginAction(user, password);
        if (response == null || response.statusCode != 200) {
            return Result.error("登录失败!网络错误或者服务器不可用。");
        }
        try {
            JSONObject obj = new JSONObject(response.body);
            if (obj.has("token"))//登录成功
            {
                String token = obj.getString("token");
                //获取用户信息
                Response re = EsbHttp.getUserInfo(user, token);
                JSONObject userObject = new JSONObject(re.body);
                UserInfo userInfo = new UserInfo();
                userInfo.setLoginCode(user);
                userInfo.setRealName(userObject.getString("realName"));
                String orgCode = "";
                String orgName = "";
                if(!userObject.get("organization").equals(null)) {
                    JSONObject orgInfo = userObject.getJSONObject("organization");
                    orgCode = orgInfo.getString("orgCode");
                    orgName = orgInfo.getString("fullName");
                    userInfo.setOrgCode(orgCode);
                    userInfo.setOrgName(orgName);
                }
                else{
                    return Result.error("该用户未配置机构!");
                }
                session.setAttribute("userInfo", userInfo);
                //判断组织编码是否为空
                String orgCodeOld = this.getSystemParam("ORG_CODE");
                if (orgCodeOld==null || orgCodeOld.length() == 0) {
                    this.saveSystemParams("FINGER_PRINT", UUID.randomUUID().toString());
                    this.saveSystemParams("ORG_CODE", orgCode);
                    this.saveSystemParams("ORG_NAME", orgName);
                    //启动标准
                    if (SysConfig.getInstance().isEmptyOrgCode()) {
                        SysConfig.getInstance().setOrgCode(orgCode);
                        Thread standardUpdateThread = new Thread(new StandardUpdateThread());
                        ThreadManage.add(ThreadManage.STANDARD_UPDATE_THREAD, standardUpdateThread);
                        ThreadManage.setUpdateInterval();
                        if (!standardUpdateThread.isAlive()) {
                            standardUpdateThread.start();
            if (response != null && response.getStatusCode() == 200) {
                JSONObject obj = new JSONObject(response.getBody());
                if (obj.has("token"))//登录成功
                {
                    String token = obj.getString("token");
                    //获取用户信息
                    Response re = EsbHttp.getUserInfo(user, token);
                    if (re != null && re.getStatusCode() == 200) {
                        JSONObject userObject = new JSONObject(re.getBody());
                        UserInfo userInfo = new UserInfo();
                        userInfo.setLoginCode(user);
                        userInfo.setRealName(userObject.getString("realName"));
                        String orgCode = "";
                        String orgName = "";
                        if(userObject.has("organization") && !userObject.get("organization").equals(null)) {
                            JSONObject orgInfo = userObject.getJSONObject("organization");
                            orgCode = orgInfo.getString("orgCode");
                            orgName = orgInfo.getString("fullName");
                            userInfo.setOrgCode(orgCode);
                            userInfo.setOrgName(orgName);
                        }
                        else{
                            return Result.error("该用户未配置机构!");
                        }
                        session.setAttribute("userInfo", userInfo);
                        //判断组织编码是否为空
                        String orgCodeOld = this.getSystemParam("ORG_CODE");
                        if (orgCodeOld==null || orgCodeOld.length() == 0) {
                            this.saveSystemParams("FINGER_PRINT", UUID.randomUUID().toString());
                            this.saveSystemParams("ORG_CODE", orgCode);
                            this.saveSystemParams("ORG_NAME", orgName);
                            //启动标准
                            SysConfig.getInstance().setOrgCode(orgCode);
                            Thread standardUpdateThread = new Thread(new StandardUpdateThread());
                            ThreadManage.add(ThreadManage.STANDARD_UPDATE_THREAD, standardUpdateThread);
                            ThreadManage.setUpdateInterval();
                            if (!standardUpdateThread.isAlive()) {
                                standardUpdateThread.start();
                            }
                            return Result.success("登录成功!");
                        }
                        else {
                            if (orgCodeOld.equals(orgCode)) {
                                return Result.success("登录成功!");
                            } else {
                                return Result.error("机构编码不一致!");
                            }
                        }
                    }
                    else{
                        return Result.error("获取用户信息失败!");
                    }
                }
                else {
                    if(obj.has("message"))
                    {
                        return Result.error("登录失败!"+obj.getString("message"));
                    }
                    return Result.success("登录成功!");
                } else {
                    if (orgCodeOld.equals(orgCode)) {
                        return Result.success("登录成功!");
                    } else {
                        return Result.error("机构编码不一致!");
                    else{
                        return Result.error("登录失败!");
                    }
                }
            }
            else {
                if(obj.has("message"))
                String msg = "登录失败。";
                if (response != null)
                {
                    return Result.error("登录失败!"+obj.getString("message"));
                }
                else{
                    return Result.error("登录失败!");
                    msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
                }
                return Result.error(msg);
            }
        }
        catch (Exception ex) {
            return Result.error(ex.getMessage());

+ 11 - 1
Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/crawler/CrawlerManager.java

@ -105,6 +105,9 @@ public class CrawlerManager {
    }
    public synchronized String dataCrawler(Date begin, Date end, String taskId, int type) {
        if (SysConfig.getInstance().isEmptyOrgCode()) {
            return "本次任务执行失败,机构代码为空";
        }
        Integer count = 0;
        Integer totalCount = 0;
        getAdapterDataSetList();
@ -127,6 +130,13 @@ public class CrawlerManager {
                if (!CollectionUtil.isEmpty(patientList)) {
                    totalCount = patientList.size();
                    for (Patient patient : patientList) {
                        String token;
                        try {
                            token = EsbHttp.getToken();
                        } catch (Exception e) {
                            LogUtil.error("本次任务执行失败,获取token失败!");
                            return "本次任务执行失败,获取token失败!";
                        }
                        if (type == 1) {
                            patient.setReUploadFlg(StringUtil.toString(true));
                        } else {
@ -134,7 +144,7 @@ public class CrawlerManager {
                        }
                        LogUtil.trace("采集->注册->打包上传,任务ID:"+taskId+",patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
                        // COLLECT->REGISTER->UPLOAD
                        Boolean result = dispatch.collectData(patient, adapterDataSetList, dataSourceMap);
                        Boolean result = dispatch.collectData(patient, adapterDataSetList, dataSourceMap, token);
                        SqlCreate sqlCreate = new SqlCreate();
                        sqlCreate.setTableName("task_track");

+ 8 - 52
Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/crawler/DataCollectDispatcher.java

@ -12,19 +12,13 @@ import com.yihu.ehr.service.patient.PatientCDAIndex;
import com.yihu.ehr.service.patient.PatientCDAUpload;
import com.yihu.ehr.util.db.DBSessionFactory;
import com.yihu.ehr.util.file.FileUtil;
import com.yihu.ehr.util.http.HOPClient;
import com.yihu.ehr.util.http.Response;
import com.yihu.ehr.util.httpclient.EsbHttp;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.CollectionUtil;
import com.yihu.ehr.util.operator.ConfigureUtil;
import com.yihu.ehr.util.operator.StringUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
public class DataCollectDispatcher {
@ -45,7 +39,7 @@ public class DataCollectDispatcher {
     * @param patient 病人
     * @return true-采集成功,false-采集失败
     */
    public Boolean collectData(Patient patient, List<AdapterDataSet> adapterDataSetList, Map<String, DBSessionFactory> dataSourceMap) {
    public Boolean collectData(Patient patient, List<AdapterDataSet> adapterDataSetList, Map<String, DBSessionFactory> dataSourceMap, String token) {
        Boolean result = true;
        Map<String, AdapterDataSet> dataSetMap = new HashMap<>();
        List<ObjectNode> dataList = new ArrayList<>();
@ -65,7 +59,7 @@ public class DataCollectDispatcher {
                    if (SysConfig.getInstance().getRegisterDataSet().equals(adapterDataSet.getAdapterDataSetT().getStdDatasetCode())) {
                        if (!StringUtil.isEmpty(jsonObject.get("data")) && !StringUtil.isEmpty(jsonObject.get("data").get(0))) {
                            if (!StringUtil.isEmpty(jsonObject.get("data").get(0).get(SysConfig.getInstance().getRegisterIdCardNo()))) {
                                register(patient, StringUtil.toString(jsonObject));
                                register(patient, StringUtil.toString(jsonObject), token);
                            }
                        }
                    }
@ -84,7 +78,7 @@ public class DataCollectDispatcher {
        try {
            if (!CollectionUtil.isEmpty(dataList)) {
                if (!upload(dataList, patient, dataSetMap)) {
                if (!upload(dataList, patient, dataSetMap, token)) {
                    result = false;
                }
            }
@ -96,7 +90,7 @@ public class DataCollectDispatcher {
        return result;
    }
    public Boolean upload(List<ObjectNode> dataList, Patient patient, Map<String, AdapterDataSet> dataSetMap) {
    public Boolean upload(List<ObjectNode> dataList, Patient patient, Map<String, AdapterDataSet> dataSetMap, String token) {
        Boolean result = true;
        try {
            DataSetTransformer dataTransformer = new DataSetTransformer();
@ -117,7 +111,7 @@ public class DataCollectDispatcher {
                }
            }
            PatientCDAUpload patientCDAUpload = new PatientCDAUpload();
            if (!patientCDAUpload.upload(patient)) {
            if (!patientCDAUpload.upload(patient, token)) {
                result = false;
            }
        } catch (Exception e) {
@ -144,46 +138,8 @@ public class DataCollectDispatcher {
     * @return boolean
     * 注册不是否成功 统一返回true
     */
    public Boolean register(Patient patient, String data) {
        if (registerMethod == null) {
            registerMethod = ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.patient.register");
        }
        if (StringUtil.isEmpty(data)){
            LogUtil.info("注册病人信息请求失败:无具体病人信息,patient_id="+patient.getPatientId()+", event_no="+patient.getEventNo());
        }
        HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
        hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
        hopClient.setUrl(SysConfig.getInstance().getPlatformUrl());
        hopClient.setMethod(registerMethod);
        List<NameValuePair> formParams = new ArrayList<>();
        formParams.add(new BasicNameValuePair("user_info", data));
        Response response = hopClient.postForm(formParams);
        if (response == null) {
            LogUtil.info("注册病人信息请求失败:响应response为null,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
        }
        if (response.statusCode != 200) {
            LogUtil.info("注册病人信息请求失败.错误代码:" + response.statusCode + "patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
        }
        ObjectMapper mapper = new ObjectMapper();
        JsonNode rootNode = null;
        try {
            rootNode = mapper.readValue(response.body, JsonNode.class);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        JsonNode codeNode = rootNode.get("code");
        JsonNode messageNode = rootNode.get("message");
        String result = codeNode.asText();
        String message = messageNode.asText();
        if (!result.equals("0") || "true".equals(message)) {
            LogUtil.info("注册病人信息请求失败.失败信息:" + message + rootNode.get("message").asText() + "patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
            return false;
        } else {
            LogUtil.info("注册病人信息成功,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
            return true;
        }
    public Boolean register(Patient patient, String data, String token) {
        return EsbHttp.register(patient, data, token);
    }

+ 5 - 50
Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/patient/PatientCDAUpload.java

@ -1,17 +1,12 @@
package com.yihu.ehr.service.patient;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.common.config.SysConfig;
import com.yihu.ehr.model.Patient;
import com.yihu.ehr.util.compress.Zipper;
import com.yihu.ehr.util.encrypt.MD5;
import com.yihu.ehr.util.encrypt.RSA;
import com.yihu.ehr.util.file.FileUtil;
import com.yihu.ehr.util.http.HOPClient;
import com.yihu.ehr.util.http.Response;
import com.yihu.ehr.util.httpclient.EsbHttp;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.ConfigureUtil;
import java.io.File;
import java.security.Key;
@ -34,7 +29,7 @@ public class PatientCDAUpload {
     * @modify 2015.09.15 airhead 修订删除目录
     * @modify 2015.09.19 airhead 修复无文档问题及错误信息
     */
    public Boolean upload(Patient patient) {
    public Boolean upload(Patient patient, String token) {
        ZipFile zipFile = zip(patient);
        try {
            if (zipFile == null || zipFile.file == null) {
@ -42,7 +37,7 @@ public class PatientCDAUpload {
                return false;
            }
            boolean result = upload(patient, zipFile);
            boolean result = upload(patient, zipFile, token);
            if (!result) {
                LogUtil.fatal("上传病人档案失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return result;
@ -96,48 +91,8 @@ public class PatientCDAUpload {
        return null;
    }
    private boolean upload(Patient patient, ZipFile zipFile) {
        try {
            if (uploadMethod == null) {
                uploadMethod = ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.patient.upload");
            }
            String fileMd5= MD5.getMd5ByFile(zipFile.file);
            HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
            hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
            hopClient.setUrl(SysConfig.getInstance().getPlatformUrl());
            hopClient.setMethod(uploadMethod);
            hopClient.setParam("md5", fileMd5);
            hopClient.setParam("package_crypto", zipFile.encryptPwd);
            hopClient.setParam("user_name", SysConfig.getInstance().getPlatformUserName());
            Response response = hopClient.postFile(zipFile.file.getAbsolutePath());
            if (response == null) {
                LogUtil.fatal("上传病人档案请求失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return false;
            }
            if (response.statusCode != 200) {
                LogUtil.fatal("上传病人档案请求失败,错误代码:" + response.statusCode + ",patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return false;
            }
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readValue(response.body, JsonNode.class);
            JsonNode codeNode = rootNode.get("code");
            String result = codeNode.asText();
            if (!result.equals("0")) {
                LogUtil.fatal("上传病人档案失败,错误代码:" + result + ",patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return false;
            } else {
                LogUtil.info("上传病人档案成功,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return true;
            }
        } catch (Exception e) {
            LogUtil.fatal("上传病人档案异常,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
            LogUtil.error(e);
            return false;
        }
    private boolean upload(Patient patient, ZipFile zipFile, String token) {
        return EsbHttp.upload(patient, zipFile.file, zipFile.encryptPwd, token);
    }
    private class ZipFile {

+ 44 - 102
Hos-Resource-Mini/src/main/java/com.yihu.ehr/service/standard/StandardManager.java

@ -9,11 +9,10 @@ import com.yihu.ehr.util.compress.Zipper;
import com.yihu.ehr.util.encode.Base64;
import com.yihu.ehr.util.encrypt.RSA;
import com.yihu.ehr.util.file.FileUtil;
import com.yihu.ehr.util.http.HOPClient;
import com.yihu.ehr.util.http.Response;
import com.yihu.ehr.util.httpclient.EsbHttp;
import com.yihu.ehr.util.httpclient.Response;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.CollectionUtil;
import com.yihu.ehr.util.operator.ConfigureUtil;
import com.yihu.ehr.util.operator.SqlCreate;
import com.yihu.ehr.util.operator.StringUtil;
import org.dom4j.Document;
@ -22,25 +21,17 @@ import org.dom4j.io.SAXReader;
import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.security.Key;
import java.util.*;
/**
 * 标准管理,负责版本的升级,解包及相关安全
 *
 * @created Created by Air on 2015/6/3.
 */
public class StandardManager {
    public static String versionMethod;
    public static String downMethod;
    private static volatile StandardManager instance;
    private DBHelper db;
    private SysConfig sysConfig;
    private String downloadFilePath;
    private String encryptPwd;
    private File[] zipFiles;
    private String localVersion;
    private String remoteVersion;
    public StandardManager(){
        if (db == null) {
@ -78,10 +69,9 @@ public class StandardManager {
        return true;
    }
    public Boolean checkUpdate() {
    public Boolean checkUpdate(String remoteVersion) {
        try {
            getRemoteVersion();
            if (remoteVersion == null) {
            if (StringUtil.isEmpty(remoteVersion)) {
                LogUtil.warn("总支撑平台尚无可用版本进行标准升级");
                return false;
            }
@ -103,13 +93,18 @@ public class StandardManager {
    }
    public boolean update() {
        if (checkUpdate()) {
            boolean result = download();
            if (!result) {
        if (sysConfig.isEmptyOrgCode()) {
            LogUtil.fatal("当前机构代码为空,版本无法更新,请确认!");
            return false;
        }
        String remoteVersion = getRemoteVersion(sysConfig.getOrgCode());
        if (checkUpdate(remoteVersion)) {
            String encryptPwd = download(remoteVersion, sysConfig.getOrgCode());
            if (StringUtil.isEmpty(encryptPwd)) {
                LogUtil.fatal("下载标准包错误.");
                return false;
            }
            versionUpdate();
            versionUpdate(encryptPwd);
        }
        return true;
    }
@ -131,39 +126,8 @@ public class StandardManager {
        return localVersion;
    }
    private void getRemoteVersion() {
        try {
            if (versionMethod == null){
                versionMethod = ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.standard.getVersion");
            }
            HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
            hopClient.setAppId(sysConfig.getPlatformAppId());
            hopClient.setUrl(sysConfig.getPlatformUrl());
            hopClient.setMethod(versionMethod);
            if (sysConfig.isEmptyOrgCode()) {
                LogUtil.fatal("当前机构代码为空,版本无法更新,请确认!");
                return;
            }
            hopClient.setParam("org_code", sysConfig.getOrgCode());
            Response response = hopClient.get();
            if (response == null || response.statusCode != 200) {
                LogUtil.fatal("获取健康云平台标准版本号失败,网络错误或者服务器不可用.");
                return;
            }
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readValue(response.body, JsonNode.class);
            String code = rootNode.path("code").asText();
            if (!code.equals("0")) {
                LogUtil.fatal("获取健康云平台标准版本号失败," + code);
                return;
            }
            remoteVersion = rootNode.path("result").path("version").asText();
        } catch (IOException e) {
            LogUtil.fatal("获取远程版本号异常");
            LogUtil.error(e);
        }
    private String getRemoteVersion(String orgCode) {
        return EsbHttp.getRemoteVersion(orgCode);
    }
    /**
@ -171,9 +135,9 @@ public class StandardManager {
     *
     * @return boolean
     */
    private boolean versionUpdate() {
    private boolean versionUpdate(String encryptPwd) {
        boolean result;
        result = unpack();
        result = unpack(encryptPwd);
        if (!result) {
            LogUtil.fatal("标准包解压错误.");
            return false;
@ -189,66 +153,44 @@ public class StandardManager {
            LogUtil.fatal("生成标准数据失败.");
            return false;
        }
        updateVersion();
        return true;
    }
    private void updateVersion() {
        if (remoteVersion != null) {
            localVersion = new String(remoteVersion);
        }
    }
    private boolean download() {
    private String download(String remoteVersion, String orgCode) {
        Response response = EsbHttp.download(remoteVersion, orgCode);
        try {
            downMethod= ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.standard.allSchemaMappingPlan");
            HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
            hopClient.setAppId(sysConfig.getPlatformAppId());
            hopClient.setUrl(sysConfig.getPlatformUrl());
            hopClient.setMethod(downMethod);
            hopClient.setParam("versionCode", remoteVersion);
            hopClient.setParam("user_name", sysConfig.getPlatformUserName());
            hopClient.setParam("orgcode", sysConfig.getOrgCode());
//            if (!bFull) {
//                hopClient.setParam("current_version", localVersion);
//            }
            Response response = hopClient.get();
            if (response == null || response.statusCode != 200) {
                LogUtil.fatal("下载标准包失败,网络错误或者服务器不可用.");
                return false;
        }
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readValue(response.body, JsonNode.class);
            String code = rootNode.path("code").asText();
            if (!code.equals("0")) {
                LogUtil.fatal("下载标准包失败," + code);
                return false;
            if (response != null && response.getStatusCode() == 200) {
                JSONObject re = new JSONObject(response.getBody());
                if (re.has("password")&&re.has("url")) {
                    String encryptPwd = re.getString("password");
                    String zipContent = re.getString("url");
                    byte[] decode = Base64.decode(zipContent);
                    String downloadFilePath = SysConfig.getInstance().getTempFile() + "/" + Constants.STANDARD_ZIP;
                    boolean writeFile = FileUtil.writeFile(downloadFilePath, decode, "UTF-8");
                    if (!writeFile) {
                        LogUtil.fatal("下载标准包失败,生成本地临时文件错误.");
                        return null;
                    }
                    return encryptPwd;
                }
                else{
                    LogUtil.fatal("下载标准包失败");
                    return null;
                }
            }
            encryptPwd = rootNode.path("result").path("cryptograph").asText();
            String zipContent = rootNode.path("result").get("zipfile").asText();
            byte[] decode = Base64.decode(zipContent);
            downloadFilePath = sysConfig.getTempFile() + "/" + Constants.STANDARD_ZIP;
            boolean writeFile = FileUtil.writeFile(downloadFilePath, decode, "UTF-8");
            if (!writeFile) {
                LogUtil.fatal("下载标准包失败,生成本地临时文件错误.");
                return false;
            else{
                LogUtil.fatal("下载标准包失败,网络错误或者服务器不可用.");
                return null;
            }
            return true;
        } catch (Exception e) {
            LogUtil.fatal("下载标准包异常:");
            LogUtil.error(e);
        }
        return false;
        return null;
    }
    private boolean unpack() {
    private boolean unpack(String encryptPwd) {
        try {
            Key key = RSA.genPublicKey(sysConfig.getPublicKey());
            if (key == null) {

+ 0 - 58
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HAHttpClient.java

@ -1,58 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import java.util.List;
import java.util.Map;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.16 9:10
 */
public class HAHttpClient implements IHAHttpClient {
    private HAHttpClientImpl haHttpClientImpl;
    private RequestConfig requestConfig;
    private HttpClientContext context;
    public HAHttpClient(RequestConfig requestConfig, HttpClientContext context) {
        haHttpClientImpl = new HAHttpClientImpl(requestConfig, context);
    }
    @Override
    public Response get(String url) {
        return get(url,null);
    }
    @Override
    public Response get(String url,Map<String,String> header) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        return haHttpClientImpl.get(httpClient, url,header);
    }
    public Response put(String url) {
        return put(url, null);
    }
    public Response put(String url,Map<String,String> header) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        return haHttpClientImpl.put(httpClient, url, header);
    }
    @Override
    public Response postForm(String url, List<NameValuePair> formParams) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        return haHttpClientImpl.postForm(httpClient, url, formParams);
    }
    @Override
    public Response postFile(String url, String filePath) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        return haHttpClientImpl.postFile(httpClient, url, filePath);
    }
}

+ 0 - 172
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HAHttpClientImpl.java

@ -1,172 +0,0 @@
package com.yihu.ehr.util.http;
import com.yihu.ehr.util.log.LogUtil;
import org.apache.http.Consts;
import org.apache.http.Header;
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.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.mime.MultipartEntity;
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.util.EntityUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.16 10:20
 */
public class HAHttpClientImpl {
    private RequestConfig requestConfig;
    private HttpClientContext context;
    public HAHttpClientImpl(RequestConfig requestConfig, HttpClientContext context) {
        this.requestConfig = requestConfig;
        this.context = context;
    }
    public Response postForm(CloseableHttpClient httpClient, String url, List<NameValuePair> formParams) {
        UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(postEntity);
        httpPost.setConfig(requestConfig);
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            response = httpClient.execute(httpPost, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
    public Response postFile(CloseableHttpClient httpClient, String url, String filePath) {
        File file = new File(filePath);
        HttpPost httpPost = new HttpPost(url);
        FileBody fileBody = new FileBody(file);
        MultipartEntity fileEntity = new MultipartEntity();
        fileEntity.addPart("file", fileBody);
        httpPost.setEntity(fileEntity);
        httpPost.setConfig(requestConfig);
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            response = httpClient.execute(httpPost, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
    public Response get(CloseableHttpClient httpClient, String url) {
        return get(httpClient,url,null);
    }
    public Response get(CloseableHttpClient httpClient, String url,Map<String,String> header) {
        HttpGet httpget = new HttpGet(url);
        httpget.setConfig(requestConfig);
        CloseableHttpResponse response;
        HttpEntity entity = null;
        if(header!=null)
        {
            for (String key : header.keySet()) {
                httpget.addHeader(key, header.get(key));
            }
        }
        try {
            response = httpClient.execute(httpget, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            LogUtil.error(e);
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
    public Response put(CloseableHttpClient httpClient, String url) {
        return put(httpClient, url, null);
    }
    public Response put(CloseableHttpClient httpClient, String url,Map<String,String> header) {
        HttpPut http = new HttpPut(url);
        http.setConfig(requestConfig);
        CloseableHttpResponse response;
        HttpEntity entity = null;
        if(header!=null)
        {
            for (String key : header.keySet()) {
                http.addHeader(key, header.get(key));
            }
        }
        try {
            response = httpClient.execute(http, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            LogUtil.error(e);
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
    private void close(CloseableHttpClient httpClient, HttpEntity entity) {
        try {
            EntityUtils.consume(entity);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            httpClient.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

+ 0 - 71
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HAHttpsClient.java

@ -1,71 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import java.util.List;
import java.util.Map;
/**
 * @author Air
 * @version 1.0
 * @created 2015.07.02 15:37
 */
public class HAHttpsClient implements IHAHttpClient {
    private HAHttpClientImpl haHttpClientImpl;
    private SSLConnectionSocketFactory sslConnectionSocketFactory;
    private RequestConfig requestConfig;
    private HttpClientContext context;
    public HAHttpsClient(SSLConnectionSocketFactory sslConnectionSocketFactory, RequestConfig requestConfig, HttpClientContext context) {
        haHttpClientImpl = new HAHttpClientImpl(requestConfig, context);
        this.sslConnectionSocketFactory = sslConnectionSocketFactory;
    }
    public Response get(String url) {
        return get(url, null);
    }
    public Response get(String url,Map<String,String> header) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.get(httpClient, url,header);
    }
    public Response put(String url) {
        return put(url, null);
    }
    public Response put(String url,Map<String,String> header) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.put(httpClient, url, header);
    }
    public Response postForm(String url, List<NameValuePair> formParams) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.postForm(httpClient, url, formParams);
    }
    public Response postFile(String url, String filePath) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.postFile(httpClient, url, filePath);
    }
}

+ 0 - 241
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HOPClient.java

@ -1,241 +0,0 @@
package com.yihu.ehr.util.http;
import com.yihu.ehr.util.encrypt.MD5;
import com.yihu.ehr.util.file.FileUtil;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.StringUtil;
import org.apache.http.NameValuePair;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.BasicCredentialsProvider;
import sun.misc.BASE64Encoder;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
public class HOPClient {
    static final public String HTTPS = "https";
    static final public String HTTP = "http";
    static private HttpsInitialise initialise = new HttpsInitialise();
    static private RequestConfig requestConfig;
    static private HttpClientContext context;
    private final String version = "1.0";
    private final String signMethod = "md5";
    private String method;
    private String timestamp;
    private String format;
    private String appId;
    private String accessToken;
    private String url;
    private TreeMap<String, String> paramMap;
    private IHAHttpClient ihaHttpClient;
    public HOPClient(String protocol) {
        paramMap = new TreeMap<>();
        if (protocol.equals(HTTPS)) {
            ihaHttpClient = new HAHttpsClient(initialise.getSslConnectionSocketFactory(), requestConfig, context);
        } else {
            ihaHttpClient = new HAHttpClient(requestConfig, context);
        }
    }
    public static void initHttps(String trustStorePath, String password) throws Exception {
        initialise.init(trustStorePath, password);
    }
    public static void initBasciAuth(String username, String password) throws Exception {
        requestConfig = RequestConfig.custom().
                setAuthenticationEnabled(true).build();
        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);
    }
    public void reset() {
        paramMap.clear();
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public void setFormat(String format) {
        this.format = format;
    }
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public void setParam(String key, String value) {
        paramMap.put(key, value);
    }
    public Response get() {
        String completeUrl = completeUrl();
        if (completeUrl == null) {
            return null;
        }
        return ihaHttpClient.get(completeUrl);
    }
    public Response basicPut(String user,String password)
    {
        String completeUrl = completeUrl();
        if (completeUrl == null) {
            return null;
        }
        Map<String,String> header = new HashMap<>();
        String auth  = new BASE64Encoder().encode((user+":"+password).getBytes());
        header.put("Authorization","Basic "+auth);
        return ihaHttpClient.put(completeUrl,header);
    }
    public boolean downLoad(String path) {
        String completeUrl = completeUrl();
        if (completeUrl == null) {
            return false;
        }
        Response response = ihaHttpClient.get(completeUrl);
        if (response == null || response.statusCode != 200) {
            return false;
        }
        try {
            boolean result = FileUtil.writeFile(path, response.body, "UTF-8");
            if (!result) {
                LogUtil.fatal("下载文件失败.");
            }
            return result;
        } catch (IOException e) {
            e.printStackTrace();
            LogUtil.error("下载文件失败:");
            LogUtil.error(e);
        }
        return false;
    }
    public Response postForm(List<NameValuePair> formParams) {
        String completeUrl = completeUrl();
        if (completeUrl == null) {
            return null;
        }
        return ihaHttpClient.postForm(completeUrl, formParams);
    }
    public Response postFile(String filePath) {
        String completeUrl = completeUrl();
        try {
            Response response = ihaHttpClient.postFile(completeUrl, filePath);
            return response;
        } catch (Exception e) {
            LogUtil.fatal(completeUrl);
            return null;
        }
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    private String completeUrl() {
        try {
//            addParam("method", method, true);
            addParam("format", format, false);
            addParam("app_id", appId, true);
            addParam("timestamp", getTimestamp(), true);
            addParam("v", version, true);
            addParam("sign_method", signMethod, true);
            addParam("access_token", accessToken, false);
            addParam("sign", signParam(), true);
            String completeUrl = url +method+ genParam();
            LogUtil.trace(completeUrl);
            return completeUrl;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    private void addParam(String paramName, String paramValue, boolean bMust) throws Exception {
        if (StringUtil.isEmpty(paramValue)) {
            if (bMust) {
                throw new Exception(paramName + "参数不能为空.");
            } else {
                return;
            }
        }
        String encodeValue = URLEncoder.encode(paramValue, "UTF-8");
        paramMap.put(paramName, encodeValue);
    }
    private String signParam() {
        Iterator<Map.Entry<String, String>> iterator = paramMap.entrySet().iterator();
        StringBuilder builder = new StringBuilder();
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            String key = next.getKey();
            String value = next.getValue();
            builder.append(key);
            builder.append(value);
        }
        try {
            return MD5.hash(builder.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    private String genParam() throws Exception {
        Iterator<Map.Entry<String, String>> iterator = paramMap.entrySet().iterator();
        StringBuilder builder = new StringBuilder();
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            String key = next.getKey();
            String value = next.getValue();
            if (value == null) {
                throw new Exception("参数错误:参数" + key + "值为空.");
            }
            if (builder.length() == 0) {
                builder.append("?");
            } else {
                builder.append("&");
            }
            builder.append(key);
            builder.append("=");
            builder.append(URLEncoder.encode(value, "UTF-8"));
        }
        return builder.toString();
    }
    private String getTimestamp() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        timestamp = format.format(new Date());
        return timestamp;
    }
}

+ 0 - 408
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HttpClientUtil.java

@ -1,408 +0,0 @@
package com.yihu.ehr.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.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.util.EntityUtils;
import org.springframework.util.StringUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
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;
    }
    /**
     * 文件上传
     *
     * @param file
     * @param url
     * @param username
     * @param password
     * @return
     * @throws IOException
     */
    public static String sendFile(File file, String url, String username, String password) throws IOException {
        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();
            httpPost.setConfig(requestConfig);
            FileBody bin = new FileBody(file);
            MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
            reqEntity.addPart("file", bin);
            httpPost.setEntity(reqEntity.build());
            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;
    }
    /**
     * 文件下载
     *
     * @param filePath
     * @param url
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static File downFile(String filePath, Map<String, Object> params, String url, String username, String password) throws Exception {
        File file = null;
        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();
            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();
        } finally {
            response.close();
            httpclient.close();
        }
        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"));
        //文件上传
        //File file = new File("F:/111.txt");
        // HttpClientUtil.sendFile(file, "http://192.168.131.6:8890/api/v1.0/resource/upload", "user", "standard");
        //文件下载
        params.put("field", "[{\"key\":\"name\",\"value\":\"资源名称\"},{\"key\":\"code\",\"value\":\"资源代码\"},{\"key\":\"type\",\"value\":\"资源类型\"},{\"key\":\"category\",\"value\":\"资源类别\"}]");
        params.put("name", "授权资源清单");
        params.put("id", "aaaaaaaa1");
        params.put("queryParams", "[]");
        HttpClientUtil.downFile("E:/aaa.xls", params, "http://192.168.131.6:8080/resource/exportAllExcel", "", "");
    }
}

+ 0 - 56
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HttpsInitialise.java

@ -1,56 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContexts;
import javax.net.ssl.SSLContext;
import java.io.File;
/**
 * Https相关环境初始化
 *
 * @author Air
 * @version 1.0
 * @created 2015.07.07 9:21
 */
public class HttpsInitialise {
    private static volatile HttpsInitialise instance = null;
    private SSLContext sslcontext;
    private SSLConnectionSocketFactory sslConnectionSocketFactory;
    public HttpsInitialise() {
    }
    public void finalize() throws Throwable {
    }
    /**
     * 初始化SSLConnectionSocketFactory.
     *
     * @param password       密码
     * @param trustStorePath 信任库路径
     * @throws Exception
     */
    public void init(String trustStorePath, String password) throws Exception {
        sslcontext = SSLContexts.custom()
                .loadTrustMaterial(new File(trustStorePath), password.toCharArray(),
                        new TrustSelfSignedStrategy())
                .build();
        // Allow TLSv1 protocol only
        sslConnectionSocketFactory = new SSLConnectionSocketFactory(
                sslcontext,
                new String[]{"TLSv1"},
                null,
                new HopHostnameVerifier());
    }
    public SSLConnectionSocketFactory getSslConnectionSocketFactory() {
        return sslConnectionSocketFactory;
    }
}

+ 0 - 20
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/IHAHttpClient.java

@ -1,20 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.NameValuePair;
import java.util.List;
import java.util.Map;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.16 9:22
 */
public interface IHAHttpClient {
    Response get(String url);
    Response get(String url,Map<String,String> header);
    Response put(String url);
    Response put(String url,Map<String,String> header);
    Response postForm(String url, List<NameValuePair> formParams);
    Response postFile(String url, String filePath);
}

+ 0 - 20
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/Response.java

@ -1,20 +0,0 @@
package com.yihu.ehr.util.http;
/**
 * @author Air
 * @version 1.0
 * @created 2015.07.02 14:43
 */
public class Response {
    public Response(int statusCode, String body) {
        this.statusCode = statusCode;
        this.body = body;
    }
    public final int statusCode;// e.g. 200
    public final String body;
//    public final String status; // e.g. "200 OK"
//    public final String proto; // e.g. "HTTP/1.0"
//    public final int protoMajor;     // e.g. 1
//    public final int protoMinor;    // e.g. 0
}

+ 258 - 37
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/EsbHttp.java

@ -1,12 +1,27 @@
package com.yihu.ehr.util.httpclient;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.common.config.SysConfig;
import com.yihu.ehr.common.constants.Constants;
import com.yihu.ehr.model.Patient;
import com.yihu.ehr.service.intf.ISystemManager;
import com.yihu.ehr.util.encrypt.MD5;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.ConfigureUtil;
import com.yihu.ehr.util.operator.StringUtil;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import sun.misc.BASE64Encoder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -22,7 +37,7 @@ public class EsbHttp {
     * 用户登录验证
     */
    public static Response loginAction(String user,String password) throws Exception{
        String loginAction = HttpHelper.defaultHttpUrl+"/api/v1.0/authorizations/users/" + user;
        String loginAction = HttpHelper.defaultHttpUrl+"/authorizations/users/" + user;
        Map<String,Object> header = new HashMap<>();
        String auth  = new BASE64Encoder().encode((user+":"+password).getBytes());
        header.put("Authorization","Basic "+auth);
@ -34,7 +49,7 @@ public class EsbHttp {
    * */
    public static Response getUserInfo(String user,String token)
    {
        String url = HttpHelper.defaultHttpUrl+"/api/v1.0/users/" + user;
        String url = HttpHelper.defaultHttpUrl+"/users/" + user;
        Map<String,Object> params = new HashMap<>();
        params.put("token",token);
        params.put("user",user);
@ -43,14 +58,13 @@ public class EsbHttp {
    /***************************** 应用接口 *********************************************/
    private static String fingerprint;
    /**
     * 获取本机指纹
     * @return
     */
    private static String GetFingerprint(){
        try {
            if (fingerprint == null || fingerprint.length() == 0) {
                fingerprint = system.getSystemParam("FINGER_PRINT");
            }
            return fingerprint;
            return system.getSystemParam("FINGER_PRINT");
        }
        catch (Exception e)
        {
@ -58,46 +72,253 @@ public class EsbHttp {
            return "";
        }
    }
    /**
     * 应用登录验证
     */
    public static String getToken() throws Exception{
        String loginAction = HttpHelper.defaultHttpUrl + "/api/v1.0/authorizations/clients/" + HttpHelper.clientId;
        Map<String, Object> header = new HashMap<>();
        header.put("Authorization", "Basic " + HttpHelper.clientKey);
        //本地指纹
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("info", "{\"fingerprint\": \""+GetFingerprint()+"\"}");
        Response response = HttpHelper.put(loginAction, params, header);
        JSONObject obj = new JSONObject(response.body);
        //判断是否成功
        if(obj.has("token"))
    public static String getToken(){
        try {
            String loginAction = HttpHelper.defaultHttpUrl + "/authorizations/clients/" + HttpHelper.clientId;
            Map<String, Object> header = new HashMap<>();
            header.put("Authorization", "Basic " + HttpHelper.clientKey);
            //本地指纹
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("info", "{\"fingerprint\": \"" + GetFingerprint() + "\"}");
            Response response = HttpHelper.put(loginAction, params, header);
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                JSONObject obj = new JSONObject(response.getBody());
                //判断是否成功
                if (obj.has("token")) {
                    return obj.getString("token");
                } else {
                    LogUtil.info("返回未包含token。");
                    return null;
                }
            } else {
                String msg = "获取Token失败。";
                if (response != null) {
                    msg += "(错误代码:" + response.getStatusCode() + ",错误信息:" + response.getBody() + ")";
                }
                LogUtil.info(msg);
                return null;
            }
        }
        catch (Exception ex)
        {
            return obj.getString("token");
            LogUtil.info("获取Token失败," + ex.getMessage());
            return null;
        }
        else{
            throw new Exception("获取token失败!");
    }
    /**
     * 修改远程补传状态
     */
    public static void changeFillMiningStatus(String remoteId,String message, String status){
        try {
            String token = getToken();
            Map<String, Object> paramMap = new HashMap<>();
            paramMap.put("id", remoteId);
            paramMap.put("status", status);
            paramMap.put("message", message);
            paramMap.put("token", token);
            String fillMiningMethod = HttpHelper.defaultHttpUrl + "/simplified-esb/changeFillMiningStatus";
            Response response = HttpHelper.post(fillMiningMethod, paramMap);
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                LogUtil.info("修改远程补传状态成功。");
            }
            else{
                String msg = "修改远程补传状态失败。";
                if (response != null)
                {
                    msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
                }
                LogUtil.info(msg);
            }
        }
        catch (Exception ex)
        {
            LogUtil.info("修改远程补传状态失败." + ex.getMessage());
        }
    }
    public static void changeFillMiningStatus(String remoteId,String message, String status) {
        String token;
    /**
     * 获取公钥
     */
    public static String getPublicKey(){
        try {
            token = getToken();
            String token = getToken();
            if (SysConfig.getInstance().getPublicKey() != null) {
                return SysConfig.getInstance().getPublicKey();
            }
            String orgCode = SysConfig.getInstance().getOrgCode();
            Map<String, Object> paramMap = new HashMap<>();
            paramMap.put("org_code", orgCode);
            paramMap.put("token", token);
            String publicKeyMethod = HttpHelper.defaultHttpUrl + "/organizations/"+orgCode+"/key";
            Response response = HttpHelper.get(publicKeyMethod, paramMap);
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                JSONObject json = new JSONObject(response.getBody());
                if(json.has("publicKey"))
                {
                    String key = json.getString("publicKey");
                    SysConfig.getInstance().setPublicKey(key);
                    return key;
                }
                else{
                    LogUtil.info("获取公钥失败,返回未包含publicKey。");
                    return null;
                }
            }
            else{
                String msg = "获取公钥失败。";
                if (response != null)
                {
                    msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
                }
                LogUtil.info(msg);
                return null;
            }
        } catch (Exception e) {
            LogUtil.info(e.getMessage());
            return null;
        }
    }
    /**
     * 获取健康云平台标准版本号
     */
    public static String getRemoteVersion(String orgCode) {
        try {
            String token = getToken();
            String versionMethod = HttpHelper.defaultHttpUrl + "/adaptions/org_plan/version";
            Map<String, Object> params = new HashMap<>();
            params.put("org_code", orgCode);
            params.put("token", token);
            Response response = HttpHelper.get(versionMethod, params);
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                return response.getBody();
            }
            else{
                String msg = "获取健康云平台标准版本号失败";
                if (response != null)
                {
                    msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
                }
                LogUtil.info(msg);
                return null;
            }
        } catch (Exception e) {
            LogUtil.error("修改远程补传状态时,获取token失败!");
            return;
            LogUtil.fatal("获取远程版本号异常");
            LogUtil.error(e);
            return null;
        }
    }
    /**
     * 注册病人
     */
    public static Boolean register(Patient patient, String data, String token) {
        try {
            String idCord = patient.getIdCard();
            if(StringUtil.isEmpty(idCord))
            {
                LogUtil.info("注册病人信息请求失败:病人无身份证,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
                return false;
            }
            String registerMethod = HttpHelper.defaultHttpUrl + "/patients/"+idCord;
            if (StringUtil.isEmpty(data)) {
                LogUtil.info("注册病人信息请求失败:无具体病人信息,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
                return false;
            }
            Map<String, Object> paramMap = new HashMap<>();
            paramMap.put("demographic_id", idCord);
            paramMap.put("json", data);
            paramMap.put("token", token);
            Response response = HttpHelper.post(registerMethod, paramMap);
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                LogUtil.info("注册病人信息成功。patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
                return true;
            }
            else{
                String msg = "注册病人信息请求失败。patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo();
                if(response != null)
                {
                    msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
                }
                LogUtil.info(msg);
                return false;
            }
        }
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("id", remoteId);
        paramMap.put("status", status);
        paramMap.put("message", message);
        paramMap.put("token", token);
        String fillMiningMethod = HttpHelper.defaultHttpUrl+"/api/v1.0/simplified-esb/changeFillMiningStatus";
        Response response = HttpHelper.post(fillMiningMethod, paramMap);
        if (response == null || response.statusCode != 200) {
            LogUtil.fatal("修改远程补传状态失败,网络错误或者服务器不可用.");
        catch (Exception e)
        {
            LogUtil.info("注册病人信息请求失败."+e.getMessage());
            return false;
        }
    }
    /**
     * 上传病人档案
     */
    public static boolean upload(Patient patient, File file, String encryptPwd, String token) {
        try {
            String uploadMethod = HttpHelper.defaultHttpUrl + "/json_package";
            String fileMd5= MD5.getMd5ByFile(file);
            Map<String, Object> paramMap = new HashMap<>();
            List<NameValuePair> formParams = new ArrayList<>();
            formParams.add(new BasicNameValuePair("md5", fileMd5));
            formParams.add(new BasicNameValuePair("package_crypto", encryptPwd));
            formParams.add(new BasicNameValuePair("org_code", SysConfig.getInstance().getOrgCode()));
            formParams.add(new BasicNameValuePair("token", token));
            Response response = HttpHelper.postFile(uploadMethod, formParams, file.getAbsolutePath());
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                LogUtil.info("上传病人档案成功,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return true;
            }
            else {
                String msg = "上传病人档案请求失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo();
                if (response != null)
                {
                    msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
                }
                LogUtil.info(msg);
                return false;
            }
        }
        catch (Exception e) {
            LogUtil.fatal("上传病人档案异常,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
            LogUtil.error(e);
            return false;
        }
    }
    /**
     * 下载标准包
     */
    public static Response download(String remoteVersion, String orgCode) {
        try {
            String token = getToken();
            String downLoadMethod = HttpHelper.defaultHttpUrl + "/adaptions/"+orgCode+"/source";
            Map<String, Object> params = new HashMap<>();
            params.put("version_code", remoteVersion);
            params.put("org_code", orgCode);
            params.put("token", token);
            Response response = HttpHelper.get(downLoadMethod, params);
            return response;
        } catch (Exception e) {
            LogUtil.fatal("下载标准包异常:");
            LogUtil.error(e);
            return null;
        }
    }

+ 1 - 1
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/http/HopHostnameVerifier.java

@ -1,4 +1,4 @@
package com.yihu.ehr.util.http;
package com.yihu.ehr.util.httpclient;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

+ 30 - 34
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/HttpClientUtil.java

@ -97,7 +97,6 @@ public class HttpClientUtil {
                request.addHeader(key, header.get(key).toString());
            }
        }
        return request;
    }
    /****************************** 公用方法 *******************************************/
@ -127,7 +126,7 @@ public class HttpClientUtil {
            } else {
                response = httpclient.execute(request);
            }
            re.setStatusCode(200);
            re.setStatusCode(response.getStatusLine().getStatusCode());
            re.setBody(EntityUtils.toString(response.getEntity(), "UTF-8"));
        } catch (Exception e) {
            re.setStatusCode(201);
@ -139,10 +138,6 @@ public class HttpClientUtil {
        return re;
    }
    /**
     * 发送文件
     *
@ -151,34 +146,32 @@ public class HttpClientUtil {
     * @param formParams 参数
     * @return
     */
    public static String postFile(String url, String filePath, List<NameValuePair> formParams, String username, String password) {
        CloseableHttpClient httpClient = getCloseableHttpClient(null);
        File file = new File(filePath);
    public static Response postFile(String url, String filePath, List<NameValuePair> formParams,SSLConnectionSocketFactory ssl, String username, String password) {
        Response re = new Response();
        CloseableHttpResponse response = null;
        CloseableHttpClient httpClient = getCloseableHttpClient(ssl);
        //设置请求信息
        RequestConfig requestConfig = RequestConfig.custom().
                setAuthenticationEnabled(true).build();
        //创建httppost请求
        HttpPost httpPost = new HttpPost(url);
        ArrayList<Header> headers = new ArrayList<Header>();
        try{
            File file = new File(filePath);
        httpPost.addHeader(new BasicHeader(HttpHeaders.AUTHORIZATION, "Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P"));
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //创建httppost请求
            HttpPost httpPost = new HttpPost(url);
        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.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());
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            httpPost.setEntity(reqEntity.build());
            //设置验证
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
@ -192,13 +185,16 @@ public class HttpClientUtil {
            } else {
                response = httpClient.execute(httpPost);
            }
            entity = response.getEntity();
            return EntityUtils.toString(entity, "UTF-8");
        } catch (IOException e) {
            return e.getMessage();
            re.setStatusCode(response.getStatusLine().getStatusCode());
            re.setBody(EntityUtils.toString(response.getEntity(), "UTF-8"));;
        } catch (Exception e) {
            re.setStatusCode(201);
            re.setBody(e.getMessage());
            System.out.print(e.getMessage());
        } finally {
            close(httpClient, response);
        }
        return re;
    }
    /**

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

@ -1,6 +1,6 @@
package com.yihu.ehr.util.httpclient;
import com.yihu.ehr.util.http.HopHostnameVerifier;
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;
@ -11,12 +11,10 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
 * Created by hzp on 2016/3/10.
 */
public class HttpHelper {
    private static String defaultPropertiesPath = "config/http.properties";
    private static SSLConnectionSocketFactory defaultSSL;
@ -137,10 +135,12 @@ public class HttpHelper {
    }
    public static Response 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 Response postFile(String url, List<NameValuePair> formParams, String filePath)
    {
        return HttpClientUtil.postFile(url, filePath, formParams, defaultSSL,defaultHttpUser,defaultHttpPassword);
    }
    /************************** Put方法 ******************************************/
    public static Response put(String url)
    {

+ 2 - 2
Hos-Resource-Mini/src/main/java/com.yihu.ehr/util/httpclient/Response.java

@ -14,8 +14,8 @@ public class Response {
        this.body = body;
    }
    public int statusCode;
    public String body;
    private int statusCode;
    private String body;
    public int getStatusCode() {

+ 5 - 7
Hos-Resource-Mini/src/main/resources/config/crawler.properties

@ -2,11 +2,9 @@
agency.name=健康之路
#总支撑平台接口请求
ha.url.standard.getVersion=/rest/v1.0/adapter-dispatcher/versionplan
ha.url.patient.register=/rest/v1.0/patient/registration
ha.url.patient.upload=/rest/v1.0/json_package/
ha.url.security.publicKey.get=/rest/v1.0/security/user_key/
ha.url.security.token.get=/rest/v1.0/security/token
ha.url.standard.allSchemaMappingPlan=/rest/v1.0/adapter-dispatcher/allSchemaMappingPlan
ha.url.user.loginAction=/api/v1.0/authorizations/users
ha.url.standard.getVersion=/api/v1.0/adaptions/version_plan
ha.url.patient.register=/api/v1.0/patient/registration
ha.url.patient.upload=/api/v1.0/packages/
ha.url.security.publicKey.get=/api/v1.0/securities/org_key/
ha.url.standard.allSchemaMappingPlan=/api/v1.0/adaptions/organization/adaption
ha.url.user.org=/api/v1.0/authorizations/users

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

@ -1,5 +1,5 @@
httpUrl = https://ehr.yihu.com
httpUrl = https://172.19.103.73:443/api/v1.0
#https://192.168.131.151:443/
sslKeystore = I:/ssl/tomcat.keystore
sslPassword = 123456

+ 0 - 8
Hos-Resource-Mini/src/main/resources/config/sys.config.xml

@ -1,14 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <debug>true</debug>
    <!--存储模式:轻量模式:0,传统模式:1-->
    <platform>
        <url>https://172.19.103.49:5666/ehr</url>
        <user pwd="123456">2</user>
        <app secret="u2akgXkkRRkiiCVR">gAP3ma6grh</app>
        <trust_store pwd="123456"></trust_store>
        <basic_auth pwd="123456">admin</basic_auth>
    </platform>
    <event_no>
        <item>HDSD03_01_031</item>
        <item>HDSD00_01_579</item>

+ 14 - 10
Hos-Resource-Mini/src/main/webapp/WEB-INF/web.xml

@ -9,6 +9,20 @@
        <listener-class>com.yihu.ehr.common.ApplicationStart</listener-class>
    </listener>
    <!--Spring-->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/applicationContext.xml</param-value>
    </context-param>
    <!--线程-->
    <listener>
        <listener-class>com.yihu.ehr.common.ThreadStart</listener-class>
    </listener>
    <!--servlet设-->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
@ -57,16 +71,6 @@
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--Spring-->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/applicationContext.xml</param-value>
    </context-param>
    <!-- 默认页面 -->
    <welcome-file-list>
        <welcome-file>/indexPage</welcome-file>

+ 10 - 2
Hos-resource/Hos-Resource.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,7 +30,7 @@
    </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: com.yihu.core:ehr-dbhelper:1.1.6" level="project" />
    <orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.1.0" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:1.6.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.1.7.RELEASE" level="project" />

+ 0 - 1
Hos-resource/src/main/webapp/WEB-INF/ehr/jsp/datacollect/editorJob.jsp

@ -34,7 +34,6 @@
    .wizard > .content > .body input.l-hidden{  display:none;  }
    .l-grid-hd-cell-checkbox div{  display: none  }
    .divIntervalOption{display: none;padding-top:10px;}
    .divIntervalOption .label-left{float:left;padding-left:4px;padding-right:4px;height:30px;line-height:30px;}
    .divIntervalOption .l-text{float:left}

+ 6 - 2
Hos-resource/src/main/webapp/WEB-INF/ehr/jsp/datacollect/editorJobJs.jsp

@ -47,9 +47,13 @@
                    }
                },
                onFinishing:function(c,a){
                    debugger
                    editorJob.setCheckVal();
                    return me.verify(4);
                },
                onFinished:function(c,a){
                    editorJob.setCheckVal();
                    me.save();
                },
                onCanceled:function(){
@ -106,7 +110,7 @@
                onCheckRow:function(checked,data,rowid,rowdata)
                {
                    var selected = me.$listPlan.getSelectedRow();
                    if(selected)
                    if(selected!=null && selected.length>0)
                    {
                        $("#txtSchemeId").val(selected.schemeId);
                        $("#txtSchemeVersion").val(selected.version);
@ -627,7 +631,7 @@
        setCheckVal:function(){
            var me = this;
            var selected = me.$listDataset.getSelectedRows();
            if(selected)
            if(selected!=null && selected.length>0)
            {
                $("#txtJobDataset").val(JSON.stringify(selected));
            }