From fea22e82e7e49691f6e0c20a29b228d0ab3173e9 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期三, 29 十月 2025 17:08:38 +0800
Subject: [PATCH] 修改问题

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java |   73 +++++++++++++++++++++++++++---------
 1 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
index 1e02d55..a778877 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -42,6 +42,7 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.InetAddress;
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -178,8 +179,7 @@
                 checkScores = scoreMapper.selectCheckScoreMap(checkScore);
             }
         }
-        //鍒嗘暟淇濈暀涓�浣嶅皬鏁�
-        checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(1, RoundingMode.HALF_UP)));
+        checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(4, RoundingMode.HALF_UP)));
         Map<Long, List<CheckScore>> map = checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId));
         for (Map.Entry<Long, List<CheckScore>> entry : map.entrySet()) {
             List<CheckScore> tempList = getCheckScores(entry);
@@ -191,18 +191,30 @@
 
     private List<CheckScore> getCheckScores(Map.Entry<Long, List<CheckScore>> entry) {
         List<CheckScore> tempList = new ArrayList<>(); // 涓存椂瀛樺偍闇�瑕佹坊鍔犵殑鍏冪礌
-        for (CheckScore listCheckScore : entry.getValue()) {
-            if (listCheckScore.getExamineCategory() == 1 && entry.getValue().size() == 1) {
-                CheckScore face = new CheckScore();
-                face.setExamineCategory((short) 2);
-                face.setScore(new BigDecimal("0.0"));
-                CheckScore car = new CheckScore();
-                car.setExamineCategory((short) 3);
-                car.setScore(new BigDecimal("0.0"));
-                tempList.add(face);
-                tempList.add(car);
+
+        boolean hasFace = false;
+        boolean hasCar = false;
+        for (int i =0;i <entry.getValue().size();i++) {
+            CheckScore checkScore = entry.getValue().get(i);
+            if (checkScore.getExamineCategory() == 2){
+                hasCar = true;
+            }else if (checkScore.getExamineCategory() == 3){
+                hasFace = true;
             }
         }
+        if (!hasCar){
+            CheckScore car = new CheckScore();
+            car.setExamineCategory((short) 2);
+            car.setScore(new BigDecimal("0.000"));
+            tempList.add(car);
+        }
+        if (!hasFace){
+            CheckScore face = new CheckScore();
+            face.setExamineCategory((short) 3);
+            face.setScore(new BigDecimal("0.000"));
+            tempList.add(face);
+        }
+
         return tempList;
     }
 
@@ -554,28 +566,53 @@
     @Override
     public Map<String, Map<String, Object>> dashboard(DashboardQuery dashboardQuery) {
         Date now = new Date();
+
+//        Calendar cal = Calendar.getInstance();
+//
+//// 2. 璁剧疆涓轰粖骞�10鏈�12鍙� 00:00:00锛堟竻闄ゆ椂鍒嗙锛岄伩鍏嶅綋鍓嶆椂闂村共鎵帮級
+//        cal.set(Calendar.MONTH, Calendar.OCTOBER);  // 10鏈堬紙鐢ㄥ父閲忔洿鐩磋锛岄伩鍏嶈0鍩猴級
+//// cal.set(Calendar.MONTH, 9);  // 涔熷彲浠ョ敤鏁板瓧9锛堜笉鎺ㄨ崘锛屽彲璇绘�у樊锛�
+//        cal.set(Calendar.DAY_OF_MONTH, 12);         // 鏃ユ湡璁句负12鍙�
+//        cal.set(Calendar.HOUR_OF_DAY, 12);           // 灏忔椂璁句负0锛�24灏忔椂鍒讹級
+//        cal.set(Calendar.MINUTE, 0);                // 鍒嗛挓璁句负0
+//        cal.set(Calendar.SECOND, 0);                // 绉掕涓�0
+//        cal.set(Calendar.MILLISECOND, 0);           // 姣璁句负0
+//
+//// 3. 杞垚Date瀵硅薄
+//        Date now = cal.getTime();
+
+
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         dashboardQuery.setStartTime(format.format(DateUtils.getDayStart(now)));
         dashboardQuery.setEndTime(format.format(DateUtils.getDayEnd(now)));
         List<CheckScore> dashboard = scoreMapper.dashboard(dashboardQuery);
+        DecimalFormat decimalFormat = new DecimalFormat("0.00%");
+        // 璁剧疆鍥涜垗浜斿叆妯″紡
+        decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
         //鍒濆鍖栧悇涓尯鍘挎暟鎹�
         Map<String, Map<String, Object>> resultMap = new HashMap<>();
         for (AreaDeptEnum value : AreaDeptEnum.values()) {
             Map<String, Object> map = new HashMap<>();
-            map.put("video", 0);
-            map.put("car", 0);
-            map.put("face", 0);
+            map.put("video", "0.00%");
+            map.put("car","0.00%");
+            map.put("face", "0.00%");
             resultMap.put(value.getName(), map);
         }
         //濉厖鍚勪釜鍖哄幙鏁版嵁
         for (CheckScore checkScore : dashboard) {
             Map<String, Object> map = resultMap.get(checkScore.getDeptName());
+            BigDecimal score = checkScore.getScore();
+            // 鏍稿績閫昏緫锛氬師濮媠core 脳10 鈫� 淇濈暀涓や綅灏忔暟 鈫� 鎷兼帴鐧惧垎鍙�
+            BigDecimal scoreMultiplied = score.multiply(new BigDecimal("100"));
+            BigDecimal scoreWithTwoDecimals = scoreMultiplied.setScale(2, RoundingMode.HALF_UP); // 淇濈暀涓や綅灏忔暟锛�46.16
+            String formattedScore = scoreWithTwoDecimals + "%"; // 鎷兼帴鐧惧垎鍙凤細46.16%
+
             if (CheckConstants.Rule_Category_Video.equals(checkScore.getExamineCategory())) {
-                map.put("video", checkScore.getScore().setScale(1, RoundingMode.HALF_UP));
+                map.put("video", formattedScore);
             } else if (CheckConstants.Rule_Category_Car.equals(checkScore.getExamineCategory())) {
-                map.put("car", checkScore.getScore().setScale(1, RoundingMode.HALF_UP));
+                map.put("car", formattedScore);
             } else if (CheckConstants.Rule_Category_Face.equals(checkScore.getExamineCategory())) {
-                map.put("face", checkScore.getScore().setScale(1, RoundingMode.HALF_UP));
+                map.put("face",formattedScore);
             }
             resultMap.put(checkScore.getDeptName(), map);
         }

--
Gitblit v1.8.0