| | |
| | | |
| | | 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.common.utils.poi.ExcelUtil; |
| | | 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.excel.StaffSalaryExportData; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import com.ruoyi.staff.dto.CalculateSalaryDto; |
| | | import com.ruoyi.staff.dto.StaffSalaryCalculateDto; |
| | | import com.ruoyi.staff.mapper.StaffLeaveMapper; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.mapper.StaffSalaryDetailMapper; |
| | | import com.ruoyi.staff.pojo.*; |
| | | 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.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 StaffLeaveMapper staffLeaveMapper; |
| | | |
| | | @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((Integer) id.get("staffState") == 0){ |
| | | StaffLeave id1 = staffLeaveMapper.selectOne(new LambdaQueryWrapper<StaffLeave>() |
| | | .eq(StaffLeave::getStaffOnJobId, id.get("id")) |
| | | .like(StaffLeave::getCreateTime, calculateSalaryDto.getDate())); |
| | | .like(StaffLeave::getLeaveDate, calculateSalaryDto.getDate())); |
| | | if(id1 == null){ |
| | | continue; |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | | @Override |
| | | public void exportSalaryDetail(HttpServletResponse response, String salaryMonth) { |
| | | LambdaQueryWrapper<StaffSalaryMain> mainWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.isNotEmpty(salaryMonth)) { |
| | | mainWrapper.eq(StaffSalaryMain::getSalaryMonth, salaryMonth); |
| | | } |
| | | List<StaffSalaryMain> mainList = staffSalaryMainMapper.selectList(mainWrapper); |
| | | |
| | | List<StaffSalaryExportData> exportDataList = new ArrayList<>(); |
| | | for (StaffSalaryMain main : mainList) { |
| | | List<StaffSalaryDetail> detailList = staffSalaryDetailMapper.selectList( |
| | | new LambdaQueryWrapper<StaffSalaryDetail>().eq(StaffSalaryDetail::getMainId, main.getId()) |
| | | ); |
| | | |
| | | for (StaffSalaryDetail detail : detailList) { |
| | | StaffSalaryExportData exportData = new StaffSalaryExportData(); |
| | | exportData.setSalaryMonth(main.getSalaryMonth()); |
| | | exportData.setSalaryTitle(main.getSalaryTitle()); |
| | | exportData.setStaffName(detail.getStaffName()); |
| | | exportData.setDeptName(detail.getDeptName()); |
| | | exportData.setBasicSalary(detail.getBasicSalary()); |
| | | exportData.setPieceSalary(detail.getPieceSalary()); |
| | | exportData.setHourlySalary(detail.getHourlySalary()); |
| | | exportData.setOtherIncome(detail.getOtherIncome()); |
| | | exportData.setSocialPersonal(detail.getSocialPersonal()); |
| | | exportData.setFundPersonal(detail.getFundPersonal()); |
| | | exportData.setOtherDeduct(detail.getOtherDeduct()); |
| | | exportData.setSocialSupplementAmount(detail.getSocialSupplementAmount()); |
| | | exportData.setSalaryTax(detail.getSalaryTax()); |
| | | exportData.setGrossSalary(detail.getGrossSalary()); |
| | | exportData.setDeductSalary(detail.getDeductSalary()); |
| | | exportData.setNetSalary(detail.getNetSalary()); |
| | | exportData.setRemark(detail.getRemark()); |
| | | exportDataList.add(exportData); |
| | | } |
| | | } |
| | | |
| | | ExcelUtil<StaffSalaryExportData> util = new ExcelUtil<>(StaffSalaryExportData.class); |
| | | util.exportExcel(response, exportDataList, "员工薪资明细"); |
| | | } |
| | | |
| | | public List<Map<String, Object>> setSchemeApplicableStaffUserInfo(List<Long> ids) { |
| | | if(CollectionUtils.isEmpty(ids)){ |
| | | return new ArrayList<>(); |