确认重症并且修改状态,返回
parent
54f3ccb349
commit
e6d4effe45
@ -0,0 +1,38 @@
|
|||||||
|
package com.docus.server.rpc.impl;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
|
import com.docus.infrastructure.web.api.CommonResult;
|
||||||
|
import com.docus.server.rpc.SdRyHospitalRpc;
|
||||||
|
import com.docus.server.rpc.util.HttpUrlUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SdRyHospitalRpcImpl implements SdRyHospitalRpc {
|
||||||
|
@Value("${docus.basic.confirmAndUpdIcuRecordStateUrl:}")
|
||||||
|
private String confirmAndUpdIcuRecordStateUrl;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<String> confirmAndUpdIcuRecordState(String inpatientNo, Integer admissTimes) {
|
||||||
|
Map<String, String> param = new HashMap<>(2);
|
||||||
|
param.put("inpatientNo",inpatientNo);
|
||||||
|
param.put("admissTimes",admissTimes.toString());
|
||||||
|
try {
|
||||||
|
String url = HttpUrlUtil.addUrlParam(confirmAndUpdIcuRecordStateUrl, param);
|
||||||
|
log.info("确认重症患者并修改标识,接口{}",url);
|
||||||
|
String resp = HttpUtil.get(url);
|
||||||
|
log.info("确认重症患者并修改标识,接口返回:{}",resp);
|
||||||
|
return JSON.parseObject(resp,new TypeReference<CommonResult<String>>(){});
|
||||||
|
}catch (Exception ex){
|
||||||
|
log.error(ex.getMessage(),ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.docus.server.rpc.util;
|
||||||
|
|
||||||
|
import com.docus.core.util.Func;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HttpUrlUtil {
|
||||||
|
/**
|
||||||
|
* 添加url参数
|
||||||
|
*
|
||||||
|
* @param url url
|
||||||
|
* @param param 参数
|
||||||
|
* @return 处理过后的url
|
||||||
|
*/
|
||||||
|
public static String addUrlParam(String url, Map<String, String> param) {
|
||||||
|
if (Func.isEmpty(param)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
StringBuilder urlBuilder = new StringBuilder(url);
|
||||||
|
// url已经添加过参数的标记
|
||||||
|
String addFlag = "?";
|
||||||
|
// url 参数连接符号,如果没有添加过,连接符号置为空
|
||||||
|
String connect = "&";
|
||||||
|
if (!url.contains(addFlag)) {
|
||||||
|
urlBuilder.append("?");
|
||||||
|
connect = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : param.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String value = entry.getValue();
|
||||||
|
urlBuilder.append(connect).append(key).append("=").append(value);
|
||||||
|
// 添加过参数,连接符置为&
|
||||||
|
connect = "&";
|
||||||
|
|
||||||
|
}
|
||||||
|
return urlBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(addUrlParam("http://www.baidu.com", null));
|
||||||
|
System.out.println(addUrlParam("http://www.baidu.com?word=1", null));
|
||||||
|
HashMap<String, String> stringStringHashMap = new HashMap<>();
|
||||||
|
stringStringHashMap.put("en","some");
|
||||||
|
System.out.println(addUrlParam("http://www.baidu.com", stringStringHashMap));
|
||||||
|
System.out.println(addUrlParam("http://www.baidu.com?word=1", stringStringHashMap));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue