Explorar o código

百分比排序

zhaops %!s(int64=5) %!d(string=hai) anos
pai
achega
505f9ab664

+ 0 - 15
src/main/java/com/diagbot/facade/ConsoleByDeptFacade.java

@@ -336,7 +336,6 @@ public class ConsoleByDeptFacade {
      * @return
      */
     public Map<String, Object> entryCountGroupByEntryAndDept(FilterVO filterVO) {
-        DecimalFormat df = new DecimalFormat("#0.00");
         Map<String, Object> retMap = new LinkedHashMap<>();
         String hospitalId = SysUserUtils.getCurrentHospitalID();
         String userId = SysUserUtils.getCurrentPrincipleID();
@@ -497,22 +496,8 @@ public class ConsoleByDeptFacade {
                 filterPageByDeptVO.setDeptName(deptList.get(0).getDeptName());
             }
         }
-        DecimalFormat df = new DecimalFormat("#0.00");
         filterPageByDeptVOSet(filterPageByDeptVO);
         IPage<CaseAndDeptNumDTO> page = qcresultInfoFacade.entryCountGroupByEntryAndDeptPage(filterPageByDeptVO);
-        List<CaseAndDeptNumDTO> 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;
     }
 

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

@@ -1236,7 +1236,9 @@
         t1.deptId,
         t1.deptName,
         count(*) AS num,
-        t2.totleNum
+        t2.totleNum,
+        ROUND( count(*) /t2.totleNum , 4 ) AS percent,
+        CONCAT(ROUND( count(*) /t2.totleNum * 100, 2 ), '%' ) AS percentStr
         FROM
         (
         SELECT