| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.mapper.AccountExpenseMapper; |
| | | import com.ruoyi.account.pojo.AccountExpense; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.domain.SysUserDept; |
| | | import com.ruoyi.project.system.mapper.SysUserDeptMapper; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.staff.dto.CalculateSalaryDto; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.dto.StaffSalaryCalculateDto; |
| | | import com.ruoyi.staff.mapper.StaffLeaveMapper; |
| | | import com.ruoyi.staff.mapper.StaffSalaryDetailMapper; |
| | | import com.ruoyi.staff.pojo.SchemeApplicableStaff; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import com.ruoyi.staff.mapper.StaffSalaryMainMapper; |
| | | import com.ruoyi.staff.pojo.StaffLeave; |
| | | import com.ruoyi.staff.pojo.StaffSalaryDetail; |
| | | import com.ruoyi.staff.pojo.StaffSalaryMain; |
| | | import com.ruoyi.staff.mapper.StaffSalaryMainMapper; |
| | | import com.ruoyi.staff.service.StaffSalaryDetailService; |
| | | import com.ruoyi.staff.service.StaffSalaryMainService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2026-03-06 01:22:05 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class StaffSalaryMainServiceImpl extends ServiceImpl<StaffSalaryMainMapper, StaffSalaryMain> implements StaffSalaryMainService { |
| | | |
| | | @Autowired |
| | | private StaffSalaryMainMapper staffSalaryMainMapper; |
| | | |
| | | @Autowired |
| | | private StaffSalaryDetailService staffSalaryDetailService; |
| | | |
| | | @Autowired |
| | | private StaffSalaryDetailMapper staffSalaryDetailMapper; |
| | | |
| | | @Autowired |
| | | private SchemeApplicableStaffServiceImpl schemeApplicableStaffService; |
| | | |
| | | @Autowired |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Autowired |
| | | private StaffOnJobMapper staffOnJobMapper; |
| | | |
| | | @Autowired |
| | | private AccountExpenseMapper accountExpenseMapper; |
| | | private final StaffSalaryMainMapper staffSalaryMainMapper; |
| | | private final StaffSalaryDetailService staffSalaryDetailService; |
| | | private final StaffSalaryDetailMapper staffSalaryDetailMapper; |
| | | private final SchemeApplicableStaffServiceImpl schemeApplicableStaffService; |
| | | private final SysUserDeptMapper sysUserDeptMapper; |
| | | private final StaffLeaveMapper staffLeaveMapper; |
| | | |
| | | @Override |
| | | public AjaxResult listPage(Page page, StaffSalaryMain staffSalaryMain) { |
| | |
| | | staffSalaryMainLambdaQueryWrapper.eq(StaffSalaryMain::getStatus, staffSalaryMain.getStatus()); |
| | | } |
| | | } |
| | | staffSalaryMainLambdaQueryWrapper.orderByDesc(StaffSalaryMain::getId); |
| | | Page<StaffSalaryMain> page1 = staffSalaryMainMapper.selectPage(page, staffSalaryMainLambdaQueryWrapper); |
| | | page1.getRecords().forEach(main -> { |
| | | List<StaffSalaryDetail> staffSalaryDetailList = staffSalaryDetailMapper.selectList(new LambdaQueryWrapper<StaffSalaryDetail>().eq(StaffSalaryDetail::getMainId, main.getId())); |
| | |
| | | }); |
| | | staffSalaryDetailService.saveBatch(staffSalaryMain.getStaffSalaryDetailList()); |
| | | } |
| | | // 和财务联动,新增支出 |
| | | if(staffSalaryMain.getStatus().equals(5)){ |
| | | AccountExpense accountExpense = new AccountExpense(); |
| | | accountExpense.setBusinessType(3); |
| | | accountExpense.setExpenseMoney(staffSalaryMain.getTotalSalary()); |
| | | accountExpense.setBusinessId(staffSalaryMain.getId()); |
| | | accountExpense.setExpenseDate(new Date()); |
| | | accountExpense.setExpenseMethod("2"); |
| | | accountExpense.setExpenseType("1"); |
| | | accountExpense.setExpenseDescribed(staffSalaryMain.getSalaryTitle()); |
| | | accountExpense.setNote(staffSalaryMain.getRemark()); |
| | | accountExpense.setInputUser(SecurityUtils.getLoginUser().getNickName()); |
| | | accountExpense.setInputTime(new Date()); |
| | | accountExpenseMapper.insert(accountExpense); |
| | | } |
| | | return AjaxResult.success("修改成功"); |
| | | } |
| | | |
| | |
| | | if(CollectionUtils.isEmpty(longs)){ |
| | | return AjaxResult.error("无员工"); |
| | | } |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | for (Map<String, Object> id : longs) { |
| | | // 判断员工是否为当月离职 |
| | | if((Integer) id.get("staffState") == 0){ |
| | | StaffLeave id1 = staffLeaveMapper.selectOne(new LambdaQueryWrapper<StaffLeave>() |
| | | .eq(StaffLeave::getStaffOnJobId, id.get("id")) |
| | | .like(StaffLeave::getLeaveDate, calculateSalaryDto.getDate())); |
| | | if(id1 == null){ |
| | | continue; |
| | | } |
| | | } |
| | | schemeApplicableStaffService.calculateByEmployeeId((Integer) id.get("id"),id,calculateSalaryDto.getDate()); |
| | | mapList.add(id); |
| | | } |
| | | return AjaxResult.success(longs); |
| | | return AjaxResult.success(mapList); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult calculateSalaryByEmployee(StaffSalaryCalculateDto staffSalaryCalculateDto) { |
| | | if (staffSalaryCalculateDto == null |
| | | || staffSalaryCalculateDto.getStaffOnJobId() == null |
| | | || StringUtils.isEmpty(staffSalaryCalculateDto.getSalaryMonth())) { |
| | | return AjaxResult.error("参数错误"); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", staffSalaryCalculateDto.getStaffOnJobId()); |
| | | map.put("staffOnJobId", staffSalaryCalculateDto.getStaffOnJobId()); |
| | | map.put("salaryMonth", staffSalaryCalculateDto.getSalaryMonth()); |
| | | map.put("staffName", staffSalaryCalculateDto.getStaffName()); |
| | | map.put("postName", staffSalaryCalculateDto.getPostName()); |
| | | map.put("deptName", staffSalaryCalculateDto.getDeptName()); |
| | | if (staffSalaryCalculateDto.getBasicSalary() != null) { |
| | | map.put("basicSalary", staffSalaryCalculateDto.getBasicSalary()); |
| | | } |
| | | map.put("pieceSalary", staffSalaryCalculateDto.getPieceSalary()); |
| | | map.put("hourlySalary", staffSalaryCalculateDto.getHourlySalary()); |
| | | map.put("otherIncome", staffSalaryCalculateDto.getOtherIncome()); |
| | | map.put("socialPersonal", staffSalaryCalculateDto.getSocialPersonal()); |
| | | map.put("fundPersonal", staffSalaryCalculateDto.getFundPersonal()); |
| | | map.put("otherDeduct", staffSalaryCalculateDto.getOtherDeduct()); |
| | | map.put("socialSupplementAmount", staffSalaryCalculateDto.getSocialSupplementAmount()); |
| | | map.put("salaryTax", staffSalaryCalculateDto.getSalaryTax()); |
| | | map.put("grossSalary", staffSalaryCalculateDto.getGrossSalary()); |
| | | map.put("deductSalary", staffSalaryCalculateDto.getDeductSalary()); |
| | | map.put("netSalary", staffSalaryCalculateDto.getNetSalary()); |
| | | map.put("remark", staffSalaryCalculateDto.getRemark()); |
| | | schemeApplicableStaffService.calculateByEmployeeId( |
| | | staffSalaryCalculateDto.getStaffOnJobId().intValue(), |
| | | map, |
| | | staffSalaryCalculateDto.getSalaryMonth() |
| | | ); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | public List<Map<String, Object>> setSchemeApplicableStaffUserInfo(List<Long> ids) { |