From 6958654d26772b6cd52a55a5e3e124de48f87617 Mon Sep 17 00:00:00 2001 From: chenqi Date: Tue, 2 Jun 2026 15:31:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(home):=20=E6=B7=BB=E5=8A=A0=E5=A4=84?= =?UTF-8?q?=E6=96=B9=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 HomeStatisticsDto 中新增今日处方、昨日处方和处方趋势字段 - 实现处方数量查询逻辑,支持按日期和医生过滤 - 计算处方数据的日环比变化率 - 更新前端界面以显示处方统计信息 - 配置处方相关的路由映射 - 修正数据绑定逻辑以正确关联处方统计数据 --- .../openhis/web/dto/HomeStatisticsDto.java | 17 ++++++- .../impl/HomeStatisticsServiceImpl.java | 45 +++++++++++++++++++ openhis-ui-vue3/src/views/index.vue | 19 +++++--- 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java index fbea3b94f..9e8b35173 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java @@ -79,4 +79,19 @@ public class HomeStatisticsDto { * 待写病历数量 */ private Integer pendingEmr; -} + + /** + * 今日处方数量 + */ + private Integer todayPrescriptions; + + /** + * 昨日处方数量 + */ + private Integer yesterdayPrescriptions; + + /** + * 处方相对前日变化百分比 + */ + private Double prescriptionTrend; +} \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java index 59b984222..acc67f090 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java @@ -15,6 +15,8 @@ import com.openhis.common.enums.ParticipantType; import com.openhis.web.dto.HomeStatisticsDto; import com.openhis.financial.domain.PaymentReconciliation; import com.openhis.financial.service.IPaymentReconciliationService; +import com.openhis.medication.domain.MedicationRequest; +import com.openhis.medication.service.IMedicationRequestService; import com.openhis.common.enums.PaymentStatus; import com.openhis.web.service.IHomeStatisticsService; import java.math.BigDecimal; @@ -56,6 +58,9 @@ public class HomeStatisticsServiceImpl implements IHomeStatisticsService { @Autowired private IPaymentReconciliationService paymentReconciliationService; + @Autowired + private IMedicationRequestService medicationRequestService; + /** * 获取首页统计数据 * @@ -131,9 +136,49 @@ public class HomeStatisticsServiceImpl implements IHomeStatisticsService { statistics.setAppointmentTrend(0.0); statistics.setPendingApprovals(0); + + // 查询今日处方数量 + int todayPrescriptions = queryPrescriptionCountByDate(new Date(), practitioner); + int yesterdayPrescriptions = queryPrescriptionCountByDate(getYesterday(), practitioner); + statistics.setTodayPrescriptions(todayPrescriptions); + statistics.setYesterdayPrescriptions(yesterdayPrescriptions); + statistics.setPrescriptionTrend(calculateTrend(todayPrescriptions, yesterdayPrescriptions)); + return statistics; } + /** + * 查询指定日期的处方数量 + * + * @param date 日期 + * @param practitioner 当前医生(null 则查全部) + * @return 处方数量 + */ + private int queryPrescriptionCountByDate(Date date, Practitioner practitioner) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date dayStart = cal.getTime(); + + cal.add(Calendar.DAY_OF_MONTH, 1); + Date dayEnd = cal.getTime(); + + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.ge(MedicationRequest::getCreateTime, dayStart) + .lt(MedicationRequest::getCreateTime, dayEnd) + .eq(MedicationRequest::getDeleteFlag, "0"); + + // 如果是医生角色,只统计自己开的处方 + if (practitioner != null) { + query.eq(MedicationRequest::getPractitionerId, practitioner.getId()); + } + + return (int) medicationRequestService.count(query); + } + /** * 查询指定日期的收款总额(状态为支付成功且未全部退款) * diff --git a/openhis-ui-vue3/src/views/index.vue b/openhis-ui-vue3/src/views/index.vue index bf2e021eb..6bcdf01b2 100755 --- a/openhis-ui-vue3/src/views/index.vue +++ b/openhis-ui-vue3/src/views/index.vue @@ -1,4 +1,4 @@ -