修复机构BUG
This commit is contained in:
parent
7b0f85ed56
commit
9e2a530ce9
@ -1907,19 +1907,9 @@ public class InspectPatientController {
|
||||
@Operation(summary = "根据日期获取卫生院体检统计")
|
||||
public CommonResult<List<WorkloadStatisticsVO>> getWorkload(@RequestParam("dates") @DateTimeFormat(pattern = "yyyy-MM-dd") List<LocalDate> dates,
|
||||
@RequestParam(value = "examhosname", required = false) String examhosname) {
|
||||
// 获取指定日期范围内的所有患者补充信息
|
||||
List<PatientSupplementVO> supplements = patientService.getPatientSupplementsByDates(dates);
|
||||
// 获取指定日期范围内的所有患者补充信息,如果有医院名称则在数据库层面直接过滤
|
||||
List<PatientSupplementVO> supplements = patientService.getPatientSupplementsByDatesAndHospital(dates, examhosname);
|
||||
|
||||
// 医院名称过滤:
|
||||
// - 若examhosname为null、"null"字符串或空字符串,则不过滤,保留所有记录
|
||||
// - 若examhosname有有效值,则只保留匹配该医院名称的记录
|
||||
if (examhosname != null && !examhosname.isEmpty() && !"null".equals(examhosname)) {
|
||||
supplements = supplements.stream()
|
||||
.filter(s -> examhosname.equals(s.getOrgname()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// 否则保持原有supplements不变
|
||||
|
||||
// 使用Map来存储统计结果,key为卫生院名称+行政村名称
|
||||
Map<String, WorkloadStatisticsVO> statisticsMap = new HashMap<>();
|
||||
|
||||
|
@ -163,6 +163,15 @@ public interface InspectPatientService {
|
||||
* @return 患者补充信息列表
|
||||
*/
|
||||
List<PatientSupplementVO> getPatientSupplementsByDates(List<LocalDate> dates);
|
||||
|
||||
/**
|
||||
* 根据日期列表和医院名称获取患者补充信息
|
||||
*
|
||||
* @param dates 日期列表
|
||||
* @param examhosname 医院名称(可选)
|
||||
* @return 患者补充信息列表
|
||||
*/
|
||||
List<PatientSupplementVO> getPatientSupplementsByDatesAndHospital(List<LocalDate> dates, String examhosname);
|
||||
|
||||
void exportStatistics(List<LocalDate> dates, HttpServletResponse response);
|
||||
|
||||
|
@ -22,7 +22,6 @@ import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.jodconverter.DocumentConverter;
|
||||
import org.jodconverter.LocalConverter;
|
||||
@ -817,21 +816,50 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 使用批量转换,避免循环中多次创建对象
|
||||
return patients.stream()
|
||||
.map(patient -> {
|
||||
PatientSupplementVO vo = new PatientSupplementVO();
|
||||
vo.setMedicalSn(patient.getMedicalSn());
|
||||
vo.setOrgname(patient.getOrgname());
|
||||
vo.setDistrictname(patient.getDistrictname());
|
||||
vo.setOldmanflag(patient.getOldmanflag());
|
||||
vo.setHtnflag(patient.getHtnflag());
|
||||
vo.setDiaflag(patient.getDiaflag());
|
||||
vo.setSmiflag(patient.getSmiflag());
|
||||
vo.setPulflag(patient.getPulflag());
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
// 转换为 PatientSupplementVO 对象
|
||||
return BeanUtils.toBean(patients, PatientSupplementVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PatientSupplementVO> getPatientSupplementsByDatesAndHospital(List<LocalDate> dates, String examhosname) {
|
||||
if (dates == null || dates.isEmpty() || dates.size() < 2) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 获取起始日期和结束日期
|
||||
LocalDate startDate = dates.get(0);
|
||||
LocalDate endDate = dates.get(1);
|
||||
|
||||
// 构建查询条件,只查询必要的字段
|
||||
LambdaQueryWrapper<InspectPatientDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper
|
||||
.select(
|
||||
InspectPatientDO::getMedicalSn,
|
||||
InspectPatientDO::getOrgname,
|
||||
InspectPatientDO::getDistrictname,
|
||||
InspectPatientDO::getOldmanflag,
|
||||
InspectPatientDO::getHtnflag,
|
||||
InspectPatientDO::getDiaflag,
|
||||
InspectPatientDO::getSmiflag,
|
||||
InspectPatientDO::getPulflag
|
||||
)
|
||||
.eq(InspectPatientDO::getIsprint, 1)
|
||||
.between(InspectPatientDO::getPrinttime, startDate.atStartOfDay(), endDate.atTime(23, 59, 59));
|
||||
|
||||
// 如果医院名称有效,添加筛选条件
|
||||
if (examhosname != null && !examhosname.isEmpty() && !"null".equals(examhosname)) {
|
||||
queryWrapper.eq(InspectPatientDO::getExamhosname, examhosname);
|
||||
}
|
||||
|
||||
// 查询患者信息
|
||||
List<InspectPatientDO> patients = patientMapper.selectList(queryWrapper);
|
||||
|
||||
if (patients == null || patients.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 转换为 PatientSupplementVO 对象
|
||||
return BeanUtils.toBean(patients, PatientSupplementVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -869,6 +897,9 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
|
||||
// 使用Map来存储统计结果,key为卫生院名称+行政村名称
|
||||
Map<String, WorkloadStatisticsVO> statisticsMap = new HashMap<>();
|
||||
|
||||
// 使用Set来记录已经统计过的患者ID,避免重复统计
|
||||
Set<String> countedPatients = new HashSet<>();
|
||||
|
||||
// 遍历所有补充信息进行统计
|
||||
for (PatientSupplementVO supplement : supplements) {
|
||||
@ -885,8 +916,17 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
vo.setSum(0);
|
||||
return vo;
|
||||
});
|
||||
|
||||
// 获取患者体检编号
|
||||
String patientId = supplement.getMedicalSn();
|
||||
|
||||
// 统计各项数量,但每个人只统计一次
|
||||
if (!countedPatients.contains(patientId)) {
|
||||
countedPatients.add(patientId);
|
||||
statistics.setSum(statistics.getSum() + 1); // 总数加1
|
||||
}
|
||||
|
||||
// 统计各项数量
|
||||
// 统计具体指标
|
||||
if ("1".equals(supplement.getOldmanflag())) {
|
||||
statistics.setOldmanflag(statistics.getOldmanflag() + 1);
|
||||
}
|
||||
@ -902,11 +942,6 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
if ("1".equals(supplement.getPulflag())) {
|
||||
statistics.setPulflag(statistics.getPulflag() + 1);
|
||||
}
|
||||
|
||||
// 计算总数
|
||||
statistics.setSum(statistics.getOldmanflag() + statistics.getHtnflag() +
|
||||
statistics.getDiaflag() + statistics.getSmiflag() +
|
||||
statistics.getPulflag());
|
||||
}
|
||||
|
||||
// excel数据
|
||||
|
Loading…
Reference in New Issue
Block a user