|
@@ -1,13 +1,19 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.dto.DeptBaseDTO;
|
|
|
import com.diagbot.dto.DeptNumDTO;
|
|
|
import com.diagbot.dto.NumDTO;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.SysUserUtils;
|
|
|
import com.diagbot.vo.FilterByDeptVO;
|
|
|
+import com.diagbot.vo.FilterPageByDeptVO;
|
|
|
import com.diagbot.vo.HPFilterByDeptVO;
|
|
|
import com.diagbot.vo.QcresultFilterByDeptVO;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -19,6 +25,7 @@ import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
@@ -452,4 +459,143 @@ public class ConsoleByDeptFacade {
|
|
|
List<DeptBaseDTO> deptList = basDeptInfoFacade.getDeptByUser(filterByDeptVO);
|
|
|
return deptList;
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 过滤条件设置
|
|
|
+ *
|
|
|
+ * @param filterPageByDeptVO
|
|
|
+ */
|
|
|
+ private void filterPageByDeptVOSet(FilterPageByDeptVO filterPageByDeptVO) {
|
|
|
+ String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
+ String userId = SysUserUtils.getCurrentPrincipleID();
|
|
|
+ String startDate = "";
|
|
|
+ String endDate = "";
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ //1-本月,2-本年,3-上月,4-去年本月,5-去年
|
|
|
+ if (filterPageByDeptVO.getType().equals(1) || filterPageByDeptVO.getType().equals(2)) {
|
|
|
+ startDate = filterFacade.getStartDateStr(filterPageByDeptVO.getType(), null);
|
|
|
+ endDate = filterFacade.getEndDateStr(filterPageByDeptVO.getType(), null);
|
|
|
+ } else if (filterPageByDeptVO.getType().equals(3) || filterPageByDeptVO.getType().equals(5)) {
|
|
|
+ startDate = filterFacade.getLastStartDateStr(filterPageByDeptVO.getType());
|
|
|
+ endDate = filterFacade.getLastEndDateStr(filterPageByDeptVO.getType());
|
|
|
+ } else if (filterPageByDeptVO.getType().equals(4)) {
|
|
|
+ String year = DateUtil.getYear(date);
|
|
|
+ startDate = filterFacade.getStartDateStr(filterPageByDeptVO.getType(), Integer.valueOf(year) - 1);
|
|
|
+ endDate = filterFacade.getEndDateStr(filterPageByDeptVO.getType(), Integer.valueOf(year) - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ filterPageByDeptVO.setStartDate(startDate);
|
|
|
+ filterPageByDeptVO.setEndDate(endDate);
|
|
|
+ filterPageByDeptVO.setHospitalId(hospitalId);
|
|
|
+ filterPageByDeptVO.setUserId(Long.valueOf(userId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 各模块缺陷占比-科室(分页)
|
|
|
+ *
|
|
|
+ * @param filterPageByDeptVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<DeptNumDTO> entryCountGroupByCaseAndDeptPage(FilterPageByDeptVO filterPageByDeptVO) {
|
|
|
+ if (StringUtil.isBlank(filterPageByDeptVO.getDeptName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入科室");
|
|
|
+ }
|
|
|
+ DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
+ filterPageByDeptVOSet(filterPageByDeptVO);
|
|
|
+ long current = filterPageByDeptVO.getCurrent();
|
|
|
+ long size = filterPageByDeptVO.getSize();
|
|
|
+ filterPageByDeptVO.setCurrent(0);
|
|
|
+ filterPageByDeptVO.setSize(filterPageByDeptVO.getTotal());
|
|
|
+ IPage<DeptNumDTO> page = qcresultInfoFacade.entryCountGroupByCaseAndDeptPage(filterPageByDeptVO);
|
|
|
+ //各科室模块-质控结果
|
|
|
+ List<DeptNumDTO> records = page.getRecords();
|
|
|
+ Map<String, List<DeptNumDTO>> recordMap = ListUtil.isEmpty(records)
|
|
|
+ ? new HashMap<>()
|
|
|
+ : EntityUtil.makeEntityListMap(records, "deptName");
|
|
|
+ //获取每个科室的病历数
|
|
|
+ QcresultFilterByDeptVO qcresultFilterByDeptVO = new QcresultFilterByDeptVO();
|
|
|
+ BeanUtil.copyProperties(filterPageByDeptVO, qcresultFilterByDeptVO);
|
|
|
+ List<NumDTO> mrNumList = qcresultInfoFacade.resultCountByDept(qcresultFilterByDeptVO);
|
|
|
+ Map<String, NumDTO> mrMap = ListUtil.isEmpty(mrNumList)
|
|
|
+ ? new HashMap<>()
|
|
|
+ : EntityUtil.makeEntityMap(mrNumList, "name");
|
|
|
+ //各模块缺陷数
|
|
|
+ List<NumDTO> standardCaseList = qcCasesFacade.entryGroupByCase();
|
|
|
+ if (ListUtil.isEmpty(standardCaseList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<String, NumDTO> standardCaseMap
|
|
|
+ = EntityUtil.makeEntityMap(standardCaseList, "name");
|
|
|
+ if (ListUtil.isNotEmpty(records)) {
|
|
|
+ Integer mrNum = mrMap.containsKey(filterPageByDeptVO.getDeptName())
|
|
|
+ ? mrMap.get(filterPageByDeptVO.getDeptName()).getNum()
|
|
|
+ : 0;
|
|
|
+ records.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(records, new Comparator<NumDTO>() {
|
|
|
+ @Override
|
|
|
+ public int compare(NumDTO o1, NumDTO o2) {
|
|
|
+ return o2.getPercent().compareTo(o1.getPercent());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DeptNumDTO> retList = Lists.newLinkedList();
|
|
|
+ if (current * size + size > records.size()) {
|
|
|
+ retList = records.subList(Long.valueOf(current * size).intValue(), records.size());
|
|
|
+ } else {
|
|
|
+ retList = records.subList(Long.valueOf(current * size).intValue(), Long.valueOf(current * size + size).intValue());
|
|
|
+ }
|
|
|
+ page.setCurrent(current);
|
|
|
+ page.setSize(size);
|
|
|
+ page.setRecords(retList);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 条目缺陷占比-科室(分页)
|
|
|
+ *
|
|
|
+ * @param filterPageByDeptVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<DeptNumDTO> entryCountGroupByEntryAndDeptPage(FilterPageByDeptVO filterPageByDeptVO) {
|
|
|
+ if (StringUtil.isBlank(filterPageByDeptVO.getDeptName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入科室");
|
|
|
+ }
|
|
|
+ DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
+ filterPageByDeptVOSet(filterPageByDeptVO);
|
|
|
+ IPage<DeptNumDTO> page = qcresultInfoFacade.entryCountGroupByEntryAndDeptPage(filterPageByDeptVO);
|
|
|
+ List<DeptNumDTO> 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;
|
|
|
+ }
|
|
|
+}
|