From ebd20ea1dae58549e9ac4dcb6bde2fabbb75be79 Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Wed, 1 Mar 2023 10:36:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=B1=E8=AF=8A=E4=BA=BA=E6=95=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=A2=9E=E5=8A=A0=E6=95=B0=E9=87=8F=E4=B8=BA0?= =?UTF-8?q?=E7=9A=84=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/PlatformService.java | 33 ++++++++++++++++--- .../resources/mapper/system/TRecordMapper.xml | 5 +-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PlatformService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PlatformService.java index 250d1a7..dfe9c55 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PlatformService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PlatformService.java @@ -5,12 +5,12 @@ import com.ruoyi.system.domain.resp.PlatformDayPlanResp; import com.ruoyi.system.domain.resp.WeekMonthPersonCountResp; import com.ruoyi.system.domain.resp.WeekMonthTimeResp; import com.ruoyi.system.mapper.TRecordMapper; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * @Author zhuqing @@ -64,7 +64,32 @@ public class PlatformService { * @return */ public List weekMonthPersonCount(Long hospitalId, Long doctorId,Long weekMonth) { - return tRecordMapper.weekMonthPersonCount(hospitalId, doctorId,weekMonth); + List list = tRecordMapper.weekMonthPersonCount(hospitalId, doctorId,weekMonth); + //定义返回值 + List result = new ArrayList<>(); + if(CollectionUtils.isNotEmpty(list)){ + Map map = list.stream().collect(Collectors.toMap(WeekMonthPersonCountResp::getCreateTime,WeekMonthPersonCountResp::getCount,(key1, key2)->key2)); + //获取开始日期 + Date startDate = list.get(0).getCreateTime(); + //获取结束日期 + Date endDate = list.get(list.size()-1).getCreateTime(); + while(startDate.compareTo(endDate) <= 0){ + WeekMonthPersonCountResp resp = new WeekMonthPersonCountResp(); + if(map.containsKey(startDate)){ + resp.setCreateTime(startDate); + resp.setCount(map.get(startDate)); + }else{ + resp.setCreateTime(startDate); + resp.setCount(0); + } + result.add(resp); + Calendar cal = Calendar.getInstance(); + cal.setTime(startDate); + cal.add(Calendar.DAY_OF_MONTH,1); + startDate = cal.getTime(); + } + } + return result; } /** diff --git a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml index bf1693d..e9d9282 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml @@ -201,7 +201,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"