From e8717e29eed1d17c780ea240c5224ff58867b326 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期二, 04 六月 2024 11:58:21 +0800
Subject: [PATCH] 2024-6-4 班次调整
---
performance-server/src/main/java/com/yuanchu/mom/utils/StyleYearUtils.java | 20 ++----
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java | 101 +++++++++++++++++++--------------
performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java | 4
3 files changed, 67 insertions(+), 58 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 d4f0b04..db37821 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
@@ -3,7 +3,6 @@
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -18,6 +17,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
@@ -42,11 +42,10 @@
@Autowired
private EnumService enumService;
- public List<PerformanceShift> list = new ArrayList<>();
-
@Transactional(rollbackFor = Exception.class)
@Override
public void performanceShiftAdd(PerformanceShiftAddDto performanceShiftAddDto) {
+ List<PerformanceShift> list = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDateTime = performanceShiftAddDto.getStartWeek().format(formatter);
String[] splitUserId = performanceShiftAddDto.getUserId().split(",");
@@ -60,22 +59,21 @@
LocalDate lastDayOfMonth = performanceShiftAddDto.getEndWeek().toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
List<LocalDateTime> localDateTimesBetween = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
localDateTimesBetween.forEach(i -> {
- for (String s : splitUserId) {
- PerformanceShift performanceShift = new PerformanceShift();
- performanceShift.setUserId(Integer.valueOf(s));
- performanceShift.setWorkTime(i);
- performanceShift.setShift("");
- list.add(performanceShift);
- }
+ PerformanceShift performanceShift = new PerformanceShift();
+ performanceShift.setUserId(Integer.valueOf(userId));
+ performanceShift.setWorkTime(i);
+ performanceShift.setShift("");
+ list.add(performanceShift);
if (list.size() >= 1000) {
baseMapper.insertBatchSomeColumn(list);
list.clear();
}
});
- if (!list.isEmpty()) {
- baseMapper.insertBatchSomeColumn(list);
- }
}
+ }
+ if (!list.isEmpty()) {
+ baseMapper.insertBatchSomeColumn(list);
+ list.clear();
}
// 鍐嶆鏇存柊
List<LocalDateTime> datesBetween = getLocalDateTimesBetween(performanceShiftAddDto.getStartWeek(), performanceShiftAddDto.getEndWeek());
@@ -203,7 +201,7 @@
}
// 骞村垎椤典笌瀵煎嚭鍏卞悓浣跨敤
- public List<Map<String, Object>> annualAttendanceProcessing(List<Map<String, Object>> mapYearList, List<Enums> shiftType){
+ public List<Map<String, Object>> annualAttendanceProcessing(List<Map<String, Object>> mapYearList, List<Enums> shiftType) {
for (Map<String, Object> map : mapYearList) {
Map<String, Object> resultMap = new LinkedHashMap<>();
Map<String, Object> hashMapYear = new LinkedHashMap<>();
@@ -212,22 +210,24 @@
for (int i = 1; i < 13; i++) {
Map<String, Object> hashMapMonth = new LinkedHashMap<>();
double totalMonthAttendance = 0;
- for (Enums enums : shiftType) {
- if (!hashMapYear.containsKey(enums.getLabel())) {
- hashMapYear.put(enums.getLabel(), 0);
+ for (Enums shift : shiftType) {
+ // 鍒濆鍖栬祴鍊�
+ if (!hashMapYear.containsKey(shift.getLabel())) {
+ hashMapYear.put(shift.getLabel(), 0);
}
// 鏈�
- if (ObjectUtils.isNotEmpty(map.get("month_str")) && map.get("work_time").equals(i)) {
+ if (!ObjectUtils.isEmpty(map.get("month_str"))) {
String charArray = map.get("month_str").toString();
- 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") || enums.getValue().equals("6")) {
+ int count = countOccurrences(charArray, i + "锛�" + shift.getValue());
+ hashMapMonth.put(shift.getLabel(), count);
+ hashMapYear.put(shift.getLabel(), new BigDecimal(hashMapYear.get(shift.getLabel()).toString()).add(new BigDecimal(count)));
+ // 鏃╋紝涓紝澶滐紝宸�
+ if (shift.getValue().equals("0") || shift.getValue().equals("1") || shift.getValue().equals("2") || shift.getValue().equals("6")) {
totalMonthAttendance += count;
totalYearAttendance += count;
}
- // 鍗婏紝鍙﹀鍗婂ぉ绠楃粰鏃�
- if (enums.getValue().equals("5")) {
+// 鍗婏紝鍙﹀鍗婂ぉ绠楃粰鏃�
+ if (shift.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));
@@ -238,7 +238,7 @@
// 绌烘暟鎹�
else {
map.put("work_time", i);
- hashMapMonth.put(enums.getLabel(), 0);
+ hashMapMonth.put(shift.getLabel(), 0);
}
}
hashMapMonth.put("totalMonthAttendance", totalMonthAttendance);
@@ -256,7 +256,7 @@
public static int countOccurrences(String str, String target) {
int count = 0;
int index = 0;
- while ((index = str.indexOf(target, index))!= -1) {
+ while ((index = str.indexOf(target, index)) != -1) {
count++;
index += target.length();
}
@@ -313,7 +313,7 @@
List<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftList(time, userName, laboratory);
mapIPage.forEach(i -> {
String[] shiftTimes = i.getShiftTime().split(";");
- int totalAttendance = 0;
+ double totalAttendance = 0;
List<Map<String, Object>> map = new ArrayList<>();
// 鍒嗗壊鏃ユ湡
for (String shiftTime : shiftTimes) {
@@ -324,12 +324,22 @@
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]);
@@ -400,12 +410,13 @@
/**
* 杩斿洖琛ㄥご
- *
+ * <p>
* 澶栧眰List浠h〃琛屽唴灞� List浠h〃鍒� 鐩稿悓鐨勫垪鏁版嵁浼氳涓诲姩鍚堝苟
* 鏋勯�犲弻鍒楄〃澶�
- * @return List<List<String>>
+ *
+ * @return List<List < String>>
*/
- private static List<List<String>> getYearHeader(String year, List<Enums> enums){
+ private static List<List<String>> getYearHeader(String year, List<Enums> enums) {
List<List<String>> line = new ArrayList<>();
line.add(Arrays.asList("鑰冨嫟姹囨��", "搴忓彿", "搴忓彿"));
line.add(Arrays.asList("鑰冨嫟姹囨��", "宸ュ彿", "宸ュ彿"));
@@ -413,19 +424,23 @@
line.add(Arrays.asList("鍑哄嫟璇︽儏", year, "鍑哄嫟"));
// 骞� header
for (Enums anEnum : enums) {
- line.add(Arrays.asList("鑰冨嫟姹囨��", year, anEnum.getLabel()));
+ if (!anEnum.getValue().equals("5")) {
+ line.add(Arrays.asList("鑰冨嫟姹囨��", year, anEnum.getLabel()));
+ }
}
// 鏈坔eader
for (int i = 1; i < 13; i++) {
line.add(Arrays.asList("鍑哄嫟璇︽儏", i + " 鏈�", "鍑哄嫟"));
for (Enums anEnum : enums) {
- line.add(Arrays.asList("鍑哄嫟璇︽儏", i + " 鏈�", anEnum.getLabel()));
+ if (!anEnum.getValue().equals("5")) {
+ line.add(Arrays.asList("鍑哄嫟璇︽儏", i + " 鏈�", anEnum.getLabel()));
+ }
}
}
return line;
}
- private static List<List<String>> getMonthHeader(LocalDateTime localDateTimeYear, List<Enums> enums){
+ private static List<List<String>> getMonthHeader(LocalDateTime localDateTimeYear, List<Enums> enums) {
String year = localDateTimeYear.getYear() + " 骞翠汉鍛樼彮娆�";
List<List<String>> line = new ArrayList<>();
line.add(Arrays.asList(year, "搴忓彿", "搴忓彿", "搴忓彿"));
@@ -458,12 +473,12 @@
excelRowList.add(list.get(i).getName());
excelRowList.add(list.get(i).getDepartment());
excelRowList.add(list.get(i).getMonthlyAttendance().get("totalAttendance"));
- excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(3).getLabel()));
- excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(4).getLabel()));
- excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(0).getLabel()));
- excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(1).getLabel()));
- excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(2).getLabel()));
- excelRowList.add(0); // 鍑哄樊
+ excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(3).getLabel())); // 浼�
+ excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(4).getLabel())); // 鍋�
+ excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(0).getLabel())); // 鏃�
+ excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(1).getLabel())); // 涓�
+ excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(2).getLabel())); // 澶�
+ excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(6).getLabel())); // 宸�
for (Map<String, Object> o : list.get(i).getList()) {
String enumLabel = "";
for (Enums anEnum : enums) {
@@ -471,7 +486,7 @@
enumLabel = anEnum.getLabel();
}
}
- excelRowList.add(ObjectUtils.isEmpty(enumLabel) ? "鏃�" : enumLabel);
+ excelRowList.add(ObjectUtils.isEmpty(enumLabel) ? "-" : enumLabel);
}
data.add(excelRowList);
}
diff --git a/performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java b/performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java
index 7c443be..25af470 100644
--- a/performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java
+++ b/performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java
@@ -13,8 +13,8 @@
// 澶寸殑绛栫暐
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 鑳屾櫙棰滆壊
- headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
- headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
+// headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
+// headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
// 瀛椾綋
WriteFont headWriteFont = new WriteFont();
diff --git a/performance-server/src/main/java/com/yuanchu/mom/utils/StyleYearUtils.java b/performance-server/src/main/java/com/yuanchu/mom/utils/StyleYearUtils.java
index 0c6646e..8c53d08 100644
--- a/performance-server/src/main/java/com/yuanchu/mom/utils/StyleYearUtils.java
+++ b/performance-server/src/main/java/com/yuanchu/mom/utils/StyleYearUtils.java
@@ -2,15 +2,9 @@
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
-import com.yuanchu.mom.pojo.AuxiliaryOutputWorkingHours;
import org.apache.poi.ss.usermodel.*;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
public class StyleYearUtils {
/**
@@ -22,7 +16,7 @@
// 澶寸殑绛栫暐
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 鑳屾櫙棰滆壊
- headWriteCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());
+// headWriteCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());
headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
// 瀛椾綋
@@ -63,7 +57,7 @@
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
// 杩欓噷闇�瑕佹寚瀹� FillPatternType 涓篎illPatternType.SOLID_FOREGROUND 涓嶇劧鏃犳硶鏄剧ず鑳屾櫙棰滆壊.澶撮粯璁や簡 FillPatternType鎵�浠ュ彲浠ヤ笉鎸囧畾
- contentWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+// contentWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
// 璁剧疆瀛椾綋
@@ -73,14 +67,14 @@
contentWriteCellStyle.setWriteFont(contentWriteFont);//鍦ㄦ牱寮忕敤搴旂敤璁剧疆鐨勫瓧浣�;
//璁剧疆鏍峰紡;
-// contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//璁剧疆搴曡竟妗�;
-// contentWriteCellStyle.setBottomBorderColor((short) 1);//璁剧疆搴曡竟妗嗛鑹�;
+ contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//璁剧疆搴曡竟妗�;
+ contentWriteCellStyle.setBottomBorderColor((short) 0);//璁剧疆搴曡竟妗嗛鑹�;
contentWriteCellStyle.setBorderLeft(BorderStyle.THIN); //璁剧疆宸﹁竟妗�;
- contentWriteCellStyle.setLeftBorderColor((short) 1);//璁剧疆宸﹁竟妗嗛鑹�;
+ contentWriteCellStyle.setLeftBorderColor((short) 0);//璁剧疆宸﹁竟妗嗛鑹�;
contentWriteCellStyle.setBorderRight(BorderStyle.THIN);//璁剧疆鍙宠竟妗�;
- contentWriteCellStyle.setRightBorderColor((short) 1);//璁剧疆鍙宠竟妗嗛鑹�;
+ contentWriteCellStyle.setRightBorderColor((short) 0);//璁剧疆鍙宠竟妗嗛鑹�;
contentWriteCellStyle.setBorderTop(BorderStyle.THIN);//璁剧疆椤惰竟妗�;
- contentWriteCellStyle.setTopBorderColor((short) 1); ///璁剧疆椤惰竟妗嗛鑹�;
+ contentWriteCellStyle.setTopBorderColor((short) 0); ///璁剧疆椤惰竟妗嗛鑹�;
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// 姘村钩灞呬腑
contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 鍨傜洿灞呬腑
--
Gitblit v1.9.3