diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java index 22d17f3..632ffff 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java @@ -439,7 +439,19 @@ public class InspectPatientController { } else { // 如果未打印,生成新的条码 checkBarCode1 = DateUtils.generateUniqueCode(); + try { + // 等待2毫秒,确保时间戳不同 + Thread.sleep(2); + } catch (InterruptedException e) { + // 忽略中断异常 + } checkBarCode2 = DateUtils.generateUniqueCode(); + try { + // 等待2毫秒,确保时间戳不同 + Thread.sleep(2); + } catch (InterruptedException e) { + // 忽略中断异常 + } checkBarCode3 = DateUtils.generateUniqueCode(); } @@ -1386,28 +1398,18 @@ public class InspectPatientController { String reportDate = ""; String medicalSn = patientDO.getMedicalSn(); - if (medicalSn != null && medicalSn.length() >= 8) { - // 提取前8位作为日期 - reportDate = medicalSn.substring(0, 8); - // 转换为yyyy-MM-dd格式 - if (reportDate.length() == 8) { - reportDate = reportDate.substring(0, 4) + "-" + reportDate.substring(4, 6) + "-" + reportDate.substring(6, 8); - } + // 使用medicalDateTime字段获取日期 + LocalDateTime medicalDateTime = patientDO.getMedicalDateTime(); + if (medicalDateTime != null) { + reportDate = medicalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); } else { - // 尝试从URL中提取体检编号 - int lastSlashIndex = pdfUrl.lastIndexOf('/'); - if (lastSlashIndex != -1) { - String fileName = pdfUrl.substring(lastSlashIndex + 1); - int dashIndex = fileName.indexOf('-'); - if (dashIndex != -1) { - String examNo = fileName.substring(0, dashIndex); - if (examNo.length() >= 8) { - reportDate = examNo.substring(0, 8); - // 转换为yyyy-MM-dd格式 - if (reportDate.length() == 8) { - reportDate = reportDate.substring(0, 4) + "-" + reportDate.substring(4, 6) + "-" + reportDate.substring(6, 8); - } - } + // 如果medicalDateTime为空,则使用medicalSn中的日期作为备选 + if (medicalSn != null && medicalSn.length() >= 8) { + // 提取前8位作为日期 + reportDate = medicalSn.substring(0, 8); + // 转换为yyyy-MM-dd格式 + if (reportDate.length() == 8) { + reportDate = reportDate.substring(0, 4) + "-" + reportDate.substring(4, 6) + "-" + reportDate.substring(6, 8); } } }