|
|
@ -2,9 +2,11 @@ package com.ynxbd.wx.pwe; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ynxbd.common.helper.common.CodeHelper; |
|
|
|
import com.ynxbd.common.helper.common.CodeHelper; |
|
|
|
|
|
|
|
import com.ynxbd.common.helper.common.DateHelper; |
|
|
|
import com.ynxbd.common.helper.common.URLHelper; |
|
|
|
import com.ynxbd.common.helper.common.URLHelper; |
|
|
|
import com.ynxbd.common.helper.http.OkHttpHelper; |
|
|
|
import com.ynxbd.common.helper.http.OkHttpHelper; |
|
|
|
import com.ynxbd.common.result.ServiceException; |
|
|
|
import com.ynxbd.common.result.ServiceException; |
|
|
|
|
|
|
|
import com.ynxbd.wx.pwe.bean.PWEToken; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
@ -39,7 +41,13 @@ public class PWEHelper { |
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
params.put("data", data); |
|
|
|
params.put("data", data); |
|
|
|
params.put("header", header); |
|
|
|
params.put("header", header); |
|
|
|
}, null); |
|
|
|
}, headers -> { |
|
|
|
|
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
|
|
|
|
headers.add("god-portal-signature", toHmacSha256Example(PWEConfig.PARTNER_SECRET, (PWEConfig.PARTNER_ID + timestamp))); |
|
|
|
|
|
|
|
headers.add("god-portal-timestamp", timestamp); |
|
|
|
|
|
|
|
headers.add("god-portal-request-id", CodeHelper.get32UUID()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
String code = resultJson.getString("retcode"); |
|
|
|
String code = resultJson.getString("retcode"); |
|
|
|
String message = resultJson.getString("retmsg"); |
|
|
|
String message = resultJson.getString("retmsg"); |
|
|
|
String reqId = resultJson.getString("request_id"); |
|
|
|
String reqId = resultJson.getString("request_id"); |
|
|
@ -58,7 +66,6 @@ public class PWEHelper { |
|
|
|
throw new ServiceException("[8.1.获取打开小程序短链]获取到的链接为空"); |
|
|
|
throw new ServiceException("[8.1.获取打开小程序短链]获取到的链接为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
return urlLink; |
|
|
|
return urlLink; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -107,42 +114,53 @@ public class PWEHelper { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* [医生端]获取预问诊报告链接 |
|
|
|
* [医生端]获取预问诊报告链接 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String getPWEReportUrl(String departmentId, String doctorId, String doctorName, String registeredId) throws ServiceException { |
|
|
|
public static Map<String, Object> getPWEReportUrl(String departmentId, String doctorId, String doctorName, String registeredId) throws ServiceException { |
|
|
|
String token = getPWEHisToken(doctorId, doctorName); |
|
|
|
PWEToken pweToken = getPWEHisToken(doctorId, doctorName); |
|
|
|
|
|
|
|
|
|
|
|
String params = URLHelper.mapToUrl(map -> { |
|
|
|
String params = URLHelper.mapToUrl(map -> { |
|
|
|
map.put("token", token); |
|
|
|
map.put("token", pweToken.getToken()); |
|
|
|
map.put("registeredId", registeredId); |
|
|
|
map.put("registeredid", registeredId); |
|
|
|
map.put("departmentId", departmentId); |
|
|
|
map.put("departmentId", departmentId); |
|
|
|
map.put("doctorId", doctorId); |
|
|
|
map.put("doctorId", filterDoctorId(doctorId)); |
|
|
|
}, true); |
|
|
|
}, true); |
|
|
|
|
|
|
|
|
|
|
|
String url = PWEConfig.IS_DEV |
|
|
|
String url = PWEConfig.IS_DEV |
|
|
|
? "https://dev-aimedical.wecity.qq.com/toolbox/prediagnosis.html" |
|
|
|
? "https://dev-aimedical.wecity.qq.com/toolbox/prediagnosis.html" |
|
|
|
: "https://aimedical.wecity.qq.com/toolbox/prediagnosis.html"; |
|
|
|
: "https://aimedical.wecity.qq.com/toolbox/prediagnosis.html"; |
|
|
|
return url + params; |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("createTime", DateHelper.getCurDateTime()); |
|
|
|
|
|
|
|
map.put("url", (url + params)); |
|
|
|
|
|
|
|
map.put("expiresIn", pweToken.getExpiresIn()); |
|
|
|
|
|
|
|
return map; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 7.2.1 通过 HisToolLoginIn 接口获取 token |
|
|
|
* 7.2.1 通过 HisToolLoginIn 接口获取 token |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static String getPWEHisToken(String doctorId, String doctorName) throws ServiceException { |
|
|
|
private static PWEToken getPWEHisToken(String doctorId, String doctorName) throws ServiceException { |
|
|
|
String url = PWEConfig.IS_DEV |
|
|
|
String url = PWEConfig.IS_DEV |
|
|
|
? "https://dev-aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/RationalDrugServer/RationalDrugServant/HisToolLogin" |
|
|
|
? "https://dev-aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/RationalDrugServer/RationalDrugServant/HisToolLogin" |
|
|
|
: "https://aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/RationalDrugServer/RationalDrugServant/HisToolLogin"; |
|
|
|
: "https://aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/RationalDrugServer/RationalDrugServant/HisToolLogin"; |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
data.put("partner_id", PWEConfig.PARTNER_ID); |
|
|
|
data.put("partner_id", PWEConfig.PARTNER_ID); |
|
|
|
data.put("doctor_id", doctorId); |
|
|
|
data.put("doctor_id", filterDoctorId(doctorId)); |
|
|
|
data.put("doctor_name", doctorName); |
|
|
|
data.put("doctor_name", doctorName); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> header = new HashMap<>(); |
|
|
|
Map<String, Object> header = new HashMap<>(); |
|
|
|
header.put("hospital_id", PWEConfig.HOSPITAL_ID); |
|
|
|
header.put("hospital_id", PWEConfig.HOSPITAL_ID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("[HisToolLoginIn 获取 token] 入参:{data:{}, header:{}}", data, header); |
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
params.put("data", data); |
|
|
|
params.put("data", data); |
|
|
|
params.put("header", header); |
|
|
|
params.put("header", header); |
|
|
|
}, null); |
|
|
|
}, headers -> { |
|
|
|
|
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
|
|
|
|
headers.add("god-portal-signature", toHmacSha256Example(PWEConfig.SECRET_KEY, (PWEConfig.HOSPITAL_ID + timestamp))); |
|
|
|
|
|
|
|
headers.add("god-portal-timestamp", timestamp); |
|
|
|
|
|
|
|
headers.add("god-portal-request-id", CodeHelper.get32UUID()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
String code = resultJson.getString("retcode"); |
|
|
|
String code = resultJson.getString("retcode"); |
|
|
|
String message = resultJson.getString("retmsg"); |
|
|
|
String message = resultJson.getString("retmsg"); |
|
|
@ -156,12 +174,16 @@ public class PWEHelper { |
|
|
|
throw new ServiceException("[HisToolLoginIn 获取 token]data返回为空"); |
|
|
|
throw new ServiceException("[HisToolLoginIn 获取 token]data返回为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
String token = dataJson.getString("token"); |
|
|
|
String token = dataJson.getString("token"); |
|
|
|
String expiresIn = dataJson.getString("expires_in"); |
|
|
|
Integer expiresIn = dataJson.getInteger("expires_in"); |
|
|
|
log.info("[HisToolLoginIn 获取 token][rid:{}] token=[{}] expires_in={}", reqId, token, expiresIn); |
|
|
|
log.info("[HisToolLoginIn 获取 token][rid:{}] token=[{}] expires_in={}", reqId, token, expiresIn); |
|
|
|
if (ObjectUtils.isEmpty(token)) { |
|
|
|
if (ObjectUtils.isEmpty(token)) { |
|
|
|
throw new ServiceException("[HisToolLoginIn 获取 token]token为空"); |
|
|
|
throw new ServiceException("[HisToolLoginIn 获取 token]token为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
return token; |
|
|
|
|
|
|
|
|
|
|
|
PWEToken pweToken = new PWEToken(); |
|
|
|
|
|
|
|
pweToken.setToken(token); |
|
|
|
|
|
|
|
pweToken.setExpiresIn(expiresIn); |
|
|
|
|
|
|
|
return pweToken; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// public static void post(String url, OkHttpHelper.MapParams params) {
|
|
|
|
// public static void post(String url, OkHttpHelper.MapParams params) {
|
|
|
@ -175,33 +197,12 @@ public class PWEHelper { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
public static JSONObject post(String url, OkHttpHelper.MapParams params, OkHttpHelper.Header header) { |
|
|
|
public static JSONObject post(String url, OkHttpHelper.MapParams params, OkHttpHelper.Header header) { |
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
return OkHttpHelper.postJson(url, params, header); |
|
|
|
return OkHttpHelper.postJson(url, params, headers -> { |
|
|
|
|
|
|
|
headers.add("god-portal-signature", toHmacSha256Example(PWEConfig.PARTNER_SECRET, (PWEConfig.PARTNER_ID + timestamp))); |
|
|
|
|
|
|
|
headers.add("god-portal-timestamp", timestamp); |
|
|
|
|
|
|
|
headers.add("god-portal-request-id", CodeHelper.get32UUID()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
public static String filterDoctorId(String doctorId) { |
|
|
|
// getUrl();
|
|
|
|
return ("*".equals(doctorId) ? "0" : doctorId); |
|
|
|
// System.out.println(System.currentTimeMillis());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// post("http://127.0.0.1:9090/micro/test_q/post_json", map -> {
|
|
|
|
|
|
|
|
// map.put("a", "1");
|
|
|
|
|
|
|
|
// map.put("b", "1");
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
|
|
|
|
String sign = PWEHelper.toHmacSha256Example(PWEConfig.PARTNER_SECRET, (PWEConfig.PARTNER_ID + timestamp)); |
|
|
|
|
|
|
|
log.info("timestamp={}, sign={}, uuid={}", timestamp, sign, CodeHelper.get32UUID()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//
|
|
|
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 签名验证 |
|
|
|
* 签名验证 |
|
|
@ -277,4 +278,95 @@ public class PWEHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static JSONObject getDiagnosisReportByCaseId(String registerId, String doctorId, String doctorName, String departmentId, String departmentName) throws ServiceException { |
|
|
|
|
|
|
|
String url = PWEConfig.IS_DEV |
|
|
|
|
|
|
|
? "https://dev-aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/DiagnosisAssistServer/DiagnosisAssistServant/GetPreDiagnosisReportByCaseId" |
|
|
|
|
|
|
|
: "https://aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/DiagnosisAssistServer/DiagnosisAssistServant/GetPreDiagnosisReportByCaseId"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
|
|
|
|
data.put("partnerId", PWEConfig.PARTNER_ID); |
|
|
|
|
|
|
|
data.put("caseId", registerId); |
|
|
|
|
|
|
|
data.put("doctorId", doctorId); |
|
|
|
|
|
|
|
data.put("doctorName", doctorName); |
|
|
|
|
|
|
|
data.put("departmentId", departmentId); |
|
|
|
|
|
|
|
data.put("departmentName", departmentName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> header = new HashMap<>(); |
|
|
|
|
|
|
|
header.put("hospitalId", PWEConfig.HOSPITAL_ID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("[7.3.1 通过 GetDiagnosisReportByCaseId 接口获取数据] 入参:data={}, header={}", data, header); |
|
|
|
|
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
|
|
|
|
params.put("data", data); |
|
|
|
|
|
|
|
params.put("header", header); |
|
|
|
|
|
|
|
}, headers -> { |
|
|
|
|
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
|
|
|
|
headers.add("god-portal-signature", toHmacSha256Example(PWEConfig.SECRET_KEY, (PWEConfig.HOSPITAL_ID + timestamp))); |
|
|
|
|
|
|
|
headers.add("god-portal-timestamp", timestamp); |
|
|
|
|
|
|
|
headers.add("god-portal-request-id", CodeHelper.get32UUID()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String code = resultJson.getString("retcode"); |
|
|
|
|
|
|
|
String message = resultJson.getString("retmsg"); |
|
|
|
|
|
|
|
String reqId = resultJson.getString("request_id"); |
|
|
|
|
|
|
|
if (!"0".equals(code)) { |
|
|
|
|
|
|
|
log.error("[7.3.1 通过 GetDiagnosisReportByCaseId 接口获取数据]失败[rid:{}] code={}, message={}", reqId, code, message); |
|
|
|
|
|
|
|
throw new ServiceException(message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JSONObject dataJson = resultJson.getJSONObject("data"); |
|
|
|
|
|
|
|
if (dataJson == null) { |
|
|
|
|
|
|
|
throw new ServiceException("[7.3.1 通过 GetDiagnosisReportByCaseId 接口获取数据]data返回为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return dataJson; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 7.3.2 通过 GetPreDiagnosisReportDialogues 接口获取对话记录 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static JSONObject getPreDiagnosisReportDialogues(String registerId, String doctorId, String doctorName, String departmentId, String departmentName) throws ServiceException { |
|
|
|
|
|
|
|
String url = PWEConfig.IS_DEV |
|
|
|
|
|
|
|
? "https://dev-aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/DiagnosisAssistServer/DiagnosisAssistServant/GetPreDiagnosisReportDialogues" |
|
|
|
|
|
|
|
: "https://aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/DiagnosisAssistServer/DiagnosisAssistServant/GetPreDiagnosisReportDialogues"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
|
|
|
|
data.put("partnerId", PWEConfig.PARTNER_ID); |
|
|
|
|
|
|
|
data.put("caseId", registerId); |
|
|
|
|
|
|
|
data.put("doctorId", doctorId); |
|
|
|
|
|
|
|
data.put("doctorName", doctorName); |
|
|
|
|
|
|
|
data.put("departmentId", departmentId); |
|
|
|
|
|
|
|
data.put("departmentName", departmentName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> header = new HashMap<>(); |
|
|
|
|
|
|
|
header.put("hospitalId", PWEConfig.HOSPITAL_ID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("[7.3.2 通过 GetPreDiagnosisReportDialogues 接口获取对话记录] 入参:data={}, header={}", data, header); |
|
|
|
|
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
|
|
|
|
params.put("data", data); |
|
|
|
|
|
|
|
params.put("header", header); |
|
|
|
|
|
|
|
}, headers -> { |
|
|
|
|
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
|
|
|
|
headers.add("god-portal-signature", toHmacSha256Example(PWEConfig.SECRET_KEY, (PWEConfig.HOSPITAL_ID + timestamp))); |
|
|
|
|
|
|
|
headers.add("god-portal-timestamp", timestamp); |
|
|
|
|
|
|
|
headers.add("god-portal-request-id", CodeHelper.get32UUID()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String code = resultJson.getString("retcode"); |
|
|
|
|
|
|
|
String message = resultJson.getString("retmsg"); |
|
|
|
|
|
|
|
String reqId = resultJson.getString("request_id"); |
|
|
|
|
|
|
|
if (!"0".equals(code)) { |
|
|
|
|
|
|
|
log.error("[7.3.2 通过 GetPreDiagnosisReportDialogues 接口获取对话记录]失败[rid:{}] code={}, message={}", reqId, code, message); |
|
|
|
|
|
|
|
throw new ServiceException(message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JSONObject dataJson = resultJson.getJSONObject("data"); |
|
|
|
|
|
|
|
if (dataJson == null) { |
|
|
|
|
|
|
|
throw new ServiceException("[7.3.2 通过 GetPreDiagnosisReportDialogues 接口获取对话记录]data返回为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return dataJson; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|