fix(#668): 请修复 Bug #668:中医处方签发按钮系统崩溃null key

由 AI Agent (guanyu) 自动修复,请查看 diff 确认变更内容。
This commit is contained in:
2026-06-10 10:49:37 +08:00
parent e2510fe0dd
commit 5fd00011db

View File

@@ -459,22 +459,38 @@ public class DoctorStationChineseMedicalAppServiceImpl implements IDoctorStation
} }
if (is_sign) { if (is_sign) {
// groupId分组 // groupId 的按组生成处方号groupingBy 不接受 null key先过滤
Map<Long, List<AdviceSaveDto>> groupMap insertOrUpdateList.stream()
= insertOrUpdateList.stream().collect(Collectors.groupingBy(AdviceSaveDto::getGroupId)); .filter(e -> e.getGroupId() != null)
// 为每个分组生成唯一的处方号 .collect(Collectors.groupingBy(AdviceSaveDto::getGroupId))
groupMap.forEach((groupId, groupList) -> { .forEach((groupId, groupList) -> {
// 先查询当前groupId是否已经被签发生成过处方号 List<MedicationRequest> list = iMedicationRequestService
List<MedicationRequest> list = iMedicationRequestService .list(new LambdaQueryWrapper<MedicationRequest>()
.list(new LambdaQueryWrapper<MedicationRequest>().eq(MedicationRequest::getGroupId, groupId)); .eq(MedicationRequest::getGroupId, groupId));
if (!list.isEmpty() && StringUtils.isNotEmpty(list.get(0).getPrescriptionNo())) { if (!list.isEmpty() && StringUtils.isNotEmpty(list.get(0).getPrescriptionNo())) {
groupList.forEach(dto -> dto.setPrescriptionNo(list.get(0).getPrescriptionNo())); groupList.forEach(dto -> dto.setPrescriptionNo(list.get(0).getPrescriptionNo()));
} else { } else {
String prescriptionNo String prescriptionNo = assignSeqUtil.getSeq(
= assignSeqUtil.getSeq(AssignSeqEnum.PRESCRIPTION_CHINESE_HERBAL_MEDICINE.getPrefix(), 8); AssignSeqEnum.PRESCRIPTION_CHINESE_HERBAL_MEDICINE.getPrefix(), 8);
groupList.forEach(dto -> dto.setPrescriptionNo(prescriptionNo)); groupList.forEach(dto -> dto.setPrescriptionNo(prescriptionNo));
}
});
// 无 groupId 的各自生成处方号
for (AdviceSaveDto dto : insertOrUpdateList) {
if (dto.getGroupId() != null) {
continue;
} }
}); if (dto.getRequestId() != null) {
MedicationRequest existing = iMedicationRequestService.getById(dto.getRequestId());
if (existing != null && StringUtils.isNotEmpty(existing.getPrescriptionNo())) {
dto.setPrescriptionNo(existing.getPrescriptionNo());
continue;
}
}
dto.setPrescriptionNo(assignSeqUtil.getSeq(
AssignSeqEnum.PRESCRIPTION_CHINESE_HERBAL_MEDICINE.getPrefix(), 8));
}
} }
// 医嘱签发编码 // 医嘱签发编码