Explorar o código

控制台-统计详情

zhaops %!s(int64=5) %!d(string=hai) anos
pai
achega
3782c93cf2

+ 117 - 1
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -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;
+    }
+    //-----------------------分页接口结束-------------------------------
 }

+ 19 - 0
src/main/java/com/diagbot/mapper/QcresultInfoMapper.java

@@ -1,15 +1,18 @@
 package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.AverageStatisticsDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.entity.QcresultInfo;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterByDeptVO;
 import com.diagbot.vo.QcresultFilterVO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -95,4 +98,20 @@ public interface QcresultInfoMapper extends BaseMapper<QcresultInfo> {
      * @return
      */
     public List<DeptNumDTO> entryCountGroupByEntryAndDept(FilterByDeptVO filterByDeptVO);
+
+    /**
+     * 各模块缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    public IPage<NumDTO> entryCountGroupByCasePage(@Param("filterPageVO") FilterPageVO filterPageVO);
+
+    /**
+     * 条目缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    public IPage<NumDTO> entryCountGroupByEntryPage(@Param("filterPageVO") FilterPageVO filterPageVO);
 }

+ 19 - 0
src/main/java/com/diagbot/service/QcresultInfoService.java

@@ -1,5 +1,6 @@
 package com.diagbot.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.dto.AverageStatisticsDTO;
 import com.diagbot.dto.DeptNumDTO;
@@ -7,9 +8,11 @@ import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.entity.QcresultInfo;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterByDeptVO;
 import com.diagbot.vo.QcresultFilterVO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -96,4 +99,20 @@ public interface QcresultInfoService extends IService<QcresultInfo> {
      * @return
      */
     public List<DeptNumDTO> entryCountGroupByEntryAndDept(FilterByDeptVO filterByDeptVO);
+
+    /**
+     * 各模块缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    public IPage<NumDTO> entryCountGroupByCasePage(@Param("filterPageVO") FilterPageVO filterPageVO);
+
+    /**
+     * 条目缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    public IPage<NumDTO> entryCountGroupByEntryPage(@Param("filterPageVO") FilterPageVO filterPageVO);
 }

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

@@ -1,5 +1,6 @@
 package com.diagbot.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.dto.AverageStatisticsDTO;
 import com.diagbot.dto.DeptNumDTO;
@@ -9,9 +10,11 @@ import com.diagbot.entity.QcresultInfo;
 import com.diagbot.mapper.QcresultInfoMapper;
 import com.diagbot.service.QcresultInfoService;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterByDeptVO;
 import com.diagbot.vo.QcresultFilterVO;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -127,4 +130,25 @@ public class QcresultInfoServiceImpl extends ServiceImpl<QcresultInfoMapper, Qcr
     public List<DeptNumDTO> entryCountGroupByEntryAndDept(FilterByDeptVO filterByDeptVO) {
         return baseMapper.entryCountGroupByEntryAndDept(filterByDeptVO);
     }
+
+    /**
+     * 各模块缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    @Override
+    public IPage<NumDTO> entryCountGroupByCasePage(@Param("filterPageVO") FilterPageVO filterPageVO) {
+        return baseMapper.entryCountGroupByCasePage(filterPageVO);
+    }
+
+    /**
+     * 条目缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    public IPage<NumDTO> entryCountGroupByEntryPage(@Param("filterPageVO") FilterPageVO filterPageVO) {
+        return baseMapper.entryCountGroupByEntryPage(filterPageVO);
+    }
 }

+ 37 - 0
src/main/java/com/diagbot/vo/FilterPageVO.java

@@ -0,0 +1,37 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/5/14 14:57
+ */
+@Getter
+@Setter
+public class FilterPageVO extends Page {
+    /**
+     * 统计维度 1-本月,2-本年
+     */
+    private Integer type;
+    /**
+     * 起始时间
+     */
+    @ApiModelProperty(hidden = true)
+    private String startDate;
+    /**
+     * 结束时间
+     */
+    @ApiModelProperty(hidden = true)
+    private String endDate;
+    /**
+     * 医院id
+     */
+    @ApiModelProperty(hidden = true)
+    private String hospitalId;
+
+    private String name;
+}

+ 34 - 0
src/main/java/com/diagbot/web/ConsoleController.java

@@ -1,8 +1,11 @@
 package com.diagbot.web;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.ConsoleFacade;
+import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -189,4 +192,35 @@ public class ConsoleController {
         return RespDTO.onSuc(consoleFacade.entryByDept(filterVO));
     }
     //-----------------------单独接口结束-------------------------------
+
+    //-----------------------分页接口开始-------------------------------
+
+    /**
+     * 各模块缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    @ApiOperation(value = "各模块缺陷占比(分页)[by:zhaops]",
+            notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
+    @PostMapping("/entryCountGroupByCasePage")
+    @SysLogger("entryCountGroupByCasePage")
+    public RespDTO<IPage<NumDTO>> entryCountGroupByCasePage(@RequestBody FilterPageVO filterPageVO) {
+        return RespDTO.onSuc(consoleFacade.entryCountGroupByCasePage(filterPageVO));
+    }
+
+    /**
+     * 各模块缺陷占比(分页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    @ApiOperation(value = "条目缺陷占比(分页)[by:zhaops]",
+            notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
+    @PostMapping("/entryCountGroupByEntryPage")
+    @SysLogger("entryCountGroupByEntryPage")
+    public RespDTO<IPage<NumDTO>> entryCountGroupByEntryPage(@RequestBody FilterPageVO filterPageVO) {
+        return RespDTO.onSuc(consoleFacade.entryCountGroupByEntryPage(filterPageVO));
+    }
+    //-----------------------分页接口结束-------------------------------
 }

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

@@ -385,4 +385,134 @@
         a.beh_dept_id,
         a.beh_dept_name
     </select>
+
+    <!-- 按模块统计质控缺陷数(分页) -->
+    <select id="entryCountGroupByCasePage"  resultType="com.diagbot.dto.NumDTO">
+        SELECT
+        d.cases_id AS id,
+        e.NAME AS name,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c,
+        med_qcresult_detail d,
+        qc_cases e,
+        qc_cases_entry f
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND e.is_deleted = 'N'
+        AND f.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = d.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND a.behospital_code = d.behospital_code
+        AND d.cases_id = e.id
+        AND d.cases_entry_id = f.id
+        AND e.id = f.cases_id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
+        </if>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
+        </if>
+        <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
+        </if>
+        <if test="filterPageVO.name != null and filterPageVO.name != ''">
+            AND e.name like CONCAT('%', #{filterPageVO.name},'%')
+        </if>
+        GROUP BY
+        d.cases_id,
+        e.`name`
+    </select>
+
+    <!-- 条目缺陷分组统计(分页) -->
+    <select id="entryCountGroupByEntryPage"  resultType="com.diagbot.dto.NumDTO">
+        SELECT t.*
+        FROM
+        (SELECT
+        t1.id,
+        t1.NAME,
+        count(*) AS num,
+        t2.totleNum
+        FROM
+        (
+        SELECT
+        d.id AS id,
+        d.NAME AS NAME
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_detail c,
+        qc_cases_entry d
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
+        </if>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
+        </if>
+        <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
+        </if>
+        <if test="filterPageVO.name != null and filterPageVO.name != ''">
+            AND d.name like CONCAT('%', #{filterPageVO.name},'%')
+        </if>
+        ) t1,(
+        SELECT
+        count(*) AS totleNum
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_detail c,
+        qc_cases_entry d
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
+        </if>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
+        </if>
+        <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
+        </if>
+        <if test="filterPageVO.name != null and filterPageVO.name != ''">
+            AND d.name like CONCAT('%', #{filterPageVO.name},'%')
+        </if>
+        ) t2
+        GROUP BY
+        t1.id,
+        t1.NAME
+        ORDER BY
+        count(*) DESC)t
+    </select>
 </mapper>