|
|
|
@ -4,11 +4,13 @@ import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
import com.docus.core.util.Func;
|
|
|
|
|
import com.docus.infrastructure.web.api.CommonResult;
|
|
|
|
|
import com.docus.infrastructure.web.api.ResultCode;
|
|
|
|
|
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.mapper.AfReportRecordMapper;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -22,6 +24,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上报下载监听
|
|
|
|
|
*
|
|
|
|
|
* @author wyb
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
@ -35,20 +38,22 @@ public class ReportDownListener {
|
|
|
|
|
|
|
|
|
|
@EventListener
|
|
|
|
|
@Async("threadPoolExecutor")
|
|
|
|
|
public void reportDown(ReportDownEvent reportDownEvent){
|
|
|
|
|
ReportDto reportDto = reportDownEvent.getReportDto();
|
|
|
|
|
public void reportDown(ReportDownEvent reportDownEvent) {
|
|
|
|
|
// 根据任务id获取上报记录信息
|
|
|
|
|
AfReportRecord afReportRecord = afReportRecordMapper.getReportRecordInfoByTaskId(reportDownEvent.getTaskId());
|
|
|
|
|
|
|
|
|
|
// 组织基础信息数据
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(reportDto);
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(afReportRecord);
|
|
|
|
|
|
|
|
|
|
// 组织文件数据
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>(5);
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(reportDto);
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(afReportRecord);
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
|
|
|
|
|
// 组织下载数据,基础信息和文件数据
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setAssortid(reportDto.getAssortId());
|
|
|
|
|
reportDownDto.setCollectorid(reportDto.getSysFlag());
|
|
|
|
|
reportDownDto.setAssortid(afReportRecord.getZdAssortId());
|
|
|
|
|
reportDownDto.setCollectorid(afReportRecord.getSysflag());
|
|
|
|
|
reportDownDto.setScanusercode("admin");
|
|
|
|
|
reportDownDto.setScanusername("admin");
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
@ -58,16 +63,21 @@ 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.timeout(5 * 1000);
|
|
|
|
|
post.header("Content-Type", "application/json; charset=utf-8");
|
|
|
|
|
post.body(requestParam);
|
|
|
|
|
HttpResponse response = post.execute();
|
|
|
|
|
String respBody = response.body();
|
|
|
|
|
log.info("调用下载服务成功,响应参数:{}",respBody);
|
|
|
|
|
afReportRecordMapper.updateStateByTaskId(reportDto.getTaskId());
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("调用下载服务失败:地址为:"+applicationBusinessConfig.getDownUrl()+" 参数为 : "+requestParam,e);
|
|
|
|
|
log.info("调用下载服务成功,响应参数:{}", respBody);
|
|
|
|
|
CommonResult commonResult = Func.readJson(respBody, CommonResult.class);
|
|
|
|
|
if (ResultCode.SUCCESS.getCode().equals(commonResult.getCode())) {
|
|
|
|
|
// 下载返回了成功更新状态
|
|
|
|
|
afReportRecordMapper.updateStateByTaskId(reportDownEvent.getTaskId());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("调用下载服务失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|