|
@ -5,9 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.yihu.hos.core.datatype.StringUtil;
|
|
import com.yihu.hos.core.datatype.StringUtil;
|
|
import com.yihu.hos.core.encrypt.MD5;
|
|
import com.yihu.hos.core.encrypt.MD5;
|
|
import com.yihu.hos.core.httpclient.HttpClientUtil;
|
|
|
|
import com.yihu.hos.core.httpclient.HttpHelper;
|
|
|
|
import com.yihu.hos.core.httpclient.HttpResponse;
|
|
|
|
|
|
import com.yihu.hos.core.http.HTTPResponse;
|
|
|
|
import com.yihu.hos.core.http.HttpClientKit;
|
|
import com.yihu.hos.core.log.Logger;
|
|
import com.yihu.hos.core.log.Logger;
|
|
import com.yihu.hos.core.log.LoggerFactory;
|
|
import com.yihu.hos.core.log.LoggerFactory;
|
|
import com.yihu.hos.crawler.model.adapter.AdapterDataSet;
|
|
import com.yihu.hos.crawler.model.adapter.AdapterDataSet;
|
|
@ -16,13 +15,14 @@ import com.yihu.hos.crawler.model.patient.Patient;
|
|
import com.yihu.hos.crawler.model.transform.EhrCondition;
|
|
import com.yihu.hos.crawler.model.transform.EhrCondition;
|
|
import com.yihu.hos.web.framework.constrant.SqlConstants;
|
|
import com.yihu.hos.web.framework.constrant.SqlConstants;
|
|
import org.apache.http.HttpStatus;
|
|
import org.apache.http.HttpStatus;
|
|
import org.apache.http.NameValuePair;
|
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
import sun.misc.BASE64Encoder;
|
|
import sun.misc.BASE64Encoder;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by hzp on 2016/3/10.
|
|
* Created by hzp on 2016/3/10.
|
|
@ -30,43 +30,45 @@ import java.util.*;
|
|
public class EsbHttp {
|
|
public class EsbHttp {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(EsbHttp.class);
|
|
private static Logger logger = LoggerFactory.getLogger(EsbHttp.class);
|
|
|
|
public static String defaultHttpUrl = "";
|
|
|
|
public static String clientId = "";
|
|
|
|
public static String clientKey = "";
|
|
|
|
public static String httpGateway = "";
|
|
|
|
|
|
/***************************** 用户接口 *********************************************/
|
|
/***************************** 用户接口 *********************************************/
|
|
/**
|
|
/**
|
|
* 用户登录验证
|
|
* 用户登录验证
|
|
*/
|
|
*/
|
|
public static HttpResponse loginAction(String user, String password) throws Exception{
|
|
|
|
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);
|
|
|
|
return HttpHelper.put(loginAction, null, header);
|
|
|
|
|
|
public static HTTPResponse loginAction(String user, String password) throws Exception {
|
|
|
|
String loginAction = defaultHttpUrl + "/authorizations/users/" + user;
|
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
|
String auth = new BASE64Encoder().encode((user + ":" + password).getBytes());
|
|
|
|
header.put("Authorization", "Basic " + auth);
|
|
|
|
return HttpClientKit.put(loginAction, null, header);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
* 获取用户信息
|
|
* 获取用户信息
|
|
* */
|
|
* */
|
|
public static HttpResponse getUserInfo(String user,String token)
|
|
|
|
{
|
|
|
|
String url = HttpHelper.defaultHttpUrl+"/users/" + user;
|
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
|
params.put("token",token);
|
|
|
|
params.put("user",user);
|
|
|
|
return HttpHelper.get(url, params);
|
|
|
|
|
|
public static HTTPResponse getUserInfo(String user, String token) {
|
|
|
|
String url = defaultHttpUrl + "/users/" + user;
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
params.put("token", token);
|
|
|
|
params.put("user", user);
|
|
|
|
return HttpClientKit.get(url, params);
|
|
}
|
|
}
|
|
|
|
|
|
/***************************** 应用接口 *********************************************/
|
|
/***************************** 应用接口 *********************************************/
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取本机指纹
|
|
* 获取本机指纹
|
|
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private static String GetFingerprint(){
|
|
|
|
|
|
private static String GetFingerprint() {
|
|
try {
|
|
try {
|
|
return UUID.randomUUID().toString();
|
|
return UUID.randomUUID().toString();
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
|
|
} catch (Exception e) {
|
|
System.out.print(e.getMessage());
|
|
System.out.print(e.getMessage());
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
@ -75,16 +77,16 @@ public class EsbHttp {
|
|
/**
|
|
/**
|
|
* 应用登录验证
|
|
* 应用登录验证
|
|
*/
|
|
*/
|
|
public static String getToken(){
|
|
|
|
|
|
public static String getToken() {
|
|
try {
|
|
try {
|
|
String loginAction = HttpHelper.defaultHttpUrl + "/authorizations/clients/" + HttpHelper.clientId;
|
|
|
|
Map<String, Object> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + HttpHelper.clientKey);
|
|
|
|
|
|
String loginAction = defaultHttpUrl + "/authorizations/clients/" + clientId;
|
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + clientKey);
|
|
//本地指纹
|
|
//本地指纹
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
params.put("info", "{\"fingerprint\": \"" + GetFingerprint() + "\"}");
|
|
params.put("info", "{\"fingerprint\": \"" + GetFingerprint() + "\"}");
|
|
|
|
|
|
HttpResponse response = HttpHelper.put(loginAction, params, header);
|
|
|
|
|
|
HTTPResponse response = HttpClientKit.put(loginAction, params, header);
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
JSONObject obj = new JSONObject(response.getBody());
|
|
JSONObject obj = new JSONObject(response.getBody());
|
|
//判断是否成功
|
|
//判断是否成功
|
|
@ -103,9 +105,7 @@ public class EsbHttp {
|
|
logger.info(msg);
|
|
logger.info(msg);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
|
|
} catch (Exception ex) {
|
|
logger.info("获取Token失败," + ex.getMessage());
|
|
logger.info("获取Token失败," + ex.getMessage());
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@ -114,7 +114,7 @@ public class EsbHttp {
|
|
/**
|
|
/**
|
|
* 获取病人列表
|
|
* 获取病人列表
|
|
*/
|
|
*/
|
|
public static String getPatientList(AdapterDataSet adapterDataSet, List<EhrCondition> queryParams){
|
|
|
|
|
|
public static String getPatientList(AdapterDataSet adapterDataSet, List<EhrCondition> queryParams) {
|
|
try {
|
|
try {
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectNode paramsNode = mapper.createObjectNode();
|
|
ObjectNode paramsNode = mapper.createObjectNode();
|
|
@ -122,11 +122,11 @@ public class EsbHttp {
|
|
paramsNode.put("tableCode", adapterDataSet.getAdapterDataSetT().getStdDatasetCode());
|
|
paramsNode.put("tableCode", adapterDataSet.getAdapterDataSetT().getStdDatasetCode());
|
|
paramsNode.put("condition", mapper.writeValueAsString(queryParams));
|
|
paramsNode.put("condition", mapper.writeValueAsString(queryParams));
|
|
|
|
|
|
List<NameValuePair> formParams = new ArrayList<>();
|
|
|
|
formParams.add(new BasicNameValuePair("api", "collectionData"));
|
|
|
|
|
|
Map<String, String> formParams = new HashMap<>();
|
|
|
|
formParams.put("api", "collectionData");
|
|
String params = mapper.writeValueAsString(paramsNode);
|
|
String params = mapper.writeValueAsString(paramsNode);
|
|
formParams.add(new BasicNameValuePair("param", params));
|
|
|
|
HttpResponse response = HttpClientUtil.postForm(HttpHelper.httpGateway, formParams);
|
|
|
|
|
|
formParams.put("param", params);
|
|
|
|
HTTPResponse response = HttpClientKit.post(httpGateway, formParams);
|
|
if (response == null || response.getStatusCode() != 200) {
|
|
if (response == null || response.getStatusCode() != 200) {
|
|
logger.error("获取病人列表错误,请求HTTP错误,请检查配置或HTTP是否可用.");
|
|
logger.error("获取病人列表错误,请求HTTP错误,请检查配置或HTTP是否可用.");
|
|
return "";
|
|
return "";
|
|
@ -151,9 +151,9 @@ public class EsbHttp {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static String getFecthData(List<NameValuePair> formParams) {
|
|
|
|
|
|
public static String getFecthData(Map<String, String> formParams) {
|
|
try {
|
|
try {
|
|
HttpResponse response = HttpClientUtil.postForm(HttpHelper.httpGateway, formParams);
|
|
|
|
|
|
HTTPResponse response = HttpClientKit.post(httpGateway, formParams);
|
|
if (response == null || response.getStatusCode() != 200) {
|
|
if (response == null || response.getStatusCode() != 200) {
|
|
logger.info("获取病人数据错误,请求HTTP错误,请检查配置或HTTP是否可用.");
|
|
logger.info("获取病人数据错误,请求HTTP错误,请检查配置或HTTP是否可用.");
|
|
return SqlConstants.EMPTY;
|
|
return SqlConstants.EMPTY;
|
|
@ -177,41 +177,38 @@ public class EsbHttp {
|
|
return SqlConstants.EMPTY;
|
|
return SqlConstants.EMPTY;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
|
|
* 获取公钥
|
|
|
|
*/
|
|
|
|
public static String getPublicKey(String orgCode){
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取公钥
|
|
|
|
*/
|
|
|
|
public static String getPublicKey(String orgCode) {
|
|
try {
|
|
try {
|
|
String token = getToken();
|
|
String token = getToken();
|
|
if (!StringUtil.isEmpty(SysConfig.getInstance().getPublicKeyMap().get(orgCode))) {
|
|
if (!StringUtil.isEmpty(SysConfig.getInstance().getPublicKeyMap().get(orgCode))) {
|
|
return SysConfig.getInstance().getPublicKeyMap().get(orgCode);
|
|
return SysConfig.getInstance().getPublicKeyMap().get(orgCode);
|
|
}
|
|
}
|
|
Map<String, Object> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + HttpHelper.clientKey);
|
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + clientKey);
|
|
|
|
Map<String, String> paramMap = new HashMap<>();
|
|
paramMap.put("org_code", orgCode);
|
|
paramMap.put("org_code", orgCode);
|
|
paramMap.put("token", token);
|
|
paramMap.put("token", token);
|
|
String publicKeyMethod = HttpHelper.defaultHttpUrl + "/organizations/"+orgCode+"/key";
|
|
|
|
HttpResponse response = HttpHelper.get(publicKeyMethod, paramMap, header);
|
|
|
|
|
|
String publicKeyMethod = defaultHttpUrl + "/organizations/" + orgCode + "/key";
|
|
|
|
HTTPResponse response = HttpClientKit.get(publicKeyMethod, paramMap, header);
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
JSONObject json = new JSONObject(response.getBody());
|
|
JSONObject json = new JSONObject(response.getBody());
|
|
if(json.has("publicKey"))
|
|
|
|
{
|
|
|
|
|
|
if (json.has("publicKey")) {
|
|
String publicKey = json.getString("publicKey");
|
|
String publicKey = json.getString("publicKey");
|
|
SysConfig.getInstance().getPublicKeyMap().put(orgCode, publicKey);
|
|
SysConfig.getInstance().getPublicKeyMap().put(orgCode, publicKey);
|
|
return publicKey;
|
|
return publicKey;
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
logger.info("获取公钥失败,返回未包含publicKey。");
|
|
logger.info("获取公钥失败,返回未包含publicKey。");
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
String msg = "获取公钥失败。";
|
|
String msg = "获取公钥失败。";
|
|
|
|
|
|
if (response != null)
|
|
|
|
{
|
|
|
|
msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
|
|
|
|
|
|
if (response != null) {
|
|
|
|
msg += "(错误代码:" + response.getStatusCode() + ",错误信息:" + response.getBody() + ")";
|
|
}
|
|
}
|
|
logger.info(msg);
|
|
logger.info(msg);
|
|
return null;
|
|
return null;
|
|
@ -228,22 +225,20 @@ public class EsbHttp {
|
|
public static String getRemoteVersion(String orgCode) {
|
|
public static String getRemoteVersion(String orgCode) {
|
|
try {
|
|
try {
|
|
String token = getToken();
|
|
String token = getToken();
|
|
String versionMethod = HttpHelper.defaultHttpUrl + "/adaptions/org_plan/version";
|
|
|
|
Map<String, Object> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + HttpHelper.clientKey);
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
String versionMethod = defaultHttpUrl + "/adaptions/org_plan/version";
|
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + clientKey);
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
params.put("org_code", orgCode);
|
|
params.put("org_code", orgCode);
|
|
params.put("token", token);
|
|
params.put("token", token);
|
|
HttpResponse response = HttpHelper.get(versionMethod, params, header);
|
|
|
|
|
|
HTTPResponse response = HttpClientKit.get(versionMethod, params, header);
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
return response.getBody();
|
|
return response.getBody();
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
String msg = "获取健康云平台标准版本号失败";
|
|
String msg = "获取健康云平台标准版本号失败";
|
|
|
|
|
|
if (response != null)
|
|
|
|
{
|
|
|
|
msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
|
|
|
|
|
|
if (response != null) {
|
|
|
|
msg += "(错误代码:" + response.getStatusCode() + ",错误信息:" + response.getBody() + ")";
|
|
}
|
|
}
|
|
logger.info(msg);
|
|
logger.info(msg);
|
|
|
|
|
|
@ -264,51 +259,45 @@ public class EsbHttp {
|
|
try {
|
|
try {
|
|
JSONObject json = new JSONObject(data);
|
|
JSONObject json = new JSONObject(data);
|
|
String colName = SysConfig.registerIdCardNo;
|
|
String colName = SysConfig.registerIdCardNo;
|
|
Map<String, Object> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + HttpHelper.clientKey);
|
|
|
|
header.put("User-Agent", "client " + HttpHelper.clientId);
|
|
|
|
if(json!=null && json.has("data")) {
|
|
|
|
JSONObject p = (JSONObject)json.getJSONArray("data").get(0);
|
|
|
|
if(!p.has(colName) || StringUtil.isEmpty(p.get(colName))) {
|
|
|
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + clientKey);
|
|
|
|
header.put("User-Agent", "client " + clientId);
|
|
|
|
if (json != null && json.has("data")) {
|
|
|
|
JSONObject p = (JSONObject) json.getJSONArray("data").get(0);
|
|
|
|
if (!p.has(colName) || StringUtil.isEmpty(p.get(colName))) {
|
|
logger.info("注册病人信息请求失败:身份证号码为空,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
|
|
logger.info("注册病人信息请求失败:身份证号码为空,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
|
|
return false;
|
|
return false;
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
String idCord = p.getString(colName);
|
|
String idCord = p.getString(colName);
|
|
String registerMethod = HttpHelper.defaultHttpUrl + "/patients/"+idCord;
|
|
|
|
|
|
String registerMethod = defaultHttpUrl + "/patients/" + idCord;
|
|
if (StringUtil.isEmpty(data)) {
|
|
if (StringUtil.isEmpty(data)) {
|
|
logger.info("注册病人信息请求失败:无具体病人信息,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
|
|
logger.info("注册病人信息请求失败:无具体病人信息,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>();
|
|
paramMap.put("demographic_id", idCord);
|
|
paramMap.put("demographic_id", idCord);
|
|
paramMap.put("json", data);
|
|
paramMap.put("json", data);
|
|
paramMap.put("token", token);
|
|
paramMap.put("token", token);
|
|
HttpResponse response = HttpHelper.post(registerMethod, paramMap, header);
|
|
|
|
|
|
HTTPResponse response = HttpClientKit.post(registerMethod, paramMap, header);
|
|
|
|
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
logger.info("注册病人信息成功。patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
logger.info("注册病人信息成功。patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
return true;
|
|
return true;
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
String msg = "注册病人信息请求失败。patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo();
|
|
String msg = "注册病人信息请求失败。patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo();
|
|
if(response != null)
|
|
|
|
{
|
|
|
|
msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
|
|
|
|
|
|
if (response != null) {
|
|
|
|
msg += "(错误代码:" + response.getStatusCode() + ",错误信息:" + response.getBody() + ")";
|
|
}
|
|
}
|
|
logger.info(msg);
|
|
logger.info(msg);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
logger.info("注册病人信息请求失败:传入数据无效,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
|
|
logger.info("注册病人信息请求失败:传入数据无效,patient_id=" + patient.getPatientId() + ", event_no=" + patient.getEventNo());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
|
|
} catch (Exception e) {
|
|
logger.info("注册病人信息请求失败." + e.getMessage());
|
|
logger.info("注册病人信息请求失败." + e.getMessage());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@ -319,34 +308,31 @@ public class EsbHttp {
|
|
*/
|
|
*/
|
|
public static boolean upload(Patient patient, File file, String encryptPwd, String token) {
|
|
public static boolean upload(Patient patient, File file, String encryptPwd, String token) {
|
|
try {
|
|
try {
|
|
String uploadMethod = HttpHelper.defaultHttpUrl + "/packages";
|
|
|
|
String fileMd5= MD5.getMd5ByFile(file);
|
|
|
|
List<NameValuePair> formParams = new ArrayList<>();
|
|
|
|
formParams.add(new BasicNameValuePair("md5", fileMd5));
|
|
|
|
formParams.add(new BasicNameValuePair("package_crypto", encryptPwd));
|
|
|
|
formParams.add(new BasicNameValuePair("org_code", patient.getOrgCode()));
|
|
|
|
formParams.add(new BasicNameValuePair("token", token));
|
|
|
|
Map<String, Object> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + HttpHelper.clientKey);
|
|
|
|
header.put("User-Agent", "client " + HttpHelper.clientId);
|
|
|
|
HttpResponse response = HttpHelper.postFile(uploadMethod, formParams, file.getAbsolutePath(), header);
|
|
|
|
|
|
String uploadMethod = defaultHttpUrl + "/packages";
|
|
|
|
String fileMd5 = MD5.getMd5ByFile(file);
|
|
|
|
Map<String, String> formParams = new HashMap<>();
|
|
|
|
formParams.put("md5", fileMd5);
|
|
|
|
formParams.put("package_crypto", encryptPwd);
|
|
|
|
formParams.put("org_code", patient.getOrgCode());
|
|
|
|
formParams.put("token", token);
|
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + clientKey);
|
|
|
|
header.put("User-Agent", "client " + clientId);
|
|
|
|
HTTPResponse response = HttpClientKit.postFile(uploadMethod, file.getAbsolutePath(), formParams, header);
|
|
|
|
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
|
|
logger.info("上传病人档案成功,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
|
|
logger.info("上传病人档案成功,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
|
|
return true;
|
|
return true;
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
} else {
|
|
String msg = "上传病人档案请求失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo();
|
|
String msg = "上传病人档案请求失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo();
|
|
|
|
|
|
if (response != null)
|
|
|
|
{
|
|
|
|
msg +="(错误代码:"+ response.getStatusCode() + ",错误信息:"+response.getBody()+")";
|
|
|
|
|
|
if (response != null) {
|
|
|
|
msg += "(错误代码:" + response.getStatusCode() + ",错误信息:" + response.getBody() + ")";
|
|
}
|
|
}
|
|
logger.info(msg);
|
|
logger.info(msg);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
|
|
} catch (Exception e) {
|
|
logger.info("上传病人档案异常,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
|
|
logger.info("上传病人档案异常,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
|
|
logger.error(e.getCause().toString());
|
|
logger.error(e.getCause().toString());
|
|
return false;
|
|
return false;
|
|
@ -357,17 +343,17 @@ public class EsbHttp {
|
|
/**
|
|
/**
|
|
* 下载标准包
|
|
* 下载标准包
|
|
*/
|
|
*/
|
|
public static HttpResponse download(String remoteVersion, String orgCode) {
|
|
|
|
|
|
public static HTTPResponse download(String remoteVersion, String orgCode) {
|
|
try {
|
|
try {
|
|
String token = getToken();
|
|
String token = getToken();
|
|
String downLoadMethod = HttpHelper.defaultHttpUrl + "/adaptions/"+orgCode+"/source";
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
String downLoadMethod = defaultHttpUrl + "/adaptions/" + orgCode + "/source";
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
params.put("version_code", remoteVersion);
|
|
params.put("version_code", remoteVersion);
|
|
params.put("org_code", orgCode);
|
|
params.put("org_code", orgCode);
|
|
params.put("token", token);
|
|
params.put("token", token);
|
|
Map<String, Object> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + HttpHelper.clientKey);
|
|
|
|
HttpResponse response = HttpHelper.get(downLoadMethod, params, header);
|
|
|
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
|
header.put("Authorization", "Basic " + clientKey);
|
|
|
|
HTTPResponse response = HttpClientKit.get(downLoadMethod, params, header);
|
|
return response;
|
|
return response;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
logger.info("下载标准包异常:");
|
|
logger.info("下载标准包异常:");
|