|
|
|
@ -10,8 +10,10 @@ import com.docus.server.report.config.ApplicationBusinessConfig;
|
|
|
|
|
import com.docus.server.report.dto.ReportDownDto;
|
|
|
|
|
import com.docus.server.report.dto.ReportDownPatientDto;
|
|
|
|
|
import com.docus.server.report.dto.ReportDownScanFileDto;
|
|
|
|
|
import com.docus.server.report.dto.ReportDto;
|
|
|
|
|
import com.docus.server.report.entity.AfReportRecord;
|
|
|
|
|
import com.docus.server.report.event.ReportDownEvent;
|
|
|
|
|
import com.docus.server.report.event.TaskConsumptionReportDownEvent;
|
|
|
|
|
import com.docus.server.report.event.ThreePartyPushReportDownEvent;
|
|
|
|
|
import com.docus.server.report.mapper.AfReportRecordMapper;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
|
@ -21,6 +23,8 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上报下载监听
|
|
|
|
@ -38,9 +42,9 @@ public class ReportDownListener {
|
|
|
|
|
|
|
|
|
|
@EventListener
|
|
|
|
|
@Async("threadPoolExecutor")
|
|
|
|
|
public void reportDown(ReportDownEvent reportDownEvent) {
|
|
|
|
|
public void threePartyPushReportDown(ThreePartyPushReportDownEvent threePartyPushReportDownEvent) {
|
|
|
|
|
// 根据任务id获取上报记录信息
|
|
|
|
|
AfReportRecord afReportRecord = afReportRecordMapper.getReportRecordInfoByTaskId(reportDownEvent.getTaskId());
|
|
|
|
|
AfReportRecord afReportRecord = afReportRecordMapper.getReportRecordInfoByTaskId(threePartyPushReportDownEvent.getTaskId());
|
|
|
|
|
|
|
|
|
|
// 组织基础信息数据
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(afReportRecord);
|
|
|
|
@ -64,20 +68,64 @@ public class ReportDownListener {
|
|
|
|
|
String requestParam = Func.toJson(reportDownDto);
|
|
|
|
|
try {
|
|
|
|
|
log.info("调用下载服务,地址:{} ,参数:{}",applicationBusinessConfig.getDownUrl(),requestParam);
|
|
|
|
|
HttpRequest post = HttpUtil.createPost(applicationBusinessConfig.getDownUrl());
|
|
|
|
|
post.timeout(5 * 1000);
|
|
|
|
|
post.header("Content-Type", "application/json; charset=utf-8");
|
|
|
|
|
post.body(requestParam);
|
|
|
|
|
HttpResponse response = post.execute();
|
|
|
|
|
String respBody = response.body();
|
|
|
|
|
String respBody = post(applicationBusinessConfig.getDownUrl(),requestParam);
|
|
|
|
|
log.info("调用下载服务成功,响应参数:{}", respBody);
|
|
|
|
|
CommonResult commonResult = Func.readJson(respBody, CommonResult.class);
|
|
|
|
|
if (ResultCode.SUCCESS.getCode().equals(commonResult.getCode())) {
|
|
|
|
|
// 下载返回了成功更新状态
|
|
|
|
|
afReportRecordMapper.updateStateByTaskId(reportDownEvent.getTaskId());
|
|
|
|
|
afReportRecordMapper.updateStateByTaskId(threePartyPushReportDownEvent.getTaskId());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("调用下载服务失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@EventListener
|
|
|
|
|
@Async("threadPoolExecutor")
|
|
|
|
|
public void taskConsumptionReporDown(TaskConsumptionReportDownEvent taskConsumptionReportDownEvent) {
|
|
|
|
|
ReportDto reportDto = taskConsumptionReportDownEvent.getReportDto();
|
|
|
|
|
// 组织基础信息数据
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(reportDto);
|
|
|
|
|
|
|
|
|
|
// 组织文件数据
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>(5);
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(reportDto);
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
|
|
|
|
|
// 组织下载数据,基础信息和文件数据
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setAssortid(reportDto.getAssortId());
|
|
|
|
|
reportDownDto.setCollectorid(reportDto.getSysFlag());
|
|
|
|
|
reportDownDto.setScanusercode("admin");
|
|
|
|
|
reportDownDto.setScanusername("admin");
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
|
|
|
|
|
// 下面是调用下载服务
|
|
|
|
|
String requestParam = Func.toJson(reportDownDto);
|
|
|
|
|
try {
|
|
|
|
|
log.info("调用下载服务,地址:{} ,参数:{}",applicationBusinessConfig.getDownUrl(),requestParam);
|
|
|
|
|
String respBody = post(applicationBusinessConfig.getDownUrl(),requestParam);
|
|
|
|
|
log.info("调用下载服务成功,响应参数:{}", respBody);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("调用下载服务失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final static Lock HTTP_POST_LOCK=new ReentrantLock();
|
|
|
|
|
public String post(String url,String body){
|
|
|
|
|
HTTP_POST_LOCK.lock();
|
|
|
|
|
try {
|
|
|
|
|
HttpRequest post = HttpUtil.createPost(url);
|
|
|
|
|
post.timeout(5 * 1000);
|
|
|
|
|
post.header("Content-Type", "application/json; charset=utf-8");
|
|
|
|
|
post.body(body);
|
|
|
|
|
HttpResponse response = post.execute();
|
|
|
|
|
return response.body();
|
|
|
|
|
}finally {
|
|
|
|
|
HTTP_POST_LOCK.unlock();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|