|
@@ -1,5 +1,6 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.aggregate.AverageStatisticsAggregate;
|
|
|
import com.diagbot.aggregate.MrStatisticsAggregate;
|
|
|
import com.diagbot.aggregate.ResultStatisticsAggregate;
|
|
@@ -8,13 +9,23 @@ import com.diagbot.dto.NumDTO;
|
|
|
import com.diagbot.dto.QcResultPercentDTO;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.SysUserUtils;
|
|
|
+import com.diagbot.vo.FilterPageVO;
|
|
|
import com.diagbot.vo.FilterVO;
|
|
|
+import com.diagbot.vo.QcresultFilterVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
@@ -38,6 +49,10 @@ public class ConsoleFacade {
|
|
|
private MrStatisticsAggregate mrStatisticsAggregate;
|
|
|
@Autowired
|
|
|
private ResultStatisticsAggregate resultStatisticsAggregate;
|
|
|
+ @Autowired
|
|
|
+ private QcresultInfoFacade qcresultInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ private QcCasesFacade qcCasesFacade;
|
|
|
|
|
|
//-----------------------聚合接口开始-------------------------------
|
|
|
|
|
@@ -128,6 +143,7 @@ public class ConsoleFacade {
|
|
|
//-----------------------聚合接口结束-------------------------------
|
|
|
|
|
|
//-----------------------单独接口开始-------------------------------
|
|
|
+
|
|
|
/**
|
|
|
* 平均住院天数
|
|
|
*
|
|
@@ -272,7 +288,7 @@ public class ConsoleFacade {
|
|
|
return retMap;
|
|
|
}
|
|
|
|
|
|
- private void filterVOSet(FilterVO filterVO){
|
|
|
+ private void filterVOSet(FilterVO filterVO) {
|
|
|
String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
|
|
|
String endDate = filterFacade.getEndDateStr(filterVO.getType(), null);
|
|
@@ -284,4 +300,104 @@ public class ConsoleFacade {
|
|
|
}
|
|
|
}
|
|
|
//-----------------------单独接口结束-------------------------------
|
|
|
+
|
|
|
+ //_______________________分页接口开始-------------------------------
|
|
|
+
|
|
|
+ private void filterPageVOSet(FilterPageVO filterPageVO) {
|
|
|
+ String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
+ String startDate = filterFacade.getStartDateStr(filterPageVO.getType(), null);
|
|
|
+ String endDate = filterFacade.getEndDateStr(filterPageVO.getType(), null);
|
|
|
+ filterPageVO.setStartDate(startDate);
|
|
|
+ filterPageVO.setEndDate(endDate);
|
|
|
+ filterPageVO.setHospitalId(hospitalId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 各模块缺陷占比(分页)
|
|
|
+ *
|
|
|
+ * @param filterPageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<NumDTO> entryCountGroupByCasePage(FilterPageVO filterPageVO) {
|
|
|
+ DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
+ filterPageVOSet(filterPageVO);
|
|
|
+ long current = filterPageVO.getCurrent();
|
|
|
+ long size = filterPageVO.getSize();
|
|
|
+ filterPageVO.setCurrent(0);
|
|
|
+ filterPageVO.setSize(filterPageVO.getTotal());
|
|
|
+ IPage<NumDTO> page = qcresultInfoFacade.entryCountGroupByCasePage(filterPageVO);
|
|
|
+ List<NumDTO> caseList = page.getRecords();
|
|
|
+ QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
|
|
|
+ BeanUtil.copyProperties(filterPageVO, qcresultFilterVO);
|
|
|
+ int mrNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
|
|
|
+ List<NumDTO> standardCaseList = qcCasesFacade.entryGroupByCase();
|
|
|
+ if (ListUtil.isEmpty(standardCaseList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<String, NumDTO> standardCaseMap
|
|
|
+ = EntityUtil.makeEntityMap(standardCaseList, "name");
|
|
|
+ if (ListUtil.isNotEmpty(caseList)) {
|
|
|
+ caseList.forEach(item -> {
|
|
|
+ if (!standardCaseMap.containsKey(item.getName())) {
|
|
|
+ item.setTotleNum(0);
|
|
|
+ item.setPercent(0d);
|
|
|
+ item.setPercentStr("0%");
|
|
|
+ } else {
|
|
|
+ Integer totleNum = standardCaseMap.get(item.getName()).getNum() * mrNum;
|
|
|
+ item.setTotleNum(totleNum);
|
|
|
+ Double percent = BigDecimal.valueOf(item.getNum())
|
|
|
+ .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
|
|
|
+ .doubleValue();
|
|
|
+ String percentStr
|
|
|
+ = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
|
|
|
+ item.setPercent(percent);
|
|
|
+ item.setPercentStr(percentStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //降序排序
|
|
|
+ Collections.sort(caseList, new Comparator<NumDTO>() {
|
|
|
+ @Override
|
|
|
+ public int compare(NumDTO o1, NumDTO o2) {
|
|
|
+ return o2.getPercent().compareTo(o1.getPercent());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ List<NumDTO> retList = Lists.newLinkedList();
|
|
|
+ if (current * size + size > caseList.size()) {
|
|
|
+ retList = caseList.subList(Long.valueOf(current * size).intValue(), caseList.size());
|
|
|
+ } else {
|
|
|
+ retList = caseList.subList(Long.valueOf(current * size).intValue(), Long.valueOf(current * size + size).intValue());
|
|
|
+ }
|
|
|
+ page.setCurrent(current);
|
|
|
+ page.setSize(size);
|
|
|
+ page.setRecords(retList);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 条目缺陷占比(分页)
|
|
|
+ *
|
|
|
+ * @param filterPageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<NumDTO> entryCountGroupByEntryPage(FilterPageVO filterPageVO) {
|
|
|
+ DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
+ filterPageVOSet(filterPageVO);
|
|
|
+ IPage<NumDTO> page = qcresultInfoFacade.entryCountGroupByEntryPage(filterPageVO);
|
|
|
+ List<NumDTO> records = page.getRecords();
|
|
|
+ if (ListUtil.isNotEmpty(records)) {
|
|
|
+ records.forEach(item -> {
|
|
|
+ Double percent = BigDecimal.valueOf(item.getNum())
|
|
|
+ .divide(BigDecimal.valueOf(item.getTotleNum()), 4, RoundingMode.HALF_UP)
|
|
|
+ .doubleValue();
|
|
|
+ item.setPercent(percent);
|
|
|
+ String percentStr
|
|
|
+ = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
|
|
|
+ item.setPercentStr(percentStr);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ page.setRecords(records);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ //-----------------------分页接口结束-------------------------------
|
|
|
}
|