parent
c73371f910
commit
09f29f299e
15 changed files with 249 additions and 12 deletions
@ -0,0 +1,159 @@ |
||||
package com.ynxbd.wx.config; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.ynxbd.common.helper.ProperHelper; |
||||
import com.ynxbd.common.helper.http.OkHttpHelper; |
||||
import com.ynxbd.common.result.JsonResult; |
||||
import com.ynxbd.common.result.JsonResultEnum; |
||||
import com.ynxbd.wx.utils.XMLUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import okhttp3.*; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* @author 李进才 |
||||
* @ClassName MiddleOfficeConfig |
||||
* @Description TODO |
||||
* @date 2024/05/16 10:46:00 |
||||
*/ |
||||
@Slf4j |
||||
public class MiddleOfficeConfig { |
||||
|
||||
private MiddleOfficeConfig() { |
||||
} |
||||
// 佳禾美康数据上传链接
|
||||
public static final String MIDDLE_OFFICE_URL; |
||||
public static final String MIDDLE_OFFICE_HOSPITAL; |
||||
public static final String MIDDLE_OFFICE_ITEM_NAME; |
||||
|
||||
public static final String RESERVE_CLOUD_URL; |
||||
public static final String RESERVE_CLOUD_TERMINAL_NO; |
||||
|
||||
|
||||
static{ |
||||
ProperHelper config = new ProperHelper().read("middle-office.properties"); |
||||
MIDDLE_OFFICE_URL = config.getString("middle_office_url"); |
||||
MIDDLE_OFFICE_HOSPITAL = config.getString("middle_office_hospital"); |
||||
MIDDLE_OFFICE_ITEM_NAME = config.getString("middle_office_item_name"); |
||||
RESERVE_CLOUD_URL = config.getString("reserve_cloud_url"); |
||||
RESERVE_CLOUD_TERMINAL_NO = config.getString("reserve_cloud_terminal_no"); |
||||
} |
||||
|
||||
public static void run(String soapUrl, String requestData, String mdUrl,String transactionCode,String responseResult){ |
||||
String interfaceName = ""; |
||||
boolean isMD = soapUrl.equals(mdUrl); |
||||
switch (transactionCode) { |
||||
case "1002": |
||||
interfaceName = "JH1401R"; |
||||
break; |
||||
case "1003": |
||||
interfaceName = "JH1402R"; |
||||
break; |
||||
case "4005": |
||||
interfaceName=isMD?"JH1421R":"JH1403R"; |
||||
break; |
||||
case "4003": |
||||
interfaceName = "JH1404R"; |
||||
break; |
||||
case "7001": |
||||
interfaceName = "JH1405R"; |
||||
break; |
||||
case "7002": |
||||
interfaceName = "JH1406R"; |
||||
break; |
||||
case "7003": |
||||
interfaceName = "JH1407R"; |
||||
break; |
||||
case "7005": |
||||
interfaceName = "JH1408R"; |
||||
break; |
||||
case "7004": |
||||
interfaceName=isMD?"JH1420R":"JH1409R"; |
||||
break; |
||||
case "3006": |
||||
case "4007": |
||||
interfaceName = "JH1410R"; |
||||
break; |
||||
case "10": |
||||
interfaceName = "JH1420R"; |
||||
break; |
||||
case "11": |
||||
interfaceName = "JH1421R"; |
||||
break; |
||||
|
||||
} |
||||
if(interfaceName.length()<5){ |
||||
return; |
||||
} |
||||
upload(interfaceName.substring(0,interfaceName.length()-1),requestData); |
||||
upload(interfaceName,responseResult); |
||||
} |
||||
|
||||
public static void upload(String interfaceName,String jsonData){ |
||||
try { |
||||
log.info("[平台数据上传]开始,interfaceName:{},jsonData:{}",interfaceName,jsonData); |
||||
if("".equals(interfaceName)||"".equals(jsonData)||interfaceName==null||jsonData==null){ |
||||
return; |
||||
} |
||||
|
||||
|
||||
JSONObject json = new JSONObject(); |
||||
JSONObject head = new JSONObject(); |
||||
JSONObject body = new JSONObject(); |
||||
|
||||
head.put("hospital",MIDDLE_OFFICE_HOSPITAL); |
||||
head.put("itemName",MIDDLE_OFFICE_ITEM_NAME); |
||||
head.put("interface",interfaceName); |
||||
body.put("data",jsonData); |
||||
json.put("head",head); |
||||
json.put("body",body); |
||||
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), String.valueOf(json)); |
||||
|
||||
Headers headers = new Headers.Builder() |
||||
.add("Content-Type", "application/json") |
||||
.build(); |
||||
|
||||
Request request = new Request.Builder() |
||||
.url(MIDDLE_OFFICE_URL) |
||||
.post(requestBody) |
||||
.headers(headers) |
||||
.build(); |
||||
|
||||
OkHttpClient okHttpClient = new OkHttpClient(); |
||||
Call call = okHttpClient.newCall(request); |
||||
call.enqueue(new Callback() { |
||||
@Override |
||||
public void onFailure(Call call, IOException e) { |
||||
log.error("[平台数据上传]上传失败,interfaceName:{},jsonData:{},error:{}",interfaceName,jsonData,e.toString()); |
||||
} |
||||
|
||||
@Override |
||||
public void onResponse(Call call, Response response) { //不在ui线程
|
||||
log.info("[平台数据上传]成功 状态码:{},interfaceName:{},jsonData:{}",response.code(),interfaceName,jsonData); |
||||
} |
||||
}); |
||||
} |
||||
catch (Exception e){ |
||||
log.error("[平台数据上传]执行失败,interfaceName:{},jsonData:{},error:{}",interfaceName,jsonData,e.toString()); |
||||
} |
||||
} |
||||
|
||||
public static void reserveRun(String patientId){ |
||||
if(RESERVE_CLOUD_URL==null){ |
||||
return; |
||||
} |
||||
String result = OkHttpHelper.get(RESERVE_CLOUD_URL,params->{ |
||||
params.put("patientID",patientId); |
||||
params.put("terminalNo",RESERVE_CLOUD_TERMINAL_NO); |
||||
}); |
||||
JsonResult jsonResult = JsonResult.xmlToBean(result, JsonResultEnum.SYS_RESERVE); |
||||
if(jsonResult==null){ |
||||
return; |
||||
} |
||||
if(jsonResult.success()){ |
||||
MessagePushConfig.businessPush("天助预约平台",patientId,jsonResult.getMessage(),null); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
middle_office_url= http://10.255.248.20:9095/proxy/ |
||||
middle_office_hospital = 红河州第一人民医院 |
||||
middle_office_item_name = 嘉和美康 |
||||
|
||||
reserve_cloud_url = http://10.255.248.155:8003/WebService1.asmx/SlipPrint |
||||
reserve_cloud_terminal_no = SelfMa |
Loading…
Reference in new issue