From b8607f49fb2ec4a4113aeb01455e90ae83781bcc Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期三, 27 五月 2026 17:11:24 +0800
Subject: [PATCH] 增加餐补夜补,计算薪资
---
src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 94 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java b/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
index 793f94f..e59ca71 100644
--- a/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
+++ b/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
@@ -13,12 +13,8 @@
import com.ruoyi.project.system.mapper.SysDeptMapper;
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.staff.controller.TaxCalculator;
-import com.ruoyi.staff.mapper.SchemeApplicableStaffMapper;
-import com.ruoyi.staff.mapper.SchemeInsuranceDetailMapper;
-import com.ruoyi.staff.mapper.StaffOnJobMapper;
-import com.ruoyi.staff.pojo.SchemeApplicableStaff;
-import com.ruoyi.staff.pojo.SchemeInsuranceDetail;
-import com.ruoyi.staff.pojo.StaffOnJob;
+import com.ruoyi.staff.mapper.*;
+import com.ruoyi.staff.pojo.*;
import com.ruoyi.staff.service.SchemeApplicableStaffService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -48,7 +44,10 @@
private final SysUserMapper sysUserMapper;
private final SysDeptMapper sysDeptMapper;
private final StaffOnJobMapper staffOnJobMapper;
+ private final PersonalShiftMapper personalShiftMapper;
+ private final PersonalAttendanceLocationConfigMapper personalAttendanceLocationConfigMapper;
private final SalesLedgerProductionAccountingService salesLedgerProductionAccountingService;
+ private final SubsidyConfigurationMapper subsidyConfigurationMapper;
@Override
@@ -191,15 +190,93 @@
// 瀹炲彂宸ヨ祫
BigDecimal netSalary = new BigDecimal("0.00");
map.put("netSalary", netSalary);
- // 璋冪敤鍩烘湰宸ヨ祫
+ // 鏍规嵁鎺掔彮鏁版嵁璁$畻鐧界彮澶╂暟鍜屽鐝ぉ鏁�
+ BigDecimal dayDays = new BigDecimal("0.00");
+ BigDecimal nightDays = new BigDecimal("0.00");
+
+ // 鏌ヨ褰撴湀鎺掔彮璁板綍
+ List<PersonalShift> shiftList = personalShiftMapper.selectList(new LambdaQueryWrapper<PersonalShift>()
+ .eq(PersonalShift::getStaffOnJobId, staffId)
+ .like(PersonalShift::getWorkTime, date));
+
+ if(!CollectionUtils.isEmpty(shiftList)){
+ // 鏀堕泦鎵�鏈夌彮娆¢厤缃甀D
+ List<Integer> configIds = shiftList.stream()
+ .map(PersonalShift::getPersonalAttendanceLocationConfigId)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+
+ if(!CollectionUtils.isEmpty(configIds)){
+ // 鏌ヨ鐝閰嶇疆淇℃伅
+ List<PersonalAttendanceLocationConfig> configList = personalAttendanceLocationConfigMapper.selectList(
+ new LambdaQueryWrapper<PersonalAttendanceLocationConfig>()
+ .in(PersonalAttendanceLocationConfig::getId, configIds));
+
+ // 鏋勫缓鐝閰嶇疆鏄犲皠
+ Map<Integer, String> configMap = configList.stream()
+ .collect(Collectors.toMap(
+ PersonalAttendanceLocationConfig::getId,
+ PersonalAttendanceLocationConfig::getShift,
+ (a, b) -> a));
+
+ // 缁熻鐧界彮鍜屽鐝ぉ鏁�
+ for (PersonalShift shift : shiftList) {
+ Integer configId = shift.getPersonalAttendanceLocationConfigId();
+ String shiftName = configMap.get(configId);
+ if(shiftName != null){
+ // 鏍规嵁鐝鍚嶇О鍒ゆ柇锛氬寘鍚�"鐧�"鎴�"鏃�"涓虹櫧鐝紝鍖呭惈"澶�"涓哄鐝�
+ if(shiftName.contains("鐧�") || shiftName.contains("鏃�")){
+ dayDays = dayDays.add(BigDecimal.ONE);
+ } else if(shiftName.contains("澶�")){
+ nightDays = nightDays.add(BigDecimal.ONE);
+ }
+ }
+ }
+ }
+ }
+ map.put("dayDays", dayDays); // 鐧界彮澶╂暟
+ map.put("nightDays", nightDays); // 澶滅彮澶╂暟
+
+ // 鏌ヨ椁愯ˉ鍜屽鐝ˉ璐�
+ // 璁$畻椁愯ˉ锛堝洖鏃忕壒鏈夛級鍜屽鐝ˉ鍔�
+ BigDecimal mealAmount = new BigDecimal("0.00"); // 椁愯ˉ
+ BigDecimal nightAmount = new BigDecimal("0.00"); // 澶滅彮琛ュ姪
+
+ // 鑾峰彇椁愯ˉ鍜屽鐝ˉ璐存爣鍑嗭紙浠庤ˉ璐撮厤缃腑鑾峰彇锛�
+ SubsidyConfiguration subsidyConfig = subsidyConfigurationMapper.selectOne(null);
+ BigDecimal mealStandard = new BigDecimal("0.00"); // 椁愯ˉ鏍囧噯
+ BigDecimal nightStandard = new BigDecimal("0.00"); // 澶滅彮琛ヨ创鏍囧噯
+ if(subsidyConfig != null){
+ mealStandard = subsidyConfig.getMealAmount() != null ? subsidyConfig.getMealAmount() : new BigDecimal("0.00");
+ nightStandard = subsidyConfig.getNightAmount() != null ? subsidyConfig.getNightAmount() : new BigDecimal("0.00");
+ }
+
+ // 椁愯ˉ锛氭皯鏃忎负鍥炴棌鐗规湁锛岃绠楁柟寮忎负(鐧界彮澶╂暟+澶滅彮澶╂暟)*椁愯ˉ鏍囧噯
StaffOnJob staffOnJobDto = staffOnJobMapper.selectById(staffId);
if(staffOnJobDto == null){
return;
}
+
+ String nation = staffOnJobDto.getNation();
+ if("鍥炴棌".equals(nation)){
+ mealAmount = dayDays.add(nightDays).multiply(mealStandard);
+ }
+
+ // 澶滅彮琛ュ姪锛氬鐝ぉ鏁�*澶滅彮琛ヨ创鏍囧噯
+ nightAmount = nightDays.multiply(nightStandard);
+
+ map.put("mealAmount", mealAmount); // 椁愯ˉ
+ map.put("nightAmount", nightAmount); // 澶滅彮琛ュ姪
+
+ // 璋冪敤鍩烘湰宸ヨ祫
basicSalary = staffOnJobDto.getBasicSalary();
map.put("basicSalary", basicSalary);
- // 搴斿彂宸ヨ祫
- map.put("grossSalary", basicSalary);
+ // 搴斿彂宸ヨ祫锛堝熀鏈伐璧�+椁愯ˉ+澶滅彮琛ュ姪+鍏朵粬鏀跺叆锛�
+ grossSalary = basicSalary.add(mealAmount).add(nightAmount).add(otherIncome);
+ map.put("grossSalary", grossSalary);
+ // 瀹炲彂宸ヨ祫鍒濆鍊�
+ netSalary = grossSalary;
+ map.put("netSalary", netSalary);
// 涓◣閲戦锛堟棤绀句繚鐗堬級
BigDecimal bigDecimal = TaxCalculator.calculateMonthlyTax(basicSalary, socialPersonal, fundPersonal);
map.put("salaryTax", bigDecimal);
@@ -242,10 +319,14 @@
// 涓◣閲戦锛堢ぞ淇濈増锛�
bigDecimal = TaxCalculator.calculateMonthlyTax(basicSalary, socialPersonal, fundPersonal);
map.put("salaryTax", bigDecimal);
- // 搴旀墸宸ヨ祫
- map.put("deductSalary", bigDecimal.add(fundPersonal).add(socialPersonal));
- // 瀹炲彂宸ヨ祫
- map.put("netSalary", basicSalary.subtract(bigDecimal).subtract(fundPersonal).subtract(socialPersonal));
+
+ // 搴旀墸宸ヨ祫 = 涓◣ + 鍏Н閲戜釜浜� + 绀句繚涓汉 + 鍏朵粬鏀嚭
+ deductSalary = bigDecimal.add(fundPersonal).add(socialPersonal).add(otherDeduct);
+ map.put("deductSalary", deductSalary);
+
+ // 瀹炲彂宸ヨ祫 = 搴斿彂宸ヨ祫 - 搴旀墸宸ヨ祫
+ netSalary = grossSalary.subtract(deductSalary);
+ map.put("netSalary", netSalary);
}
--
Gitblit v1.9.3