From 4d730af0447c686133130d0116a0fa3dd82c2dca Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Tue, 10 Nov 2026 01:41:03 +0000
Subject: [PATCH] Merge branch 'wcd-2411-update' into wcd
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java | 88 +++++++++++++++++++++++++++++--------------
1 files changed, 59 insertions(+), 29 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
index 752102b..3d228e1 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
@@ -15,6 +15,7 @@
*/
package me.zhengjie.modules.treatment.service.impl;
+import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel;
@@ -122,13 +123,16 @@
UserLevelWage userLevelWage = null;
// 如果传递进来的日期在转正日期之前
- if(date1.before(date2)) {
- // 查询没转正且年月最大的数据
- userLevelWage = userLevelWageRepository.findByUserIdAndNoWorker(criteria.getUserId(), confirmationTime);
- } else {
- // 查询第二条转正且日期最大的数据
- userLevelWage = userLevelWageRepository.findByUserIdAndYesWorker(criteria.getUserId(), confirmationTime);
- }
+// if(date1.before(date2)) {
+// // 查询没转正且年月最大的数据
+// userLevelWage = userLevelWageRepository.findByUserIdAndNoWorker(criteria.getUserId(), confirmationTime);
+// } else {
+// // 查询第二条转正且日期最大的数据
+// userLevelWage = userLevelWageRepository.findByUserIdAndYesWorker(criteria.getUserId(), confirmationTime);
+// }
+
+ // 获取小于等于当前月份且日期最大的数据。
+ userLevelWage = userLevelWageRepository.findByUserCurrentLevelWage(criteria.getUserId(), yearMonth);
// UserLevelWage userLevelWage = userLevelWageRepository.findbyUserIdAndDate(criteria.getUserId(), yearMonth);
@@ -145,12 +149,12 @@
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter);
// 获取月初日期
- LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1);
+ LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
// 获取下月初日期
- LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1);
+ LocalDateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
// 查询指定员工的加班补助金额工资
- Double overTimeSalary = attendanceOvertimeRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth);
+ Double overTimeSalary = attendanceOvertimeRepository.findByUserIdAndYearMonth(criteria.getUserId(), DateUtil.parseAttStartTime(firstDayOfMonth), DateUtil.parseAttEndTime(lastDayOfMonth));
// 查询配置表
SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("加班补助金额");
@@ -162,32 +166,58 @@
}
@Override
- public Double queryTravelAllowance(UserLevelWageQueryCriteria criteria) {
+ public Double queryTravelAllowance(UserLevelWageQueryCriteria criteria, JSONObject jsonObject) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter);
// 获取月初日期
- LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1);
- // 获取下月初日期
- LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1);
+ LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
+ // 获取月末最后一天日期
+ LocalDateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
// 查询出差表的记录
- List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth);
- Map<String, Double> attendanceBusinessTravelMap = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(AttendanceBusinessTravel::getCategory, Collectors.summingDouble(AttendanceBusinessTravel::getTravelDuration)));
+ List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(criteria.getUserId(), firstDayOfMonth, lastDayOfMonth);
+ // TODO:因一天可填多条出差记录,每条最小的时长是0.5天,导致可能会有当天总时长超出1天的情况。(每天出差类型只会有一种,不考虑多种的情况)
+ List<AttendanceBusinessTravel> calcAttendanceBusinessTravelList = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(
+ (AttendanceBusinessTravel businessTravel) -> businessTravel.getTravelStartTime().toLocalDateTime().toLocalDate().toString(),
+ Collectors.reducing(null, (AttendanceBusinessTravel prev, AttendanceBusinessTravel cur) -> {
+ if (prev == null) {
+ return cur;
+ }
+ // 计算工时
+ prev.setTravelDuration(new BigDecimal(prev.getTravelDuration()).add(new BigDecimal(cur.getTravelDuration())).min(BigDecimal.ONE).doubleValue());
+ return prev;
+ })
+ )).values().stream().collect(Collectors.toList());
+ Map<String, Double> attendanceBusinessTravelMap = calcAttendanceBusinessTravelList.stream().collect(Collectors.groupingBy(AttendanceBusinessTravel::getCategory, Collectors.summingDouble(AttendanceBusinessTravel::getTravelDuration)));
- BigDecimal travelSubsidy = new BigDecimal(0.0);
- // 出差补助金
- attendanceBusinessTravelMap.forEach((key, value) -> {
- if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
- // 出差补助金
- SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
- travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
- } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
- // 客户现场补助金
-// SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
- travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
- }
- });
+ // 出差时长
+ Double travelHours = attendanceBusinessTravelMap.entrySet().stream().filter(entry -> entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL))
+ .map(Map.Entry::getValue).collect(Collectors.summingDouble(Double::doubleValue));
+ // 客户现场时长
+ Double customerSiteHours = attendanceBusinessTravelMap.entrySet().stream().filter(entry -> entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE))
+ .map(Map.Entry::getValue).collect(Collectors.summingDouble(Double::doubleValue));
+ // 合计
+ BigDecimal travelMoney = new BigDecimal(sysConfigProportionRepository.findByTitle("出差补助金额").getProportion());
+ BigDecimal customerSiteMoney = new BigDecimal(30);
+ BigDecimal travelSubsidy = BigDecimal.valueOf(travelHours).multiply(travelMoney).add(BigDecimal.valueOf(customerSiteHours).multiply(customerSiteMoney));
+
+ // 记录计算公式
+ if (jsonObject != null) {
+ jsonObject.put("travelWage", String.format("【(出差时长H * 出差补助) + (客户现场时长H * 客户现场补助)】:(%.2f * %.2f) + (%.2f * %.2f)", BigDecimal.valueOf(travelHours), travelMoney, BigDecimal.valueOf(customerSiteHours), customerSiteMoney));
+ }
+// // 出差补助金
+// attendanceBusinessTravelMap.forEach((key, value) -> {
+// if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
+// // 出差补助金
+// SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
+// travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
+// } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
+// // 客户现场补助金
+//// SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
+// travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
+// }
+// });
return travelSubsidy.doubleValue();
}
--
Gitblit v1.9.3