fix: post请求修复

docus-active-query-service_1.3
wyb 4 months ago
parent fc6802f9cb
commit 7a12972a8d

@ -5,10 +5,15 @@ import com.alibaba.fastjson.JSON;
import com.docus.bgts.entity.CommonResult;
import com.docus.bgts.rpc.DownloadPlatformRpc;
import com.docus.bgts.rpc.dto.ReportDownDto;
import com.docus.bgts.rpc.dto.ReportDownPatientDto;
import com.docus.bgts.rpc.dto.ReportDownScanFileDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
/**
@ -31,7 +36,10 @@ public class DownloadPlatformRpcImpl implements DownloadPlatformRpc {
String bodyParam = JSON.toJSONString(resources);
log.info("[{}] 上报病案文件到下载平台,地址:{} ,参数:{}", contextId, url, bodyParam);
try {
String resp = HttpUtil.post(url, bodyParam);
String resp = HttpUtil.createPost(url)
.body(bodyParam, ContentType.APPLICATION_JSON.getMimeType())
.execute()
.body();
log.info("[{}] 上报病案文件到下载平台,返回内容:{}", contextId, resp);
return JSON.parseObject(resp, CommonResult.class);
} catch (Exception ex) {
@ -47,7 +55,11 @@ public class DownloadPlatformRpcImpl implements DownloadPlatformRpc {
String bodyParam = JSON.toJSONString(resources);
log.info("[{}] 上报封存病案文件到下载平台,地址:{} ,参数:{}", contextId, url, bodyParam);
try {
String resp = HttpUtil.post(url, bodyParam);
String resp = HttpUtil.createPost(url)
.body(bodyParam, ContentType.APPLICATION_JSON.getMimeType())
.execute()
.body();
log.info("[{}] 上报封存病案文件到下载平台,返回内容:{}", contextId, resp);
return JSON.parseObject(resp, CommonResult.class);
} catch (Exception ex) {
@ -55,4 +67,31 @@ public class DownloadPlatformRpcImpl implements DownloadPlatformRpc {
throw ex;
}
}
public static void main(String[] args) {
DownloadPlatformRpcImpl platformRpc = new DownloadPlatformRpcImpl();
platformRpc.downloadPlatformAddress="http://127.0.0.1:9291";
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
reportDownPatientDto.setPatientid("123");
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setDownurl("666http");
reportDownScanFileDto.setFilestoragetype(1);
reportDownScanFileDto.setFilesource(1);
reportDownScanFileDto.setFiletitle("dm");
reportDownScanFileDto.setSerialnum("fileid");
List<ReportDownScanFileDto> reportDownScanFileDtos = Collections.singletonList(reportDownScanFileDto);
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid("test");
reportDownDto.setAssortid("assortid");
reportDownDto.setPatient(reportDownPatientDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
CommonResult commonResult = platformRpc.sealReport(reportDownDto);
System.out.println(JSON.toJSONString(commonResult));
}
}

Loading…
Cancel
Save