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"