|
@@ -1,6 +1,7 @@
|
|
|
package com.management.platform.service;
|
|
|
|
|
|
import com.management.platform.entity.UserCorpwxTime;
|
|
|
+import com.management.platform.util.DateTimeUtil;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -143,7 +144,15 @@ public class ExcelParserService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private double calculateWorkHours(String startTime, String endTime) {
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String startTime = "08:30";
|
|
|
+ String endTime = "18:16";
|
|
|
+ double workHours = calculateWorkHours(startTime, endTime);
|
|
|
+
|
|
|
+ System.out.println("工作时长:" + workHours + "小时");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static double calculateWorkHours(String startTime, String endTime) {
|
|
|
// 简单计算工作时长(小时)
|
|
|
// 实际应用中需要更精确的计算,考虑午休时间等
|
|
|
String[] startParts = startTime.split(":");
|
|
@@ -166,9 +175,17 @@ public class ExcelParserService {
|
|
|
hours -= 1;
|
|
|
}
|
|
|
//减去晚休时间,17:30-18:00
|
|
|
- if (startHour <= 17 && endHour > 18) {
|
|
|
+ if (startHour <= 17 && endHour >= 18) {
|
|
|
hours -= 0.5;
|
|
|
}
|
|
|
+ double minPart = hours - (int)hours;
|
|
|
+
|
|
|
+ if (minPart > 0 && minPart < 0.5) {
|
|
|
+ minPart = 0;
|
|
|
+ } else if (minPart > 0.5) {
|
|
|
+ minPart = 0.5;
|
|
|
+ }
|
|
|
+ hours = (int)hours + minPart;
|
|
|
|
|
|
return hours;
|
|
|
}
|