|
@@ -1,6 +1,7 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.AverageStatisticsDTO;
|
|
|
import com.diagbot.dto.ResultDetailDTO;
|
|
|
import com.diagbot.entity.BehospitalInfo;
|
|
|
import com.diagbot.entity.QcresultInfo;
|
|
@@ -35,6 +36,8 @@ public class ConsoleFacade {
|
|
|
private QcresultInfoFacade qcresultInfoFacade;
|
|
|
@Autowired
|
|
|
private BehospitalInfoFacade behospitalInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ private HomePageFacade homePageFacade;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -180,12 +183,95 @@ public class ConsoleFacade {
|
|
|
return retMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 医院运营相关统计
|
|
|
+ *
|
|
|
+ * @param filterVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> averageStatistics(FilterVO filterVO) {
|
|
|
+ Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
+ List<AverageStatisticsDTO> retAverageDayNumList = Lists.newLinkedList();
|
|
|
+ List<AverageStatisticsDTO> retAverageFeeList = Lists.newLinkedList();
|
|
|
+ retMap.put("平均住院日", Lists.newLinkedList());
|
|
|
+ retMap.put("平均住院费用", Lists.newLinkedList());
|
|
|
+ String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
+ filterVO.setHospitalId(hospitalId);
|
|
|
+ String startDate = getStartDateStr(filterVO.getType());
|
|
|
+ filterVO.setStartDate(startDate);
|
|
|
+
|
|
|
+ List<AverageStatisticsDTO> averageDayNumList = homePageFacade.getAverageDayNum(filterVO);
|
|
|
+ List<AverageStatisticsDTO> averageFeeList = homePageFacade.getAverageFee(filterVO);
|
|
|
+
|
|
|
+ if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
|
|
|
+ filterVO.setLimitCount(10);
|
|
|
+ }
|
|
|
+ Integer limitCount = filterVO.getLimitCount();
|
|
|
+
|
|
|
+ //平均住院日
|
|
|
+ if (ListUtil.isNotEmpty(averageDayNumList)) {
|
|
|
+ if (averageDayNumList.size() < limitCount) {
|
|
|
+ retAverageDayNumList = BeanUtil.listCopyTo(averageDayNumList, AverageStatisticsDTO.class);
|
|
|
+ } else {
|
|
|
+ Double averageValue = 0d;
|
|
|
+ Integer num = 0;
|
|
|
+ for (AverageStatisticsDTO averageStatisticsDTO : averageDayNumList) {
|
|
|
+ if (retAverageDayNumList.size() < limitCount - 1) {
|
|
|
+ retAverageDayNumList.add(averageStatisticsDTO);
|
|
|
+ } else {
|
|
|
+ averageValue = BigDecimal
|
|
|
+ .valueOf(averageValue)
|
|
|
+ .add(BigDecimal.valueOf(averageStatisticsDTO.getAverageValue()))
|
|
|
+ .doubleValue();
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ averageValue = BigDecimal.valueOf(averageValue).divide(BigDecimal.valueOf(num)).doubleValue();
|
|
|
+ AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
|
|
|
+ retAverageStatistics.setDeptName("其他");
|
|
|
+ retAverageStatistics.setAverageValue(averageValue);
|
|
|
+ retAverageDayNumList.add(retAverageStatistics);
|
|
|
+ }
|
|
|
+ retMap.put("平均住院日", retAverageDayNumList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //平均住院费用
|
|
|
+ if (ListUtil.isNotEmpty(averageFeeList)) {
|
|
|
+ if (averageFeeList.size() < limitCount) {
|
|
|
+ retAverageFeeList = BeanUtil.listCopyTo(averageFeeList, AverageStatisticsDTO.class);
|
|
|
+ } else {
|
|
|
+ Double averageValue = 0d;
|
|
|
+ Integer num = 0;
|
|
|
+ for (AverageStatisticsDTO averageStatisticsDTO : averageFeeList) {
|
|
|
+ if (retAverageFeeList.size() < limitCount - 1) {
|
|
|
+ retAverageFeeList.add(averageStatisticsDTO);
|
|
|
+ } else {
|
|
|
+ averageValue = BigDecimal
|
|
|
+ .valueOf(averageValue)
|
|
|
+ .add(BigDecimal.valueOf(averageStatisticsDTO.getAverageValue()))
|
|
|
+ .doubleValue();
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ averageValue = BigDecimal.valueOf(averageValue).divide(BigDecimal.valueOf(num)).doubleValue();
|
|
|
+ AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
|
|
|
+ retAverageStatistics.setDeptName("其他");
|
|
|
+ retAverageStatistics.setAverageValue(averageValue);
|
|
|
+ retAverageFeeList.add(retAverageStatistics);
|
|
|
+ }
|
|
|
+ retMap.put("平均住院费用", retAverageFeeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 筛选起始时间
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
- public String getStartDateStr(Integer type) {
|
|
|
+ public String getStartDateStr(Integer type) {
|
|
|
Date date = new Date();
|
|
|
String startDate = "";
|
|
|
String year = DateUtil.getYear(date);
|