ソースを参照

湘雅三院科室控制台接口优化

chengyao 3 年 前
コミット
e5f9efcd54

+ 138 - 0
src/main/java/com/diagbot/aggregate/LeaveHosCountByDeptAggregate.java

@@ -0,0 +1,138 @@
+package com.diagbot.aggregate;
+
+import com.diagbot.dto.DeptBaseDTO;
+import com.diagbot.dto.NumDTO;
+import com.diagbot.facade.BasDeptInfoFacade;
+import com.diagbot.facade.BehospitalInfoFacade;
+import com.diagbot.util.EntityUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.FilterVO;
+import io.github.lvyahui8.spring.annotation.DataConsumer;
+import io.github.lvyahui8.spring.annotation.DataProvider;
+import io.github.lvyahui8.spring.annotation.InvokeParameter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/7/15 16:03
+ */
+@Component
+public class LeaveHosCountByDeptAggregate {
+    @Autowired
+    private BehospitalInfoFacade behospitalInfoFacade;
+    @Autowired
+    private BasDeptInfoFacade basDeptInfoFacade;
+
+    @DataProvider("setAllLeaveHosCount")
+    public Map<String, Object> setAllLeaveHosCount(
+            @InvokeParameter("filterVO") FilterVO filterVO,
+            @DataConsumer("leaveHosCountByDept") List<NumDTO> totleNumList,
+            @DataConsumer("deathCountByDept") List<NumDTO> deathNumList,
+            @DataConsumer("operationCountByDept") List<NumDTO> operationNumList) {
+        Map<String, Object> retMap = new LinkedHashMap<>();
+        //关联科室
+        Map<String, Object> deptMap = getDeptByUser(filterVO);
+        if (deptMap == null) {
+            return retMap;
+        }
+        Map<String, NumDTO> totleMap = ListUtil.isEmpty(totleNumList)
+                ? new HashMap<>()
+                : EntityUtil.makeEntityMap(totleNumList, "name");
+
+        Map<String, NumDTO> deathMap = new HashMap<>();
+        Map<String, NumDTO> operationMap = new HashMap<>();
+        deathMap = ListUtil.isEmpty(deathNumList)
+                ? new HashMap<>()
+                : EntityUtil.makeEntityMap(deathNumList, "name");
+        operationMap = ListUtil.isEmpty(operationNumList)
+                ? new HashMap<>()
+                : EntityUtil.makeEntityMap(operationNumList, "name");
+
+
+        for (String deptName : deptMap.keySet()) {
+            Map<String, Object> map = new LinkedHashMap<>();
+            map.put("总人数", 0);
+            map.put("死亡人数", 0);
+            map.put("手术病人数", 0);
+            if (totleMap.containsKey(deptName)) {
+                map.put("总人数", totleMap.get(deptName).getNum());
+            }
+            if (deathMap.containsKey(deptName)) {
+                map.put("死亡人数", deathMap.get(deptName).getNum());
+            }
+            if (operationMap.containsKey(deptName)) {
+                map.put("手术病人数", operationMap.get(deptName).getNum());
+            }
+            retMap.put(deptName, map);
+        }
+        return retMap;
+    }
+
+    /**
+     * 出院总人数
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("leaveHosCountByDept")
+    public List<NumDTO> leaveHosCountByDept(@InvokeParameter("filterVO") FilterVO filterVO) {
+        long L1 = System.currentTimeMillis();
+        List<NumDTO> numDTOS = behospitalInfoFacade.leaveHosCountByDept(filterVO);
+        long L2 = System.currentTimeMillis();
+        System.out.println("出院总人数 = " + (L2-L1));
+        return numDTOS;
+    }
+
+    /**
+     * 死亡人数
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("deathCountByDept")
+    public List<NumDTO> deathCountByDept(@InvokeParameter("filterVO") FilterVO filterVO) {
+        long L1 = System.currentTimeMillis();
+        List<NumDTO> numDTOS = behospitalInfoFacade.deathCountByDept(filterVO);
+        long L2 = System.currentTimeMillis();
+        System.out.println("死亡人数 = " + (L2-L1));
+        return numDTOS;
+
+    }
+
+    /**
+     * 手术人数
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("operationCountByDept")
+    public List<NumDTO> operationCountByDept(@InvokeParameter("filterVO") FilterVO filterVO) {
+        long L1 = System.currentTimeMillis();
+        List<NumDTO> numDTOS = behospitalInfoFacade.operationCountByDept(filterVO);
+        long L2 = System.currentTimeMillis();
+        System.out.println("手术人数 = " + (L2-L1));
+        return numDTOS;
+    }
+
+    /**
+     * 用户关联科室
+     *
+     * @param filterVO
+     * @return
+     */
+    public Map<String, Object> getDeptByUser(FilterVO filterVO) {
+        List<DeptBaseDTO> deptList = basDeptInfoFacade.getDeptByUser(filterVO);
+        if (ListUtil.isNotEmpty(deptList)) {
+            return EntityUtil.makeMapWithKeyValue(deptList, "deptName", "deptId");
+        } else {
+            return null;
+        }
+    }
+}

+ 80 - 94
src/main/java/com/diagbot/facade/ConsoleByDeptFacade.java

@@ -11,7 +11,7 @@ import com.diagbot.exception.CommonException;
 import com.diagbot.util.*;
 import com.diagbot.vo.*;
 import com.google.common.collect.Lists;
-import org.apache.commons.collections4.MapUtils;
+import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +45,8 @@ public class ConsoleByDeptFacade {
     private SysHospitalSetFacade sysHospitalSetFacade;
     @Autowired
     private QcCasesEntryFacade qcCasesEntryFacade;
+    @Autowired
+    private DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade;
 
 
     /**
@@ -54,6 +56,7 @@ public class ConsoleByDeptFacade {
      * @return
      */
     public Map<String, Object> leaveHosCountByDept(FilterVO filterVO) {
+        long L1 = System.currentTimeMillis();
         Map<String, Object> retMap = new LinkedHashMap<>();
         filterFacade.filterVOSet(filterVO);
         //关联科室
@@ -61,40 +64,14 @@ public class ConsoleByDeptFacade {
         if (deptMap == null) {
             return retMap;
         }
-        //出院总人数
-        List<NumDTO> totleNumList = behospitalInfoFacade.leaveHosCountByDept(filterVO);
-        Map<String, NumDTO> totleMap = ListUtil.isEmpty(totleNumList)
-                ? new HashMap<>()
-                : EntityUtil.makeEntityMap(totleNumList, "name");
-        Map<String, NumDTO> deathMap = new HashMap<>();
-        Map<String, NumDTO> operationMap = new HashMap<>();
-        //终末--死亡人数/手术病人数
-            //死亡人数
-            List<NumDTO> deathNumList = behospitalInfoFacade.deathCountByDept(filterVO);
-             deathMap = ListUtil.isEmpty(deathNumList)
-                    ? new HashMap<>()
-                    : EntityUtil.makeEntityMap(deathNumList, "name");
-            //手术人数
-            List<NumDTO> operationNumList = behospitalInfoFacade.operationCountByDept(filterVO);
-             operationMap = ListUtil.isEmpty(operationNumList)
-                    ? new HashMap<>()
-                    : EntityUtil.makeEntityMap(operationNumList, "name");
-
-        for (String deptName : deptMap.keySet()) {
-            Map<String, Object> map = new LinkedHashMap<>();
-            map.put("总人数", 0);
-            map.put("死亡人数", 0);
-            map.put("手术病人数", 0);
-            if (totleMap.containsKey(deptName)) {
-                map.put("总人数", totleMap.get(deptName).getNum());
-            }
-            if(deathMap.containsKey(deptName)) {
-                map.put("死亡人数", deathMap.get(deptName).getNum());
-            }
-            if(operationMap.containsKey(deptName)) {
-                map.put("手术病人数", operationMap.get(deptName).getNum());
-            }
-            retMap.put(deptName, map);
+        try {
+            Map<String, Object> invokeParams = new HashMap<>();
+            invokeParams.put("filterVO", filterVO);
+            retMap  = dataBeanAggregateQueryFacade.get("setAllLeaveHosCount", invokeParams, Map.class);
+            long L2 = System.currentTimeMillis();
+            System.out.println("总耗时 = " + (L2-L1));
+        } catch (Exception e) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
         }
         return retMap;
     }
@@ -124,70 +101,79 @@ public class ConsoleByDeptFacade {
         DecimalFormat df = new DecimalFormat("#0.00");
         Map<String, Object> retMap = new LinkedHashMap<>();
         filterFacade.filterVOSet(filterVO);
+        //关联科室
+        Map<String, Object> deptMap = getDeptByUser(filterVO);
+        if (deptMap == null) {
+            return retMap;
+        }
         QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
         BeanUtil.copyProperties(filterVO, qcresultFilterVO);
         //质控病历数
-        Map<String,Object> maps = qcresultInfoFacade.resultMrCountByDept(qcresultFilterVO);
-        if(MapUtils.isEmpty(maps)){
+        List<Map<String,Object>> maps = qcresultInfoFacade.resultMrCountByDept(qcresultFilterVO);
+        if(ListUtil.isEmpty(maps)){
             return retMap;
         }
-        List<NumDTO> retList = Lists.newLinkedList();
-        int totleNum = 0;
-        int firstLevelNum = 0;
-        int secondLevelNum = 0;
-        int thirdLevelNum = 0;
-        if(null != maps.get("num")){
-            totleNum = Integer.parseInt(maps.get("num").toString());
-        }
-        if(null != maps.get("firNum")){
-            firstLevelNum = Integer.parseInt(maps.get("firNum").toString());
-        }
-        if(null != maps.get("secNum")){
-            secondLevelNum = Integer.parseInt(maps.get("secNum").toString());
-        }
-        if(null != maps.get("thrNum")){
-            thirdLevelNum = Integer.parseInt(maps.get("thrNum").toString());
-        }
-
-            NumDTO totleNumDTO = new NumDTO();
-            totleNumDTO.setName("累计质控病历数");
-            totleNumDTO.setTotleNum(totleNum);
-            totleNumDTO.setNum(totleNum);
-            NumDTO firstLevelNumDTO = new NumDTO();
-            firstLevelNumDTO.setName("甲级病历");
-            firstLevelNumDTO.setNum(firstLevelNum);
-            firstLevelNumDTO.setTotleNum(totleNum);
-            Double firstPercent = BigDecimal.valueOf(firstLevelNum)
-                    .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
-                    .doubleValue();
-            String firstPercentStr = df.format(BigDecimal.valueOf(firstPercent).multiply(BigDecimal.valueOf(100))) + "%";
-            firstLevelNumDTO.setPercent(firstPercent);
-            firstLevelNumDTO.setPercentStr(firstPercentStr);
-            NumDTO secondLevelNumDTO = new NumDTO();
-            secondLevelNumDTO.setName("乙级病历");
-            secondLevelNumDTO.setNum(secondLevelNum);
-            secondLevelNumDTO.setTotleNum(totleNum);
-            Double secondPercent = BigDecimal.valueOf(secondLevelNum)
-                    .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
-                    .doubleValue();
-            String secondPercentStr = df.format(BigDecimal.valueOf(secondPercent).multiply(BigDecimal.valueOf(100))) + "%";
-            secondLevelNumDTO.setPercent(secondPercent);
-            secondLevelNumDTO.setPercentStr(secondPercentStr);
-            NumDTO thirdLevelNumDTO = new NumDTO();
-            thirdLevelNumDTO.setName("丙级病历");
-            thirdLevelNumDTO.setNum(thirdLevelNum);
-            thirdLevelNumDTO.setTotleNum(totleNum);
-            Double thirdPercent = BigDecimal.valueOf(thirdLevelNum)
-                    .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
-                    .doubleValue();
-            String thirdPercentStr = df.format(BigDecimal.valueOf(thirdPercent).multiply(BigDecimal.valueOf(100))) + "%";
-            thirdLevelNumDTO.setPercent(thirdPercent);
-            thirdLevelNumDTO.setPercentStr(thirdPercentStr);
-            retList.add(totleNumDTO);
-            retList.add(firstLevelNumDTO);
-            retList.add(secondLevelNumDTO);
-            retList.add(thirdLevelNumDTO);
-            retMap.put((String)maps.get("NAME"), retList);
+        for (Map<String, Object> map : maps) {
+            if(null != map.get("NAME") && StringUtils.isNotBlank(map.get("NAME").toString()) && deptMap.containsKey(map.get("NAME").toString())){
+                List<NumDTO> retList = Lists.newLinkedList();
+                int totleNum = 0;
+                int firstLevelNum = 0;
+                int secondLevelNum = 0;
+                int thirdLevelNum = 0;
+                if(null != map.get("num")){
+                    totleNum = Integer.parseInt(map.get("num").toString());
+                }
+                if(null != map.get("firNum")){
+                    firstLevelNum = Integer.parseInt(map.get("firNum").toString());
+                }
+                if(null != map.get("secNum")){
+                    secondLevelNum = Integer.parseInt(map.get("secNum").toString());
+                }
+                if(null != map.get("thrNum")){
+                    thirdLevelNum = Integer.parseInt(map.get("thrNum").toString());
+                }
+
+                NumDTO totleNumDTO = new NumDTO();
+                totleNumDTO.setName("累计质控病历数");
+                totleNumDTO.setTotleNum(totleNum);
+                totleNumDTO.setNum(totleNum);
+                NumDTO firstLevelNumDTO = new NumDTO();
+                firstLevelNumDTO.setName("甲级病历");
+                firstLevelNumDTO.setNum(firstLevelNum);
+                firstLevelNumDTO.setTotleNum(totleNum);
+                Double firstPercent = BigDecimal.valueOf(firstLevelNum)
+                        .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
+                        .doubleValue();
+                String firstPercentStr = df.format(BigDecimal.valueOf(firstPercent).multiply(BigDecimal.valueOf(100))) + "%";
+                firstLevelNumDTO.setPercent(firstPercent);
+                firstLevelNumDTO.setPercentStr(firstPercentStr);
+                NumDTO secondLevelNumDTO = new NumDTO();
+                secondLevelNumDTO.setName("乙级病历");
+                secondLevelNumDTO.setNum(secondLevelNum);
+                secondLevelNumDTO.setTotleNum(totleNum);
+                Double secondPercent = BigDecimal.valueOf(secondLevelNum)
+                        .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
+                        .doubleValue();
+                String secondPercentStr = df.format(BigDecimal.valueOf(secondPercent).multiply(BigDecimal.valueOf(100))) + "%";
+                secondLevelNumDTO.setPercent(secondPercent);
+                secondLevelNumDTO.setPercentStr(secondPercentStr);
+                NumDTO thirdLevelNumDTO = new NumDTO();
+                thirdLevelNumDTO.setName("丙级病历");
+                thirdLevelNumDTO.setNum(thirdLevelNum);
+                thirdLevelNumDTO.setTotleNum(totleNum);
+                Double thirdPercent = BigDecimal.valueOf(thirdLevelNum)
+                        .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
+                        .doubleValue();
+                String thirdPercentStr = df.format(BigDecimal.valueOf(thirdPercent).multiply(BigDecimal.valueOf(100))) + "%";
+                thirdLevelNumDTO.setPercent(thirdPercent);
+                thirdLevelNumDTO.setPercentStr(thirdPercentStr);
+                retList.add(totleNumDTO);
+                retList.add(firstLevelNumDTO);
+                retList.add(secondLevelNumDTO);
+                retList.add(thirdLevelNumDTO);
+                retMap.put(map.get("NAME").toString(), retList);
+            }
+        }
         return retMap;
     }
 

+ 1 - 1
src/main/java/com/diagbot/mapper/QcresultInfoMapper.java

@@ -89,7 +89,7 @@ public interface QcresultInfoMapper extends BaseMapper<QcresultInfo> {
      */
     public List<NumDTO> resultCountByDept(QcresultFilterVO qcresultFilterVO);
 
-    public Map<String,Object> resultMrCountByDept(QcresultFilterVO qcresultFilterVO);
+    public List<Map<String,Object>> resultMrCountByDept(QcresultFilterVO qcresultFilterVO);
 
     /**
      * 各模块缺陷占比-按科室

+ 1 - 1
src/main/java/com/diagbot/service/QcresultInfoService.java

@@ -87,7 +87,7 @@ public interface QcresultInfoService extends IService<QcresultInfo> {
      */
     public List<NumDTO> resultCountByDept(QcresultFilterVO qcresultFilterVO);
 
-    public Map<String,Object> resultMrCountByDept(QcresultFilterVO qcresultFilterVO);
+    public  List<Map<String,Object>> resultMrCountByDept(QcresultFilterVO qcresultFilterVO);
 
     /**
      * 各模块缺陷占比-按科室

+ 1 - 1
src/main/java/com/diagbot/service/impl/QcresultInfoServiceImpl.java

@@ -114,7 +114,7 @@ public class QcresultInfoServiceImpl extends ServiceImpl<QcresultInfoMapper, Qcr
         return baseMapper.resultCountByDept(qcresultFilterVO);
     }
     @Override
-    public Map<String,Object> resultMrCountByDept(QcresultFilterVO qcresultFilterVO){
+    public List<Map<String,Object>> resultMrCountByDept(QcresultFilterVO qcresultFilterVO){
         return baseMapper.resultMrCountByDept(qcresultFilterVO);
     }
 

+ 3 - 0
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -1141,6 +1141,9 @@
         <if test="gradeType != null and gradeType != ''">
             AND c.grade_type = #{gradeType}
         </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
     </select>
 
     <!-- 按模块统计质控缺陷数 -->