接口查询判断循环结束

3.2.4.44
wyb 2 years ago
parent 0e7689a0d9
commit ace67cb33e

@ -35,6 +35,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -159,14 +160,14 @@ public class ReportJob {
if (Func.isNotEmpty(nurseInsertSugarReportList)) {
Integer filesNumber = nurseInsertSugarReportList.get(0).getFILES_NUMBER();
Integer nurseFileCount = tBasicMapper.getNurseFileCount(patientId);
if (filesNumber == null || nurseFileCount==null) {
log.warn("{} , {},未保存护理提交的文件数量或者未获取到接口返回的文件数量!",inpatientNo,admissTimes);
nurseFileCountError(inpatientNo,admissTimes);
if (filesNumber == null || nurseFileCount == null) {
log.warn("{} , {},未保存护理提交的文件数量或者未获取到接口返回的文件数量!", inpatientNo, admissTimes);
nurseFileCountError(inpatientNo, admissTimes);
return;
}
if (!filesNumber.equals(nurseFileCount)) {
log.warn("{} , {},护理提交的文件数量与接口返回的文件数量不匹配!",inpatientNo,admissTimes);
nurseFileCountError(inpatientNo,admissTimes);
log.warn("{} , {},护理提交的文件数量与接口返回的文件数量不匹配!", inpatientNo, admissTimes);
nurseFileCountError(inpatientNo, admissTimes);
return;
}
ReportDto reportDto;
@ -220,10 +221,10 @@ public class ReportJob {
TaskValidateConfig.ValidateConfig dischargeDepartmenConfig = cancelCollectTaskConfig.getDischargeDepartment();
CollectTaskValidation validation;
// 是否验证了,每个验证不通过都会返回记录是否进入了验证进入了且验证未返回代表全部通过了改变标记为true返回。
boolean validated=false;
boolean validated = false;
// 验证入院时间
if (admissionDateConfig != null && admissionDateConfig.isEffective()) {
validated=true;
validated = true;
validation = new CollectTaskValidation.CollectTaskAdmissionDateValidation();
CollectTaskValidation.ValidationResult validationResult = validation.validate(taskDTO.getHospitals().get(0).getAdmissDate(), admissionDateConfig);
if (validationResult.getCode() == ResultCode.FAILED) {
@ -232,7 +233,7 @@ public class ReportJob {
}
// 验证出院时间
if (dischargeDateConfig != null && dischargeDateConfig.isEffective()) {
validated=true;
validated = true;
validation = new CollectTaskValidation.CollectTaskDischargeDateValidation();
CollectTaskValidation.ValidationResult validationResult = validation.validate(taskDTO.getHospitals().get(0).getDisDate(), dischargeDateConfig);
if (validationResult.getCode() == ResultCode.FAILED) {
@ -241,7 +242,7 @@ public class ReportJob {
}
// 验证入院科室
if (amissionDepartmentConfig != null && amissionDepartmentConfig.isEffective()) {
validated=true;
validated = true;
validation = new CollectTaskValidation.CollectTaskAdmissionDepartmentValidation();
CollectTaskValidation.ValidationResult validationResult = validation.validate(taskDTO.getHospitals().get(0).getAdmissDeptName(), amissionDepartmentConfig);
if (validationResult.getCode() == ResultCode.FAILED) {
@ -250,7 +251,7 @@ public class ReportJob {
}
// 验证出院科室
if (dischargeDepartmenConfig != null && dischargeDepartmenConfig.isEffective()) {
validated=true;
validated = true;
validation = new CollectTaskValidation.CollectTaskDischargeDepartmentValidation();
CollectTaskValidation.ValidationResult validationResult = validation.validate(taskDTO.getHospitals().get(0).getDisDeptName(), dischargeDepartmenConfig);
if (validationResult.getCode() == ResultCode.FAILED) {
@ -258,7 +259,7 @@ public class ReportJob {
}
}
return validated;
return validated;
}
private void validateAdmissionDate(String admissDate, String collectorId) {
@ -356,7 +357,10 @@ public class ReportJob {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
boolean loopCondition = true;
// 报告接口返回的总数
AtomicInteger reportTotalCount = new AtomicInteger(0);
// 已经查询的条数
int alreadyQrCount = 0;
do {
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
@ -383,17 +387,15 @@ public class ReportJob {
sdJxReportDto.setPatentTypeCode("1");
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getInspectReportByJxId(sdJxReportDto);
List<ReportDto> reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
alreadyQrCount += pageSize;
List<ReportDto> reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic, reportTotalCount);
reportDtos.addAll(reportDtoList);
// 解析之后,总数已经赋值了,判断已经查询的数量是否已经满足总数
if (reportTotalCount.get() == 0 || alreadyQrCount >= reportTotalCount.get()) {
break;
}
if (reportDtoList.size() < pageSize) {
loopCondition = false;
}
reportDtos.addAll(reportDtoList);
pageNum++;
} while (loopCondition);
} while (true);
return reportDtos;
} catch (Exception ex) {
log.error("查询门诊检查报告出错啦!", ex);
@ -406,7 +408,10 @@ public class ReportJob {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
boolean loopCondition = true;
// 报告接口返回的总数
AtomicInteger reportTotalCount = new AtomicInteger(0);
// 已经查询的条数
int alreadyQrCount = 0;
do {
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
@ -433,16 +438,15 @@ public class ReportJob {
sdJxReportDto.setPatentTypeCode("3");
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getInspectReportByJxId(sdJxReportDto);
List<ReportDto> reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
alreadyQrCount += pageSize;
List<ReportDto> reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic, reportTotalCount);
reportDtos.addAll(reportDtoList);
// 解析之后,总数已经赋值了,判断已经查询的数量是否已经满足总数
if (reportTotalCount.get() == 0 || alreadyQrCount >= reportTotalCount.get()) {
break;
}
if (reportDtoList.size() < pageSize) {
loopCondition = false;
}
reportDtos.addAll(reportDtoList);
pageNum++;
} while (loopCondition);
} while (true);
return reportDtos;
} catch (Exception ex) {
log.error("查询住院检查报告出错啦!", ex);
@ -454,13 +458,22 @@ public class ReportJob {
System.out.println(createBase64SaveDir());
}
private List<ReportDto> parseQuerySdRyInspectReport(String respBody, TBasic tBasic) {
private List<ReportDto> parseQuerySdRyInspectReport(String respBody, TBasic tBasic, AtomicInteger reportTotalCount) {
JSONObject jsonObject = Func.readJson(respBody, JSONObject.class);
Object resultCode = jsonObject.get("ResultCode");
String successCode = "0";
if (!successCode.equals(String.valueOf(resultCode))) {
return new ArrayList<>();
}
try {
Object countObj = jsonObject.get("count");
if (countObj != null) {
int count = Integer.parseInt(countObj.toString());
reportTotalCount.set(count);
}
} catch (Exception ex) {
log.error("解析count出错了", ex);
}
TableJsonRead jsonRead = new TableJsonRead();
SdPacsServerConfig config = jsonRead.Read("data-config", "sdry-pacs-server.json", SdPacsServerConfig.class);
try {
@ -614,7 +627,11 @@ public class ReportJob {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
boolean loopCondition = true;
// 报告接口返回的总数
AtomicInteger reportTotalCount = new AtomicInteger(0);
// 已经查询的条数
int alreadyQrCount = 0;
do {
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
@ -640,18 +657,17 @@ public class ReportJob {
sdJxReportDto.setEndTime(endTime);
sdJxReportDto.setPatentTypeCode("3");
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getLisReportByJxId(sdJxReportDto);
List<ReportDto> reportDtoList = parseQuerySdRyLisReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
alreadyQrCount += pageSize;
List<ReportDto> reportDtoList = parseQuerySdRyLisReport(respBody, tBasic, reportTotalCount);
reportDtos.addAll(reportDtoList);
// 解析之后,总数已经赋值了,判断已经查询的数量是否已经满足总数
if (reportTotalCount.get() == 0 || alreadyQrCount >= reportTotalCount.get()) {
break;
}
if (reportDtoList.size() < pageSize) {
loopCondition = false;
}
reportDtos.addAll(reportDtoList);
pageNum++;
} while (loopCondition);
} while (true);
return reportDtos;
} catch (Exception ex) {
log.error("查询Lis报告出错啦", ex);
@ -667,7 +683,10 @@ public class ReportJob {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
boolean loopCondition = true;
// 报告接口返回的总数
AtomicInteger reportTotalCount = new AtomicInteger(0);
// 已经查询的条数
int alreadyQrCount = 0;
do {
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
@ -695,16 +714,15 @@ public class ReportJob {
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getLisReportByJxId(sdJxReportDto);
List<ReportDto> reportDtoList = parseQuerySdRyLisReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
alreadyQrCount = +pageSize;
List<ReportDto> reportDtoList = parseQuerySdRyLisReport(respBody, tBasic, reportTotalCount);
reportDtos.addAll(reportDtoList);
// 解析之后,总数已经赋值了,判断已经查询的数量是否已经满足总数
if (reportTotalCount.get() == 0 || alreadyQrCount >= reportTotalCount.get()) {
break;
}
if (reportDtoList.size() < pageSize) {
loopCondition = false;
}
reportDtos.addAll(reportDtoList);
pageNum++;
} while (loopCondition);
} while (true);
return reportDtos;
} catch (Exception ex) {
log.error("查询Lis报告出错啦", ex);
@ -712,13 +730,22 @@ public class ReportJob {
}
}
private List<ReportDto> parseQuerySdRyLisReport(String respBody, TBasic tBasic) {
private List<ReportDto> parseQuerySdRyLisReport(String respBody, TBasic tBasic, AtomicInteger reportTotalCount) {
JSONObject jsonObject = Func.readJson(respBody, JSONObject.class);
Object resultCode = jsonObject.get("ResultCode");
String successCode = "0";
if (!successCode.equals(String.valueOf(resultCode))) {
return new ArrayList<>();
}
try {
Object countObj = jsonObject.get("count");
if (countObj != null) {
int count = Integer.parseInt(countObj.toString());
reportTotalCount.set(count);
}
} catch (Exception ex) {
log.error("解析count出错了", ex);
}
try {
Object data = jsonObject.get("data");
String dataJsonStr = Func.toJson(data);

@ -113,7 +113,7 @@ public class ReportServiceImpl implements ReportService {
// 如果出现多条出错的情况,还是得保存收到的信息,人工干预处理
patientId = tBasicMapper.getPatientIdByInpatientNoAndAdminssTimes(reportDto.getInpatientNo(), reportDto.getAdmisstimes());
} catch (Exception ex) {
log.error("查询病案主键出错了", ex);
log.error("查询病案主键出错了,病案号:"+reportDto.getInpatientNo()+" ,住院次数:"+reportDto.getAdmisstimes(), ex);
}
// 不验证数据,始终保存收到的信息
AfReportRecord afReportRecord = afReportRecordMapper.getRecordBySerialnumAndInpatientNoAndSysFlag(reportDto.getSerialnum(), reportDto.getInpatientNo(), reportDto.getAdmisstimes(), reportDto.getSysFlag());

Loading…
Cancel
Save