|
@@ -2,6 +2,7 @@ package org.jeecg.modules.salary.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import lombok.Synchronized;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
@@ -66,6 +67,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
List<SalaryManagementDetail> detailList = salaryManagementDetailMapper.selectByUserTotal(userId, beginDate, endDate);
|
|
|
List<SalaryManagementWorkOvertime> overTimeList = salaryManagementWorkOvertimeMapper.selectByUserTotal(userId, beginDate, endDate);
|
|
|
List<SalaryManagementHoliday> holidayList = salaryManagementHolidayMapper.selectByUserTotal(userId, beginDate.substring(0, 4), endDate.substring(0, 4));
|
|
|
+ List<SalaryManagementExtra> extraList = salaryManagementExtraMapper.selectByUserTotal(userId,beginDate, endDate,null);
|
|
|
|
|
|
BigDecimal phoneBill = new BigDecimal("0");
|
|
|
BigDecimal lunch = new BigDecimal("0");
|
|
@@ -86,6 +88,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
BigDecimal totalDeduction = new BigDecimal("0");
|
|
|
BigDecimal actualOccurrence = new BigDecimal("0");
|
|
|
|
|
|
+
|
|
|
for (SalaryManagementDetail d : detailList) {
|
|
|
|
|
|
phoneBill = phoneBill.add(d.getPhoneBill() == null ? BigDecimal.ZERO : d.getPhoneBill());
|
|
@@ -133,6 +136,18 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
actualOccurrence = actualOccurrence.add(hisActualOccurrenceNew);
|
|
|
}
|
|
|
|
|
|
+ for (SalaryManagementExtra d : extraList) {
|
|
|
+
|
|
|
+
|
|
|
+ String hisTotalPayable = d.getBeforeTaxAmount() == null ? "nghotxDTNyeHgH0mlfbJig==" : d.getBeforeTaxAmount();
|
|
|
+ hisTotalPayable = AesEncryptUtil.desEncrypt(hisTotalPayable).trim();
|
|
|
+ BigDecimal hisTotalPayableNew = new BigDecimal(hisTotalPayable);
|
|
|
+ totalPayable = totalPayable.add(hisTotalPayableNew);
|
|
|
+
|
|
|
+
|
|
|
+ actualOccurrence = actualOccurrence.add(hisTotalPayableNew);
|
|
|
+ }
|
|
|
+
|
|
|
for (SalaryManagementHoliday d : holidayList) {
|
|
|
personalTax = personalTax.add(d.getPersonalTax() == null ? BigDecimal.ZERO : d.getPersonalTax());
|
|
|
|
|
@@ -485,20 +500,21 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
+ @Synchronized
|
|
|
public Result<?> generatePayroll(SalaryManagement salaryManagement) {
|
|
|
|
|
|
String type = salaryManagement.getType();
|
|
|
|
|
|
if (StringUtils.isBlank(type)) {
|
|
|
- return Result.error("参数异常type、yearWithMonth");
|
|
|
+ return Result.error("参数异常type");
|
|
|
}
|
|
|
|
|
|
- String yearWithMonth = salaryManagement.getYearWithMonth();
|
|
|
+ String yearWithMonth = salaryManagement.getYearWithMonth();
|
|
|
|
|
|
- String endMonth = salaryManagement.getEndMonth();
|
|
|
- String beginMonth = salaryManagement.getBeginMonth();
|
|
|
+ String endMonth = salaryManagement.getEndMonth();
|
|
|
+ String beginMonth = salaryManagement.getBeginMonth();
|
|
|
|
|
|
- String yearWith = salaryManagement.getYearWith();
|
|
|
+ String yearWith = salaryManagement.getYearWith();
|
|
|
|
|
|
if (StringUtils.isBlank(yearWithMonth)) {
|
|
|
yearWithMonth = "2024-12-12";
|
|
@@ -511,28 +527,48 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
queryWrapper1.ne("salary", "HV3ndEx8HV9kd1WNbxLgwg==");
|
|
|
queryWrapper1.ne("type", "福利现金");
|
|
|
queryWrapper1.ne("type", "年终奖");
|
|
|
+
|
|
|
+ QueryWrapper<SalaryManagement> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.eq("del_flag", "0");
|
|
|
+ queryWrapper2.ne("salary", "nghotxDTNyeHgH0mlfbJig==");
|
|
|
+ queryWrapper2.ne("salary", "HV3ndEx8HV9kd1WNbxLgwg==");
|
|
|
+
|
|
|
if(type.equals("年休工资单")){
|
|
|
+ queryWrapper2.eq("year_with_month",yearWith);
|
|
|
+ queryWrapper2.eq("type","年休工资单");
|
|
|
|
|
|
queryWrapper1.likeRight("year_with_month",yearWith);
|
|
|
queryWrapper1.last("and generation_time > " +
|
|
|
"(select generation_time from salary_management where year_with_month ='"+yearWith+"' and type ='年休工资单' and del_flag=0 limit 1 ) ");
|
|
|
}else if(type.equals("加班工资单")){
|
|
|
|
|
|
+ queryWrapper2.eq("year_with_month",yearWithMonth);
|
|
|
+ queryWrapper2.eq("type","加班工资单");
|
|
|
+
|
|
|
queryWrapper1.likeRight("year_with_month",withMonth);
|
|
|
queryWrapper1.last("and (year_with_month > '"+yearWithMonth+"' or generation_time > " +
|
|
|
"(select generation_time from salary_management where year_with_month ='"+yearWithMonth+"' and type ='加班工资单' and del_flag=0 limit 1 ) ) ");
|
|
|
}else{
|
|
|
|
|
|
+ queryWrapper2.eq("year_with_month",yearWithMonth);
|
|
|
+ queryWrapper2.eq("type","月度工资单");
|
|
|
+
|
|
|
queryWrapper1.likeRight("year_with_month",withMonth);
|
|
|
queryWrapper1.last("and (year_with_month > '"+yearWithMonth+"' or generation_time > " +
|
|
|
"(select generation_time from salary_management where year_with_month ='"+yearWithMonth+"' and type ='月度工资单' and del_flag=0 limit 1 ) ) ");
|
|
|
}
|
|
|
|
|
|
- List<SalaryManagement> list1 = salaryManagementMapper.selectList(queryWrapper1);
|
|
|
- if(list1.size() > 0){
|
|
|
- return Result.error("后续薪资已计算,无法生成此月工资单!!");
|
|
|
+ List<SalaryManagement> list2 = salaryManagementMapper.selectList(queryWrapper2);
|
|
|
+
|
|
|
+ if(list2.size() > 0){
|
|
|
+
|
|
|
+ List<SalaryManagement> list1 = salaryManagementMapper.selectList(queryWrapper1);
|
|
|
+ if(list1.size() > 0){
|
|
|
+ return Result.error("后续薪资已计算,无法生成此月工资单!!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
SalaryManagement salaryManagementMFY = new SalaryManagement();
|
|
|
SalaryManagement salaryManagementNBSY = new SalaryManagement();
|
|
|
SalaryManagement salaryManagementZZ = new SalaryManagement();
|
|
@@ -652,7 +688,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
|
|
|
|
|
|
BigDecimal totalPayable = new BigDecimal("0");
|
|
|
- totalPayable = bigWages.add(phoneBill).add(lunch).add(housingSubsidies).add(transportation).add(fullAttendance);
|
|
|
+ totalPayable = bigWages.add(phoneBill).add(lunch).add(housingSubsidies).add(transportation).add(fullAttendance).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
String totalPayableText = AesEncryptUtil.encrypt(totalPayable.toString());
|
|
|
salaryManagementDetail.setTotalPayable(totalPayableText);
|
|
@@ -679,7 +715,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
salaryManagementDetail.setPersonalCost(personalCost);
|
|
|
|
|
|
BigDecimal sickCost = new BigDecimal("0");
|
|
|
- if(personalLeave.compareTo(BigDecimal.ZERO)!=0){
|
|
|
+ if(sickLeave.compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
|
|
sickCost = bigWages.divide(workingHours.multiply(attendanceDays), 12, BigDecimal.ROUND_HALF_UP).divide(new BigDecimal("60"), 12, BigDecimal.ROUND_HALF_UP)
|
|
|
.multiply(sickLeave).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
@@ -693,10 +729,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
payTaxes = totalPayable.subtract(socialSecurity).subtract(accumulationFund).subtract(new BigDecimal("5000")).subtract(deduction)
|
|
|
.subtract(personalCost).subtract(sickCost).subtract(latenessCost).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
|
|
|
- if(payTaxes.compareTo(BigDecimal.ZERO) < 0){
|
|
|
- sb.append("实际应纳税所得额为"+payTaxes+"故默认为0!!");
|
|
|
- payTaxes = new BigDecimal("0");
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -704,10 +737,10 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
|
|
|
BigDecimal cumulative = new BigDecimal("0");
|
|
|
List<SalaryManagementDetail> cumulativeList = salaryManagementDetailMapper.selectByUser(userId, withMonth, yearWithMonth);
|
|
|
- List<SalaryManagementWorkOvertime> cumulativeOvertimeList = salaryManagementWorkOvertimeMapper.selectByUser(userId, withMonth, yearWithMonth);
|
|
|
+ List<SalaryManagementWorkOvertime> cumulativeOvertimeList = salaryManagementWorkOvertimeMapper.selectByUser(userId, withMonth, null);
|
|
|
List<SalaryManagementHoliday> holidayList = salaryManagementHolidayMapper.selectByUser(userId,withMonth);
|
|
|
|
|
|
- List<SalaryManagementExtra> extra = salaryManagementExtraMapper.selectByUser(userId,withMonth,null,"0");
|
|
|
+ List<SalaryManagementExtra> extra = salaryManagementExtraMapper.selectByUser(userId,withMonth,yearWithMonth,"0");
|
|
|
|
|
|
|
|
|
|
|
@@ -726,8 +759,15 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效福利现金" + cumulativeList.size() + "条,共计金额"+extraTax+"已计入应纳税所得额与累计所得额中;");
|
|
|
+
|
|
|
+ sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效福利现金" + extra.size() + "条,共计金额"+extraTax+"已计入应纳税所得额与累计所得额中;");
|
|
|
payTaxes = payTaxes.add(extraTax);
|
|
|
+
|
|
|
+ if(payTaxes.compareTo(BigDecimal.ZERO) < 0){
|
|
|
+ sb.append("实际应纳税所得额为"+payTaxes+"故默认为0!!");
|
|
|
+ payTaxes = new BigDecimal("0");
|
|
|
+ }
|
|
|
+
|
|
|
String payTaxesText = AesEncryptUtil.encrypt(payTaxes.toString());
|
|
|
salaryManagementDetail.setPayTaxes(payTaxesText);
|
|
|
|
|
@@ -759,7 +799,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- sb.append(withMonth+"年度,此时之前("+yearWithMonth+")有效年休工资单"+cumulativeList.size()+"条,已累计入累计所得额中;");
|
|
|
+ sb.append(withMonth+"年度,此时之前("+yearWithMonth+")有效年休工资单"+holidayList.size()+"条,已累计入累计所得额中;");
|
|
|
|
|
|
if (cumulativeOvertimeList.size() > 0) {
|
|
|
for (SalaryManagementWorkOvertime detail : cumulativeOvertimeList) {
|
|
@@ -773,7 +813,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
cumulative = cumulative.add(bigPayTaxes);
|
|
|
}
|
|
|
}
|
|
|
- sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效加班工资单" + cumulativeList.size() + "条,已累计入累计所得额中;");
|
|
|
+ sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效加班工资单" + cumulativeOvertimeList.size() + "条,已累计入累计所得额中;");
|
|
|
cumulative = cumulative.add(payTaxes).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
String cumulativeText = AesEncryptUtil.encrypt(cumulative.toString());
|
|
|
salaryManagementDetail.setCumulative(cumulativeText);
|
|
@@ -809,7 +849,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
personalTax = new BigDecimal("0");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ personalTax = personalTax.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
salaryManagementDetail.setPersonalTax(personalTax);
|
|
|
|
|
|
salaryManagementDetail.setLatenessCost(latenessCost);
|
|
@@ -825,7 +865,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
|
|
|
|
|
|
BigDecimal totalDeduction = new BigDecimal("0");
|
|
|
- totalDeduction = personalTax.add(socialSecurity).add(accumulationFund).add(latenessCost).add(personalCost).add(sickCost);
|
|
|
+ totalDeduction = personalTax.add(socialSecurity).add(accumulationFund).add(latenessCost).add(personalCost).add(sickCost).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
salaryManagementDetail.setTotalDeduction(totalDeduction);
|
|
|
|
|
@@ -1007,7 +1047,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
cumulative = cumulative.add(bigPayTaxes);
|
|
|
}
|
|
|
}
|
|
|
- sb.append(withMonth + "年度,此时之前(" + newYear + ")有效加班工资单" + cumulativeList.size() + "条,已累计入累计所得额中;");
|
|
|
+ sb.append(withMonth + "年度,此时之前(" + newYear + ")有效加班工资单" + cumulativeOvertimeList.size() + "条,已累计入累计所得额中;");
|
|
|
cumulative = cumulative.add(wages).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
} else {
|
|
|
sb.append("本次应发薪资年休工资为0,不计入累计所得额中");
|
|
@@ -1046,7 +1086,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
personalTax = new BigDecimal("0");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ personalTax = personalTax.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
salaryManagementHoliday.setPersonalTax(personalTax);
|
|
|
|
|
|
|
|
@@ -1139,11 +1179,6 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
List<SalaryManagementWorkOvertime> workOvertimeListNBSY = new ArrayList<>();
|
|
|
List<SalaryManagementWorkOvertime> workOvertimeListZZ = new ArrayList<>();
|
|
|
|
|
|
- List<SalaryAttendanceDetail> list = salaryAttendanceDetailMapper.selectWorkOvertime(beginMonth, endMonth);
|
|
|
-
|
|
|
- if (list.size() < 1) {
|
|
|
- return Result.error("执行失败,没有找到" + beginMonth + "-" + endMonth + "的考勤数据!");
|
|
|
- }
|
|
|
|
|
|
String salaryBase = salaryChangeRecordMapper.selectSalary();
|
|
|
if (StringUtils.isBlank(salaryBase)) {
|
|
@@ -1153,6 +1188,14 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
String salaryBaseText = AesEncryptUtil.desEncrypt(salaryBase).trim();
|
|
|
|
|
|
BigDecimal salaryBaseBig = new BigDecimal(salaryBaseText);
|
|
|
+
|
|
|
+
|
|
|
+ List<SalaryAttendanceDetail> list = salaryAttendanceDetailMapper.selectWorkOvertime(beginMonth, endMonth,salaryBaseBig);
|
|
|
+
|
|
|
+ if (list.size() < 1) {
|
|
|
+ return Result.error("执行失败,没有找到" + beginMonth + "-" + endMonth + "的考勤数据!");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
for (SalaryAttendanceDetail o : list) {
|
|
|
|
|
@@ -1160,9 +1203,16 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
|
|
|
String userId = o.getUserId();
|
|
|
String orgName = o.getOrgName();
|
|
|
- BigDecimal workingHours = o.getWorkingHours() == null ? BigDecimal.ZERO : o.getWorkingHours();
|
|
|
- BigDecimal attendanceDays = o.getAttendanceDays() == null ? BigDecimal.ZERO : o.getAttendanceDays();
|
|
|
- BigDecimal workOvertime = o.getWorkOvertime() == null ? BigDecimal.ZERO : o.getWorkOvertime();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal workOverTotal = o.getFullAttendance() == null ? BigDecimal.ZERO : o.getFullAttendance();
|
|
|
|
|
|
SalaryManagementWorkOvertime salaryAttendanceWorkOvertime = new SalaryManagementWorkOvertime();
|
|
|
salaryAttendanceWorkOvertime.setUserId(userId);
|
|
@@ -1173,9 +1223,9 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
salaryAttendanceWorkOvertime.setCardNo(o.getCardNo());
|
|
|
|
|
|
|
|
|
- BigDecimal workOverTotal = new BigDecimal("0");
|
|
|
- workOverTotal = salaryBaseBig.divide(attendanceDays, 8, BigDecimal.ROUND_HALF_UP)
|
|
|
- .divide(workingHours.multiply(new BigDecimal("60")), 8, BigDecimal.ROUND_HALF_UP).multiply(workOvertime).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
salaryAttendanceWorkOvertime.setWorkOvertimeCost(workOverTotal);
|
|
|
|
|
|
String payTaxesText = AesEncryptUtil.encrypt(workOverTotal.toString());
|
|
@@ -1219,7 +1269,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
cumulative = cumulative.add(bigPayTaxes);
|
|
|
}
|
|
|
}
|
|
|
- sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效加班工资单" + cumulativeList.size() + "条,已累计入累计所得额中;");
|
|
|
+ sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效加班工资单" + cumulativeOvertimeList.size() + "条,已累计入累计所得额中;");
|
|
|
|
|
|
if(holidayList.size() > 0){
|
|
|
for(SalaryManagementHoliday detail:holidayList){
|
|
@@ -1234,7 +1284,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- sb.append(withMonth+"年度,此时之前("+yearWithMonth+")有效年休工资单"+cumulativeList.size()+"条,已累计入累计所得额中;");
|
|
|
+ sb.append(withMonth+"年度,此时之前("+yearWithMonth+")有效年休工资单"+holidayList.size()+"条,已累计入累计所得额中;");
|
|
|
|
|
|
cumulative = cumulative.add(workOverTotal).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
} else {
|
|
@@ -1277,6 +1327,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ personalTax = personalTax.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
salaryAttendanceWorkOvertime.setPersonalTax(personalTax);
|
|
|
|
|
|
|
|
@@ -1375,7 +1426,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
}else{
|
|
|
e.setCalculateDate(yearWith);
|
|
|
}
|
|
|
- e.setActionLog("计入工资单:"+type+"年度:"+yearWith+"年月:"+yearWithMonth);
|
|
|
+ e.setActionLog(DateUtils.now()+"计入工资单:"+type+"年度:"+yearWith+"年月:"+yearWithMonth);
|
|
|
salaryManagementExtraMapper.updateById(e);
|
|
|
}
|
|
|
}
|