From 2f9f2b3edb14efdd1e2071e26420e9c9d20b1992 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期三, 22 五月 2024 16:14:30 +0800
Subject: [PATCH] 2024-5-22 班次模块调整

---
 performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java |   58 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java b/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
index e6fa72e..d4f0b04 100644
--- a/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
+++ b/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
@@ -19,6 +19,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -100,7 +101,7 @@
         List<Map<String, Object>> mapYearIPage = baseMapper.performanceShiftYearPage(time, userName, laboratory);
         mapIPage.getRecords().forEach(i -> {
             String[] shiftTimes = i.getShiftTime().split(";");
-            int totalAttendance = 0;
+            double totalAttendance = 0;
             List<Map<String, Object>> map = new ArrayList<>();
             // 鍒嗗壊鏃ユ湡
             for (String shiftTime : shiftTimes) {
@@ -111,19 +112,29 @@
                         i.getMonthlyAttendance().put(enums.getLabel(), 0);
                     }
                     if (enums.getValue().equals(shiftTimeAndShift[1])) {
-                        Integer num = (Integer) i.getMonthlyAttendance().get(enums.getLabel());
-                        i.getMonthlyAttendance().put(enums.getLabel(), num += 1);
+                        BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(enums.getLabel()).toString());
+                        i.getMonthlyAttendance().put(enums.getLabel(), bigDecimal.add(new BigDecimal("1")));
+                    }
+                    // 鍗婏紝鍙﹀鍗婂ぉ绠楃粰鏃�
+                    if (shiftTimeAndShift[1].equals("5") && enums.getValue().equals("0")) {
+                        BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(enums.getLabel()).toString());
+                        i.getMonthlyAttendance().put(enums.getLabel(), bigDecimal.add(new BigDecimal("0.5")));
                     }
                 }
-                if (shiftTimeAndShift[1].equals("1") || shiftTimeAndShift[1].equals("2") || shiftTimeAndShift[1].equals("0")) {
+                // 鏃╋紝涓紝澶滐紝宸�
+                if (shiftTimeAndShift[1].equals("1") || shiftTimeAndShift[1].equals("2") || shiftTimeAndShift[1].equals("0") || shiftTimeAndShift[1].equals("6")) {
                     i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1);
+                }
+                // 鍗�
+                if (shiftTimeAndShift[1].equals("5")) {
+                    i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 0.5);
                 }
                 hashMap.put("id", shiftTimeAndShift[2]);
                 hashMap.put("shift", shiftTimeAndShift[1]);
                 hashMap.put("time", shiftTimeAndShift[0]);
                 map.add(hashMap);
             }
-            int totalYearAttendance = 0;
+            double totalYearAttendance = 0;
             Map<String, Object> hashMap = new HashMap<>();
             for (Map<String, Object> record : mapYearIPage) {
                 if (record.get("user_id").toString().equals(i.getUserId())) {
@@ -132,12 +143,21 @@
                             hashMap.put(enums.getLabel(), 0);
                         }
                         if (enums.getValue().equals(record.get("shift"))) {
-                            Integer num = (Integer) hashMap.get(enums.getLabel());
-                            hashMap.put(enums.getLabel(), num += 1);
+                            BigDecimal num = new BigDecimal(hashMap.get(enums.getLabel()).toString());
+                            hashMap.put(enums.getLabel(), num.add(new BigDecimal("1")));
+                        }
+                        // 鍗婏紝鍙﹀鍗婂ぉ绠楃粰鏃�
+                        if (record.get("shift").equals("5") && enums.getValue().equals("0")) {
+                            BigDecimal bigDecimal = new BigDecimal(hashMap.get(enums.getLabel()).toString());
+                            hashMap.put(enums.getLabel(), bigDecimal.add(new BigDecimal("0.5")));
                         }
                     }
-                    if (record.get("shift").equals("1") || record.get("shift").equals("2") || record.get("shift").equals("0")) {
+                    if (record.get("shift").equals("1") || record.get("shift").equals("2") || record.get("shift").equals("0") || record.get("shift").equals("6")) {
                         hashMap.put("totalAttendance", totalYearAttendance += 1);
+                    }
+                    // 鍗�
+                    if (record.get("shift").equals("5")) {
+                        hashMap.put("totalAttendance", totalYearAttendance += 0.5);
                     }
                 }
             }
@@ -187,11 +207,11 @@
         for (Map<String, Object> map : mapYearList) {
             Map<String, Object> resultMap = new LinkedHashMap<>();
             Map<String, Object> hashMapYear = new LinkedHashMap<>();
-            int totalYearAttendance = 0;
+            double totalYearAttendance = 0;
             // 涓�骞�12涓湀
             for (int i = 1; i < 13; i++) {
                 Map<String, Object> hashMapMonth = new LinkedHashMap<>();
-                int totalMonthAttendance = 0;
+                double totalMonthAttendance = 0;
                 for (Enums enums : shiftType) {
                     if (!hashMapYear.containsKey(enums.getLabel())) {
                         hashMapYear.put(enums.getLabel(), 0);
@@ -202,9 +222,17 @@
                         int count = countOccurrences(charArray, i + "锛�" + enums.getValue());
                         hashMapMonth.put(enums.getLabel(), count);
                         hashMapYear.put(enums.getLabel(), Integer.parseInt(hashMapYear.get(enums.getLabel()).toString()) + count );
-                        if (enums.getValue().equals("0") || enums.getValue().equals("1") || enums.getValue().equals("2")) {
+                        if (enums.getValue().equals("0") || enums.getValue().equals("1") || enums.getValue().equals("2") || enums.getValue().equals("6")) {
                             totalMonthAttendance += count;
                             totalYearAttendance += count;
+                        }
+                        // 鍗婏紝鍙﹀鍗婂ぉ绠楃粰鏃�
+                        if (enums.getValue().equals("5")) {
+                            BigDecimal multiply = new BigDecimal("0.5").multiply(new BigDecimal(count)).setScale(1, BigDecimal.ROUND_CEILING);
+                            hashMapMonth.put(shiftType.get(0).getLabel(), new BigDecimal(hashMapMonth.get(shiftType.get(0).getLabel()).toString()).add(multiply));
+                            hashMapYear.put(shiftType.get(0).getLabel(), new BigDecimal(hashMapYear.get(shiftType.get(0).getLabel()).toString()).add(multiply));
+                            totalMonthAttendance += multiply.doubleValue();
+                            totalYearAttendance += multiply.doubleValue();
                         }
                     }
                     // 绌烘暟鎹�
@@ -245,14 +273,18 @@
             Map<String, Object> year = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("year")), Map.class);
             excelRowList.add(year.get("totalYearAttendance"));
             enums.forEach(j -> {
-                excelRowList.add(year.get(j.getLabel()));
+                if (!j.getValue().equals("5")) {
+                    excelRowList.add(year.get(j.getLabel()));
+                }
             });
             Map<String, Map<String, Object>> month = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("month")), Map.class);
             for (int j = 1; j < 13; j++) {
                 Object totalMonthAttendance = month.get(j + "").get("totalMonthAttendance");
                 excelRowList.add(totalMonthAttendance);
                 for (Enums anEnum : enums) {
-                    excelRowList.add(month.get(j + "").get(anEnum.getLabel()));
+                    if (!anEnum.getValue().equals("5")) {
+                        excelRowList.add(month.get(j + "").get(anEnum.getLabel()));
+                    }
                 }
             }
             data.add(excelRowList);

--
Gitblit v1.9.3