Merge remote-tracking branch 'origin/main'
# Conflicts: # yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientService.java # yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java
This commit is contained in:
commit
5702b925ea
@ -1628,11 +1628,10 @@ public class InspectPatientController {
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportPatientExcel(@Valid InspectPatientPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<InspectPatientDO> list = patientService.getPatientPage(pageReqVO).getList();
|
||||
// 直接获取需要的字段数据,优化查询性能
|
||||
List<InspectPatientExcelVO> list = patientService.getPatientForExcel(pageReqVO);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "患者信息.xls", "数据", InspectPatientExcelVO.class,
|
||||
BeanUtils.toBean(list, InspectPatientExcelVO.class));
|
||||
ExcelUtils.write(response, "患者信息.xls", "数据", InspectPatientExcelVO.class, list);
|
||||
}
|
||||
|
||||
@GetMapping("/createPatientInspectDataReport")
|
||||
|
@ -103,6 +103,14 @@ public interface InspectPatientService {
|
||||
*/
|
||||
PageResult<InspectPatientDO> getPatientPage(InspectPatientPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取患者信息用于Excel导出
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 包含导出所需字段的患者信息列表
|
||||
*/
|
||||
List<InspectPatientExcelVO> getPatientForExcel(InspectPatientPageReqVO pageReqVO);
|
||||
|
||||
//根据条码获取患者信息
|
||||
InspectPatientDO getPatientOfMedicalSn(String medicalSn);
|
||||
//验证身份证号是否存在
|
||||
|
@ -942,4 +942,75 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InspectPatientExcelVO> getPatientForExcel(InspectPatientPageReqVO pageReqVO) {
|
||||
// 构建查询条件,只查询Excel导出需要的字段
|
||||
LambdaQueryWrapper<InspectPatientDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(
|
||||
InspectPatientDO::getMedicalSn,
|
||||
InspectPatientDO::getPName,
|
||||
InspectPatientDO::getGender,
|
||||
InspectPatientDO::getCardId,
|
||||
InspectPatientDO::getPhoneNum,
|
||||
InspectPatientDO::getDomicileaddress,
|
||||
InspectPatientDO::getIsprint
|
||||
);
|
||||
|
||||
// 添加筛选条件
|
||||
if (pageReqVO.getMedicalSn() != null) {
|
||||
queryWrapper.eq(InspectPatientDO::getMedicalSn, pageReqVO.getMedicalSn());
|
||||
}
|
||||
// 检查大写字段,如果为空则尝试通过getter方法获取小写字段
|
||||
String patientName = null;
|
||||
// 使用反射尝试获取pname字段(如果存在)
|
||||
try {
|
||||
if (pageReqVO.getPName() != null) {
|
||||
patientName = pageReqVO.getPName();
|
||||
} else {
|
||||
java.lang.reflect.Method method = pageReqVO.getClass().getMethod("getPname");
|
||||
if (method != null) {
|
||||
Object result = method.invoke(pageReqVO);
|
||||
if (result != null) {
|
||||
patientName = result.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 忽略反射异常
|
||||
}
|
||||
|
||||
if (patientName != null && !patientName.isEmpty()) {
|
||||
queryWrapper.like(InspectPatientDO::getPName, patientName);
|
||||
}
|
||||
if (pageReqVO.getGender() != null) {
|
||||
queryWrapper.eq(InspectPatientDO::getGender, pageReqVO.getGender());
|
||||
}
|
||||
if (pageReqVO.getCardId() != null) {
|
||||
queryWrapper.eq(InspectPatientDO::getCardId, pageReqVO.getCardId());
|
||||
}
|
||||
if (pageReqVO.getPhoneNum() != null) {
|
||||
queryWrapper.eq(InspectPatientDO::getPhoneNum, pageReqVO.getPhoneNum());
|
||||
}
|
||||
if (pageReqVO.getStatus() != null) {
|
||||
queryWrapper.eq(InspectPatientDO::getStatus, pageReqVO.getStatus());
|
||||
}
|
||||
if (pageReqVO.getIsprint() != null) {
|
||||
queryWrapper.eq(InspectPatientDO::getIsprint, pageReqVO.getIsprint());
|
||||
}
|
||||
if (pageReqVO.getPrintTimeRange() != null && pageReqVO.getPrintTimeRange().length > 1) {
|
||||
queryWrapper.between(InspectPatientDO::getPrinttime,
|
||||
pageReqVO.getPrintTimeRange()[0],
|
||||
pageReqVO.getPrintTimeRange()[1]);
|
||||
}
|
||||
|
||||
// 按ID降序排序
|
||||
queryWrapper.orderByDesc(InspectPatientDO::getId);
|
||||
|
||||
// 查询数据
|
||||
List<InspectPatientDO> patientList = patientMapper.selectList(queryWrapper);
|
||||
|
||||
// 转换为Excel VO对象
|
||||
return BeanUtils.toBean(patientList, InspectPatientExcelVO.class);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user