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 | 136 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 109 insertions(+), 27 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 d57a25e..e59ca71 100644
--- a/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
+++ b/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
@@ -4,7 +4,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.bean.dto.UserAccountDto;
import com.ruoyi.production.bean.dto.UserProductionAccountingDto;
import com.ruoyi.production.service.SalesLedgerProductionAccountingService;
@@ -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,21 +44,25 @@
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
- public R<?> listPage(Page page, SchemeApplicableStaff schemeApplicableStaff) {
+ public AjaxResult listPage(Page page, SchemeApplicableStaff schemeApplicableStaff) {
LambdaQueryWrapper<SchemeApplicableStaff> schemeApplicableStaffLambdaQueryWrapper = new LambdaQueryWrapper<>();
if(schemeApplicableStaff != null){
if(StringUtils.isNotEmpty(schemeApplicableStaff.getTitle())){
schemeApplicableStaffLambdaQueryWrapper.like(SchemeApplicableStaff::getTitle, schemeApplicableStaff.getTitle());
}
}
+ schemeApplicableStaffLambdaQueryWrapper.orderByDesc(SchemeApplicableStaff::getId);
Page<SchemeApplicableStaff> page1 = schemeApplicableStaffMapper.selectPage(page, schemeApplicableStaffLambdaQueryWrapper);
List<Long> collect = page1.getRecords().stream().map(SchemeApplicableStaff::getId).collect(Collectors.toList());
if(CollectionUtils.isEmpty(collect)){
- return R.ok(page1);
+ return AjaxResult.success(page1);
}
List<SchemeInsuranceDetail> schemeInsuranceDetails = schemeInsuranceDetailMapper
.selectList(new LambdaQueryWrapper<SchemeInsuranceDetail>()
@@ -82,7 +82,7 @@
item.setDeptNames(sysDepts.stream().map(SysDept::getDeptName).collect(Collectors.joining(",")));
}
});
- return R.ok(page1);
+ return AjaxResult.success(page1);
}
public void setSchemeApplicableStaffUserInfo(SchemeApplicableStaff schemeApplicableStaff) {
@@ -103,12 +103,12 @@
}
@Override
- public R<?> add(SchemeApplicableStaff schemeApplicableStaff) {
+ public AjaxResult add(SchemeApplicableStaff schemeApplicableStaff) {
if(schemeApplicableStaff == null){
- return R.fail("鍙傛暟閿欒");
+ return AjaxResult.error("鍙傛暟閿欒");
}
if(CollectionUtils.isEmpty(schemeApplicableStaff.getSchemeInsuranceDetailList())){
- return R.fail("璇烽�夋嫨鏂规鏄庣粏");
+ return AjaxResult.error("璇烽�夋嫨鏂规鏄庣粏");
}
setSchemeApplicableStaffUserInfo(schemeApplicableStaff); //鏍规嵁閮ㄩ棬璁剧疆鐢ㄦ埛淇℃伅
int insert = schemeApplicableStaffMapper.insert(schemeApplicableStaff);
@@ -116,13 +116,13 @@
item.setSchemeId(schemeApplicableStaff.getId());
schemeInsuranceDetailMapper.insert(item);
});
- return R.ok(insert);
+ return AjaxResult.success(insert);
}
@Override
- public R<?> updateSchemeApplicableStaff(SchemeApplicableStaff schemeApplicableStaff) {
+ public AjaxResult updateSchemeApplicableStaff(SchemeApplicableStaff schemeApplicableStaff) {
if(schemeApplicableStaff == null){
- return R.fail("鍙傛暟閿欒");
+ return AjaxResult.error("鍙傛暟閿欒");
}
setSchemeApplicableStaffUserInfo(schemeApplicableStaff); //鏍规嵁閮ㄩ棬璁剧疆鐢ㄦ埛淇℃伅
int update = schemeApplicableStaffMapper.updateById(schemeApplicableStaff);
@@ -133,18 +133,18 @@
item.setSchemeId(schemeApplicableStaff.getId());
schemeInsuranceDetailMapper.insert(item);
});
- return R.ok(update);
+ return AjaxResult.success(update);
}
@Override
- public R<?> delete(List<Long> ids) {
+ public AjaxResult delete(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
- return R.fail("鍙傛暟閿欒");
+ return AjaxResult.error("鍙傛暟閿欒");
}
int delete = schemeApplicableStaffMapper.deleteBatchIds(ids);
schemeInsuranceDetailMapper.delete(new LambdaQueryWrapper<SchemeInsuranceDetail>()
.in(SchemeInsuranceDetail::getSchemeId, ids));
- return R.ok(delete);
+ return AjaxResult.success(delete);
}
/**
@@ -190,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);
@@ -241,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