diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java index 908517e2..f5530839 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java @@ -1058,9 +1058,20 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp iServiceRequestService.remove( new LambdaQueryWrapper().eq(ServiceRequest::getParentId, adviceSaveDto.getRequestId()));// 删除诊疗套餐对应的子项 - // 删除费用项 - iChargeItemService.deleteByServiceTableAndId(CommonConstants.TableName.WOR_SERVICE_REQUEST, - adviceSaveDto.getRequestId()); + // 🔧 Bug Fix #219: 删除费用项前查询确认 + Long requestId = adviceSaveDto.getRequestId(); + String serviceTable = CommonConstants.TableName.WOR_SERVICE_REQUEST; + // 先查询费用项是否存在 + List existingChargeItems = iChargeItemService.getChargeItemInfoByReqId(Arrays.asList(requestId)); + if (existingChargeItems == null || existingChargeItems.isEmpty()) { + log.warn("BugFix#219: 删除诊疗医嘱时未找到费用项, requestId={}, serviceTable={}", requestId, serviceTable); + } else { + log.info("BugFix#219: 找到 {} 个费用项, 准备删除, requestId={}, serviceTable={}", + existingChargeItems.size(), requestId, serviceTable); + // 删除费用项 + iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId); + log.info("BugFix#219: 费用项删除完成, requestId={}", requestId); + } } for (AdviceSaveDto adviceSaveDto : insertOrUpdateList) {