Преглед на файлове

台州/长兴控制台图表,新增同比图例

chengyao преди 4 години
родител
ревизия
093de8cffc

+ 22 - 3
src/main/java/com/diagbot/aggregate/AverageStatisticsAggregate.java

@@ -274,26 +274,45 @@ public class AverageStatisticsAggregate {
         if (averageList.size() <= limitCount) {
             retAverageList = BeanUtil.listCopyTo(averageList, AverageStatisticsDTO.class);
         } else {
-            retAverageList = averageList.subList(0, limitCount - 1);
-            List<AverageStatisticsDTO> otherList = averageList.subList(limitCount - 1, averageList.size());
+            retAverageList = averageList.subList(0, limitCount - 2);
+            List<AverageStatisticsDTO> otherList = averageList.subList(limitCount - 2, averageList.size());
             Double totleValue = otherList
                     .stream()
                     .map(i -> BigDecimal.valueOf(i.getTotleValue()))
                     .reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue();
+            Double sameTotleValue = otherList
+                    .stream()
+                    .map(i -> BigDecimal.valueOf(i.getSameTotleValue()))
+                    .reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue();
             Integer num = otherList
                     .stream()
                     .map(AverageStatisticsDTO::getNum)
                     .reduce(0, Integer::sum);
+            Integer sameNum = otherList
+                    .stream()
+                    .map(AverageStatisticsDTO::getSameNum)
+                    .reduce(0, Integer::sum);
             Double averageValue = BigDecimal.valueOf(totleValue)
                     .divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP)
                     .doubleValue();
+            Double lastYearAverageValue = 0d;
+            if(0 != sameNum){
+                 lastYearAverageValue = BigDecimal.valueOf(sameTotleValue)
+                        .divide(BigDecimal.valueOf(sameNum), 2, RoundingMode.HALF_UP)
+                        .doubleValue();
+            }
+
+
             AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
             retAverageStatistics.setName("其他");
             retAverageStatistics.setNum(num);
+            retAverageStatistics.setSameNum(sameNum);
+            retAverageStatistics.setSameTotleValue(sameTotleValue);
+            retAverageStatistics.setLastYearAverageValue(lastYearAverageValue);
             retAverageStatistics.setAverageValue(averageValue);
             retAverageStatistics.setTotleValue(totleValue);
             retAverageList.add(retAverageStatistics);
         }
         return retAverageList;
     }
-}
+}

+ 4 - 2
src/main/java/com/diagbot/dto/AverageStatisticsDTO.java

@@ -15,10 +15,12 @@ public class AverageStatisticsDTO {
     private String id;
     @Excel(name = "科室名称", width = 30, orderNum = "1")
     private String name;
-    private Integer num;
+    private Integer num = 0;
+    private Integer sameNum = 0; //同期num
     @Excel(name = "本年平均住院天数(天)", width = 15, orderNum = "2")
     private Double averageValue = 0d;
     private Double totleValue = 0d;
+    private Double sameTotleValue = 0d;
     //环比平均值
     @Excel(name = "去年平均住院天数(天)", width = 15, orderNum = "3")
     private Double lastAverageValue = 0d;
@@ -26,4 +28,4 @@ public class AverageStatisticsDTO {
     private Double lastYearAverageValue = 0d;
     //科室分类
     private String deptClass;
-}
+}

+ 137 - 2
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -160,14 +160,81 @@ public class ConsoleFacade {
      */
     public Map<String, Object> getAverageScore(FilterVO filterVO) {
         Map<String, Object> retMap = new HashMap<>();
-        filterFacade.filterVOSet(filterVO);
+        filterFacade.filterVOSame(filterVO);
         List<AverageStatisticsDTO> averageScoreList = averageStatisticsAggregate.getAverageScore(filterVO);
+
+        AverageStatisticsDTO item = getGlobleAverageTitle(averageScoreList);
+            if (item != null) {
+                averageScoreList.add(0, item);
+            }
+
         if (ListUtil.isNotEmpty(averageScoreList)) {
             retMap.put("各科室质控平均分", averageScoreList);
         }
         return retMap;
     }
 
+    /**
+     * 增加全院记录
+     *
+     * @param records
+     * @return
+     */
+    public AverageStatisticsDTO getGlobleAverageTitle(List<AverageStatisticsDTO> records) {
+        DecimalFormat df = new DecimalFormat("#0.00");
+        AverageStatisticsDTO item = new AverageStatisticsDTO();
+        if (ListUtil.isEmpty(records)) {
+            return null;
+        }
+
+        //数量
+        Integer num = records
+                .stream()
+                .map(AverageStatisticsDTO::getNum)
+                .reduce(0, Integer::sum);
+
+        //同期数量
+        Integer sameNum = records
+                .stream()
+                .map(AverageStatisticsDTO::getSameNum)
+                .reduce(0, Integer::sum);
+
+        Double totleValue = records
+                .stream()
+                .map(i -> BigDecimal.valueOf(i.getTotleValue()))
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .doubleValue();
+
+        Double sameTotleValue = records
+                .stream()
+                .map(i -> BigDecimal.valueOf(i.getSameTotleValue()))
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .doubleValue();
+
+        Double averageValue = 0d;
+        if(0 != num){
+             averageValue = BigDecimal.valueOf(totleValue)
+                    .divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP)
+                    .doubleValue();
+        }
+        Double lastYearAverageValue = 0d;
+        if(0 != sameNum) {
+            lastYearAverageValue = BigDecimal.valueOf(sameTotleValue)
+                    .divide(BigDecimal.valueOf(sameNum), 2, RoundingMode.HALF_UP)
+                    .doubleValue();
+        }
+
+        item.setName("全院");
+        item.setNum(num);
+        item.setSameNum(sameNum);
+        item.setAverageValue(averageValue);
+        item.setTotleValue(totleValue);
+        item.setSameTotleValue(sameTotleValue);
+        item.setLastYearAverageValue(lastYearAverageValue);
+        return item;
+    }
+
+
     /**
      * 各科室质控平均分(首页)-根据内外科系统统计
      *
@@ -175,7 +242,7 @@ public class ConsoleFacade {
      * @return
      */
     public List<AverageStatisticsDTO> getAverageScoreByDeptClass(FilterVO filterVO) {
-        filterFacade.filterVOSet(filterVO);
+        filterFacade.filterVOSame(filterVO);
         List<AverageStatisticsDTO> retAverageScoreList = Lists.newLinkedList();
         List<AverageStatisticsDTO> averageScoreList = qcresultInfoFacade.getAverageScoreByDeptClass(filterVO);
         Integer limitCount = filterVO.getLimitCount();
@@ -183,9 +250,77 @@ public class ConsoleFacade {
         if (ListUtil.isNotEmpty(averageScoreList)) {
             retAverageScoreList = averageStatisticsAggregate.getLimitAverageList(averageScoreList, limitCount);
         }
+        AverageStatisticsDTO item = getGlobleInOutTitle(retAverageScoreList,filterVO);
+        if (item != null) {
+            retAverageScoreList.add(0, item);
+        }
         return retAverageScoreList;
     }
 
+    /**
+     * 增加内外科记录
+     *
+     * @param records
+     * @return
+     */
+    public AverageStatisticsDTO getGlobleInOutTitle(List<AverageStatisticsDTO> records,FilterVO filterVO) {
+        DecimalFormat df = new DecimalFormat("#0.00");
+        AverageStatisticsDTO item = new AverageStatisticsDTO();
+        if (ListUtil.isEmpty(records)) {
+            return null;
+        }
+
+        //数量
+        Integer num = records
+                .stream()
+                .map(AverageStatisticsDTO::getNum)
+                .reduce(0, Integer::sum);
+
+        //同期数量
+        Integer sameNum = records
+                .stream()
+                .map(AverageStatisticsDTO::getSameNum)
+                .reduce(0, Integer::sum);
+
+        Double totleValue = records
+                .stream()
+                .map(i -> BigDecimal.valueOf(i.getTotleValue()))
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .doubleValue();
+
+        Double sameTotleValue = records
+                .stream()
+                .map(i -> BigDecimal.valueOf(i.getSameTotleValue()))
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .doubleValue();
+
+        Double averageValue = 0d;
+        if(0 != num){
+            averageValue = BigDecimal.valueOf(totleValue)
+                    .divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP)
+                    .doubleValue();
+        }
+        Double lastYearAverageValue = 0d;
+        if(0 != sameNum) {
+            lastYearAverageValue = BigDecimal.valueOf(sameTotleValue)
+                    .divide(BigDecimal.valueOf(sameNum), 2, RoundingMode.HALF_UP)
+                    .doubleValue();
+        }
+
+    if("内科".equals(filterVO.getDeptClass())){
+        item.setName("内科系统");
+    }else{
+        item.setName("外科系统");
+    }
+        item.setNum(num);
+        item.setSameNum(sameNum);
+        item.setAverageValue(averageValue);
+        item.setTotleValue(totleValue);
+        item.setSameTotleValue(sameTotleValue);
+        item.setLastYearAverageValue(lastYearAverageValue);
+        return item;
+    }
+
     /**
      * 各科室甲级病历占比
      *

+ 56 - 1
src/main/java/com/diagbot/facade/FilterFacade.java

@@ -89,6 +89,28 @@ public class FilterFacade {
         return dateStr;
     }
 
+    /**
+     * 获取上一年同期开始结束时间
+     *
+     * @param date
+     * @return
+     */
+    public String getStaEndDate(String date) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date dateStart = new Date();
+        try {
+             dateStart = formatter.parse(date);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(dateStart);
+        c.add(Calendar.YEAR, -1);
+        Date y = c.getTime();
+        String newDate = formatter.format(y);
+        return newDate;
+    }
+
     /**
      * 获取上一年同期开始结束时间
      *
@@ -99,7 +121,7 @@ public class FilterFacade {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
         Date dateStart = new Date();
         try {
-             dateStart = formatter.parse(date);
+            dateStart = formatter.parse(date);
         } catch (ParseException e) {
             e.printStackTrace();
         }
@@ -248,6 +270,39 @@ public class FilterFacade {
         filterOrderVO.setLimitCount(filterVO.getLimitCount());
     }
 
+    /**
+     * 过滤条件设置
+     *
+     * @param filterVO
+     */
+    public void filterVOSame(FilterVO filterVO) {
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        String userId = SysUserUtils.getCurrentPrincipleID();
+        filterVO.setHospitalId(hospitalId);
+        filterVO.setUserId(Long.valueOf(userId));
+        if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
+            filterVO.setLimitCount(10);
+        }
+        if (StringUtil.isBlank(filterVO.getStartDate())) {
+            String startDate = getStartDateStr(filterVO.getType(), null);
+            filterVO.setStartDate(startDate);
+            String lastStartDate = getStaEndDate(startDate);
+            filterVO.setLastStartDate(lastStartDate);
+        }else{
+            String lastStartDate = getStaEndDate(filterVO.getStartDate());
+            filterVO.setLastStartDate(lastStartDate);
+        }
+        if (StringUtil.isBlank(filterVO.getEndDate())) {
+            String endDate = getEndDateStr(filterVO.getType(), null);
+            filterVO.setEndDate(endDate);
+            String lastEndDate = getStaEndDate(endDate);
+            filterVO.setLastEndDate(lastEndDate);
+        }else{
+            String lastEndDate = getStaEndDate(filterVO.getEndDate());
+            filterVO.setLastEndDate(lastEndDate);
+        }
+    }
+
     /**
      * 过滤条件设置
      *

+ 2 - 0
src/main/java/com/diagbot/vo/FilterVO.java

@@ -33,10 +33,12 @@ public class FilterVO {
     /**
      * 去年同期起始时间
      */
+    @ApiModelProperty(hidden = true)
     private String lastStartDate;
     /**
      * 去年同期结束时间
      */
+    @ApiModelProperty(hidden = true)
     private String lastEndDate;
 
     /**

+ 121 - 2
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -818,6 +818,16 @@
     </select>
     <!-- 各科室质控平均分(首页) -->
     <select id="getAverageScore" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
+        select
+        m1.id,
+        m1.name,
+        m1.totleValue,
+        m2.sameTotleValue,
+        m1.averageValue,
+        m2.lastYearAverageValue,
+        m1.num,
+        m2.sameNum
+        from(
         SELECT
         a.beh_dept_id AS id,
         a.beh_dept_name AS name,
@@ -857,11 +867,65 @@
         </if>
         GROUP BY
         a.beh_dept_id,
-        a.beh_dept_name
+        a.beh_dept_name)m1 left join
+        ( SELECT
+        a.beh_dept_id AS id,
+        a.beh_dept_name AS name,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue,
+        count(*) AS sameNum
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = c.behospital_code
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name)m2
+        on
+        m1.id = m2.id
+        and m1.name = m2.name
     </select>
 
     <!-- 各科室质控平均分(首页)-根据内外科系统统计 -->
     <select id="getAverageScoreByDeptClass" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
+        select
+        m1.id,
+        m1.name,
+        m1.totleValue,
+        m2.sameTotleValue,
+        m1.averageValue,
+        m2.lastYearAverageValue,
+        m1.num,
+        m2.sameNum,
+        m1.deptClass
+        from(
         SELECT
         a.beh_dept_id AS id,
         a.beh_dept_name AS NAME,
@@ -913,7 +977,62 @@
         </if>
         GROUP BY
         a.beh_dept_id,
-        a.beh_dept_name
+        a.beh_dept_name) m1 left join
+        (SELECT
+        a.beh_dept_id AS id,
+        a.beh_dept_name AS NAME,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue,
+        count(*) AS sameNum ,
+        e.dept_name as deptClass
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        bas_dept_info d,
+        bas_dept_info e
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND e.is_deleted = 'N'
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = d.hospital_id
+        AND a.hospital_id = e.hospital_id
+        AND a.behospital_code = c.behospital_code
+        AND a.beh_dept_id = d.dept_id
+        AND d.parent_dept_id = e.dept_id
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="deptClass != null and deptClass != ''">
+            AND e.dept_name = #{deptClass}
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name)m2
+        on
+        m1.id = m2.id
+        and m1.name = m2.name
     </select>
 
     <!-- 按科室统计质控病历数 -->