薪资计算

This commit is contained in:
andy 2025-06-05 09:50:28 +08:00
parent 5769b67686
commit 13b0c28817
37 changed files with 1268 additions and 597 deletions

View File

@ -4,20 +4,13 @@ import com.alibaba.fastjson2.JSONObject;
import com.evo.attendance.domain.vo.RzAttendanceData;
import com.evo.attendance.domain.vo.RzAttendanceVo;
import com.evo.common.constant.Constants;
import com.evo.common.utils.Collections;
import com.evo.common.utils.StringUtils;
import com.evo.common.utils.spring.SpringUtils;
import com.evo.equipment.domain.EqButton;
import com.evo.equipment.mapper.EqButtonMapper;
import com.evo.system.domain.SysStaff;
import com.evo.system.mapper.SysStaffMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 打开处理接口

View File

@ -7,6 +7,7 @@ import com.evo.attendance.domain.RzAttendanceDetail;
import com.evo.attendance.mapper.RzAttendanceDetailMapper;
import com.evo.attendance.mapper.RzAttendanceMapper;
import com.evo.attendance.processor.PunchTheClockStrategyExchangeProcessor;
import com.evo.common.annotation.Log;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.entity.SysDept;
import com.evo.common.utils.Collections;
@ -24,7 +25,9 @@ import com.evo.personnelMatters.mapper.RzOverTimeMapper;
import com.evo.system.domain.SysStaff;
import com.evo.system.mapper.SysDeptMapper;
import com.evo.system.mapper.SysStaffMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -43,6 +46,7 @@ import java.util.Date;
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Service
@Slf4j
public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeProcessor {
@Resource
private SysStaffMapper sysStaffMapper;
@ -107,6 +111,7 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP
//根据ID查询员工信息 ,判断员工是否存在不存在返回失败
SysStaff sysStaff = sysStaffMapper.selectSysStaffByUserId(Long.valueOf(userId));//打卡记录信息
log.info("日常-打卡信息如下: 员工姓名:{}, 打卡时间:{}. 打卡设备:{}, 打卡情况: {}",sysStaff.getName(), sdfd.format(date), sn, rules);
//检查用户数据
String error = checkStaff(sysStaff, sn);
if(StringUtils.isNotEmpty(error)){
@ -362,7 +367,9 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP
RzOverTimeDetail rzOverTimeDetail = rzOverTimeDetailMapper.queryRzOverTimeDetailByDateAndOverId(rzOverTime.getId(),date);
rzOverTimeDetail.setOverTimeEnd(date);
//计算加班时长 小时
double hours = (rzOverTimeDetail.getOverTimeEnd().getTime() - rzOverTimeDetail.getOverTimeStart().getTime())/1000/60/60;
double minutes = (rzOverTimeDetail.getOverTimeEnd().getTime() - rzOverTimeDetail.getOverTimeStart().getTime())/1000/60;
//计算小时, 保留2位小数
double hours = new BigDecimal(minutes).divide(new BigDecimal(60),2,BigDecimal.ROUND_HALF_UP).doubleValue();
//获取规则
JSONObject deviceRules = ParamUtils.getDeviceOverTimeRules(sn);
//获取最大加班时长

View File

@ -18,6 +18,7 @@ import com.evo.personnelMatters.mapper.BsOverTimeMapper;
import com.evo.personnelMatters.mapper.EqOverStaffMapper;
import com.evo.system.domain.SysStaff;
import com.evo.system.mapper.SysStaffMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
@ -35,6 +36,7 @@ import java.util.Date;
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Service
@Slf4j
public class TSDeviceExchangeProcessor implements PunchTheClockStrategyExchangeProcessor {
@Resource
private SysStaffMapper sysStaffMapper;
@ -76,11 +78,11 @@ public class TSDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP
@Override
public String exchangeFace(String userId, String sn, Date date, String button, String rules) {
if(!ParamUtils.checkTsDeviceButton(sn, rules)){
return initMessage(1, "无效打卡");
}
SysStaff sysStaff = sysStaffMapper.selectSysStaffByUserId(Long.valueOf(userId));
log.info("特殊-打卡信息如下: 员工姓名:{}, 打卡时间:{}. 打卡设备:{}, 打卡情况: {}",sysStaff.getName(), sdfd.format(date), sn, rules);
//检查用户数据
String error = checkStaff(sysStaff, sn);
if(StringUtils.isNotEmpty(error)){

View File

@ -1,40 +1,20 @@
package com.evo.attendance.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.evo.attendance.domain.*;
import com.evo.attendance.mapper.*;
import com.evo.attendance.processor.PunchTheClockStrategyExchangeProcessor;
import com.evo.common.constant.Constants;
import com.evo.common.utils.Collections;
import com.evo.common.utils.DateUtils;
import com.evo.common.utils.StringUtils;
import com.evo.equipment.domain.EqButton;
import com.evo.equipment.domain.EqImages;
import com.evo.equipment.mapper.EqButtonMapper;
import com.evo.equipment.mapper.EqImagesMapper;
import com.evo.attendance.domain.vo.RzAttendanceData;
import com.evo.attendance.domain.vo.RzAttendanceVo;
import com.evo.attendance.processor.PunchTheClockStrategyExchangeProcessor;
import com.evo.attendance.service.PunchTheClockService;
import com.evo.personnelMatters.domain.EqOverStaff;
import com.evo.personnelMatters.domain.RzOverTime;
import com.evo.personnelMatters.domain.RzOverTimeDetail;
import com.evo.personnelMatters.domain.SpecialOverTime;
import com.evo.personnelMatters.mapper.BsOverTimeMapper;
import com.evo.personnelMatters.mapper.EqOverStaffMapper;
import com.evo.personnelMatters.mapper.RzOverTimeDetailMapper;
import com.evo.personnelMatters.mapper.RzOverTimeMapper;
import com.evo.system.domain.SysStaff;
import com.evo.system.mapper.SysStaffDetailMapper;
import com.evo.system.mapper.SysStaffMapper;
import com.evo.utils.DateUtil;
import com.evo.common.utils.Collections;
import com.evo.common.utils.StringUtils;
import com.evo.equipment.domain.EqButton;
import com.evo.equipment.mapper.EqButtonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@ -46,30 +26,6 @@ public class PunchTheClockServiceImpl implements PunchTheClockService {
@Resource
private EqButtonMapper eqButtonMapper;
@Resource
private EqImagesMapper eqImagesMapper; //照片管理
@Resource
private RzAttendanceMapper rzAttendanceMapper; //考勤记录
@Resource
private RzAttendanceDetailMapper rzAttendanceDetailMapper; //打卡明细
@Resource
private SysStaffMapper sysStaffMapper; //员工信息
@Resource
private SysStaffDetailMapper sysStaffDetailMapper; //员工详情
@Resource
private RzOverTimeDetailMapper rzOverTimeDetailMapper; //加班详情
@Resource
private RzOverTimeMapper rzOverTimeMapper; //加班统计
@Resource
private RzAttendanceStatisticalMapper rzAttendanceStatisticalMapper; //打卡统计
@Resource
private RzSpecialAttendanceMapper rzSpecialAttendanceMapper;
@Resource
private EqOverStaffMapper eqOverStaffMapper;
@Resource
private BsOverTimeMapper bsOverTimeMapper;
@Resource
private RzSpecialOverTimeMapper rzSpecialOverTimeMapper;
@Autowired
private ApplicationContext applicationContext;
/**

View File

@ -8,6 +8,7 @@ import com.evo.attendance.domain.RzAttendanceDetail;
import com.evo.attendance.domain.vo.RzAttendanceDetailVO;
import com.evo.attendance.mapper.RzAttendanceDetailMapper;
import com.evo.common.annotation.DataScope;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.AjaxResult;
import com.evo.common.core.domain.entity.SysDept;
import com.evo.common.utils.DateUtils;
@ -105,7 +106,7 @@ public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzA
//判断考勤时间
Long sj = (rzAttendance.getWorkEndTime().getTime() - rzAttendance.getWorkStartTime().getTime()) / 1000 / 60 / 60;
if (sj >= 8) {
rzAttendance.setWorkSum(new BigDecimal(8));
rzAttendance.setWorkSum(Constants.DAY_WORK_HOUR);
} else if (sj >= 4) {
rzAttendance.setWorkSum(new BigDecimal(4));
}

View File

@ -25,6 +25,7 @@ import com.evo.system.domain.SysStaff;
import com.evo.system.mapper.SysDeptMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.beans.Transient;
@ -154,7 +155,7 @@ public class RzAttendanceStatisticalServiceImpl extends ServiceImpl<RzAttendance
}
@Override
@Transient
@Transactional
public RzAttendanceStatistical createRzAttendance(SysStaff sysStaff, List<String> dayList, Date date) {
if(date == null){
date = DateUtils.getNowDate();
@ -187,7 +188,7 @@ public class RzAttendanceStatisticalServiceImpl extends ServiceImpl<RzAttendance
rzAttendanceStatistical.setStaffId(sysStaff.getUserId());
rzAttendanceStatistical.setName(sysStaff.getName());
rzAttendanceStatistical.setMonth(date);
rzAttendanceStatistical.setShouldAttendance(new BigDecimal(ParamUtils.getMonthWorkDayNum(getMonthWorkDayNum(date))).multiply(new BigDecimal("8.00")));
rzAttendanceStatistical.setShouldAttendance(new BigDecimal(ParamUtils.getMonthWorkDayNum(DateUtils.getYear(date), DateUtils.getMonth(date))).multiply(new BigDecimal("8.00")));
rzAttendanceStatistical.setDeptId(sysStaff.getDeptId());
rzAttendanceStatistical.setAbsenteeism(new BigDecimal(0));
getBaseMapper().insert(rzAttendanceStatistical);
@ -242,27 +243,20 @@ public class RzAttendanceStatisticalServiceImpl extends ServiceImpl<RzAttendance
//查询特殊加班汇总数据
list.stream().forEach(statistical ->{
//首选抓取员工考勤记录
Map<String, Object> attendance = attendanceMap.get(statistical.getStaffId());
Map<String, Object> attendance = attendanceMap.get(String.valueOf(statistical.getStaffId()));
if(attendance != null){
statistical.setRealAttendance(getValue(attendance,"workNum"));
statistical.setEssentialAttendance(getValue(attendance,"workSum"));
statistical.setNightNumber(getValue(attendance,"nightNumber").longValue());
statistical.setMiddleShiftNumber(getValue(attendance,"middleShiftNumber").longValue());
}
//继续计算加班数据
Map<String, Object> overTime = overTimeMap.get(statistical.getStaffId());
if(overTime != null){
statistical.setWorkOvertimeNumber(getValue(overTime,"overTimeHours"));
}
statistical.setWorkOvertimeNumber(getValue(overTimeMap.get(String.valueOf(statistical.getStaffId())),"overTimeHours"));
//继续计算特殊加班数据
Map<String, Object> specialAttendance = specialAttendanceMap.get(statistical.getStaffId());
if(specialAttendance != null){
statistical.setOverTimeHours(getValue(specialAttendance,"workHours"));
}
//继续计算特殊加班数据
Map<String, Object> leave = leaveMap.get(statistical.getStaffId());
if(leave != null){
statistical.setAbsenteeism(getValue(leave,"leaveHour"));
}
statistical.setOverTimeHours(getValue(specialAttendanceMap.get(String.valueOf(statistical.getStaffId())),"workHours"));
//继续计算请假
statistical.setAbsenteeism(getValue(leaveMap.get(String.valueOf(statistical.getStaffId())),"leaveHour"));
//实际出勤=打卡+加班+特殊加班
statistical.setRealAttendance(statistical.getEssentialAttendance().add(statistical.getWorkOvertimeNumber()).add(statistical.getOverTimeHours()));
});
//更新全部考勤
@ -271,15 +265,7 @@ public class RzAttendanceStatisticalServiceImpl extends ServiceImpl<RzAttendance
}
public BigDecimal getValue(Map<String, Object> map, String key){
return new BigDecimal(ObjectUtils.isEmpty(map.get(key)) ? "0" : String.valueOf(map.get(key)));
return new BigDecimal(Collections.isEmpty(map) || ObjectUtils.isEmpty(map.get(key)) ? "0" : String.valueOf(map.get(key)));
}
public Integer getMonthWorkDayNum(Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.getActualMaximum(java.util.Calendar.MONTH);
}
}

View File

@ -3,6 +3,7 @@ package com.evo.common.constant;
import java.math.BigDecimal;
import java.util.Locale;
import io.jsonwebtoken.Claims;
import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer;
/**
* 通用常量信息
@ -120,4 +121,15 @@ public class Constants
public static final String SUBSIDY_PROPORTION = "0.05"; //请假补助扣除比例
public static final String SUBSIDY_PERIOD = "0.80"; //试用期工资
public static final String SUBSIDY_PERIOD_1 = "0.20"; //试用期工资的余百分比
public static final Long zc_code = 38l; //早餐消费
public static final Long wc_code = 39l; //午餐消费
public static final Long wcc_code = 40L; //晚餐消费
public static final Long gr_zc_code = 66l; //个人早餐消费
public static final Long gr_wc_code = 67l; //个人午餐消费
public static final Long gr_wcc_code = 68L; //个人晚餐消费
public static final BigDecimal DAY_WORK_HOUR = new BigDecimal(8);
}

View File

@ -0,0 +1,62 @@
package com.evo.common.controller;
import com.alibaba.fastjson2.JSONObject;
import com.evo.common.core.domain.AjaxResult;
import com.evo.common.core.page.TableDataInfo;
import com.evo.common.utils.ParamUtils;
import com.evo.finance.domain.RzSalaryDetail;
import com.evo.personnelMatters.domain.RzOverTimeDetail;
import com.evo.personnelMatters.mapper.RzOverTimeDetailMapper;
import com.evo.personnelMatters.mapper.RzOverTimeMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
*
*
* @ClassName:TestController
* @date: 2025年06月04日 11:12
* @author: andy.shi
* @contact: 17330188597
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@RestController
@RequestMapping("/test")
public class TestController {
@Resource
private RzOverTimeMapper rzOverTimeMapper;
@Resource
private RzOverTimeDetailMapper rzOverTimeDetailMapper;
/**
* 清洗加班
*/
@GetMapping("/overTime")
public AjaxResult overTime(Date date) {
// rzOverTimeMapper.sele
// RzOverTimeDetail rzOverTimeDetail = rzOverTimeDetailMapper.queryRzOverTimeDetailByDateAndOverId(rzOverTime.getId(),date);
// rzOverTimeDetail.setOverTimeEnd(date);
// //计算加班时长 小时
// double minutes = (rzOverTimeDetail.getOverTimeEnd().getTime() - rzOverTimeDetail.getOverTimeStart().getTime())/1000/60;
// //计算小时, 保留2位小数
// double hours = new BigDecimal(minutes).divide(new BigDecimal(60),2,BigDecimal.ROUND_HALF_UP).doubleValue();
// //获取规则
// JSONObject deviceRules = ParamUtils.getDeviceOverTimeRules(sn);
// //获取最大加班时长
// Integer maxOverTimeHour = deviceRules.getInteger("maxHour");
// //记录加班时长
// rzOverTimeDetail.setOverTimeHours(BigDecimal.valueOf(((hours > maxOverTimeHour) ? maxOverTimeHour : hours)));
// if(rzOverTimeDetailMapper.updateRzOverTimeDetail(rzOverTimeDetail) < 1){
return AjaxResult.success();
}
}

View File

@ -7,6 +7,7 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -47,12 +48,14 @@ public class SysDept extends BaseEntity
private String delFlag;
/** 父部门名称 */
@TableField(exist = false)
private String parentName;
/** 是否加班 */
private String isOverTime;
/** 子部门 */
@TableField(exist = false)
private List<SysDept> children = new ArrayList<SysDept>();
@NotBlank(message = "部门名称不能为空")

View File

@ -0,0 +1,29 @@
package com.evo.common.utils;
import org.apache.commons.lang3.ObjectUtils;
import java.math.BigDecimal;
/**
*
*
* @ClassName:DataUtils
* @date: 2025年06月03日 10:25
* @author: andy.shi
* @contact: 17330188597
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
public class DataUtils {
public static final BigDecimal DEFAULT_VALUE = new BigDecimal(0);
public static <T> T findDefaultValue(T v, T dv){
if(ObjectUtils.isNotEmpty(v)){
return v;
}
return dv;
}
}

View File

@ -239,6 +239,25 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return calendar.getTime();
}
public static Integer getYear(Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.YEAR);
}
public static Integer getMonth(Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.MONTH)+1;
}
public static Integer getMonthDays(Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH,1);
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
}
public static Long getBetweenDays(Date start, Date end){
Calendar currentDate = Calendar.getInstance();
currentDate.setTime(start);

View File

@ -1,5 +1,6 @@
package com.evo.common.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.evo.attendance.domain.RzSysParam;
import com.evo.attendance.service.IRzSysParamService;
@ -54,6 +55,15 @@ public class ParamUtils {
return param.getParamValue();
}
/***
* 获取日薪全勤天数
* @return
*/
public static String dailyWageGsBasicPrice(){
RzSysParam param= paramService.getRzSysParam("日薪的基本工资", "daily_wage_basic_price","1800","日薪的基本工资");
return param.getParamValue();
}
/***
* 获取那些请假类型不包含法休
* @return
@ -140,8 +150,11 @@ public class ParamUtils {
* @param monthNum
* @return
*/
public static String getMonthWorkDayNum(Integer monthNum){
return dictDataService.selectDictValue("sys_work_days",monthNum+"");
public static String getMonthWorkDayNum(Integer year, Integer monthNum){
//获取当前年
RzHoliday rzHoliday = rzHolidayService.selectRzHolidayByYear(year);
JSONObject workJson = JSONObject.parseObject(rzHoliday.getWorkInfo());
return workJson.containsKey(String.valueOf(monthNum)) ? workJson.getString(String.valueOf(monthNum)) : "26";
}
/***

View File

@ -359,6 +359,7 @@ public class ExcelUtilSs<T>{
wb.write(out);
return AjaxResult.success(filename);
}catch (Exception e){
e.printStackTrace();
log.error("导出Excel异常{}", e.getMessage());
throw new CustomException("导出Excel失败请联系网站管理员");
}

View File

@ -121,8 +121,8 @@ public class EqSnDetailServiceImpl extends ServiceImpl<EqSnDetailMapper, EqSnDet
String url = ParamUtils.getGlobalStaticUrl();
for(SysStaff user : userList){
try {
// userPhotoList.add(Collections.asMap("userId", String.valueOf(user.getUserId()), "name", user.getName(), "photoUrl", url+longRzUploadMap.get(user.getUserId()).getFileName()));
userPhotoList.add(Collections.asMap("userId", String.valueOf(user.getUserId()), "name", user.getName(), "photoUrl", longRzUploadMap.get(user.getUserId()).getUrl()));
userPhotoList.add(Collections.asMap("userId", String.valueOf(user.getUserId()), "name", user.getName(), "photoUrl", url+longRzUploadMap.get(user.getUserId()).getFileName()));
// userPhotoList.add(Collections.asMap("userId", String.valueOf(user.getUserId()), "name", user.getName(), "photoUrl", longRzUploadMap.get(user.getUserId()).getUrl()));
} catch (Exception e) {
log.error("员工:"+String.valueOf(user.getUserId())+" 的照片拼装出现问题:"+e.getMessage());
}

View File

@ -10,6 +10,7 @@ import com.evo.attendance.domain.vo.RzSalaryVo;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.entity.SysDept;
import com.evo.common.core.domain.entity.SysDictData;
import com.evo.common.utils.DataUtils;
import com.evo.common.utils.StringUtils;
import com.evo.common.utils.poi.ExcelUtil;
import com.evo.common.utils.poi.ExcelUtilSs;
@ -137,14 +138,12 @@ public class RzSalaryDetailController extends BaseController
sheetNameList.add(sysDept.getDeptName());
//部门小计
SalaryVo xj_salaryVo = new SalaryVo();
xj_salaryVo.setBasicSalary(new BigDecimal("0.00"));
xj_salaryVo.setName("小计:");
//查询部门下的数据
List<RzSalaryDetail> pay_list = rzSalaryDetailService.selectSalaryDetailByDeptId(sysDept.getDeptId(),rzSalaryDetail.getMonth());
for (RzSalaryDetail salaryDetail : pay_list) {
salaryVo = new SalaryVo();
if(StringUtils.isNull(xj_salaryVo.getBasicSalary())){
xj_salaryVo.setBasicSalary(new BigDecimal("0.00"));
}
xj_salaryVo.setBasicSalary(xj_salaryVo.getBasicSalary().add(salaryDetail.getBasicSalary()));
if(StringUtils.isNull(xj_salaryVo.getOvertimeSalary())){
xj_salaryVo.setOvertimeSalary(new BigDecimal("0.00"));
@ -256,95 +255,95 @@ public class RzSalaryDetailController extends BaseController
if(StringUtils.isNull(gj_salaryVo.getOvertimeSalary())){
gj_salaryVo.setOvertimeSalary(new BigDecimal("0.00"));
}
gj_salaryVo.setOvertimeSalary(gj_salaryVo.getOvertimeSalary().add(salaryVoz.getOvertimeSalary()));
gj_salaryVo.setOvertimeSalary(gj_salaryVo.getOvertimeSalary().add(DataUtils.findDefaultValue(salaryVoz.getOvertimeSalary(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getLevelSubsidies())){
gj_salaryVo.setLevelSubsidies(new BigDecimal("0.00"));
}
gj_salaryVo.setLevelSubsidies(gj_salaryVo.getLevelSubsidies().add(salaryVoz.getLevelSubsidies()));
gj_salaryVo.setLevelSubsidies(gj_salaryVo.getLevelSubsidies().add(DataUtils.findDefaultValue(salaryVoz.getLevelSubsidies(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getContractSubsidies())){
gj_salaryVo.setContractSubsidies(new BigDecimal("0.00"));
}
gj_salaryVo.setContractSubsidies(gj_salaryVo.getContractSubsidies().add(salaryVoz.getContractSubsidies()));
gj_salaryVo.setContractSubsidies(gj_salaryVo.getContractSubsidies().add(DataUtils.findDefaultValue(salaryVoz.getContractSubsidies(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getSenioritySalary())){
gj_salaryVo.setSenioritySalary(new BigDecimal("0.00"));
}
gj_salaryVo.setSenioritySalary(gj_salaryVo.getSenioritySalary().add(salaryVoz.getSenioritySalary()));
gj_salaryVo.setSenioritySalary(gj_salaryVo.getSenioritySalary().add(DataUtils.findDefaultValue(salaryVoz.getSenioritySalary(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getSocialSubsidies())){
gj_salaryVo.setSocialSubsidies(new BigDecimal("0.00"));
}
gj_salaryVo.setSocialSubsidies(gj_salaryVo.getSocialSubsidies().add(salaryVoz.getSocialSubsidies()));
gj_salaryVo.setSocialSubsidies(gj_salaryVo.getSocialSubsidies().add(DataUtils.findDefaultValue(salaryVoz.getSocialSubsidies(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getFullSubsidies())){
gj_salaryVo.setFullSubsidies(new BigDecimal("0.00"));
}
gj_salaryVo.setFullSubsidies(gj_salaryVo.getFullSubsidies().add(salaryVoz.getFullSubsidies()));
gj_salaryVo.setFullSubsidies(gj_salaryVo.getFullSubsidies().add(DataUtils.findDefaultValue(salaryVoz.getFullSubsidies(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getNightSubsidies())){
gj_salaryVo.setNightSubsidies(new BigDecimal("0.00"));
}
gj_salaryVo.setNightSubsidies(gj_salaryVo.getNightSubsidies().add(salaryVoz.getNightSubsidies()));
gj_salaryVo.setNightSubsidies(gj_salaryVo.getNightSubsidies().add(DataUtils.findDefaultValue(salaryVoz.getNightSubsidies(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getDinnerSubsidies())){
gj_salaryVo.setDinnerSubsidies(new BigDecimal("0.00"));
}
gj_salaryVo.setDinnerSubsidies(gj_salaryVo.getDinnerSubsidies().add(salaryVoz.getDinnerSubsidies()));
gj_salaryVo.setDinnerSubsidies(gj_salaryVo.getDinnerSubsidies().add(DataUtils.findDefaultValue(salaryVoz.getDinnerSubsidies(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getSubsidyOrBonus())){
gj_salaryVo.setSubsidyOrBonus(new BigDecimal("0.00"));
}
gj_salaryVo.setSubsidyOrBonus(gj_salaryVo.getSubsidyOrBonus().add(salaryVoz.getSubsidyOrBonus()));
gj_salaryVo.setSubsidyOrBonus(gj_salaryVo.getSubsidyOrBonus().add(DataUtils.findDefaultValue(salaryVoz.getSubsidyOrBonus(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getAbsenteeismSalary())){
gj_salaryVo.setAbsenteeismSalary(new BigDecimal("0.00"));
}
gj_salaryVo.setAbsenteeismSalary(gj_salaryVo.getAbsenteeismSalary().add(salaryVoz.getAbsenteeismSalary()));
gj_salaryVo.setAbsenteeismSalary(gj_salaryVo.getAbsenteeismSalary().add(DataUtils.findDefaultValue(salaryVoz.getAbsenteeismSalary(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getAbsenteeismSubsidies())){
gj_salaryVo.setAbsenteeismSubsidies(new BigDecimal("0.00"));
}
gj_salaryVo.setAbsenteeismSubsidies(gj_salaryVo.getAbsenteeismSubsidies().add(salaryVoz.getAbsenteeismSubsidies()));
gj_salaryVo.setAbsenteeismSubsidies(gj_salaryVo.getAbsenteeismSubsidies().add(DataUtils.findDefaultValue(salaryVoz.getAbsenteeismSubsidies(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getMealFee())){
gj_salaryVo.setMealFee(new BigDecimal("0.00"));
}
gj_salaryVo.setMealFee(gj_salaryVo.getMealFee().add(salaryVoz.getMealFee()));
gj_salaryVo.setMealFee(gj_salaryVo.getMealFee().add(DataUtils.findDefaultValue(salaryVoz.getMealFee(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getDeductions())){
gj_salaryVo.setDeductions(new BigDecimal("0.00"));
}
gj_salaryVo.setDeductions(gj_salaryVo.getDeductions().add(salaryVoz.getDeductions()));
gj_salaryVo.setDeductions(gj_salaryVo.getDeductions().add(DataUtils.findDefaultValue(salaryVoz.getDeductions(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getSalary())){
gj_salaryVo.setSalary(new BigDecimal("0.00"));
}
gj_salaryVo.setSalary(gj_salaryVo.getSalary().add(salaryVoz.getSalary()));
gj_salaryVo.setSalary(gj_salaryVo.getSalary().add(DataUtils.findDefaultValue(salaryVoz.getSalary(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getPayInsurance())){
gj_salaryVo.setPayInsurance(new BigDecimal("0.00"));
}
gj_salaryVo.setPayInsurance(gj_salaryVo.getPayInsurance().add(salaryVoz.getPayInsurance()));
gj_salaryVo.setPayInsurance(gj_salaryVo.getPayInsurance().add(DataUtils.findDefaultValue(salaryVoz.getPayInsurance(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getSalaryBeforeTax())){
gj_salaryVo.setSalaryBeforeTax(new BigDecimal("0.00"));
}
gj_salaryVo.setSalaryBeforeTax(gj_salaryVo.getSalaryBeforeTax().add(salaryVoz.getSalaryBeforeTax()));
gj_salaryVo.setSalaryBeforeTax(gj_salaryVo.getSalaryBeforeTax().add(DataUtils.findDefaultValue(salaryVoz.getSalaryBeforeTax(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getTotalWages())){
gj_salaryVo.setTotalWages(new BigDecimal("0.00"));
}
gj_salaryVo.setTotalWages(gj_salaryVo.getTotalWages().add(salaryVoz.getTotalWages()));
gj_salaryVo.setTotalWages(gj_salaryVo.getTotalWages().add(DataUtils.findDefaultValue(salaryVoz.getTotalWages(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getAnnualExemptionAmount())){
gj_salaryVo.setAnnualExemptionAmount(new BigDecimal("0.00"));
}
gj_salaryVo.setAnnualExemptionAmount(gj_salaryVo.getAnnualExemptionAmount().add(salaryVoz.getAnnualExemptionAmount()));
gj_salaryVo.setAnnualExemptionAmount(gj_salaryVo.getAnnualExemptionAmount().add(DataUtils.findDefaultValue(salaryVoz.getAnnualExemptionAmount(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getSpecialDeduction())){
gj_salaryVo.setSpecialDeduction(new BigDecimal("0.00"));
}
gj_salaryVo.setSpecialDeduction(gj_salaryVo.getSpecialDeduction().add(salaryVoz.getSpecialDeduction()));
gj_salaryVo.setSpecialDeduction(gj_salaryVo.getSpecialDeduction().add(DataUtils.findDefaultValue(salaryVoz.getSpecialDeduction(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getSlowDownTheDeduction())){
gj_salaryVo.setSlowDownTheDeduction(new BigDecimal("0.00"));
}
gj_salaryVo.setSlowDownTheDeduction(gj_salaryVo.getSlowDownTheDeduction().add(salaryVoz.getSlowDownTheDeduction()));
gj_salaryVo.setSlowDownTheDeduction(gj_salaryVo.getSlowDownTheDeduction().add(DataUtils.findDefaultValue(salaryVoz.getSlowDownTheDeduction(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getAggregatePersonalIncomeTax())){
gj_salaryVo.setAggregatePersonalIncomeTax(new BigDecimal("0.00"));
}
gj_salaryVo.setAggregatePersonalIncomeTax(gj_salaryVo.getAggregatePersonalIncomeTax().add(salaryVoz.getAggregatePersonalIncomeTax()));
gj_salaryVo.setAggregatePersonalIncomeTax(gj_salaryVo.getAggregatePersonalIncomeTax().add(DataUtils.findDefaultValue(salaryVoz.getAggregatePersonalIncomeTax(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getTaxPayable())){
gj_salaryVo.setTaxPayable(new BigDecimal("0.00"));
}
gj_salaryVo.setTaxPayable(gj_salaryVo.getTaxPayable().add(salaryVoz.getTaxPayable()));
gj_salaryVo.setTaxPayable(gj_salaryVo.getTaxPayable().add(DataUtils.findDefaultValue(salaryVoz.getTaxPayable(), DataUtils.DEFAULT_VALUE)));
if(StringUtils.isNull(gj_salaryVo.getNetPayroll())){
gj_salaryVo.setNetPayroll(new BigDecimal("0.00"));
}
gj_salaryVo.setNetPayroll(gj_salaryVo.getNetPayroll().add(salaryVoz.getNetPayroll()));
gj_salaryVo.setNetPayroll(gj_salaryVo.getNetPayroll().add(DataUtils.findDefaultValue(salaryVoz.getNetPayroll(), DataUtils.DEFAULT_VALUE)));
}
gj_salaryVo.setName("伊特总计:");
list.add(gj_salaryVo);
@ -466,30 +465,30 @@ public class RzSalaryDetailController extends BaseController
list0.add(salaryVo);
}
list.add(xj_salaryVo);
payRollZong.setBasicSalary(xj_salaryVo.getBasicSalary().add(payRollZong.getBasicSalary()));
payRollZong.setOvertimeSalary(xj_salaryVo.getOvertimeSalary().add(payRollZong.getOvertimeSalary()));
payRollZong.setLevelSubsidies(xj_salaryVo.getLevelSubsidies().add(payRollZong.getLevelSubsidies()));
payRollZong.setContractSubsidies(xj_salaryVo.getContractSubsidies().add(payRollZong.getContractSubsidies()));
payRollZong.setSenioritySalary(xj_salaryVo.getSenioritySalary().add(payRollZong.getSenioritySalary()));
payRollZong.setSocialSubsidies(xj_salaryVo.getSocialSubsidies().add(payRollZong.getSocialSubsidies()));
payRollZong.setFullSubsidies(xj_salaryVo.getFullSubsidies().add(payRollZong.getFullSubsidies()));
payRollZong.setNightSubsidies(xj_salaryVo.getNightSubsidies().add(payRollZong.getNightSubsidies()));
payRollZong.setDinnerSubsidies(xj_salaryVo.getDinnerSubsidies().add(payRollZong.getDinnerSubsidies()));
payRollZong.setSubsidyOrBonus(xj_salaryVo.getSubsidyOrBonus().add(payRollZong.getSubsidyOrBonus()));
payRollZong.setAbsenteeismSalary(xj_salaryVo.getAbsenteeismSalary().add(payRollZong.getAbsenteeismSalary()));
payRollZong.setAbsenteeismSubsidies(xj_salaryVo.getAbsenteeismSubsidies().add(payRollZong.getAbsenteeismSubsidies()));
payRollZong.setMealFee(xj_salaryVo.getMealFee().add(payRollZong.getMealFee()));
payRollZong.setDeductions(xj_salaryVo.getDeductions().add(payRollZong.getDeductions()));
payRollZong.setSalary(xj_salaryVo.getSalary().add(payRollZong.getSalary()));
payRollZong.setPayInsurance(xj_salaryVo.getPayInsurance().add(payRollZong.getPayInsurance()));
payRollZong.setSalaryBeforeTax(xj_salaryVo.getSalaryBeforeTax().add(payRollZong.getSalaryBeforeTax()));
payRollZong.setTotalWages(xj_salaryVo.getTotalWages().add(payRollZong.getTotalWages()));
payRollZong.setAnnualExemptionAmount(xj_salaryVo.getAnnualExemptionAmount().add(payRollZong.getAnnualExemptionAmount()));
payRollZong.setSpecialDeduction(xj_salaryVo.getSpecialDeduction().add(payRollZong.getSpecialDeduction()));
payRollZong.setSlowDownTheDeduction(xj_salaryVo.getSlowDownTheDeduction().add(payRollZong.getSlowDownTheDeduction()));
payRollZong.setAggregatePersonalIncomeTax(xj_salaryVo.getAggregatePersonalIncomeTax().add(payRollZong.getAggregatePersonalIncomeTax()));
payRollZong.setTaxPayable(xj_salaryVo.getTaxPayable().add(payRollZong.getTaxPayable()));
payRollZong.setNetPayroll(xj_salaryVo.getNetPayroll().add(payRollZong.getNetPayroll()));
payRollZong.setBasicSalary(DataUtils.findDefaultValue(xj_salaryVo.getBasicSalary(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getBasicSalary(), DataUtils.DEFAULT_VALUE)));
payRollZong.setOvertimeSalary(DataUtils.findDefaultValue(xj_salaryVo.getOvertimeSalary(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getOvertimeSalary(), DataUtils.DEFAULT_VALUE)));
payRollZong.setLevelSubsidies(DataUtils.findDefaultValue(xj_salaryVo.getLevelSubsidies(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getLevelSubsidies(), DataUtils.DEFAULT_VALUE)));
payRollZong.setContractSubsidies(DataUtils.findDefaultValue(xj_salaryVo.getContractSubsidies(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getContractSubsidies(), DataUtils.DEFAULT_VALUE)));
payRollZong.setSenioritySalary(DataUtils.findDefaultValue(xj_salaryVo.getSenioritySalary(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getSenioritySalary(), DataUtils.DEFAULT_VALUE)));
payRollZong.setSocialSubsidies(DataUtils.findDefaultValue(xj_salaryVo.getSocialSubsidies(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getSocialSubsidies(), DataUtils.DEFAULT_VALUE)));
payRollZong.setFullSubsidies(DataUtils.findDefaultValue(xj_salaryVo.getFullSubsidies(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getFullSubsidies(), DataUtils.DEFAULT_VALUE)));
payRollZong.setNightSubsidies(DataUtils.findDefaultValue(xj_salaryVo.getNightSubsidies(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getNightSubsidies(), DataUtils.DEFAULT_VALUE)));
payRollZong.setDinnerSubsidies(DataUtils.findDefaultValue(xj_salaryVo.getDinnerSubsidies(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getDinnerSubsidies(), DataUtils.DEFAULT_VALUE)));
payRollZong.setSubsidyOrBonus(DataUtils.findDefaultValue(xj_salaryVo.getSubsidyOrBonus(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getSubsidyOrBonus(), DataUtils.DEFAULT_VALUE)));
payRollZong.setAbsenteeismSalary(DataUtils.findDefaultValue(xj_salaryVo.getAbsenteeismSalary(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getAbsenteeismSalary(), DataUtils.DEFAULT_VALUE)));
payRollZong.setAbsenteeismSubsidies(DataUtils.findDefaultValue(xj_salaryVo.getAbsenteeismSubsidies(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getAbsenteeismSubsidies(), DataUtils.DEFAULT_VALUE)));
payRollZong.setMealFee(DataUtils.findDefaultValue(xj_salaryVo.getMealFee(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getMealFee(), DataUtils.DEFAULT_VALUE)));
payRollZong.setDeductions(DataUtils.findDefaultValue(xj_salaryVo.getDeductions(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getDeductions(), DataUtils.DEFAULT_VALUE)));
payRollZong.setSalary(DataUtils.findDefaultValue(xj_salaryVo.getSalary(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getSalary(), DataUtils.DEFAULT_VALUE)));
payRollZong.setPayInsurance(DataUtils.findDefaultValue(xj_salaryVo.getPayInsurance(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getPayInsurance(), DataUtils.DEFAULT_VALUE)));
payRollZong.setSalaryBeforeTax(DataUtils.findDefaultValue(xj_salaryVo.getSalaryBeforeTax(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getSalaryBeforeTax(), DataUtils.DEFAULT_VALUE)));
payRollZong.setTotalWages(DataUtils.findDefaultValue(xj_salaryVo.getTotalWages(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getTotalWages(), DataUtils.DEFAULT_VALUE)));
payRollZong.setAnnualExemptionAmount(DataUtils.findDefaultValue(xj_salaryVo.getAnnualExemptionAmount(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getAnnualExemptionAmount(), DataUtils.DEFAULT_VALUE)));
payRollZong.setSpecialDeduction(DataUtils.findDefaultValue(xj_salaryVo.getSpecialDeduction(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getSpecialDeduction(), DataUtils.DEFAULT_VALUE)));
payRollZong.setSlowDownTheDeduction(DataUtils.findDefaultValue(xj_salaryVo.getSlowDownTheDeduction(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getSlowDownTheDeduction(), DataUtils.DEFAULT_VALUE)));
payRollZong.setAggregatePersonalIncomeTax(DataUtils.findDefaultValue(xj_salaryVo.getAggregatePersonalIncomeTax(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getAggregatePersonalIncomeTax(), DataUtils.DEFAULT_VALUE)));
payRollZong.setTaxPayable(DataUtils.findDefaultValue(xj_salaryVo.getTaxPayable(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getTaxPayable(), DataUtils.DEFAULT_VALUE)));
payRollZong.setNetPayroll(DataUtils.findDefaultValue(xj_salaryVo.getNetPayroll(), DataUtils.DEFAULT_VALUE).add(DataUtils.findDefaultValue(payRollZong.getNetPayroll(), DataUtils.DEFAULT_VALUE)));
}
}
list.add(payRollZong);

View File

@ -2,6 +2,8 @@ package com.evo.finance.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

View File

@ -0,0 +1,391 @@
package com.evo.finance.processor;
import com.evo.attendance.domain.RzAttendanceStatistical;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.AjaxResult;
import com.evo.common.utils.*;
import com.evo.common.utils.spring.SpringUtils;
import com.evo.finance.domain.RzSalaryDetail;
import com.evo.finance.mapper.RzSalaryDetailMapper;
import com.evo.personnelMatters.domain.RzSubsidy;
import com.evo.personnelMatters.domain.RzSubsidyInfo;
import com.evo.personnelMatters.mapper.RzSubsidyInfoMapper;
import com.evo.personnelMatters.mapper.RzSubsidyMapper;
import com.evo.personnelMatters.service.IRzSubsidyInfoService;
import com.evo.restaurant.domain.RzRestaurantStatistics;
import com.evo.restaurant.mapper.RzRestaurantStatisticsMapper;
import com.evo.system.domain.SysStaff;
import com.evo.system.domain.SysStaffDetail;
import com.evo.system.mapper.SysDictDataMapper;
import com.evo.system.mapper.SysStaffDetailMapper;
import com.evo.system.utils.SubsidyCalculationUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 薪资计算接口
*
* @ClassName:SalaryCalculationStrategyExchangeProcessor
* @date: 2025年06月02日 15:39
* @author: andy.shi
* @contact: 17330188597
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
public interface SalaryCalculationStrategyExchangeProcessor {
Logger logger = LoggerFactory.getLogger(SalaryCalculationStrategyExchangeProcessor.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat ym = new SimpleDateFormat("yyyy-MM");
SimpleDateFormat y = new SimpleDateFormat("yyyy");
boolean accept(SysStaffDetail detail);
/***
* 中班补助标识
*/
String zbName = "中班补助";
/***
* 夜班补助标识
*/
String ybName = "夜班补助";
/***
* 夜餐补助标识
*/
String ycName = "夜餐补助";
/***
* 合同补助标识
*/
String htName = "合同补助";
/***
* 新农合补助标识
*/
String xnhName = "新农合补助";
/***
* 工龄补助标识
*/
String glName = "工龄补助";
/***
* 学历补助标识
*/
String xlName = "学历补助";
/***
* 计算新薪资
* @return
*/
void exchangeSalaryCalculation(SysStaff sysStaff, SysStaffDetail detail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical, Map<Long, Boolean> overTimeMap);
void monthSalary(Date limitMonth, Date month, Date limitDate ,SysStaff sysStaff, SysStaffDetail sysStaffDetail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical);
/***
* 构建 应发, 税前, 五险一金
* @param detail
* @param rzSalaryDetail
*/
default void buildRzSalaryDetail(SysStaff sysStaff, SysStaffDetail detail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical){
if(rzSalaryDetail.getName().equals("胡毅鹏")){
System.out.println(1111);
}
Date limitDate = DateUtils.addMonths(sysStaff.getEmploymentDate(), Integer.valueOf(String.valueOf(sysStaff.getWorkerTerm())));
Date limitMonth = null;
Date month = null;
try {
limitMonth = ym.parse(ymd.format(limitDate));
month = ym.parse(ymd.format(rzSalaryDetail.getMonth()));
} catch (ParseException e) {
logger.error("时间格式化异常"+e.getMessage());
}
rzSalaryDetail.setBasicSalary(detail.getBasicSalary());
rzSalaryDetail.setJobSalary(detail.getJobsSalary());
rzSalaryDetail.setDailyWage(detail.getDailyWage());
//计算基础数据
monthSalary(limitMonth, month,limitDate,sysStaff,detail,rzSalaryDetail, attendanceStatistical);
//计算应发工资 合算月工资+加班工资+学历补助+合同补助+社保补助+工龄工资+全勤奖+加班工资+夜班补助+夜餐补助+其他补助+销售提成-餐费扣款-缺勤扣款-补助扣款
rzSalaryDetail.setSalary(rzSalaryDetail.getMonthSalary().add(rzSalaryDetail.getOvertimeSalary()).add(rzSalaryDetail.getNightSubsidies()).add(rzSalaryDetail.getDinnerSubsidies())
.add(DataUtils.findDefaultValue(rzSalaryDetail.getFullSubsidies(), DataUtils.DEFAULT_VALUE)).add(rzSalaryDetail.getLevelSubsidies()).add(rzSalaryDetail.getContractSubsidies()).add(rzSalaryDetail.getSocialSubsidies())
.add(rzSalaryDetail.getSenioritySalary()).add(rzSalaryDetail.getSubsidyOrBonus()).add(rzSalaryDetail.getSalesCommission()).subtract(rzSalaryDetail.getAbsenteeismSalary())
.subtract(rzSalaryDetail.getMealFee()).subtract(rzSalaryDetail.getAbsenteeismSubsidies()));
//五险一金
rzSalaryDetail.setAccumulationFund(detail.getAccumulationFund()); //公积金
rzSalaryDetail.setUnemploymentInsurance(detail.getUnemploymentInsurance()); //失业保险
rzSalaryDetail.setMaternityInsurance(detail.getMaternityInsurance()); //生育保险
rzSalaryDetail.setMedicalInsurance(detail.getMedicalInsurance()); //医疗保险
rzSalaryDetail.setEndowmentInsurance(detail.getEndowmentInsurance()); //养老保险
rzSalaryDetail.setEmploymentInjuryInsurance(detail.getEmploymentInjuryInsurance()); //工伤保险
//税前工资 应发 - 社保 -公司缴纳
rzSalaryDetail.setSalaryBeforeTax(rzSalaryDetail.getSalary().subtract(rzSalaryDetail.getAccumulationFund()).subtract(rzSalaryDetail.getUnemploymentInsurance())
.subtract(rzSalaryDetail.getMaternityInsurance()).subtract(rzSalaryDetail.getMedicalInsurance())
.subtract(rzSalaryDetail.getEndowmentInsurance()).subtract(rzSalaryDetail.getEmploymentInjuryInsurance()).subtract(detail.getCountInsurance()));
}
/***
* 补助
* @param attendanceStatistical
*/
default void subsidy(SysStaff sysStaff, SysStaffDetail detail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical){
//计算实际出勤占比, 如果实际出勤小于应出勤的半数, 则社保有员工承担
//转正才享有
if(Constants.JOB_STATIS_1.equals(sysStaff.getStatus())){
detail = SubsidyCalculationUtils.subsidyCalculation(sysStaff, detail, null);
rzSalaryDetail.setMiddleSubsidies(new BigDecimal(attendanceStatistical.getMiddleShiftNumber()).multiply(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(detail.getExtendeds().get(zbName), 0)))));
rzSalaryDetail.setNightSubsidies(new BigDecimal(attendanceStatistical.getNightNumber()).multiply(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(detail.getExtendeds().get(ybName), 0)))));
rzSalaryDetail.setDinnerSubsidies(new BigDecimal(attendanceStatistical.getNightNumber()).multiply(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(detail.getExtendeds().get(ycName), 0)))));
rzSalaryDetail.setLevelSubsidies(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(detail.getExtendeds().get(xlName), 0))));
rzSalaryDetail.setContractSubsidies(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(detail.getExtendeds().get(htName), 0))));
rzSalaryDetail.setSocialSubsidies(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(detail.getExtendeds().get(xnhName), 0))));
rzSalaryDetail.setSenioritySalary(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(detail.getExtendeds().get(glName), 0))));
rzSalaryDetail.setSalesCommission(DataUtils.findDefaultValue(detail.getSalesCommission(), DataUtils.DEFAULT_VALUE));
//其他补助+固定补助
rzSalaryDetail.setSubsidyOrBonus(detail.getOtherSubsidies().add(detail.getFixedAllowance()));
}
}
// /***
// * 计算加班工资
// * @param rzSalaryDetail
// * @param attendanceStatistical
// * @param isOverTime
// */
// default void autoCalculationOverTimeWorkSalary(BigDecimal salary, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical, Boolean isOverTime){
// if(!isOverTime){
// rzSalaryDetail.setOvertimeSalary(new BigDecimal(0));
// }else{
// BigDecimal hourlyWage = salary.divide(new BigDecimal(ParamUtils.getMonthWorkDayNum(DateUtils.getMonth(rzSalaryDetail.getMonth()))),2,BigDecimal.ROUND_HALF_UP);
// //计算加班工资
// rzSalaryDetail.setOvertimeSalary(attendanceStatistical.getOverTimeHours().multiply(hourlyWage));
// }
// }
/***
* 计算扣款
*/
default void deduction(SysStaffDetail detail, RzSalaryDetail rzSalaryDetail, BigDecimal ycHours , BigDecimal cqHours){
//其他扣款
rzSalaryDetail.setDeductions(detail.getDeductions());
//餐饮扣款
RzRestaurantStatistics rzRestaurantStatistics = SpringUtils.getBean(RzRestaurantStatisticsMapper.class).selectRzRestaurantStatisticsByUserIdAndDate(detail.getStaffId(),rzSalaryDetail.getMonth());
rzSalaryDetail.setMealFee(rzRestaurantStatistics.getPersonalSumConsumption());
if(ycHours.compareTo(cqHours) != 0){
Long ycDays = ycHours.divide(Constants.DAY_WORK_HOUR).longValue();
//补助总钱数
BigDecimal bzAmount = rzSalaryDetail.getLevelSubsidies().add(rzSalaryDetail.getContractSubsidies()).add(rzSalaryDetail.getSenioritySalary()).add(rzSalaryDetail.getSocialSubsidies());
//一天的补助
BigDecimal bzDayAmount = bzAmount.divide(new BigDecimal(ycDays),2,BigDecimal.ROUND_HALF_UP);
//计算补助扣款, 总补助-出勤补助=补助扣款, 出勤补助= 天补助*出勤天数
rzSalaryDetail.setAbsenteeismSubsidies(bzAmount.subtract(bzDayAmount.multiply(new BigDecimal(cqHours.divide(Constants.DAY_WORK_HOUR).doubleValue()))));
}else{
//计算补助扣款, 总补助-出勤补助=补助扣款, 出勤补助= 天补助*出勤天数
rzSalaryDetail.setAbsenteeismSubsidies(new BigDecimal(0));
}
}
/***
* 计算社保占比
* @param detail
* @param attendanceStatistical
*/
default void socialSecurity(SysStaffDetail detail, RzAttendanceStatistical attendanceStatistical){
//计算实际出勤占比, 如果实际出勤小于应出勤的半数, 则社保有员工承担
BigDecimal proportion = attendanceStatistical.getRealAttendance().divide(attendanceStatistical.getShouldAttendance(),2, RoundingMode.HALF_UP);
if(proportion.compareTo(new BigDecimal("0.50")) < 0){
detail.setCountInsurance(new BigDecimal("0.00"));
}
}
/***
* 开始计算薪资
*/
default void calculation(SysStaff sysStaff, SysStaffDetail detail, RzSalaryDetail rzSalaryDetail){
RzSalaryDetailMapper rzSalaryDetailMapper = SpringUtils.getBean(RzSalaryDetailMapper.class);
SysStaffDetailMapper sysStaffDetailMapper = SpringUtils.getBean(SysStaffDetailMapper.class);
//获取统计月份
int curr_month = rzSalaryDetail.getMonth().getMonth();
//获取工资统计月份,查询上个月的纳税公司 得到年度免征额
RzSalaryDetail old_rzSalary = rzSalaryDetailMapper.selectRzSalaryDetailByStaffId(rzSalaryDetail.getStaffId());
if(curr_month == 12){
rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00"));
}else{
//判断员工为 新入职公司纳税主题改变同一主题超一年的同一主题不超一年但跨年的
if(StringUtils.isNull(old_rzSalary) || !old_rzSalary.getWbFlag().equals(sysStaff.getCompanyName())
|| (rzSalaryDetail.getMonth().getTime() - old_rzSalary.getMonth().getTime())/1000/60/60/24 > 365
|| (old_rzSalary.getMonth().getMonth() < 12 && old_rzSalary.getMonth().getMonth() > rzSalaryDetail.getMonth().getMonth())){
rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00"));
}else{
rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00").add(old_rzSalary.getAnnualExemptionAmount()));
}
}
// 本年累计已发工资本年累计已发工资+本月税前工资
rzSalaryDetail.setTotalWages(detail.getTotalWages().add(rzSalaryDetail.getSalaryBeforeTax()));
// 专项附加扣除六项附加扣除额相加
rzSalaryDetail.setSpecialDeduction(detail.getChildrenEducation().add(detail.getSupportTheOld()).add(detail.getHousingLoans()).add(detail.getHousingRents()).add(detail.getAdultEducation()).add(detail.getTreatmentForSeriousDisease()));
rzSalaryDetail.setTaxableIncome(rzSalaryDetail.getTotalWages());
// 判断应纳税所得额额度额度不一样税率不一样
if (rzSalaryDetail.getTaxableIncome().doubleValue() > 0 && rzSalaryDetail.getTaxableIncome().doubleValue() <= 36000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.03"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("0"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 36000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 144000L) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.10"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("2520"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 144000L && rzSalaryDetail.getTaxableIncome().doubleValue() <= 300000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.20"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("16920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 300000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 420000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.25"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("31920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 420000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 660000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.30"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("52920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 660000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 960000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.35"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("85920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 960000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.45"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("181920"));
} else {
// 应纳税所得额小于0(免征额+专项扣除>应发工资时)
// 此阶税率为百分之0速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.00"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("0"));
}
//判断是否外包外包公司员工不做税(月薪50000不上税)
if("外包".equals(sysStaff.getCompanyName())){
// 实发工资 = 税前工资
rzSalaryDetail.setNetPayroll(rzSalaryDetail.getSalaryBeforeTax());
}else {
// 应纳税额 (本年累计已发工资-年度免征额-累计专项扣除-本月专项扣除)
BigDecimal tax = rzSalaryDetail.getTotalWages().subtract(rzSalaryDetail.getSpecialDeduction()).subtract(rzSalaryDetail.getAnnualExemptionAmount());
if(tax.doubleValue() <= 0.0){
rzSalaryDetail.setTaxableIncome(new BigDecimal("0.00"));
}else{
rzSalaryDetail.setTaxableIncome(tax);
}
// 判断税前工资是否大于5000,如果小于则不在计算个税
if (rzSalaryDetail.getSalaryBeforeTax().doubleValue() > 5000.00){
// 本月应缴税额(本月应纳税所得额*税率-速减数-本年累计已预缴个税)
rzSalaryDetail.setTaxPayable(
rzSalaryDetail.getTaxableIncome().multiply(rzSalaryDetail.getTaxRate()).subtract(rzSalaryDetail.getSlowDownTheDeduction()).subtract(detail.getAggregatePersonalIncomeTax()));
if (rzSalaryDetail.getTaxPayable().doubleValue() <= 0) {
rzSalaryDetail.setTaxPayable(new BigDecimal("0.00"));
}
} else {
// 应纳税所得额
rzSalaryDetail.setTaxableIncome(new BigDecimal("0.00"));
rzSalaryDetail.setTaxPayable(new BigDecimal("0.00"));
}
// 实发工资税前工资-本月应缴个人所得税
rzSalaryDetail.setNetPayroll(rzSalaryDetail.getSalaryBeforeTax().subtract(rzSalaryDetail.getTaxPayable()));
// 本年累计已缴税额
rzSalaryDetail.setAggregatePersonalIncomeTax(detail.getAggregatePersonalIncomeTax().add(rzSalaryDetail.getTaxPayable()));
}
rzSalaryDetail.setId(null);
if(rzSalaryDetailMapper.insert(rzSalaryDetail)< 0){
throw new RuntimeException("生成员工考勤详情失败");
}
//判断统计月缴费公司和上一次是否一个公司
if(StringUtils.isNull(old_rzSalary) || old_rzSalary.getWbFlag().equals(sysStaff.getCompanyName())){
// 把本年累计个税
detail.setAggregatePersonalIncomeTax(rzSalaryDetail.getAggregatePersonalIncomeTax());
// 把本年累计专项扣除保存到员工信息表中
detail.setSpecialDeduction(detail.getSpecialDeduction().add(rzSalaryDetail.getSpecialDeduction()));
// 把本年累计已发工资保存到员工信息表中
detail.setTotalWages(rzSalaryDetail.getTotalWages());
if(sysStaffDetailMapper.updateSysStaffDetail(detail)< 0){
throw new RuntimeException("更新员工详情信息异常");
}
}else{
//删除原来的数据
detail.setDelFlag(Constants.DELETE_FLAG_1);
sysStaffDetailMapper.updateById(detail);
//新建详情数据
// 把本年累计已缴个税保存到员工信息表中
detail.setAggregatePersonalIncomeTax(rzSalaryDetail.getTaxPayable());
// 把本年累计专项扣除保存到员工信息表中
detail.setSpecialDeduction(rzSalaryDetail.getSpecialDeduction());
// 把本年累计已发工资保存到员工信息表中
detail.setTotalWages(rzSalaryDetail.getSalaryBeforeTax());
detail.setId(null);
if(sysStaffDetailMapper.insert(detail)< 0){
throw new RuntimeException("新增员工详情信息异常");
}
}
}
// default BigDecimal autoMonthSalary(SysStaff sysStaff, RzSalaryDetail rzSalaryDetail,BigDecimal salary) {
// try {
// Date limitDate = DateUtils.addMonths(sysStaff.getEmploymentDate(), Integer.valueOf(String.valueOf(sysStaff.getWorkerTerm())));
// //如果计算薪资的月份 小于转正的月份, 则按照全额薪资的80%发放
// if(limitDate.compareTo(rzSalaryDetail.getMonth()) > 0){
// return salary.multiply(new BigDecimal("0.8"));
// }
// //如果转正日期的月份=计算薪资的月份, 则需要分析占比
// if(ym.format(limitDate).equals(ym.format(rzSalaryDetail.getMonth()))){
// List<String> monthAllDays = DateUtils.getMonthAndDays(rzSalaryDetail.getMonth());
// List<String> holidayList = Collections.findDuplicatesList(monthAllDays, ParamUtils.getHoliddayList(Integer.valueOf(y.format(rzSalaryDetail.getMonth())),0));
// //出勤全天剔除放假时间, 获取正常出勤天
// monthAllDays.retainAll(holidayList);
// List<String> notFullAmount = Collections.emptyList();
// for (int i = 0; i < monthAllDays.size(); i++) {
// if(limitDate.compareTo(ymd.parse(monthAllDays.get(i)))>= 0){
// break;
// }
// //记录非全勤的天数
// notFullAmount.add(monthAllDays.get(i));
// }
// //计算非全额薪资的占比
// BigDecimal proportion = new BigDecimal(notFullAmount.size()).divide(new BigDecimal(monthAllDays.size()),2, BigDecimal.ROUND_HALF_UP);
// BigDecimal notFullSalary = salary.multiply(proportion);
// BigDecimal fullSalary = salary.multiply(new BigDecimal(1).subtract(proportion));
// return notFullSalary.add(fullSalary);
// }
// //默认 薪资计算日期超过转正日期, 返回全额
// return salary;
// } catch (ParseException e) {
// logger.error("计算薪资占比出现异常"+e.getMessage());
// return new BigDecimal("0");
// }
// }
}

View File

@ -0,0 +1,104 @@
package com.evo.finance.processor.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.evo.attendance.domain.RzAttendance;
import com.evo.attendance.domain.RzAttendanceStatistical;
import com.evo.attendance.mapper.RzAttendanceMapper;
import com.evo.common.constant.Constants;
import com.evo.common.utils.DateUtils;
import com.evo.common.utils.ParamUtils;
import com.evo.finance.domain.RzSalaryDetail;
import com.evo.finance.processor.SalaryCalculationStrategyExchangeProcessor;
import com.evo.personnelMatters.mapper.RzLeaveDetailMapper;
import com.evo.system.domain.SysStaff;
import com.evo.system.domain.SysStaffDetail;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 日薪计算规则类
*
* @ClassName:FailyWageStrategyExchangeProcessor
* @date: 2025年06月02日 15:42
* @author: andy.shi
* @contact: 17330188597
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Service
public class DailyWageStrategyExchangeProcessor implements SalaryCalculationStrategyExchangeProcessor {
@Resource
private RzAttendanceMapper rzAttendanceMapper;
@Resource
private RzLeaveDetailMapper rzLeaveDetailMapper;
@Override
public boolean accept(SysStaffDetail detail) {
//日薪不为空, 并且大于0
return detail.getDailyWage() != null && detail.getDailyWage().compareTo(new BigDecimal(0)) > 0;
}
@Override
public void exchangeSalaryCalculation(SysStaff sysStaff, SysStaffDetail sysStaffDetail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical, Map<Long, Boolean> overTimeMap) {
//组件基础数据
buildRzSalaryDetail(sysStaff, sysStaffDetail,rzSalaryDetail, attendanceStatistical);
// //计算基本工资
// monthSalary(sysStaff, sysStaffDetail,rzSalaryDetail, attendanceStatistical);
//计算社保
socialSecurity(sysStaffDetail, attendanceStatistical);
//计算薪资
calculation(sysStaff, sysStaffDetail,rzSalaryDetail);
}
@Override
public void monthSalary(Date limitMonth, Date month, Date limitDate ,SysStaff sysStaff, SysStaffDetail detail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical){
//如果计算薪资的月份 小于转正的月份, 则按照全额薪资的80%发放
if(limitMonth.compareTo(month) > 0){
rzSalaryDetail.setMonthSalary(rzSalaryDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP).multiply(attendanceStatistical.getRealAttendance()).multiply(new BigDecimal(Constants.SUBSIDY_PERIOD)));
rzSalaryDetail.setOvertimeSalary(rzSalaryDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP).multiply(attendanceStatistical.getWorkOvertimeNumber()).multiply(new BigDecimal(Constants.SUBSIDY_PERIOD)));
}else if(limitDate.compareTo(rzSalaryDetail.getMonth()) < 0){
rzSalaryDetail.setMonthSalary(rzSalaryDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP).multiply(attendanceStatistical.getRealAttendance().add(attendanceStatistical.getWorkOvertimeNumber())));
rzSalaryDetail.setOvertimeSalary(rzSalaryDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP).multiply(attendanceStatistical.getWorkOvertimeNumber()));
}else {
//根据转正日期查询员工的打卡信息
List<RzAttendance> att_list = rzAttendanceMapper.queryMonthAttendanceByStaffId(sysStaff.getUserId(), rzSalaryDetail.getMonth());
BigDecimal att_work = new BigDecimal("0.0");
for (RzAttendance rzAttendance : att_list) {
if(rzAttendance.getAttendanceDate().before(sysStaff.getWagesRatioDate())) {
att_work = att_work.add(rzAttendance.getWorkSum());
}
}
//未转正需要扣除的工资
BigDecimal work = rzSalaryDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP).multiply(att_work).multiply(new BigDecimal(Constants.SUBSIDY_PERIOD_1));
rzSalaryDetail.setBasicSalary(rzSalaryDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP).multiply(attendanceStatistical.getRealAttendance()).subtract(work));
rzSalaryDetail.setOvertimeSalary(rzSalaryDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP).multiply(attendanceStatistical.getWorkOvertimeNumber()));
}
//检查是否当月有工伤假
Long hour = rzLeaveDetailMapper.selectLeaveHourByUserIdAndDateAndType(sysStaff.getUserId(), rzSalaryDetail.getMonth(), 60l);
if(hour.compareTo(0l)> 0){
//存在工伤假, 需要计算
BigDecimal gs = new BigDecimal(ParamUtils.dailyWageGsBasicPrice()).divide(new BigDecimal(DateUtils.getMonthDays(rzSalaryDetail.getMonth())),2, RoundingMode.HALF_UP).multiply(new BigDecimal(hour).divide(Constants.DAY_WORK_HOUR,2,RoundingMode.HALF_UP));
rzSalaryDetail.setMonthSalary(rzSalaryDetail.getMonthSalary().add(gs));
}
//计算补助
subsidy(sysStaff, detail, rzSalaryDetail, attendanceStatistical);
//计算扣减
;
deduction(detail, rzSalaryDetail, new BigDecimal(DateUtils.getMonthDays(rzSalaryDetail.getMonth())).multiply(Constants.DAY_WORK_HOUR), rzAttendanceMapper.selectOne(new QueryWrapper<RzAttendance>().select( " sum(work_num) as workNum ").lambda().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth())).getWorkSum());
//deduction(detail, rzSalaryDetail, String.valueOf(DateUtils.getMonthDays(rzSalaryDetail.getMonth())), rzAttendanceMapper.selectCount(new LambdaQueryWrapper<RzAttendance>().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth()).select(RzAttendance::getId)));
//日薪没有缺勤扣款, 上一天就一天
rzSalaryDetail.setAbsenteeismSalary(new BigDecimal(0));
}
}

View File

@ -0,0 +1,129 @@
package com.evo.finance.processor.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.evo.attendance.domain.RzAttendance;
import com.evo.attendance.domain.RzAttendanceStatistical;
import com.evo.attendance.mapper.RzAttendanceMapper;
import com.evo.common.constant.Constants;
import com.evo.common.utils.Collections;
import com.evo.common.utils.DataUtils;
import com.evo.common.utils.DateUtils;
import com.evo.common.utils.ParamUtils;
import com.evo.finance.domain.RzSalaryDetail;
import com.evo.finance.processor.SalaryCalculationStrategyExchangeProcessor;
import com.evo.personnelMatters.mapper.RzLeaveDetailMapper;
import com.evo.system.domain.SysStaff;
import com.evo.system.domain.SysStaffDetail;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 月薪计算规则类
*
* @ClassName:MonthlySalaryStrategyExchangeProcessor
* @date: 2025年06月02日 15:41
* @author: andy.shi
* @contact: 17330188597
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Service
public class MonthlySalaryStrategyExchangeProcessor implements SalaryCalculationStrategyExchangeProcessor {
@Resource
private RzAttendanceMapper rzAttendanceMapper;
@Resource
private RzLeaveDetailMapper rzLeaveDetailMapper;
private List<Long> qx = Collections.asList(56l,58l,59l,83l,60l);
private List<Long> qx8 = Collections.asList(52l);
@Override
public boolean accept(SysStaffDetail detail) {
//基本工资不为空, 并且大于0 并且岗位工资不为空, 并且大于0
return (detail.getBasicSalary() != null && detail.getBasicSalary().compareTo(new BigDecimal(0)) > 0) && (detail.getJobsSalary() != null && detail.getJobsSalary().compareTo(new BigDecimal(0)) > 0);
}
/***
* @param sysStaff
* @param sysStaffDetail
* @param rzSalaryDetail
* @param attendanceStatistical
* @param overTimeMap
*/
@Override
public void exchangeSalaryCalculation(SysStaff sysStaff, SysStaffDetail sysStaffDetail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical, Map<Long, Boolean> overTimeMap) {
// //计算基本工资
// monthSalary(sysStaff, sysStaffDetail,rzSalaryDetail, attendanceStatistical);
//组件基础数据
buildRzSalaryDetail(sysStaff, sysStaffDetail,rzSalaryDetail, attendanceStatistical);
//计算薪资
calculation(sysStaff, sysStaffDetail,rzSalaryDetail);
}
@Override
public void monthSalary(Date limitMonth, Date month, Date limitDate ,SysStaff sysStaff, SysStaffDetail detail, RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical){
//如果计算薪资的月份 小于转正的月份, 则按照全额薪资的80%发放
if(limitMonth.compareTo(month) > 0){
rzSalaryDetail.setMonthSalary(rzSalaryDetail.getBasicSalary().add(rzSalaryDetail.getJobSalary()).multiply(new BigDecimal(Constants.SUBSIDY_PERIOD)));
}else if(limitMonth.compareTo(month) < 0){
rzSalaryDetail.setMonthSalary(rzSalaryDetail.getBasicSalary().add(rzSalaryDetail.getJobSalary()));
}else {
BigDecimal att_work = new BigDecimal("0.0");
List<RzAttendance> att_list = rzAttendanceMapper.queryMonthAttendanceByStaffId(sysStaff.getUserId(), rzSalaryDetail.getMonth());
for (RzAttendance rzAttendance : att_list) {
if(rzAttendance.getAttendanceDate().before(limitDate)) {
att_work = att_work.add(rzAttendance.getWorkSum());
}
}
//未转正需要扣除的工资
BigDecimal work = rzSalaryDetail.getBasicSalary().add(rzSalaryDetail.getJobSalary()).divide(attendanceStatistical.getShouldAttendance(),2, RoundingMode.HALF_UP).multiply(att_work).multiply(new BigDecimal(Constants.SUBSIDY_PERIOD_1));
rzSalaryDetail.setMonthSalary(rzSalaryDetail.getBasicSalary().add(rzSalaryDetail.getJobSalary()).subtract(work));
}
//获取工作日天数
String workNum = ParamUtils.getMonthWorkDayNum(DateUtils.getYear(rzSalaryDetail.getMonth()), DateUtils.getMonth(rzSalaryDetail.getMonth()));
//时薪
BigDecimal hourlyWage = rzSalaryDetail.getMonthSalary().divide(new BigDecimal(workNum),2,BigDecimal.ROUND_HALF_UP).divide(Constants.DAY_WORK_HOUR,2,BigDecimal.ROUND_HALF_UP);
//计算加班工资
rzSalaryDetail.setOvertimeSalary(DataUtils.findDefaultValue(attendanceStatistical.getOverTimeHours(), new BigDecimal(0)).multiply(hourlyWage));
//计算补助
subsidy(sysStaff, detail, rzSalaryDetail, attendanceStatistical);
//计算扣减
deduction(detail, rzSalaryDetail, new BigDecimal(workNum).multiply(Constants.DAY_WORK_HOUR), rzAttendanceMapper.selectOne(new QueryWrapper<RzAttendance>().select( " sum(work_num) as workNum ").lambda().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth())).getWorkSum());
//deduction(detail, rzSalaryDetail,workNum, rzAttendanceMapper.selectCount(new LambdaQueryWrapper<RzAttendance>().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth()).select(RzAttendance::getId)));
//计算社保
socialSecurity(detail, attendanceStatistical);
/***
* 婚假, 陪产假 丧假 年假 流产 全新发放
* 产假 无薪
* 病假 基本工资*0.8
* 工伤假 不包含补贴
*/
Long total8Hour = 0l;
for (Long type: qx8) {
Long hour = rzLeaveDetailMapper.selectLeaveHourByUserIdAndDateAndType(sysStaff.getUserId(), rzSalaryDetail.getMonth(), type);
if(hour.compareTo(0l)> 0){
total8Hour = total8Hour+ hour;
}
}
if(total8Hour.compareTo(0l)> 0){
//存在工伤假, 需要计算
BigDecimal gs = rzSalaryDetail.getBasicSalary().divide(new BigDecimal(ParamUtils.getMonthWorkDayNum(DateUtils.getYear(rzSalaryDetail.getMonth()), DateUtils.getMonth(rzSalaryDetail.getMonth()))),2, RoundingMode.HALF_UP).multiply(new BigDecimal(total8Hour).divide(Constants.DAY_WORK_HOUR,2,RoundingMode.HALF_UP));
rzSalaryDetail.setMonthSalary(rzSalaryDetail.getMonthSalary().add(gs));
}
Long totalAllHour = 0l;
for (Long type: qx) {
Long hour = rzLeaveDetailMapper.selectLeaveHourByUserIdAndDateAndType(sysStaff.getUserId(), rzSalaryDetail.getMonth(), type);
if(hour.compareTo(0l)> 0){
totalAllHour = totalAllHour+hour;
}
}
//请假时长
rzSalaryDetail.setAbsenteeismSalary(hourlyWage.multiply(attendanceStatistical.getAbsenteeism().subtract(new BigDecimal(totalAllHour))));
}
}

View File

@ -2,21 +2,28 @@ package com.evo.finance.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.evo.attendance.domain.RzAttendance;
import com.evo.attendance.domain.RzAttendanceStatistical;
import com.evo.attendance.domain.RzSpecialOverTime;
import com.evo.attendance.domain.vo.RzSalaryVo;
import com.evo.attendance.mapper.RzAttendanceMapper;
import com.evo.attendance.mapper.RzAttendanceStatisticalMapper;
import com.evo.attendance.mapper.RzSpecialOverTimeMapper;
import com.evo.attendance.processor.PunchTheClockStrategyExchangeProcessor;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.AjaxResult;
import com.evo.common.core.domain.entity.SysDept;
import com.evo.common.utils.DateUtils;
import com.evo.common.utils.ParamUtils;
import com.evo.common.utils.SecurityUtils;
import com.evo.common.utils.StringUtils;
import com.evo.finance.domain.RzSalaryDetail;
import com.evo.finance.domain.RzSalaryStatistics;
import com.evo.finance.mapper.RzSalaryDetailMapper;
import com.evo.finance.mapper.RzSalaryStatisticsMapper;
import com.evo.finance.processor.SalaryCalculationStrategyExchangeProcessor;
import com.evo.finance.service.IRzSalaryDetailService;
import com.evo.personnelMatters.domain.RzHoliday;
import com.evo.personnelMatters.mapper.RzHolidayMapper;
import com.evo.restaurant.domain.RzRestaurantStatistics;
import com.evo.restaurant.mapper.RzRestaurantStatisticsMapper;
@ -26,15 +33,22 @@ import com.evo.system.mapper.SysDeptMapper;
import com.evo.system.mapper.SysStaffDetailMapper;
import com.evo.system.mapper.SysStaffMapper;
import com.evo.system.service.ISysDictDataService;
import com.evo.utils.DateUtil;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 工资详情Service业务层处理
@ -67,7 +81,8 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl<RzSalaryDetailMapper,
private RzSpecialOverTimeMapper rzSpecialOverTimeMapper;
@Resource
private ISysDictDataService sysDictDataService;
@Autowired
private ApplicationContext applicationContext;
/**
* 查询工资详情
*
@ -145,203 +160,250 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl<RzSalaryDetailMapper,
}catch (Exception e){
e.printStackTrace();
}
Map<Long, Boolean> overTimeMap = deptMapper.selectList(new LambdaQueryWrapper<SysDept>().eq(SysDept::getDelFlag, Constants.DELETE_FLAG_0).select(SysDept::getIsOverTime, SysDept::getDeptId)).stream().collect(Collectors.toMap(SysDept::getDeptId,d->"0".equals(d.getIsOverTime())));
for (SysStaff sysStaff : st_list) {
if(sysStaff.getName().equals("胡毅鹏")){
System.out.println(1111);
}
rzSalaryDetail.setStaffId(sysStaff.getUserId()); //员工ID
rzSalaryDetail.setDeptId(sysStaff.getDeptId()); //部门
rzSalaryDetail.setName(sysStaff.getName()); //姓名
rzSalaryDetail.setWbFlag(sysStaff.getCompanyName()); //公司
//计算获得的工资
SysStaffDetail salaryDetail = calculateSalary(sysStaff,rzSalaryDetail.getMonth(),sbrq);
rzSalaryDetail.setMonthSalary(salaryDetail.getBasicSalary()); //基本工资
rzSalaryDetail.setAbsenteeismSalary(salaryDetail.getAbsenteeismSalary()); //请假扣除工资
rzSalaryDetail.setOvertimeSalary(salaryDetail.getOverWages()); //加班工资
//查询考勤统计
RzAttendanceStatistical attendanceStatistical = rzAttendanceStatisticalMapper.getRzAttendanceStatisticalByDateAndName(sysStaff.getUserId(), rzSalaryDetail.getMonth());
//查询员工详情
SysStaffDetail sysStaffDetail = sysStaffDetailMapper.selectSysStaffDetailByStaffId(sysStaff.getUserId());
Map<String, SalaryCalculationStrategyExchangeProcessor> salaryCalculationExchangeProcessorMap = applicationContext.getBeansOfType(SalaryCalculationStrategyExchangeProcessor.class);
for (SalaryCalculationStrategyExchangeProcessor processor : salaryCalculationExchangeProcessorMap.values()) {
if (processor.accept(sysStaffDetail)) {
processor.exchangeSalaryCalculation(sysStaff, sysStaffDetail, rzSalaryDetail, attendanceStatistical, overTimeMap);
}
}
}
//不为空, 为日薪
// if(sysStaffDetail.getDailyWage() != null){
//
// }else
// //如果都不为空, 则为月薪
// if(sysStaffDetail.getBasicSalary() != null && sysStaffDetail.getJobsSalary()!=null){
// rzSalaryDetail.setMonthSalary(sysStaffDetail.getBasicSalary());
// rzSalaryDetail.setJobSalary(sysStaffDetail.getJobsSalary());
// rzSalaryDetail.setDailyWage(new BigDecimal(0));
// //计算加班工资
// autoCalculationOverTimeWorkSalary(rzSalaryDetail, attendanceStatistical, overTimeMap.get(rzSalaryDetail.getDeptId()));
//
// }
// //计算获得的工资
// SysStaffDetail salaryDetail = calculateSalary(sysStaff,rzSalaryDetail.getMonth(),sbrq);
// rzSalaryDetail.setMonthSalary(salaryDetail.getBasicSalary()); //基本工资
// rzSalaryDetail.setAbsenteeismSalary(salaryDetail.getAbsenteeismSalary()); //请假扣除工资
// rzSalaryDetail.setOvertimeSalary(salaryDetail.getOverWages()); //加班工资
// rzSalaryDetail.setNightSubsidies(salaryDetail.getNightShiftSubsidies()); //夜班补助
// rzSalaryDetail.setDinnerSubsidies(salaryDetail.getDinnerSubsidies()); //夜餐补助
// rzSalaryDetail.setMiddleSubsidies(salaryDetail.getMiddleSubsidies()); //中班补助
//查询员工详情
SysStaffDetail sysStaffDetail = sysStaffDetailMapper.selectSysStaffDetailByStaffId(sysStaff.getUserId());
// SysStaffDetail sysStaffDetail = sysStaffDetailMapper.selectSysStaffDetailByStaffId(sysStaff.getUserId());
// rzSalaryDetail.setFullSubsidies(sysStaffDetail.getFullFrequentlySubsidies()); //全勤奖
// rzSalaryDetail.setLevelSubsidies(sysStaffDetail.getLevelOfEducationSubsidies()); //学历
// rzSalaryDetail.setContractSubsidies(sysStaffDetail.getContractSubsidies()); //合同
// rzSalaryDetail.setSocialSubsidies(sysStaffDetail.getSocialSecuritySubsidies()); //社保
rzSalaryDetail.setSubsidyOrBonus(sysStaffDetail.getOtherSubsidies().add(sysStaffDetail.getFixedAllowance())); //其他补助
// rzSalaryDetail.setSubsidyOrBonus(sysStaffDetail.getOtherSubsidies().add(sysStaffDetail.getFixedAllowance())); //其他补助
//补助扣除 TODO 福利扣除百分比
// rzSalaryDetail.setAbsenteeismSubsidies(sysStaffDetail.getLevelOfEducationSubsidies().add(sysStaffDetail.getContractSubsidies())
// .add(sysStaffDetail.getSenioritySubsidies()).add(sysStaffDetail.getSocialSecuritySubsidies()).multiply(salaryDetail.getAbsenteeismSubsidies()));
rzSalaryDetail.setDeductions(sysStaffDetail.getDeductions()); //其他扣款
//计算工龄,以每月10号社保缴纳计算
int years = sbrq.getYear() - sysStaff.getEmploymentDate().getYear();
int months = sbrq.getMonth() - sysStaff.getEmploymentDate().getMonth();
int days = sbrq.getDate() - sysStaff.getEmploymentDate().getDate();
if(months < 0){
years -= 1;
}
if(months == 0 && days < 0){
years -= 1;
}
// rzSalaryDetail.setDeductions(sysStaffDetail.getDeductions()); //其他扣款
// //计算工龄,以每月10号社保缴纳计算
// int years = sbrq.getYear() - sysStaff.getEmploymentDate().getYear();
// int months = sbrq.getMonth() - sysStaff.getEmploymentDate().getMonth();
// int days = sbrq.getDate() - sysStaff.getEmploymentDate().getDate();
// if(months < 0){
// years -= 1;
// }
// if(months == 0 && days < 0){
// years -= 1;
// }
// if(years > 10){
// rzSalaryDetail.setSenioritySalary(sysStaffDetail.getSenioritySubsidies().multiply(new BigDecimal("10.0"))); //工龄
// }else{
// rzSalaryDetail.setSenioritySalary(sysStaffDetail.getSenioritySubsidies().multiply(new BigDecimal(years))); //工龄
// }
//餐费
RzRestaurantStatistics rzRestaurantStatistics = rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsByUserIdAndDate(sysStaff.getUserId(),rzSalaryDetail.getMonth());
rzSalaryDetail.setMealFee(rzRestaurantStatistics.getPersonalSumConsumption()); //餐费扣除
//计算应发工资 合算月工资+学历补助+合同补助+社保补助+工龄工资+全勤奖+加班工资+夜班补助+夜餐补助+其他补助
BigDecimal sum = rzSalaryDetail.getMonthSalary().add(rzSalaryDetail.getOvertimeSalary()).add(rzSalaryDetail.getNightSubsidies()).add(rzSalaryDetail.getDinnerSubsidies())
.add(rzSalaryDetail.getFullSubsidies()).add(rzSalaryDetail.getLevelSubsidies()).add(rzSalaryDetail.getContractSubsidies()).add(rzSalaryDetail.getSocialSubsidies())
.add(rzSalaryDetail.getSenioritySalary()).add(rzSalaryDetail.getSubsidyOrBonus()).subtract(rzSalaryDetail.getAbsenteeismSalary())
.subtract(rzSalaryDetail.getMealFee()).subtract(rzSalaryDetail.getAbsenteeismSubsidies());
rzSalaryDetail.setSalary(sum);
//五险一金
rzSalaryDetail.setAccumulationFund(sysStaffDetail.getAccumulationFund()); //公积金
rzSalaryDetail.setUnemploymentInsurance(sysStaffDetail.getUnemploymentInsurance()); //失业保险
rzSalaryDetail.setMaternityInsurance(sysStaffDetail.getMaternityInsurance()); //生育保险
rzSalaryDetail.setMedicalInsurance(sysStaffDetail.getMedicalInsurance()); //医疗保险
rzSalaryDetail.setEndowmentInsurance(sysStaffDetail.getEndowmentInsurance()); //养老保险
rzSalaryDetail.setEmploymentInjuryInsurance(sysStaffDetail.getEmploymentInjuryInsurance()); //工伤保险
//税前工资 应发 - 社保
rzSalaryDetail.setSalaryBeforeTax(rzSalaryDetail.getSalary().subtract(rzSalaryDetail.getAccumulationFund()).subtract(rzSalaryDetail.getUnemploymentInsurance())
.subtract(rzSalaryDetail.getMaternityInsurance()).subtract(rzSalaryDetail.getMedicalInsurance())
.subtract(rzSalaryDetail.getEndowmentInsurance()).subtract(rzSalaryDetail.getEmploymentInjuryInsurance()).subtract(salaryDetail.getCountInsurance()));
//获取统计月份
int curr_month = rzSalaryDetail.getMonth().getMonth();
//获取工资统计月份,查询上个月的纳税公司 得到年度免征额
RzSalaryDetail old_rzSalary = rzSalaryDetailMapper.selectRzSalaryDetailByStaffId(sysStaff.getUserId());
if(curr_month == 12){
rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00"));
}else{
//判断员工为 新入职公司纳税主题改变同一主题超一年的同一主题不超一年但跨年的
if(StringUtils.isNull(old_rzSalary) || !old_rzSalary.getWbFlag().equals(sysStaff.getCompanyName())
|| (rzSalaryDetail.getMonth().getTime() - old_rzSalary.getMonth().getTime())/1000/60/60/24 > 365
|| (old_rzSalary.getMonth().getMonth() < 12 && old_rzSalary.getMonth().getMonth() > rzSalaryDetail.getMonth().getMonth())){
rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00"));
}else{
rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00").add(old_rzSalary.getAnnualExemptionAmount()));
}
}
// 本年累计已发工资本年累计已发工资+本月税前工资
rzSalaryDetail.setTotalWages(sysStaffDetail.getTotalWages().add(rzSalaryDetail.getSalaryBeforeTax()));
// 专项附加扣除六项附加扣除额相加
rzSalaryDetail.setSpecialDeduction(sysStaffDetail.getChildrenEducation().add(sysStaffDetail.getSupportTheOld()).add(sysStaffDetail.getHousingLoans())
.add(sysStaffDetail.getHousingRents()).add(sysStaffDetail.getAdultEducation()).add(sysStaffDetail.getTreatmentForSeriousDisease()));
// 判断应纳税所得额额度额度不一样税率不一样
if (rzSalaryDetail.getTaxableIncome().doubleValue() > 0 && rzSalaryDetail.getTaxableIncome().doubleValue() <= 36000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.03"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("0"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 36000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 144000L) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.10"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("2520"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 144000L && rzSalaryDetail.getTaxableIncome().doubleValue() <= 300000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.20"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("16920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 300000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 420000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.25"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("31920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 420000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 660000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.30"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("52920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 660000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 960000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.35"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("85920"));
} else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 960000l) {
// 此阶税率为百分之3速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.45"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("181920"));
} else {
// 应纳税所得额小于0(免征额+专项扣除>应发工资时)
// 此阶税率为百分之0速减数为0
rzSalaryDetail.setTaxRate(new BigDecimal("0.00"));
// 速算扣除数速算扣除数跟税率同步
rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("0"));
}
//判断是否外包外包公司员工不做税(月薪50000不上税)
if("外包".equals(sysStaff.getCompanyName())){
// 实发工资 = 税前工资
rzSalaryDetail.setNetPayroll(rzSalaryDetail.getSalaryBeforeTax());
}else {
// 应纳税额 (本年累计已发工资-年度免征额-累计专项扣除-本月专项扣除)
BigDecimal tax = rzSalaryDetail.getTotalWages().subtract(rzSalaryDetail.getSpecialDeduction()).subtract(rzSalaryDetail.getAnnualExemptionAmount());
if(tax.doubleValue() <= 0.0){
rzSalaryDetail.setTaxableIncome(new BigDecimal("0.00"));
}else{
rzSalaryDetail.setTaxableIncome(tax);
}
// 判断税前工资是否大于5000,如果小于则不在计算个税
if (rzSalaryDetail.getSalaryBeforeTax().doubleValue() > 5000.00){
// 本月应缴税额(本月应纳税所得额*税率-速减数-本年累计已预缴个税)
rzSalaryDetail.setTaxPayable(
rzSalaryDetail.getTaxableIncome().multiply(rzSalaryDetail.getTaxRate()).subtract(rzSalaryDetail.getSlowDownTheDeduction()).subtract(sysStaffDetail.getAggregatePersonalIncomeTax()));
if (rzSalaryDetail.getTaxPayable().doubleValue() <= 0) {
rzSalaryDetail.setTaxPayable(new BigDecimal("0.00"));
}
} else {
// 应纳税所得额
rzSalaryDetail.setTaxableIncome(new BigDecimal("0.00"));
rzSalaryDetail.setTaxPayable(new BigDecimal("0.00"));
}
// 实发工资税前工资-本月应缴个人所得税
rzSalaryDetail.setNetPayroll(rzSalaryDetail.getSalaryBeforeTax().subtract(rzSalaryDetail.getTaxPayable()));
// 本年累计已缴税额
rzSalaryDetail.setAggregatePersonalIncomeTax(sysStaffDetail.getAggregatePersonalIncomeTax().add(rzSalaryDetail.getTaxPayable()));
}
rzSalaryDetail.setCreateTime(DateUtils.getNowDate());
rzSalaryDetail.setDelFlag(Constants.DELETE_FLAG_0);
rzSalaryDetail.setCreateBy(SecurityUtils.getUsername());
// 保存工资信息
i = rzSalaryDetailMapper.insertRzSalaryDetail(rzSalaryDetail);
if(i < 1){
return AjaxResult.error();
}
//判断统计月缴费公司和上一次是否一个公司
if(StringUtils.isNull(old_rzSalary) || old_rzSalary.getWbFlag().equals(sysStaff.getCompanyName())){
// 把本年累计个税
sysStaffDetail.setAggregatePersonalIncomeTax(rzSalaryDetail.getAggregatePersonalIncomeTax());
// 把本年累计专项扣除保存到员工信息表中
sysStaffDetail.setSpecialDeduction(sysStaffDetail.getSpecialDeduction().add(rzSalaryDetail.getSpecialDeduction()));
// 把本年累计已发工资保存到员工信息表中
sysStaffDetail.setTotalWages(rzSalaryDetail.getTotalWages());
i = sysStaffDetailMapper.updateSysStaffDetail(sysStaffDetail);
if(i < 1){
return AjaxResult.error();
}
}else{
//删除原来的数据
sysStaffDetail.setDelFlag(Constants.DELETE_FLAG_1);
i = sysStaffDetailMapper.updateSysStaffDetail(sysStaffDetail);
//新建详情数据
// 把本年累计已缴个税保存到员工信息表中
sysStaffDetail.setAggregatePersonalIncomeTax(rzSalaryDetail.getTaxPayable());
// 把本年累计专项扣除保存到员工信息表中
sysStaffDetail.setSpecialDeduction(rzSalaryDetail.getSpecialDeduction());
// 把本年累计已发工资保存到员工信息表中
sysStaffDetail.setTotalWages(rzSalaryDetail.getSalaryBeforeTax());
sysStaffDetail.setId(null);
i = sysStaffDetailMapper.insertSysStaffDetail(sysStaffDetail);
if(i < 1){
return AjaxResult.error();
}
}
}
// //餐费
// RzRestaurantStatistics rzRestaurantStatistics = rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsByUserIdAndDate(sysStaff.getUserId(),rzSalaryDetail.getMonth());
// rzSalaryDetail.setMealFee(rzRestaurantStatistics.getPersonalSumConsumption()); //餐费扣除
// //计算应发工资 合算月工资+学历补助+合同补助+社保补助+工龄工资+全勤奖+加班工资+夜班补助+夜餐补助+其他补助
// BigDecimal sum = rzSalaryDetail.getMonthSalary().add(rzSalaryDetail.getOvertimeSalary()).add(rzSalaryDetail.getNightSubsidies()).add(rzSalaryDetail.getDinnerSubsidies())
// .add(rzSalaryDetail.getFullSubsidies()).add(rzSalaryDetail.getLevelSubsidies()).add(rzSalaryDetail.getContractSubsidies()).add(rzSalaryDetail.getSocialSubsidies())
// .add(rzSalaryDetail.getSenioritySalary()).add(rzSalaryDetail.getSubsidyOrBonus()).subtract(rzSalaryDetail.getAbsenteeismSalary())
// .subtract(rzSalaryDetail.getMealFee()).subtract(rzSalaryDetail.getAbsenteeismSubsidies());
// rzSalaryDetail.setSalary(sum);
// //五险一金
// rzSalaryDetail.setAccumulationFund(sysStaffDetail.getAccumulationFund()); //公积金
// rzSalaryDetail.setUnemploymentInsurance(sysStaffDetail.getUnemploymentInsurance()); //失业保险
// rzSalaryDetail.setMaternityInsurance(sysStaffDetail.getMaternityInsurance()); //生育保险
// rzSalaryDetail.setMedicalInsurance(sysStaffDetail.getMedicalInsurance()); //医疗保险
// rzSalaryDetail.setEndowmentInsurance(sysStaffDetail.getEndowmentInsurance()); //养老保险
// rzSalaryDetail.setEmploymentInjuryInsurance(sysStaffDetail.getEmploymentInjuryInsurance()); //工伤保险
// //税前工资 应发 - 社保
//// rzSalaryDetail.setSalaryBeforeTax(rzSalaryDetail.getSalary().subtract(rzSalaryDetail.getAccumulationFund()).subtract(rzSalaryDetail.getUnemploymentInsurance())
//// .subtract(rzSalaryDetail.getMaternityInsurance()).subtract(rzSalaryDetail.getMedicalInsurance())
//// .subtract(rzSalaryDetail.getEndowmentInsurance()).subtract(rzSalaryDetail.getEmploymentInjuryInsurance()).subtract(salaryDetail.getCountInsurance()));
//
// //获取统计月份
// int curr_month = rzSalaryDetail.getMonth().getMonth();
// //获取工资统计月份,查询上个月的纳税公司 得到年度免征额
// RzSalaryDetail old_rzSalary = rzSalaryDetailMapper.selectRzSalaryDetailByStaffId(sysStaff.getUserId());
// if(curr_month == 12){
// rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00"));
// }else{
// //判断员工为 新入职公司纳税主题改变同一主题超一年的同一主题不超一年但跨年的
// if(StringUtils.isNull(old_rzSalary) || !old_rzSalary.getWbFlag().equals(sysStaff.getCompanyName())
// || (rzSalaryDetail.getMonth().getTime() - old_rzSalary.getMonth().getTime())/1000/60/60/24 > 365
// || (old_rzSalary.getMonth().getMonth() < 12 && old_rzSalary.getMonth().getMonth() > rzSalaryDetail.getMonth().getMonth())){
// rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00"));
// }else{
// rzSalaryDetail.setAnnualExemptionAmount(new BigDecimal("5000.00").add(old_rzSalary.getAnnualExemptionAmount()));
// }
// }
// // 本年累计已发工资本年累计已发工资+本月税前工资
// rzSalaryDetail.setTotalWages(sysStaffDetail.getTotalWages().add(rzSalaryDetail.getSalaryBeforeTax()));
// // 专项附加扣除六项附加扣除额相加
// rzSalaryDetail.setSpecialDeduction(sysStaffDetail.getChildrenEducation().add(sysStaffDetail.getSupportTheOld()).add(sysStaffDetail.getHousingLoans())
// .add(sysStaffDetail.getHousingRents()).add(sysStaffDetail.getAdultEducation()).add(sysStaffDetail.getTreatmentForSeriousDisease()));
//
// // 判断应纳税所得额额度额度不一样税率不一样
// if (rzSalaryDetail.getTaxableIncome().doubleValue() > 0 && rzSalaryDetail.getTaxableIncome().doubleValue() <= 36000l) {
// // 此阶税率为百分之3速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.03"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("0"));
// } else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 36000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 144000L) {
// // 此阶税率为百分之3速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.10"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("2520"));
// } else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 144000L && rzSalaryDetail.getTaxableIncome().doubleValue() <= 300000l) {
// // 此阶税率为百分之3速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.20"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("16920"));
// } else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 300000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 420000l) {
// // 此阶税率为百分之3速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.25"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("31920"));
// } else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 420000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 660000l) {
// // 此阶税率为百分之3速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.30"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("52920"));
// } else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 660000l && rzSalaryDetail.getTaxableIncome().doubleValue() <= 960000l) {
// // 此阶税率为百分之3速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.35"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("85920"));
// } else if (rzSalaryDetail.getTaxableIncome().doubleValue() > 960000l) {
// // 此阶税率为百分之3速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.45"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("181920"));
// } else {
// // 应纳税所得额小于0(免征额+专项扣除>应发工资时)
// // 此阶税率为百分之0速减数为0
// rzSalaryDetail.setTaxRate(new BigDecimal("0.00"));
// // 速算扣除数速算扣除数跟税率同步
// rzSalaryDetail.setSlowDownTheDeduction(new BigDecimal("0"));
// }
//
// //判断是否外包外包公司员工不做税(月薪50000不上税)
// if("外包".equals(sysStaff.getCompanyName())){
// // 实发工资 = 税前工资
// rzSalaryDetail.setNetPayroll(rzSalaryDetail.getSalaryBeforeTax());
// }else {
// // 应纳税额 (本年累计已发工资-年度免征额-累计专项扣除-本月专项扣除)
// BigDecimal tax = rzSalaryDetail.getTotalWages().subtract(rzSalaryDetail.getSpecialDeduction()).subtract(rzSalaryDetail.getAnnualExemptionAmount());
// if(tax.doubleValue() <= 0.0){
// rzSalaryDetail.setTaxableIncome(new BigDecimal("0.00"));
// }else{
// rzSalaryDetail.setTaxableIncome(tax);
// }
// // 判断税前工资是否大于5000,如果小于则不在计算个税
// if (rzSalaryDetail.getSalaryBeforeTax().doubleValue() > 5000.00){
// // 本月应缴税额(本月应纳税所得额*税率-速减数-本年累计已预缴个税)
// rzSalaryDetail.setTaxPayable(
// rzSalaryDetail.getTaxableIncome().multiply(rzSalaryDetail.getTaxRate()).subtract(rzSalaryDetail.getSlowDownTheDeduction()).subtract(sysStaffDetail.getAggregatePersonalIncomeTax()));
// if (rzSalaryDetail.getTaxPayable().doubleValue() <= 0) {
// rzSalaryDetail.setTaxPayable(new BigDecimal("0.00"));
// }
// } else {
// // 应纳税所得额
// rzSalaryDetail.setTaxableIncome(new BigDecimal("0.00"));
// rzSalaryDetail.setTaxPayable(new BigDecimal("0.00"));
// }
// // 实发工资税前工资-本月应缴个人所得税
// rzSalaryDetail.setNetPayroll(rzSalaryDetail.getSalaryBeforeTax().subtract(rzSalaryDetail.getTaxPayable()));
// // 本年累计已缴税额
// rzSalaryDetail.setAggregatePersonalIncomeTax(sysStaffDetail.getAggregatePersonalIncomeTax().add(rzSalaryDetail.getTaxPayable()));
// }
// rzSalaryDetail.setCreateTime(DateUtils.getNowDate());
// rzSalaryDetail.setDelFlag(Constants.DELETE_FLAG_0);
// rzSalaryDetail.setCreateBy(SecurityUtils.getUsername());
// // 保存工资信息
// i = rzSalaryDetailMapper.insertRzSalaryDetail(rzSalaryDetail);
// if(i < 1){
// return AjaxResult.error();
// }
// //判断统计月缴费公司和上一次是否一个公司
// if(StringUtils.isNull(old_rzSalary) || old_rzSalary.getWbFlag().equals(sysStaff.getCompanyName())){
// // 把本年累计个税
// sysStaffDetail.setAggregatePersonalIncomeTax(rzSalaryDetail.getAggregatePersonalIncomeTax());
// // 把本年累计专项扣除保存到员工信息表中
// sysStaffDetail.setSpecialDeduction(sysStaffDetail.getSpecialDeduction().add(rzSalaryDetail.getSpecialDeduction()));
// // 把本年累计已发工资保存到员工信息表中
// sysStaffDetail.setTotalWages(rzSalaryDetail.getTotalWages());
// i = sysStaffDetailMapper.updateSysStaffDetail(sysStaffDetail);
// if(i < 1){
// return AjaxResult.error();
// }
// }else{
// //删除原来的数据
// sysStaffDetail.setDelFlag(Constants.DELETE_FLAG_1);
// i = sysStaffDetailMapper.updateSysStaffDetail(sysStaffDetail);
// //新建详情数据
// // 把本年累计已缴个税保存到员工信息表中
// sysStaffDetail.setAggregatePersonalIncomeTax(rzSalaryDetail.getTaxPayable());
// // 把本年累计专项扣除保存到员工信息表中
// sysStaffDetail.setSpecialDeduction(rzSalaryDetail.getSpecialDeduction());
// // 把本年累计已发工资保存到员工信息表中
// sysStaffDetail.setTotalWages(rzSalaryDetail.getSalaryBeforeTax());
// sysStaffDetail.setId(null);
// i = sysStaffDetailMapper.insertSysStaffDetail(sysStaffDetail);
// if(i < 1){
// return AjaxResult.error();
// }
// }
// }
return AjaxResult.success();
}
// public void autoCalculationOverTimeWorkSalary(RzSalaryDetail rzSalaryDetail, RzAttendanceStatistical attendanceStatistical, Boolean isOverTime){
// if(!isOverTime){
// rzSalaryDetail.setOvertimeSalary(new BigDecimal(0));
// }else{
// BigDecimal salary = rzSalaryDetail.getJobSalary().add(rzSalaryDetail.getBasicSalary());
// BigDecimal hourlyWage = salary.divide(new BigDecimal(ParamUtils.getMonthWorkDayNum(DateUtils.getMonth(rzSalaryDetail.getMonth()))),2,BigDecimal.ROUND_HALF_UP);
// //计算加班工资
// rzSalaryDetail.setOvertimeSalary(attendanceStatistical.getOverTimeHours().multiply(hourlyWage));
// }
//
// }
/**
* 计算员工的工资信息
* @param sysStaff 员工信息
@ -356,7 +418,21 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl<RzSalaryDetailMapper,
//获取当前月
Integer monthNum = calendar.getActualMaximum(Calendar.MONTH);
//根据当前月获取字典信息
String wordDays = sysDictDataService.selectDictValue("sys_work_days", monthNum+"");
// String wordDays = sysDictDataService.selectDictValue("sys_work_days", monthNum+"");
//如果没有配置工作时长, 则默认为26天工作日
// if(StringUtils.isEmpty(wordDays)){
// wordDays = "26";
// }
// //计算当月出勤时长
// Integer workHours = Integer.valueOf(wordDays)*8;
//计算是否全勤
// rzHolidayMapper.selectList();
//获取假期信息
//判断假期和特殊上班时间
@ -366,7 +442,7 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl<RzSalaryDetailMapper,
// //获取全年天数 - 节假日天数
//获取全年天数 - 节假日天数
// int days = calendar.getActualMaximum(Calendar.DAY_OF_YEAR);
// SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM");
// SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd");
@ -393,7 +469,7 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl<RzSalaryDetailMapper,
// BigDecimal bfb = new BigDecimal("0.00");
// //获取考勤统计
// RzAttendanceStatistical rzAttendanceStatistical = rzAttendanceStatisticalMapper.getRzAttendanceStatisticalByDateAndName(sysStaff.getUserId(), monthNum);
// //判断入职日期社保缴纳日期以前入职计算补助扣除比例
//// //判断入职日期社保缴纳日期以前入职计算补助扣除比例
// if(sysStaff.getEmploymentDate().before(date)){
// //计算请假百分比
// BigDecimal b = rzAttendanceStatistical.getAbsenteeism().divide(new BigDecimal("4"));
@ -402,9 +478,9 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl<RzSalaryDetailMapper,
// }else{
// sysStaffDetail.setAbsenteeismSubsidies(new BigDecimal("1.00"));
// }
//// sysStaffDetail.setNightShiftSubsidies(sysStaffDetail.getNightShiftSubsidies().multiply(new BigDecimal(rzAttendanceStatistical.getNightNumber())));
//// sysStaffDetail.setDinnerSubsidies(sysStaffDetail.getDinnerSubsidies().multiply(new BigDecimal(rzAttendanceStatistical.getNightNumber())));
// //是否打卡
// sysStaffDetail.setNightShiftSubsidies(sysStaffDetail.getNightShiftSubsidies().multiply(new BigDecimal(rzAttendanceStatistical.getNightNumber())));
// sysStaffDetail.setDinnerSubsidies(sysStaffDetail.getDinnerSubsidies().multiply(new BigDecimal(rzAttendanceStatistical.getNightNumber())));
//// //是否打卡
// if("".equals(sysStaff.getClockIn())){
// return sysStaffDetail;
// }

View File

@ -117,6 +117,7 @@ public class SecurityConfig
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
.antMatchers("/websocket/**").permitAll()
.antMatchers("/test/**").permitAll()
.antMatchers("/api/v1/verify_user").permitAll()
.antMatchers("/api/v1/record/face").permitAll()
.antMatchers("/api/v2/verify_user_yt").permitAll()

View File

@ -31,5 +31,7 @@ public class RzHoliday extends BaseEntity
private Integer year;
/** 假期信息, 采用json格式存储 一个日期对应一个名称 */
private String holidayInfo;
/** 工作日天数信息 采用json格式存储 每个月份对应一个天数 */
private String workInfo;
}

View File

@ -75,4 +75,13 @@ public interface RzLeaveDetailMapper extends BaseMapper<RzLeaveDetail>
List<Map<String,Object>> getLeaveHour(@Param("date") Date date);
/***
* 根据类型查询数据
* @param userId
* @param date
* @param type
* @return
*/
Long selectLeaveHourByUserIdAndDateAndType(@Param("userId") Long userId,@Param("date") Date date, @Param("type") Long type);
}

View File

@ -19,8 +19,10 @@ import javax.annotation.Resource;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 假期管理Service业务层处理
@ -41,6 +43,7 @@ public class RzHolidayServiceImpl extends ServiceImpl<RzHolidayMapper, RzHoliday
rzHoliday = new RzHoliday();
rzHoliday.setYear(year);
rzHoliday.setHolidayInfo(JSONObject.toJSONString(getAllYearRoundSunday(year)));
rzHoliday.setWorkInfo(workMonthDayNum(rzHoliday));
save(rzHoliday);
}
return rzHoliday;
@ -76,6 +79,25 @@ public class RzHolidayServiceImpl extends ServiceImpl<RzHolidayMapper, RzHoliday
holidaysMaps.remove(holidayParamVo.getHolidayDate());
}
rzHoliday.setHolidayInfo(JSONObject.toJSONString(holidaysMaps));
rzHoliday.setWorkInfo(workMonthDayNum(rzHoliday));
return updateById(rzHoliday);
}
public String workMonthDayNum(RzHoliday holiday){
Map<String, Integer> holidaysMaps = JSONObject.parseObject(holiday.getHolidayInfo(), Map.class);
List<String> holidays = holidaysMaps.keySet().stream().collect(Collectors.toList());
Map<String, Integer> sundays = Collections.emptyMap();
Calendar c = Calendar.getInstance();
for (int i = 0; i < 12; i++) {
c.set(holiday.getYear(),i,1);
List<String> monthDays = DateUtils.getMonthAndDays(c.getTime());
List<String> monthHolidays = Collections.findDuplicatesList(Collections.asList(monthDays.toArray(new String[monthDays.size()])), holidays);
sundays.put(String.valueOf(c.get(Calendar.MONTH)+1), monthDays.size()-monthHolidays.size());
}
return JSONObject.toJSONString(sundays);
}
}

View File

@ -349,7 +349,7 @@ public class RzLeaveDetailServiceImpl extends ServiceImpl<RzLeaveDetailMapper, R
}
//计算结束时间和请假时长 此处使用beginDate 而不使用rzLeaveDetail.getLeaveStartTime() 的原因是, 上面获取全部请假日期的时候, 已经处理过时间, 只需要增加公休,法休时间就可以了
rzLeaveDetail.setLeaveEndTime(DateUtils.addDays(beginDate, endDays));
rzLeaveDetail.setLeaveHour(new BigDecimal(sysDictData.getDictValue()).multiply(new BigDecimal(8)).intValue());
rzLeaveDetail.setLeaveHour(new BigDecimal(sysDictData.getDictValue()).multiply(Constants.DAY_WORK_HOUR).intValue());
}else{
//不需要计算, 过滤节假日啥的, 只过滤周末就好了
if(rzLeaveDetail.getLeaveStartTime() == null || rzLeaveDetail.getLeaveEndTime() == null){
@ -378,7 +378,7 @@ public class RzLeaveDetailServiceImpl extends ServiceImpl<RzLeaveDetailMapper, R
endDays = new BigDecimal(endDays).add(new BigDecimal(holidays.size())).intValue();
}
//计算结束时间和请假时长 此处使用beginDate 而不使用rzLeaveDetail.getLeaveStartTime() 的原因是, 上面获取全部请假日期的时候, 已经处理过时间, 只需要增加公休,法休时间就可以了
rzLeaveDetail.setLeaveHour(new BigDecimal(holidayDates.size()).subtract(new BigDecimal(endDays)).multiply(new BigDecimal(8)).intValue());
rzLeaveDetail.setLeaveHour(new BigDecimal(holidayDates.size()).subtract(new BigDecimal(endDays)).multiply(Constants.DAY_WORK_HOUR).intValue());
}
return rzLeaveDetail;

View File

@ -2,7 +2,11 @@ package com.evo.restaurant.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.evo.common.annotation.Excel;
@ -14,6 +18,7 @@ import com.evo.common.core.domain.BaseEntity;
* @author evo
* @date 2024-11-21
*/
@Data
public class RzRestaurantStatistics extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -97,206 +102,9 @@ public class RzRestaurantStatistics extends BaseEntity
private String remarks;
/** 删除标记 */
@TableField(fill = FieldFill.INSERT)
private String delFlag;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setStaffId(Long staffId)
{
this.staffId = staffId;
}
public Long getStaffId()
{
return staffId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getDeptId()
{
return deptId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setMonth(Date month)
{
this.month = month;
}
public Date getMonth()
{
return month;
}
public void setBreakfastExpend(BigDecimal breakfastExpend)
{
this.breakfastExpend = breakfastExpend;
}
public BigDecimal getBreakfastExpend()
{
return breakfastExpend;
}
public void setBreakfastNumber(Long breakfastNumber)
{
this.breakfastNumber = breakfastNumber;
}
public Long getBreakfastNumber()
{
return breakfastNumber;
}
public void setBreakfastPreSumExpend(BigDecimal breakfastPreSumExpend)
{
this.breakfastPreSumExpend = breakfastPreSumExpend;
}
public BigDecimal getBreakfastPreSumExpend()
{
return breakfastPreSumExpend;
}
public void setBreakfastSumExpend(BigDecimal breakfastSumExpend)
{
this.breakfastSumExpend = breakfastSumExpend;
}
public BigDecimal getBreakfastSumExpend()
{
return breakfastSumExpend;
}
public void setLunchExpend(BigDecimal lunchExpend)
{
this.lunchExpend = lunchExpend;
}
public BigDecimal getLunchExpend()
{
return lunchExpend;
}
public void setLunchNumber(Long lunchNumber)
{
this.lunchNumber = lunchNumber;
}
public Long getLunchNumber()
{
return lunchNumber;
}
public void setLunchPreSumExpend(BigDecimal lunchPreSumExpend)
{
this.lunchPreSumExpend = lunchPreSumExpend;
}
public BigDecimal getLunchPreSumExpend()
{
return lunchPreSumExpend;
}
public void setLunchSumExpend(BigDecimal lunchSumExpend)
{
this.lunchSumExpend = lunchSumExpend;
}
public BigDecimal getLunchSumExpend()
{
return lunchSumExpend;
}
public void setSupperExpend(BigDecimal supperExpend)
{
this.supperExpend = supperExpend;
}
public BigDecimal getSupperExpend()
{
return supperExpend;
}
public void setSupperNumber(Long supperNumber)
{
this.supperNumber = supperNumber;
}
public Long getSupperNumber()
{
return supperNumber;
}
public void setSupperPreSumExpend(BigDecimal supperPreSumExpend)
{
this.supperPreSumExpend = supperPreSumExpend;
}
public BigDecimal getSupperPreSumExpend()
{
return supperPreSumExpend;
}
public void setSupperSumExpend(BigDecimal supperSumExpend)
{
this.supperSumExpend = supperSumExpend;
}
public BigDecimal getSupperSumExpend()
{
return supperSumExpend;
}
public void setPersonalSumConsumption(BigDecimal personalSumConsumption)
{
this.personalSumConsumption = personalSumConsumption;
}
public BigDecimal getPersonalSumConsumption()
{
return personalSumConsumption;
}
public void setSumConsumption(BigDecimal sumConsumption)
{
this.sumConsumption = sumConsumption;
}
public BigDecimal getSumConsumption()
{
return sumConsumption;
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
public String getRemarks()
{
return remarks;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -1,8 +1,11 @@
package com.evo.restaurant.mapper;
import com.evo.restaurant.domain.RzRestaurantDetail;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 餐饮详情Mapper接口
@ -37,4 +40,5 @@ public interface RzRestaurantDetailMapper
public int insertRzRestaurantDetail(RzRestaurantDetail rzRestaurantDetail);
public List<Map<String, Object>> selectRzRestaurantDetailListMap(@Param("month") Date month);
}

View File

@ -1,9 +1,12 @@
package com.evo.restaurant.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evo.restaurant.domain.RzRestaurantStatistics;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 餐饮统计Mapper接口
@ -11,7 +14,7 @@ import java.util.List;
* @author chenyj
* @date 2024-11-18
*/
public interface RzRestaurantStatisticsMapper
public interface RzRestaurantStatisticsMapper extends BaseMapper<RzRestaurantStatistics>
{
/**
* 查询餐饮统计
@ -53,6 +56,8 @@ public interface RzRestaurantStatisticsMapper
*/
public RzRestaurantStatistics selectRzRestaurantStatisticsByUserIdAndDate(@Param("staffId") Long staffId,@Param("date") Date date);
public List<Map<String, Object>> selectRzRestaurantStatisticsDate(@Param("date") Date date);
public List<RzRestaurantStatistics> selectRzRestaurantStatisticsByDate(Date date);
}

View File

@ -1,9 +1,13 @@
package com.evo.restaurant.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.AjaxResult;
import com.evo.common.core.domain.entity.SysDept;
import com.evo.common.core.domain.entity.SysDictData;
import com.evo.common.utils.Collections;
import com.evo.common.utils.DataUtils;
import com.evo.common.utils.DateUtils;
import com.evo.common.utils.StringUtils;
import com.evo.restaurant.domain.RzRestaurantDetail;
@ -20,6 +24,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 餐饮统计Service业务层处理
@ -28,10 +34,8 @@ import java.util.List;
* @date 2024-09-18
*/
@Service
public class RzRestaurantStatisticsServiceImpl implements IRzRestaurantStatisticsService
public class RzRestaurantStatisticsServiceImpl extends ServiceImpl<RzRestaurantStatisticsMapper, RzRestaurantStatistics> implements IRzRestaurantStatisticsService
{
@Resource
private RzRestaurantStatisticsMapper rzRestaurantStatisticsMapper;
@Resource
private SysDeptMapper deptMapper; //部门信息
@Resource
@ -53,7 +57,7 @@ public class RzRestaurantStatisticsServiceImpl implements IRzRestaurantStatistic
@Override
public RzRestaurantStatistics selectRzRestaurantStatisticsById(Long id)
{
return rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsById(id);
return getBaseMapper().selectRzRestaurantStatisticsById(id);
}
/**
* 查询餐饮统计列表
@ -64,20 +68,10 @@ public class RzRestaurantStatisticsServiceImpl implements IRzRestaurantStatistic
@Override
public List<RzRestaurantStatistics> selectRzRestaurantStatisticsList(RzRestaurantStatistics rzRestaurantStatistics)
{
List<RzRestaurantStatistics> res_list = rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsList(rzRestaurantStatistics);
try{
List<RzRestaurantStatistics> res_list = getBaseMapper().selectRzRestaurantStatisticsList(rzRestaurantStatistics);
Map<Long, String> deptNameMap = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()).stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
for (RzRestaurantStatistics restaurantStatistics : res_list) {
SysDept sysDept = deptMapper.selectDeptById(restaurantStatistics.getDeptId());
if (sysDept !=null){
restaurantStatistics.setCompanyName(deptMapper.selectDeptById(restaurantStatistics.getDeptId()).getDeptName());
}else {
restaurantStatistics.setCompanyName("1");
}
}
} catch (Exception e) {
throw new RuntimeException(e);
restaurantStatistics.setCompanyName(DataUtils.findDefaultValue(deptNameMap.get(restaurantStatistics.getDeptId()), "实习生"));
}
return res_list;
}
@ -91,7 +85,6 @@ public class RzRestaurantStatisticsServiceImpl implements IRzRestaurantStatistic
//获取在职员工
List<SysStaff> st_list = sysStaffMapper.selectSysStaffListAll();
//查询员工的详细信息
List<SysStaffDetail> dt_list = sysStaffDetailMapper.selectSysStaffDetailList(null);
RzRestaurantStatistics rzRestaurantStatistics = null;
for (SysStaff sysStaff : st_list) {
rzRestaurantStatistics = new RzRestaurantStatistics();
@ -100,17 +93,7 @@ public class RzRestaurantStatisticsServiceImpl implements IRzRestaurantStatistic
rzRestaurantStatistics.setName(sysStaff.getName());
rzRestaurantStatistics.setMonth(DateUtils.getNowDate());
//查询早午晚三餐消费
// for (SysStaffDetail sysStaffDetail : dt_list) {
// if(sysStaff.getUserId() == sysStaffDetail.getStaffId()){
// rzRestaurantStatistics.setBreakfastExpend(sysStaffDetail.getBreakfastExpend());
// rzRestaurantStatistics.setLunchExpend(sysStaffDetail.getLunchExpend());
// rzRestaurantStatistics.setSupperExpend(sysStaffDetail.getSupperExpend());
// }
// }
rzRestaurantStatistics.setCreateTime(DateUtils.getNowDate());
rzRestaurantStatistics.setDelFlag(Constants.DELETE_FLAG_0);
rzRestaurantStatistics.setCreateBy("admin");
rzRestaurantStatisticsMapper.insertRzRestaurantStatistics(rzRestaurantStatistics);
getBaseMapper().insert(rzRestaurantStatistics);
}
//获取只吃饭不打卡的职员工
List<RzRestaurantImages> img_list = rzRestaurantImagesMapper.selectRzRestaurantImagesList(null);
@ -119,13 +102,12 @@ public class RzRestaurantStatisticsServiceImpl implements IRzRestaurantStatistic
rzRestaurantStatistics.setStaffId(rzRestaurantImages.getId());
rzRestaurantStatistics.setName(rzRestaurantImages.getName());
rzRestaurantStatistics.setMonth(DateUtils.getNowDate());
rzRestaurantStatistics.setCreateTime(DateUtils.getNowDate());
rzRestaurantStatistics.setDelFlag(Constants.DELETE_FLAG_0);
rzRestaurantStatistics.setCreateBy("admin");
rzRestaurantStatisticsMapper.insertRzRestaurantStatistics(rzRestaurantStatistics);
getBaseMapper().insertRzRestaurantStatistics(rzRestaurantStatistics);
}
}
/**
* 校正数据
* @return
@ -136,64 +118,65 @@ public class RzRestaurantStatisticsServiceImpl implements IRzRestaurantStatistic
return AjaxResult.error("请输入校正日期!!");
}
//根据日期查询统计日期内的统计信息
List<RzRestaurantStatistics> rt_list = rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsList(rzRestaurantStatistics);
List<RzRestaurantStatistics> rt_list = getBaseMapper().selectRzRestaurantStatisticsList(rzRestaurantStatistics);
//根据月份统计打卡信息
RzRestaurantDetail rzRestaurantDetail = new RzRestaurantDetail();
rzRestaurantDetail.setMonth(rzRestaurantStatistics.getMonth());
List<RzRestaurantDetail> rd_list = rzRestaurantDetailMapper.selectRzRestaurantDetailList(rzRestaurantDetail);
/***
* 住宿233
* 不住宿月薪433
* 不住宿日薪438
*/
Map<String, List<Map<String, Object>>> map = rzRestaurantDetailMapper.selectRzRestaurantDetailListMap(rzRestaurantStatistics.getMonth()).stream().collect(Collectors.groupingBy(d->String.valueOf(d.get("staffId"))));
//查询消费情况
List<SysDictData> dic_list = sysDictDataMapper.selectDictDataByType(Constants.SYS_RESTAUTANT);
Map<Long,String> dicMap = sysDictDataMapper.selectDictDataByType(Constants.SYS_RESTAUTANT).stream().collect(Collectors.toMap(SysDictData::getDictCode, SysDictData::getDictValue));
//优先检查是否为住宿
Map<Long, Boolean> zsMap = sysStaffMapper.selectSysStaffListAll().stream().collect(Collectors.toMap(SysStaff::getUserId, d->"".equals(d.getZsFlag())));
//然后在检查是否为日薪
Map<Long, Boolean> rxMap = sysStaffDetailMapper.selectList(new LambdaQueryWrapper<SysStaffDetail>().in(SysStaffDetail::getStaffId, zsMap.keySet().toArray())).stream().collect(Collectors.toMap(SysStaffDetail::getStaffId, d->d.getDailyWage() != null && d.getDailyWage().intValue() > 0));
//循环统计信息
for (RzRestaurantStatistics restaurantStatistics : rt_list) {
//记录早午晚三餐次数
Long breakfast = 0l;
Long lunch = 0l;
Long supper = 0l;
//循环打卡详情
for (RzRestaurantDetail restaurantDetail : rd_list) {
if(restaurantStatistics.getStaffId() == restaurantDetail.getStaffId()){
if("早餐".equals(restaurantDetail.getSign())){
breakfast += 1;
continue;
}
if("午餐".equals(restaurantDetail.getSign())){
lunch += 1;
continue;
}
if("晚餐".equals(restaurantDetail.getSign())){
supper += 1;
Map<String, String> mapDetail = DataUtils.findDefaultValue(map.get(String.valueOf(restaurantStatistics.getStaffId())), Collections.asList(Collections.asMap("type","早餐","num","0","type","午餐","num","0","type","晚餐","num","0"))).stream().collect(Collectors.toMap(d->String.valueOf(d.get("type")), d->String.valueOf(d.get("num"))));
restaurantStatistics.setBreakfastNumber(Long.valueOf(DataUtils.findDefaultValue(mapDetail.get("早餐"),"0")));
restaurantStatistics.setLunchNumber(Long.valueOf(DataUtils.findDefaultValue(mapDetail.get("午餐"),"0")));
restaurantStatistics.setSupperNumber(Long.valueOf(DataUtils.findDefaultValue(mapDetail.get("晚餐"),"0")));
//记录午餐单价
restaurantStatistics.setLunchExpend(new BigDecimal(dicMap.get(Constants.gr_wc_code)));
//午餐消费
restaurantStatistics.setBreakfastExpend(new BigDecimal(dicMap.get(Constants.gr_zc_code)));
//晚餐
restaurantStatistics.setSupperExpend( new BigDecimal(dicMap.get(Constants.gr_wcc_code)));
//如果不是住宿人员
if(!DataUtils.findDefaultValue(zsMap.get(restaurantStatistics.getStaffId()),false) ){
restaurantStatistics.setBreakfastExpend(new BigDecimal(dicMap.get(Constants.zc_code)));
//没有这个人员的详情, 或者是不住宿日薪
if(DataUtils.findDefaultValue(rxMap.get(restaurantStatistics.getStaffId()),true)){
restaurantStatistics.setSupperExpend( new BigDecimal(dicMap.get(Constants.wcc_code)));
}
}
}
restaurantStatistics.setBreakfastNumber(breakfast);
restaurantStatistics.setLunchNumber(lunch);
restaurantStatistics.setSupperNumber(supper);
//计算费用
restaurantStatistics.setBreakfastPreSumExpend(restaurantStatistics.getBreakfastExpend().multiply(new BigDecimal(restaurantStatistics.getBreakfastNumber())));
restaurantStatistics.setLunchPreSumExpend(restaurantStatistics.getLunchExpend().multiply(new BigDecimal(restaurantStatistics.getLunchNumber())));
restaurantStatistics.setSupperPreSumExpend(restaurantStatistics.getSupperExpend().multiply(new BigDecimal(restaurantStatistics.getSupperNumber())));
for (SysDictData sysDictData : dic_list) {
if(sysDictData.getDictLabel().indexOf("早餐") != -1){
restaurantStatistics.setBreakfastSumExpend(new BigDecimal(sysDictData.getDictValue()).multiply(new BigDecimal(restaurantStatistics.getBreakfastNumber())));
}
if(sysDictData.getDictLabel().indexOf("午餐") != -1){
restaurantStatistics.setLunchSumExpend(new BigDecimal(sysDictData.getDictValue()).multiply(new BigDecimal(restaurantStatistics.getLunchNumber())));
}
if(sysDictData.getDictLabel().indexOf("晚餐") != -1){
restaurantStatistics.setSupperSumExpend(new BigDecimal(sysDictData.getDictValue()).multiply(new BigDecimal(restaurantStatistics.getSupperNumber())));
}
}
restaurantStatistics.setPersonalSumConsumption(restaurantStatistics.getBreakfastPreSumExpend().add(restaurantStatistics.getLunchPreSumExpend())
.add(restaurantStatistics.getSupperPreSumExpend()));
restaurantStatistics.setSumConsumption(restaurantStatistics.getBreakfastSumExpend().add(restaurantStatistics.getLunchSumExpend())
.add(restaurantStatistics.getSupperSumExpend()));
rzRestaurantStatisticsMapper.updateRzRestaurantStatistics(restaurantStatistics);
restaurantStatistics.setPersonalSumConsumption(restaurantStatistics.getBreakfastPreSumExpend().add(restaurantStatistics.getLunchPreSumExpend()).add(restaurantStatistics.getSupperPreSumExpend()));
//计算总消费
restaurantStatistics.setBreakfastSumExpend(new BigDecimal(dicMap.get(Constants.zc_code)).multiply(new BigDecimal(restaurantStatistics.getBreakfastNumber())));
restaurantStatistics.setLunchSumExpend(new BigDecimal(dicMap.get(Constants.wc_code)).multiply(new BigDecimal(restaurantStatistics.getLunchNumber())));
restaurantStatistics.setSupperSumExpend(new BigDecimal(dicMap.get(Constants.wcc_code)).multiply(new BigDecimal(restaurantStatistics.getSupperNumber())));
restaurantStatistics.setSumConsumption(restaurantStatistics.getBreakfastSumExpend().add(restaurantStatistics.getLunchSumExpend()).add(restaurantStatistics.getSupperSumExpend()));
getBaseMapper().updateRzRestaurantStatistics(restaurantStatistics);
}
return AjaxResult.success();
}
@Override
public List<RzRestaurantStatistics> selectRzRestaurantStatisticsListBySxs(RzRestaurantStatistics rzRestaurantStatistics){
return rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsByDate(rzRestaurantStatistics.getMonth());
return getBaseMapper().selectRzRestaurantStatisticsByDate(rzRestaurantStatistics.getMonth());
}
}

View File

@ -2,8 +2,11 @@ package com.evo.system.domain;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.annotation.TableField;
import com.evo.common.utils.Collections;
import com.evo.common.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -197,4 +200,11 @@ public class SysStaff extends BaseEntity
private String subsidys;
@TableField(exist = false)
private List<Long> subsidyList;
public List<Long> getSubsidyList() {
if(StringUtils.isNotEmpty(subsidys)){
subsidyList = Collections.asList(subsidys.split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
}
return subsidyList;
}
}

View File

@ -3,11 +3,13 @@ package com.evo.system.utils;
import com.alibaba.fastjson2.util.BeanUtils;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.entity.SysDictData;
import com.evo.common.utils.Collections;
import com.evo.common.utils.DateUtils;
import com.evo.common.utils.spring.SpringUtils;
import com.evo.personnelMatters.domain.RzSubsidy;
import com.evo.personnelMatters.domain.RzSubsidyInfo;
import com.evo.personnelMatters.mapper.RzSubsidyMapper;
import com.evo.personnelMatters.service.IRzSubsidyInfoService;
import com.evo.system.domain.SysStaff;
import com.evo.system.domain.SysStaffDetail;
import com.evo.system.mapper.SysDictDataMapper;
@ -35,12 +37,16 @@ public class SubsidyCalculationUtils {
public static final String ht = "12";
public static final String gl = "14";
public static final String xnh = "13";
public static final String yc = "11";
public static SysStaffDetail subsidyCalculation(SysStaff staff, SysStaffDetail staffDetail, List<RzSubsidyInfo> subsidyInfoList){
//正式员工并且有补助信息
if(Constants.JOB_STATIS_1.equals(staff.getStatus())){
if(Collections.isEmpty(subsidyInfoList)){
subsidyInfoList = SpringUtils.getBean(IRzSubsidyInfoService.class).list();
}
if(StringUtils.isNotEmpty(staff.getSubsidys())){
Map<Long, RzSubsidyInfo> map = subsidyInfoList.stream().collect(Collectors.toMap(RzSubsidyInfo::getId, d->d, (k1, K2)->k1));
Boolean isAdd = true;
@ -59,6 +65,8 @@ public class SubsidyCalculationUtils {
value = value.multiply(new BigDecimal(year));
}else if(xnh.equals(subsidyId)){
isAdd = "新农合".equals(staff.getSocialType()) && ("".equals(staff.getSocialSubsidy()) || "享有".equals(staff.getSocialSubsidy()));
}else if(yc.equals(subsidyId)){
isAdd = "".equals(staff.getZsFlag());
}
if(isAdd) staffDetail.getExtendeds().put(key, value);
}

View File

@ -5,6 +5,7 @@ import com.evo.attendance.service.IRzAttendanceService;
import com.evo.attendance.service.IRzAttendanceStatisticalService;
import com.evo.common.utils.DateUtils;
import com.evo.equipment.service.IEqSnDetailService;
import com.evo.restaurant.domain.RzRestaurantStatistics;
import com.evo.restaurant.service.IRzRestaurantStatisticsService;
import com.evo.system.service.ISysStaffService;
import org.springframework.scheduling.annotation.Scheduled;
@ -33,12 +34,25 @@ public class TaskController {
};
/**
* 每月1号 100 自动生成餐饮统计信息
* 同步校正上月的考勤数据
*/
@Scheduled(cron = "0 0 1 1 * ?")
public void insertRzRestaurantStatistics(){
rzRestaurantStatisticsService.insertRzRestaurantStatistics();
}
/**
* 每月1号 120 自动校正餐饮数据
* 同步校正上月的考勤数据
*/
@Scheduled(cron = "0 20 1 1 * ?")
public void autoCorrect(){
//因为是计算上个月, 所以需要当前时间-1月
RzRestaurantStatistics rzRestaurantStatistics = new RzRestaurantStatistics();
rzRestaurantStatistics.setMonth(DateUtils.addMonths(new Date(), -1));
rzRestaurantStatisticsService.correct(rzRestaurantStatistics);
}
/**
* 每天凌晨3点核算前一天的考勤情况
*/

View File

@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectRzSalaryDetailVo">
select id, staff_id, name, month, wb_flag, dept_id,month_salary, basic_salary, job_salary, daily_wage, hours_salary, overtime_salary, level_subsidies, contract_subsidies, seniority_salary, social_subsidies, full_subsidies, night_subsidies, dinner_subsidies, subsidy_or_bonus, absenteeism_salary, absenteeism_subsidies, meal_fee, deductions, salary, pay_insurance, endowment_insurance, medical_insurance, employment_injury_insurance, maternity_insurance, unemployment_insurance, accumulation_fund, salary_before_tax, total_wages, annual_exemption_amount, special_deduction, taxable_income, tax_rate, slow_down_the_deduction, aggregate_personal_income_tax, aggregate_tax, tax_payable, net_payroll,sales_commissions, remarks, del_flag, create_by, create_time, update_by, update_time from rz_salary_detail
select id, staff_id, name, month, wb_flag, dept_id,month_salary, basic_salary, job_salary, daily_wage, hours_salary, overtime_salary, level_subsidies, contract_subsidies, seniority_salary, social_subsidies, full_subsidies, night_subsidies, dinner_subsidies, subsidy_or_bonus, absenteeism_salary, absenteeism_subsidies, meal_fee, deductions, salary, pay_insurance, endowment_insurance, medical_insurance, employment_injury_insurance, maternity_insurance, unemployment_insurance, accumulation_fund, salary_before_tax, total_wages, annual_exemption_amount, special_deduction, taxable_income, tax_rate, slow_down_the_deduction, aggregate_personal_income_tax, aggregate_tax, tax_payable, net_payroll, remarks, del_flag, create_by, create_time, update_by, update_time from rz_salary_detail
</sql>
<select id="selectRzSalaryDetailList" parameterType="RzSalaryDetail" resultMap="RzSalaryDetailResult">

View File

@ -114,8 +114,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getLeaveHour" resultType="java.util.Map">
SELECT l.user_id as staffId, sum(JSON_EXTRACT(ld.extension,CONCAT('$.',CONCAT("hours",DATE_FORMAT(#{date},'%m'))))) as leaveHour
FROM `rz_leave_detail` ld left join rz_leave l on l.id = ld.leave_id
where JSON_EXTRACT(extension,CONCAT('$.',CONCAT("month",DATE_FORMAT(#{date},'%m'))))=DATE_FORMAT(#{date},'%m-%d')
where JSON_EXTRACT(extension,CONCAT('$.',CONCAT("month",DATE_FORMAT(#{date},'%m'))))=DATE_FORMAT(#{date},'%Y-%m')
GROUP BY l.user_id
</select>
<select id="selectLeaveHourByUserIdAndDateAndType" resultType="java.lang.Long">
SELECT ifnull(sum(JSON_EXTRACT(ld.extension,CONCAT('$.',CONCAT("hours",DATE_FORMAT(#{date},'%m'))))), 0)
FROM `rz_leave_detail` ld left join rz_leave l on l.id = ld.leave_id
where ld.del_flag = '0' and ld.type = #{type} and l.user_id=#{userId} and JSON_EXTRACT(extension,CONCAT('$.',CONCAT("month",DATE_FORMAT(#{date},'%m'))))=DATE_FORMAT(#{date},'%Y-%m')
</select>
</mapper>

View File

@ -74,4 +74,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<select id="selectRzRestaurantDetailListMap" resultType="java.util.Map">
select count(id) as num,staff_id as staffId,sign as type from rz_restaurant_detail where del_flag = '0' and DATE_FORMAT( date, '%Y%m' ) = DATE_FORMAT( #{month} , '%Y%m' )
GROUP BY staff_id,sign
</select>
</mapper>

View File

@ -153,4 +153,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where staff_id > 10000 and del_flag = '0' and DATE_FORMAT( month, '%Y%m' ) = DATE_FORMAT(#{date} , '%Y%m' )
</select>
<select id="selectRzRestaurantStatisticsDate" resultType="java.util.Map">
select staff_id as staffId, personal_sum_consumption as personalSumConsumption from rz_restaurant_statistics
where del_flag = '0' and DATE_FORMAT( month, '%Y%m' ) = DATE_FORMAT(#{date} , '%Y%m' )
group by staff_id
</select>
</mapper>

View File

@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectSysStaffVo">
select user_id,company_name, dept_id, code, name, id_card,is_leader, sex, age, phone, address, level, major, school, bank_number,social_subsidy, bank, employment_date, experience, worker_term, regular_date, quit_date, contract_start, contract_end, contract_type, social_type, seniority, is_overtime_pay, zs_flag, secrecy, injury, insurance, introducer, clock_in, status, wages_ratio_date, remarks, del_flag, create_by, create_time, update_by, update_time, image_url,time_clock from sys_staff
select user_id,company_name, dept_id, code, name, id_card,is_leader, sex, age, phone, address, level, major, school, bank_number,social_subsidy, bank, employment_date, experience, worker_term, regular_date, quit_date, contract_start, contract_end, contract_type, social_type, seniority, is_overtime_pay, zs_flag, secrecy, injury, insurance, introducer, clock_in, status, wages_ratio_date, remarks, del_flag, create_by, create_time, update_by, update_time, image_url,time_clock,subsidys from sys_staff
</sql>
<select id="selectSysStaffList" parameterType="com.evo.system.domain.SysStaff" resultMap="SysStaffResult">