huminmin
4 天以前 b8607f49fb2ec4a4113aeb01455e90ae83781bcc
src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
@@ -13,12 +13,8 @@
import com.ruoyi.project.system.mapper.SysDeptMapper;
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.staff.controller.TaxCalculator;
import com.ruoyi.staff.mapper.SchemeApplicableStaffMapper;
import com.ruoyi.staff.mapper.SchemeInsuranceDetailMapper;
import com.ruoyi.staff.mapper.StaffOnJobMapper;
import com.ruoyi.staff.pojo.SchemeApplicableStaff;
import com.ruoyi.staff.pojo.SchemeInsuranceDetail;
import com.ruoyi.staff.pojo.StaffOnJob;
import com.ruoyi.staff.mapper.*;
import com.ruoyi.staff.pojo.*;
import com.ruoyi.staff.service.SchemeApplicableStaffService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -48,7 +44,10 @@
    private final SysUserMapper sysUserMapper;
    private final SysDeptMapper sysDeptMapper;
    private final StaffOnJobMapper staffOnJobMapper;
    private final PersonalShiftMapper personalShiftMapper;
    private final PersonalAttendanceLocationConfigMapper personalAttendanceLocationConfigMapper;
    private final SalesLedgerProductionAccountingService salesLedgerProductionAccountingService;
    private final SubsidyConfigurationMapper subsidyConfigurationMapper;
    @Override
@@ -191,15 +190,93 @@
        // 实发工资
        BigDecimal netSalary = new BigDecimal("0.00");
        map.put("netSalary", netSalary);
        // 调用基本工资
        // 根据排班数据计算白班天数和夜班天数
        BigDecimal dayDays = new BigDecimal("0.00");
        BigDecimal nightDays = new BigDecimal("0.00");
        // 查询当月排班记录
        List<PersonalShift> shiftList = personalShiftMapper.selectList(new LambdaQueryWrapper<PersonalShift>()
                .eq(PersonalShift::getStaffOnJobId, staffId)
                .like(PersonalShift::getWorkTime, date));
        if(!CollectionUtils.isEmpty(shiftList)){
            // 收集所有班次配置ID
            List<Integer> configIds = shiftList.stream()
                    .map(PersonalShift::getPersonalAttendanceLocationConfigId)
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(configIds)){
                // 查询班次配置信息
                List<PersonalAttendanceLocationConfig> configList = personalAttendanceLocationConfigMapper.selectList(
                        new LambdaQueryWrapper<PersonalAttendanceLocationConfig>()
                                .in(PersonalAttendanceLocationConfig::getId, configIds));
                // 构建班次配置映射
                Map<Integer, String> configMap = configList.stream()
                        .collect(Collectors.toMap(
                                PersonalAttendanceLocationConfig::getId,
                                PersonalAttendanceLocationConfig::getShift,
                                (a, b) -> a));
                // 统计白班和夜班天数
                for (PersonalShift shift : shiftList) {
                    Integer configId = shift.getPersonalAttendanceLocationConfigId();
                    String shiftName = configMap.get(configId);
                    if(shiftName != null){
                        // 根据班次名称判断:包含"白"或"日"为白班,包含"夜"为夜班
                        if(shiftName.contains("白") || shiftName.contains("日")){
                            dayDays = dayDays.add(BigDecimal.ONE);
                        } else if(shiftName.contains("夜")){
                            nightDays = nightDays.add(BigDecimal.ONE);
                        }
                    }
                }
            }
        }
        map.put("dayDays", dayDays); // 白班天数
        map.put("nightDays", nightDays); // 夜班天数
        // 查询餐补和夜班补贴
        // 计算餐补(回族特有)和夜班补助
        BigDecimal mealAmount = new BigDecimal("0.00"); // 餐补
        BigDecimal nightAmount = new BigDecimal("0.00"); // 夜班补助
        // 获取餐补和夜班补贴标准(从补贴配置中获取)
        SubsidyConfiguration subsidyConfig = subsidyConfigurationMapper.selectOne(null);
        BigDecimal mealStandard = new BigDecimal("0.00"); // 餐补标准
        BigDecimal nightStandard = new BigDecimal("0.00"); // 夜班补贴标准
        if(subsidyConfig != null){
            mealStandard = subsidyConfig.getMealAmount() != null ? subsidyConfig.getMealAmount() : new BigDecimal("0.00");
            nightStandard = subsidyConfig.getNightAmount() != null ? subsidyConfig.getNightAmount() : new BigDecimal("0.00");
        }
        // 餐补:民族为回族特有,计算方式为(白班天数+夜班天数)*餐补标准
        StaffOnJob staffOnJobDto = staffOnJobMapper.selectById(staffId);
        if(staffOnJobDto == null){
            return;
        }
        String nation = staffOnJobDto.getNation();
        if("回族".equals(nation)){
            mealAmount = dayDays.add(nightDays).multiply(mealStandard);
        }
        // 夜班补助:夜班天数*夜班补贴标准
        nightAmount = nightDays.multiply(nightStandard);
        map.put("mealAmount", mealAmount); // 餐补
        map.put("nightAmount", nightAmount); // 夜班补助
        // 调用基本工资
        basicSalary = staffOnJobDto.getBasicSalary();
        map.put("basicSalary", basicSalary);
        // 应发工资
        map.put("grossSalary", basicSalary);
        // 应发工资(基本工资+餐补+夜班补助+其他收入)
        grossSalary = basicSalary.add(mealAmount).add(nightAmount).add(otherIncome);
        map.put("grossSalary", grossSalary);
        // 实发工资初始值
        netSalary = grossSalary;
        map.put("netSalary", netSalary);
        // 个税金额(无社保版)
        BigDecimal bigDecimal = TaxCalculator.calculateMonthlyTax(basicSalary, socialPersonal, fundPersonal);
        map.put("salaryTax", bigDecimal);
@@ -242,10 +319,14 @@
        // 个税金额(社保版)
        bigDecimal = TaxCalculator.calculateMonthlyTax(basicSalary, socialPersonal, fundPersonal);
        map.put("salaryTax", bigDecimal);
        // 应扣工资
        map.put("deductSalary", bigDecimal.add(fundPersonal).add(socialPersonal));
        // 实发工资
        map.put("netSalary", basicSalary.subtract(bigDecimal).subtract(fundPersonal).subtract(socialPersonal));
        // 应扣工资 = 个税 + 公积金个人 + 社保个人 + 其他支出
        deductSalary = bigDecimal.add(fundPersonal).add(socialPersonal).add(otherDeduct);
        map.put("deductSalary", deductSalary);
        // 实发工资 = 应发工资 - 应扣工资
        netSalary = grossSalary.subtract(deductSalary);
        map.put("netSalary", netSalary);
    }