| | |
| | | return; // æè¿å空åè¡¨ï¼æ ¹æ®ä¸å¡éæ±è°æ´ |
| | | } |
| | | Long staffId = id.longValue(); |
| | | // 社ä¿éé¢ |
| | | BigDecimal socialPersonal = new BigDecimal("0.00"); |
| | | // å
¬ç§¯ééé¢ |
| | | BigDecimal fundPersonal = new BigDecimal("0.00"); |
| | | // åºæ¬å·¥èµ |
| | | BigDecimal basicSalary = new BigDecimal("0.00"); |
| | | map.put("fundPersonal", fundPersonal); // å
¬ç§¯é |
| | | map.put("socialPersonal", socialPersonal); // 社ä¿éé¢ |
| | | map.put("socialSupplementAmount", BigDecimal.ZERO); // 社ä¿è¡¥ç¼´éé¢ |
| | | map.put("basicSalary", basicSalary); // åºæ¬å·¥èµ |
| | | // 个ç¨éé¢ |
| | | BigDecimal salaryTax = new BigDecimal("0.00"); |
| | | map.put("salaryTax", salaryTax); |
| | | // è®¡ä»¶å·¥èµ |
| | | BigDecimal pieceSalary = new BigDecimal("0.00"); |
| | | map.put("pieceSalary", pieceSalary); |
| | | // 计æ¶å·¥èµ |
| | | BigDecimal hourlySalary = new BigDecimal("0.00"); |
| | | map.put("hourlySalary", hourlySalary); |
| | | // å
¶ä»æ¶å
¥ |
| | | BigDecimal otherIncome = new BigDecimal("0.00"); |
| | | map.put("otherIncome", otherIncome); |
| | | // å
¶ä»æ¯åº |
| | | BigDecimal otherDeduct = new BigDecimal("0.00"); |
| | | map.put("otherDeduct", otherDeduct); |
| | | // åºåå·¥èµ |
| | | BigDecimal grossSalary = new BigDecimal("0.00"); |
| | | map.put("grossSalary", grossSalary); |
| | | // åºæ£å·¥èµ |
| | | BigDecimal deductSalary = new BigDecimal("0.00"); |
| | | map.put("deductSalary", deductSalary); |
| | | // å®åå·¥èµ |
| | | BigDecimal netSalary = new BigDecimal("0.00"); |
| | | map.put("netSalary", netSalary); |
| | | // æ ¹æ®æçæ°æ®è®¡ç®ç½ç天æ°åå¤çå¤©æ° |
| | | BigDecimal dayDays = new BigDecimal("0.00"); |
| | | BigDecimal nightDays = new BigDecimal("0.00"); |
| | | // åç«¯ä¼ å
¥çå¯ç¼è¾å¼ä¼å
ï¼å
¶ä½å段ç±å端ç»ä¸è®¡ç® |
| | | boolean hasBasicSalaryInput = hasValue(map, "basicSalary"); |
| | | boolean hasDayDaysInput = hasValue(map, "dayDays"); |
| | | boolean hasNightDaysInput = hasValue(map, "nightDays"); |
| | | boolean hasPieceSalaryInput = hasValue(map, "pieceSalary"); |
| | | boolean hasHourlySalaryInput = hasValue(map, "hourlySalary"); |
| | | boolean hasSocialPersonalInput = hasValue(map, "socialPersonal"); |
| | | boolean hasFundPersonalInput = hasValue(map, "fundPersonal"); |
| | | |
| | | BigDecimal basicSalary = getBigDecimal(map, "basicSalary"); |
| | | BigDecimal dayDays = getBigDecimal(map, "dayDays"); |
| | | BigDecimal nightDays = getBigDecimal(map, "nightDays"); |
| | | BigDecimal pieceSalary = getBigDecimal(map, "pieceSalary"); |
| | | BigDecimal hourlySalary = getBigDecimal(map, "hourlySalary"); |
| | | BigDecimal otherIncome = getBigDecimal(map, "otherIncome"); |
| | | BigDecimal otherDeduct = getBigDecimal(map, "otherDeduct"); |
| | | BigDecimal socialPersonalInput = getBigDecimal(map, "socialPersonal"); |
| | | BigDecimal fundPersonalInput = getBigDecimal(map, "fundPersonal"); |
| | | BigDecimal socialPersonal = BigDecimal.ZERO; |
| | | BigDecimal fundPersonal = BigDecimal.ZERO; |
| | | BigDecimal salaryTax = BigDecimal.ZERO; |
| | | BigDecimal grossSalary = BigDecimal.ZERO; |
| | | BigDecimal deductSalary = BigDecimal.ZERO; |
| | | BigDecimal netSalary = BigDecimal.ZERO; |
| | | BigDecimal dayDaysInput = dayDays; |
| | | BigDecimal nightDaysInput = nightDays; |
| | | otherIncome = defaultIfNull(otherIncome); |
| | | otherDeduct = defaultIfNull(otherDeduct); |
| | | map.put("socialSupplementAmount", BigDecimal.ZERO); |
| | | |
| | | // æ¥è¯¢å½ææçè®°å½ |
| | | List<PersonalShift> shiftList = personalShiftMapper.selectList(new LambdaQueryWrapper<PersonalShift>() |
| | | .eq(PersonalShift::getStaffOnJobId, staffId) |
| | | .like(PersonalShift::getWorkTime, date)); |
| | | BigDecimal computedDayDays = BigDecimal.ZERO; |
| | | BigDecimal computedNightDays = BigDecimal.ZERO; |
| | | if (!hasDayDaysInput || !hasNightDaysInput) { |
| | | 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(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)); |
| | | 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)); |
| | | // æå»ºç次é
ç½®æ å° |
| | | 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); |
| | | // ç»è®¡ç½çåå¤çå¤©æ° |
| | | for (PersonalShift shift : shiftList) { |
| | | Integer configId = shift.getPersonalAttendanceLocationConfigId(); |
| | | String shiftName = configMap.get(configId); |
| | | if(shiftName != null){ |
| | | // æ ¹æ®ç次åç§°å¤æï¼å
å«"ç½"æ"æ¥"为ç½çï¼å
å«"å¤"为å¤ç |
| | | if(shiftName.contains("ç½") || shiftName.contains("æ¥")){ |
| | | computedDayDays = computedDayDays.add(BigDecimal.ONE); |
| | | } else if(shiftName.contains("å¤")){ |
| | | computedNightDays = computedNightDays.add(BigDecimal.ONE); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | dayDays = hasDayDaysInput ? defaultIfNull(dayDaysInput) : computedDayDays; |
| | | nightDays = hasNightDaysInput ? defaultIfNull(nightDaysInput) : computedNightDays; |
| | | 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); |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!hasBasicSalaryInput) { |
| | | basicSalary = defaultIfNull(staffOnJobDto.getBasicSalary()); |
| | | } else { |
| | | basicSalary = defaultIfNull(basicSalary); |
| | | } |
| | | |
| | | String nation = staffOnJobDto.getNation(); |
| | | // æ¥è¯¢é¤è¡¥åå¤ç补贴 |
| | | // 计ç®é¤è¡¥ï¼åæç¹æï¼åå¤çè¡¥å© |
| | | BigDecimal mealAmount = new BigDecimal("0.00"); // é¤è¡¥ |
| | | BigDecimal nightAmount = new BigDecimal("0.00"); // å¤çè¡¥å© |
| | | if("åæ".equals(nation)){ |
| | | mealAmount = dayDays.add(nightDays).multiply(mealStandard); |
| | | } |
| | |
| | | map.put("nightAmount", nightAmount); // å¤çè¡¥å© |
| | | |
| | | // è°ç¨åºæ¬å·¥èµ |
| | | basicSalary = staffOnJobDto.getBasicSalary(); |
| | | map.put("basicSalary", basicSalary); |
| | | // åºåå·¥èµï¼åºæ¬å·¥èµ+é¤è¡¥+å¤çè¡¥å©+å
¶ä»æ¶å
¥ï¼ |
| | | grossSalary = basicSalary.add(mealAmount).add(nightAmount).add(otherIncome); |
| | | map.put("otherIncome", otherIncome); |
| | | map.put("otherDeduct", otherDeduct); |
| | | // 计æ¶å·¥èµ è®¡ä»¶å·¥èµ |
| | | if (!hasPieceSalaryInput || !hasHourlySalaryInput) { |
| | | UserProductionAccountingDto userProductionAccountingDto = new UserProductionAccountingDto(); |
| | | userProductionAccountingDto.setUserId(getUidByStaffId(staffId)); |
| | | userProductionAccountingDto.setDate(date); |
| | | UserAccountDto byUserId = salesLedgerProductionAccountingService.getByUserId(userProductionAccountingDto); |
| | | if(byUserId != null){ |
| | | if (!hasPieceSalaryInput) { |
| | | pieceSalary = byUserId.getAccountBalance(); |
| | | } |
| | | if (!hasHourlySalaryInput) { |
| | | hourlySalary = byUserId.getAccount(); |
| | | } |
| | | } |
| | | } |
| | | map.put("pieceSalary", defaultIfNull(pieceSalary)); |
| | | map.put("hourlySalary", defaultIfNull(hourlySalary)); |
| | | // åºåå·¥èµï¼åºæ¬å·¥èµ+é¤è¡¥+å¤çè¡¥å©+计件工èµ+计æ¶å·¥èµ+å
¶ä»æ¶å
¥ï¼ |
| | | grossSalary = basicSalary |
| | | .add(mealAmount) |
| | | .add(nightAmount) |
| | | .add(defaultIfNull(pieceSalary)) |
| | | .add(defaultIfNull(hourlySalary)) |
| | | .add(otherIncome); |
| | | map.put("grossSalary", grossSalary); |
| | | // å®åå·¥èµåå§å¼ |
| | | netSalary = grossSalary; |
| | | map.put("netSalary", netSalary); |
| | | // 计æ¶å·¥èµ è®¡ä»¶å·¥èµ |
| | | UserProductionAccountingDto userProductionAccountingDto = new UserProductionAccountingDto(); |
| | | userProductionAccountingDto.setUserId(getUidByStaffId(staffId)); |
| | | userProductionAccountingDto.setDate(date); |
| | | UserAccountDto byUserId = salesLedgerProductionAccountingService.getByUserId(userProductionAccountingDto); |
| | | if(byUserId != null){ |
| | | map.put("pieceSalary", byUserId.getAccountBalance()); |
| | | map.put("hourlySalary", byUserId.getAccount()); |
| | | // åºå å®åå¢å |
| | | grossSalary = grossSalary.add(byUserId.getAccountBalance()).add(byUserId.getAccount()); |
| | | map.put("grossSalary", grossSalary); |
| | | netSalary = netSalary.add(byUserId.getAccountBalance()).add(byUserId.getAccount()); |
| | | map.put("netSalary", netSalary); |
| | | } |
| | | // 2. æ¥è¯¢è¯¥äººå对åºçç¤¾ä¿æ¹æ¡ |
| | | List<SchemeApplicableStaff> schemeList = schemeApplicableStaffMapper.selectSchemeByStaffId(staffId); |
| | | if (CollectionUtils.isEmpty(schemeList)) { |
| | |
| | | socialPersonal = socialPersonal.add(amount); |
| | | } |
| | | } |
| | | BigDecimal currentMonthSocialPersonal = socialPersonal; |
| | | BigDecimal currentMonthSocialPersonal = hasSocialPersonalInput ? defaultIfNull(socialPersonalInput) : socialPersonal; |
| | | if (!hasSocialPersonalInput) { |
| | | map.put("socialPersonal", currentMonthSocialPersonal); |
| | | } |
| | | BigDecimal resolvedFundPersonal = hasFundPersonalInput ? defaultIfNull(fundPersonalInput) : fundPersonal; |
| | | if (!hasFundPersonalInput) { |
| | | map.put("fundPersonal", resolvedFundPersonal); |
| | | } |
| | | BigDecimal socialSupplementAmount = calculateSocialSupplementAmount( |
| | | staffId, |
| | | staffOnJobDto, |
| | | targetMonth, |
| | | currentScheme, |
| | | currentDetailList, |
| | | socialPersonal |
| | | currentMonthSocialPersonal |
| | | ); |
| | | BigDecimal totalSocialPersonal = currentMonthSocialPersonal.add(socialSupplementAmount); |
| | | map.put("socialPersonal", currentMonthSocialPersonal); |
| | | map.put("fundPersonal", fundPersonal); |
| | | map.put("socialSupplementAmount", socialSupplementAmount); |
| | | // 个ç¨éé¢ï¼ç¤¾ä¿çï¼ |
| | | BigDecimal bigDecimal = TaxCalculator.calculateMonthlyTax(grossSalary, totalSocialPersonal, fundPersonal); |
| | | BigDecimal bigDecimal = TaxCalculator.calculateMonthlyTax(grossSalary, totalSocialPersonal, resolvedFundPersonal); |
| | | map.put("salaryTax", bigDecimal); |
| | | |
| | | // åºæ£å·¥èµ = ä¸ªç¨ + å
¬ç§¯é个人 + 社ä¿ä¸ªäºº + 社ä¿è¡¥ç¼´ + å
¶ä»æ¯åº |
| | | deductSalary = bigDecimal.add(fundPersonal).add(totalSocialPersonal).add(otherDeduct); |
| | | deductSalary = bigDecimal.add(resolvedFundPersonal).add(totalSocialPersonal).add(otherDeduct); |
| | | map.put("deductSalary", deductSalary); |
| | | |
| | | // å®åå·¥èµ = åºåå·¥èµ - åºæ£å·¥èµ |
| | |
| | | |
| | | } |
| | | |
| | | private BigDecimal getBigDecimal(Map<String, Object> map, String key) { |
| | | if (map == null || !map.containsKey(key) || map.get(key) == null) { |
| | | return null; |
| | | } |
| | | Object value = map.get(key); |
| | | if (value instanceof BigDecimal) { |
| | | return (BigDecimal) value; |
| | | } |
| | | if (value instanceof Number) { |
| | | return new BigDecimal(value.toString()); |
| | | } |
| | | String text = String.valueOf(value).trim(); |
| | | if (text.isEmpty()) { |
| | | return null; |
| | | } |
| | | return new BigDecimal(text); |
| | | } |
| | | |
| | | private boolean hasValue(Map<String, Object> map, String key) { |
| | | return map != null && map.containsKey(key) && map.get(key) != null; |
| | | } |
| | | |
| | | private BigDecimal defaultIfNull(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | /** |
| | | * éè¿åå·¥Idè·åç¨æ·id |
| | | * @param staffId |