-
mentioned in commit 757f2751
Showing
3 changed files
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/salary/ReportSalaryDim.java
@@ -93,7 +93,7 @@ public class ReportSalaryDim extends BaseEntity<ReportSalaryDim, Long> { | @@ -93,7 +93,7 @@ public class ReportSalaryDim extends BaseEntity<ReportSalaryDim, Long> { | ||
93 | private StarLevelEnum starLevel; | 93 | private StarLevelEnum starLevel; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | - * 总薪酬 | 96 | + * 总薪酬 = actRevenueTotalMoney(总收入合计) - actDeductTotalMoney(总扣除合计) |
97 | */ | 97 | */ |
98 | private BigDecimal totalReward; | 98 | private BigDecimal totalReward; |
99 | 99 | ||
@@ -102,4 +102,64 @@ public class ReportSalaryDim extends BaseEntity<ReportSalaryDim, Long> { | @@ -102,4 +102,64 @@ public class ReportSalaryDim extends BaseEntity<ReportSalaryDim, Long> { | ||
102 | */ | 102 | */ |
103 | private BigDecimal kpiScoreRatio; | 103 | private BigDecimal kpiScoreRatio; |
104 | 104 | ||
105 | + /** | ||
106 | + * 总收入合计 | ||
107 | + */ | ||
108 | + private BigDecimal actRevenueTotalMoney; | ||
109 | + | ||
110 | + /** | ||
111 | + * 总绩效提成 | ||
112 | + */ | ||
113 | + private BigDecimal actKpiMoney; | ||
114 | + | ||
115 | + /** | ||
116 | + * 总内部奖励 | ||
117 | + */ | ||
118 | + private BigDecimal actAwardMoney; | ||
119 | + | ||
120 | + /** | ||
121 | + * 总福利补贴 | ||
122 | + */ | ||
123 | + private BigDecimal actSubsidyMoney; | ||
124 | + | ||
125 | + /** | ||
126 | + * 总试用期工资 | ||
127 | + */ | ||
128 | + private BigDecimal actProbationMoney; | ||
129 | + | ||
130 | + /** | ||
131 | + * 总岗位最低补偿 | ||
132 | + */ | ||
133 | + private BigDecimal actJobCompensateMoney; | ||
134 | + | ||
135 | + /** | ||
136 | + * 总考评奖励 | ||
137 | + */ | ||
138 | + private BigDecimal actEvalAwardMoney; | ||
139 | + | ||
140 | + /** | ||
141 | + * 总扣除合计 | ||
142 | + */ | ||
143 | + private BigDecimal actDeductTotalMoney; | ||
144 | + | ||
145 | + /** | ||
146 | + * 总内部罚款扣除 | ||
147 | + */ | ||
148 | + private BigDecimal actPenaltyMoney; | ||
149 | + | ||
150 | + /** | ||
151 | + * 总社保扣除 | ||
152 | + */ | ||
153 | + private BigDecimal actNecessaryMoney; | ||
154 | + | ||
155 | + /** | ||
156 | + * 总个税扣除 | ||
157 | + */ | ||
158 | + private BigDecimal actPersonTaxMoney; | ||
159 | + | ||
160 | + /** | ||
161 | + * 总公积金扣除 | ||
162 | + */ | ||
163 | + private BigDecimal actAccumulationFundMoney; | ||
164 | + | ||
105 | } | 165 | } |
fw-morax-domain/src/main/java/cn/fw/morax/domain/enums/EvalUseTargetEnum.java
@@ -16,7 +16,7 @@ public enum EvalUseTargetEnum implements IEnum<Integer> { | @@ -16,7 +16,7 @@ public enum EvalUseTargetEnum implements IEnum<Integer> { | ||
16 | */ | 16 | */ |
17 | NO(1, "无目标"), | 17 | NO(1, "无目标"), |
18 | FIRST_TARGET(2, "第一目标"), | 18 | FIRST_TARGET(2, "第一目标"), |
19 | - EXTRA_TARGET(2, "额外目标值"), | 19 | + EXTRA_TARGET(3, "额外目标值"), |
20 | ; | 20 | ; |
21 | 21 | ||
22 | /** | 22 | /** |
fw-morax-server/src/main/java/cn/fw/morax/server/task/SalaryReportTask.java
@@ -6,7 +6,7 @@ import cn.fw.morax.common.constant.TimeTaskConstant; | @@ -6,7 +6,7 @@ import cn.fw.morax.common.constant.TimeTaskConstant; | ||
6 | import cn.fw.morax.common.utils.DateUtil; | 6 | import cn.fw.morax.common.utils.DateUtil; |
7 | import cn.fw.morax.common.utils.PublicUtil; | 7 | import cn.fw.morax.common.utils.PublicUtil; |
8 | import cn.fw.morax.domain.bo.salary.SalaryGroupProjectBO; | 8 | import cn.fw.morax.domain.bo.salary.SalaryGroupProjectBO; |
9 | -import cn.fw.morax.domain.db.kpi.*; | 9 | +import cn.fw.morax.domain.db.kpi.IndicatorUserValue; |
10 | import cn.fw.morax.domain.db.salary.*; | 10 | import cn.fw.morax.domain.db.salary.*; |
11 | import cn.fw.morax.domain.enums.*; | 11 | import cn.fw.morax.domain.enums.*; |
12 | import cn.fw.morax.domain.vo.salary.SalaryGroupProjectParamVO; | 12 | import cn.fw.morax.domain.vo.salary.SalaryGroupProjectParamVO; |
@@ -49,6 +49,8 @@ import java.util.*; | @@ -49,6 +49,8 @@ import java.util.*; | ||
49 | import java.util.concurrent.atomic.AtomicInteger; | 49 | import java.util.concurrent.atomic.AtomicInteger; |
50 | import java.util.concurrent.locks.Lock; | 50 | import java.util.concurrent.locks.Lock; |
51 | import java.util.function.Function; | 51 | import java.util.function.Function; |
52 | +import java.util.function.Predicate; | ||
53 | +import java.util.function.ToDoubleFunction; | ||
52 | import java.util.stream.Collectors; | 54 | import java.util.stream.Collectors; |
53 | 55 | ||
54 | /** | 56 | /** |
@@ -86,6 +88,7 @@ public class SalaryReportTask { | @@ -86,6 +88,7 @@ public class SalaryReportTask { | ||
86 | private final CommonService commonService; | 88 | private final CommonService commonService; |
87 | private final EhrRpcService ehrRpcService; | 89 | private final EhrRpcService ehrRpcService; |
88 | private final OopRpcService oopRpcService; | 90 | private final OopRpcService oopRpcService; |
91 | + private final SalaryPoolDetailService salaryPoolDetailService; | ||
89 | 92 | ||
90 | 93 | ||
91 | @Value("${special-indicator-code.car-series}") | 94 | @Value("${special-indicator-code.car-series}") |
@@ -223,10 +226,12 @@ public class SalaryReportTask { | @@ -223,10 +226,12 @@ public class SalaryReportTask { | ||
223 | List<SalaryPool> pools, | 226 | List<SalaryPool> pools, |
224 | Long reportSalaryId) { | 227 | Long reportSalaryId) { |
225 | MultiKeyMap<Long, BigDecimal> userSalaryMap = this.getUserIndicatorHitMap(salaryGroupProjects, date, pools); | 228 | MultiKeyMap<Long, BigDecimal> userSalaryMap = this.getUserIndicatorHitMap(salaryGroupProjects, date, pools); |
229 | + Map<Long, List<SalaryPoolDetail>> salaryPoolDetailMap = this.getSalaryPoolDetailMap(date, pools); | ||
226 | List<ReportSalaryDimValue> reportSalaryValues = new ArrayList<>(); | 230 | List<ReportSalaryDimValue> reportSalaryValues = new ArrayList<>(); |
227 | //人的维度为基础,计算各个指标信息对应的数据 | 231 | //人的维度为基础,计算各个指标信息对应的数据 |
228 | for (SalaryPool pool : pools) { | 232 | for (SalaryPool pool : pools) { |
229 | - ReportSalaryDim reportSalaryDim = saveStaffDim(pool, date, reportSalaryId); | 233 | + List<SalaryPoolDetail> salaryPoolIdDetails = Optional.ofNullable(salaryPoolDetailMap.get(pool.getId())).orElse(Collections.emptyList()); |
234 | + ReportSalaryDim reportSalaryDim = saveStaffDim(pool, date, reportSalaryId,salaryPoolIdDetails); | ||
230 | userDims.add(reportSalaryDim); | 235 | userDims.add(reportSalaryDim); |
231 | final Long userId = pool.getUserId(); | 236 | final Long userId = pool.getUserId(); |
232 | final Long reportSalaryDimId = reportSalaryDim.getId(); | 237 | final Long reportSalaryDimId = reportSalaryDim.getId(); |
@@ -286,9 +291,7 @@ public class SalaryReportTask { | @@ -286,9 +291,7 @@ public class SalaryReportTask { | ||
286 | if (PublicUtil.isEmpty(shopDimReportIds)) { | 291 | if (PublicUtil.isEmpty(shopDimReportIds)) { |
287 | continue; | 292 | continue; |
288 | } | 293 | } |
289 | - BigDecimal averageSalary = calcAverageTotalSalary(userDims, shopDimReportIds); | ||
290 | - BigDecimal kpiScoreRatio = calcAverageKpiScoreRatio(userDims, shopDimReportIds); | ||
291 | - final Long shopReportSalaryDimId = this.saveShopDimDB(shopId, shopMap, date, reportSalaryId, averageSalary, kpiScoreRatio); | 294 | + final Long shopReportSalaryDimId = this.saveShopDimDB(shopId, shopMap, date, reportSalaryId, userDims, shopDimReportIds); |
292 | 295 | ||
293 | for (SalaryGroupProjectBO salaryGroupProject : salaryGroupProjects) { | 296 | for (SalaryGroupProjectBO salaryGroupProject : salaryGroupProjects) { |
294 | BigDecimal value = calcAverageValue(userSalaryValues, shopDimReportIds, salaryGroupProject.getId().toString()); | 297 | BigDecimal value = calcAverageValue(userSalaryValues, shopDimReportIds, salaryGroupProject.getId().toString()); |
@@ -341,9 +344,9 @@ public class SalaryReportTask { | @@ -341,9 +344,9 @@ public class SalaryReportTask { | ||
341 | if (PublicUtil.isEmpty(managerStaffDimReportIds)) { | 344 | if (PublicUtil.isEmpty(managerStaffDimReportIds)) { |
342 | continue; | 345 | continue; |
343 | } | 346 | } |
344 | - BigDecimal kpiScoreRatio = calcAverageKpiScoreRatio(userDims, managerStaffDimReportIds); | ||
345 | - BigDecimal averageSalary = calcAverageTotalSalary(userDims, managerStaffDimReportIds); | ||
346 | - final Long reportSalaryDimId = this.saveManagerDimDB(manager, date, reportSalaryId, managerMap, averageSalary, kpiScoreRatio, manageStaffIds); | 347 | + //BigDecimal kpiScoreRatio = calcAverageKpiScoreRatio(userDims, managerStaffDimReportIds); |
348 | + //BigDecimal averageSalary = calcAverageTotalSalary(userDims, managerStaffDimReportIds); | ||
349 | + final Long reportSalaryDimId = this.saveManagerDimDB(manager, date, reportSalaryId, managerMap,manageStaffIds,managerStaffDimReportIds,userDims); | ||
347 | for (SalaryGroupProjectBO salaryGroupProject : salaryGroupProjects) { | 350 | for (SalaryGroupProjectBO salaryGroupProject : salaryGroupProjects) { |
348 | BigDecimal value = calcAverageValue(userSalaryValues, managerStaffDimReportIds, salaryGroupProject.getId().toString()); | 351 | BigDecimal value = calcAverageValue(userSalaryValues, managerStaffDimReportIds, salaryGroupProject.getId().toString()); |
349 | childReportSalaryDimValues.add(this.convertProjectValueDB(salaryGroupProject, value)); | 352 | childReportSalaryDimValues.add(this.convertProjectValueDB(salaryGroupProject, value)); |
@@ -371,6 +374,44 @@ public class SalaryReportTask { | @@ -371,6 +374,44 @@ public class SalaryReportTask { | ||
371 | return staffInfos.stream().collect(Collectors.toMap(StaffBaseInfoDTO::getId, Function.identity(), (v1, v2) -> v1)); | 374 | return staffInfos.stream().collect(Collectors.toMap(StaffBaseInfoDTO::getId, Function.identity(), (v1, v2) -> v1)); |
372 | } | 375 | } |
373 | 376 | ||
377 | + /** | ||
378 | + * 抽象处理平均值计算 | ||
379 | + * @param data | ||
380 | + * @param predicate | ||
381 | + * @param field | ||
382 | + * @return | ||
383 | + */ | ||
384 | + private <T> BigDecimal calcAverage(final Collection<T> data,Predicate<T> predicate, final ToDoubleFunction<T> field) { | ||
385 | + if (CollectionUtils.isEmpty(data)) { | ||
386 | + return BigDecimal.ZERO; | ||
387 | + } | ||
388 | + Double averageRatioDouble = data.stream() | ||
389 | + .filter(predicate) | ||
390 | + .mapToDouble(field) | ||
391 | + .average() | ||
392 | + .orElse(0); | ||
393 | + return BigDecimal.valueOf(averageRatioDouble); | ||
394 | + } | ||
395 | + | ||
396 | + /** | ||
397 | + * 抽象处理平均值计算 | ||
398 | + * @param data | ||
399 | + * @param field | ||
400 | + * @return | ||
401 | + * @param <T> | ||
402 | + */ | ||
403 | + private <T> BigDecimal calcAverage(final Collection<T> data, final ToDoubleFunction<T> field) { | ||
404 | + if (CollectionUtils.isEmpty(data)) { | ||
405 | + return BigDecimal.ZERO; | ||
406 | + } | ||
407 | + Double averageRatioDouble = data.stream() | ||
408 | + .mapToDouble(field) | ||
409 | + .average() | ||
410 | + .orElse(0); | ||
411 | + return BigDecimal.valueOf(averageRatioDouble); | ||
412 | + } | ||
413 | + | ||
414 | + | ||
374 | public BigDecimal calcAverageTotalSalary(List<ReportSalaryDim> dims, Set<Long> ReportDimIds) { | 415 | public BigDecimal calcAverageTotalSalary(List<ReportSalaryDim> dims, Set<Long> ReportDimIds) { |
375 | Double averageRatioDouble = dims.stream() | 416 | Double averageRatioDouble = dims.stream() |
376 | .filter(user -> ReportDimIds.contains(user.getId())) | 417 | .filter(user -> ReportDimIds.contains(user.getId())) |
@@ -398,8 +439,12 @@ public class SalaryReportTask { | @@ -398,8 +439,12 @@ public class SalaryReportTask { | ||
398 | return new BigDecimal(averageRatioDouble.toString()); | 439 | return new BigDecimal(averageRatioDouble.toString()); |
399 | } | 440 | } |
400 | 441 | ||
401 | - public Long saveShopDimDB(Long shopId, Map<Long, String> shopMap, | ||
402 | - LocalDate date, Long reportSalaryId, BigDecimal averageSalary, BigDecimal kpiScoreRatio) { | 442 | + public Long saveShopDimDB(Long shopId, |
443 | + Map<Long, String> shopMap, | ||
444 | + LocalDate date, | ||
445 | + Long reportSalaryId, | ||
446 | + List<ReportSalaryDim> userDims, | ||
447 | + Set<Long> shopDimReportIds) { | ||
403 | ReportSalaryDim reportSalaryDim = new ReportSalaryDim(); | 448 | ReportSalaryDim reportSalaryDim = new ReportSalaryDim(); |
404 | reportSalaryDim.setDimension(ReportDimensionEnum.SHOP); | 449 | reportSalaryDim.setDimension(ReportDimensionEnum.SHOP); |
405 | reportSalaryDim.setReferId(shopId); | 450 | reportSalaryDim.setReferId(shopId); |
@@ -407,24 +452,118 @@ public class SalaryReportTask { | @@ -407,24 +452,118 @@ public class SalaryReportTask { | ||
407 | reportSalaryDim.setShopName(shopMap.get(shopId)); | 452 | reportSalaryDim.setShopName(shopMap.get(shopId)); |
408 | reportSalaryDim.setDataDate(date); | 453 | reportSalaryDim.setDataDate(date); |
409 | reportSalaryDim.setReportSalaryId(reportSalaryId); | 454 | reportSalaryDim.setReportSalaryId(reportSalaryId); |
410 | - reportSalaryDim.setTotalReward(averageSalary); | ||
411 | - reportSalaryDim.setKpiScoreRatio(kpiScoreRatio); | 455 | + //计算平均值薪酬的额外项 |
456 | + extCalcAverage(userDims, shopDimReportIds, reportSalaryDim); | ||
412 | reportSalaryDimService.save(reportSalaryDim); | 457 | reportSalaryDimService.save(reportSalaryDim); |
413 | return reportSalaryDim.getId(); | 458 | return reportSalaryDim.getId(); |
414 | } | 459 | } |
460 | + | ||
461 | + /** | ||
462 | + * 计算平均值薪酬的额外项 | ||
463 | + * @param userDims | ||
464 | + * @param shopDimReportIds | ||
465 | + * @param reportSalaryDim | ||
466 | + */ | ||
467 | + private void extCalcAverage(List<ReportSalaryDim> userDims, Set<Long> shopDimReportIds, ReportSalaryDim reportSalaryDim) { | ||
468 | + List<ReportSalaryDim> filterUserDims = userDims.stream().filter(e -> shopDimReportIds.contains(e.getId())).collect(Collectors.toList()); | ||
469 | + //绩效得分率(N) | ||
470 | + reportSalaryDim.setKpiScoreRatio(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getKpiScoreRatio()).orElse(BigDecimal.ZERO).doubleValue())); | ||
471 | + //收入-平均值 | ||
472 | + reportSalaryDim.setActKpiMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActKpiMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
473 | + reportSalaryDim.setActAwardMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActAwardMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
474 | + reportSalaryDim.setActSubsidyMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActSubsidyMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
475 | + reportSalaryDim.setActProbationMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActProbationMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
476 | + reportSalaryDim.setActJobCompensateMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActJobCompensateMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
477 | + reportSalaryDim.setActEvalAwardMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActEvalAwardMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
478 | + //总收入合计平均值 | ||
479 | + reportSalaryDim.setActRevenueTotalMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActRevenueTotalMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
480 | + //reportSalaryDim.setActRevenueTotalMoney( | ||
481 | + // reportSalaryDim.getActKpiMoney() | ||
482 | + // .add(reportSalaryDim.getActAwardMoney()) | ||
483 | + // .add(reportSalaryDim.getActSubsidyMoney()) | ||
484 | + // .add(reportSalaryDim.getActProbationMoney()) | ||
485 | + // .add(reportSalaryDim.getActJobCompensateMonry()) | ||
486 | + // .add(reportSalaryDim.getActEvalAwardMoney()) | ||
487 | + //); | ||
488 | + //扣除-平均值 | ||
489 | + reportSalaryDim.setActPenaltyMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActPenaltyMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
490 | + reportSalaryDim.setActNecessaryMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActNecessaryMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
491 | + reportSalaryDim.setActPersonTaxMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActPersonTaxMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
492 | + reportSalaryDim.setActAccumulationFundMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActAccumulationFundMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
493 | + //总扣除合计平均值 | ||
494 | + reportSalaryDim.setActDeductTotalMoney(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getActDeductTotalMoney()).orElse(BigDecimal.ZERO).doubleValue())); | ||
495 | + //reportSalaryDim.setActDeductTotalMoney( | ||
496 | + // reportSalaryDim.getActPenaltyMoney() | ||
497 | + // .add(reportSalaryDim.getActNecessaryMoney()) | ||
498 | + // .add(reportSalaryDim.getActPersonTaxMoney()) | ||
499 | + // .add(reportSalaryDim.getActAccumulationFundMoney()) | ||
500 | + //); | ||
501 | + //总薪酬平均值 = 总收入合计 - 总扣除合计 or 直接取平均值 | ||
502 | + reportSalaryDim.setTotalReward(calcAverage(filterUserDims, e -> Optional.ofNullable(e.getTotalReward()).orElse(BigDecimal.ZERO).doubleValue())); | ||
503 | + //reportSalaryDim.setTotalReward( | ||
504 | + // reportSalaryDim.getActRevenueTotalMoney() | ||
505 | + // .subtract(reportSalaryDim.getActDeductTotalMoney())); | ||
506 | + } | ||
507 | + | ||
508 | + /** | ||
509 | + * 计算人员的 | ||
510 | + * 增加 薪资类型相关项目处理 ++ | ||
511 | + * @param salaryPoolDetails | ||
512 | + * @param reportSalaryDim | ||
513 | + */ | ||
514 | + private void extCaleUserMoney(List<SalaryPoolDetail> salaryPoolDetails, ReportSalaryDim reportSalaryDim) { | ||
515 | + //额外计算项++ | ||
516 | + Map<SalaryTypeEnum, List<SalaryPoolDetail>> salaryTypeEnumListMap = salaryPoolDetails | ||
517 | + .stream() | ||
518 | + .collect(Collectors.groupingBy(SalaryPoolDetail::getType)); | ||
519 | + //收入 | ||
520 | + reportSalaryDim.setActKpiMoney(getSalaryTypeEnumMoney(salaryTypeEnumListMap,SalaryTypeEnum.ROYALTIES)); | ||
521 | + reportSalaryDim.setActAwardMoney(getSalaryTypeEnumMoney(salaryTypeEnumListMap,SalaryTypeEnum.AWARD)); | ||
522 | + reportSalaryDim.setActSubsidyMoney(getSalaryTypeEnumMoney(salaryTypeEnumListMap,SalaryTypeEnum.SUBSIDY)); | ||
523 | + reportSalaryDim.setActProbationMoney(getSalaryTypeEnumMoney(salaryTypeEnumListMap,SalaryTypeEnum.PROBATION)); | ||
524 | + reportSalaryDim.setActJobCompensateMoney(BigDecimal.ZERO); | ||
525 | + reportSalaryDim.setActEvalAwardMoney(BigDecimal.ZERO); | ||
526 | + //总收入合计 | ||
527 | + reportSalaryDim.setActRevenueTotalMoney( | ||
528 | + reportSalaryDim.getActKpiMoney() | ||
529 | + .add(reportSalaryDim.getActAwardMoney()) | ||
530 | + .add(reportSalaryDim.getActSubsidyMoney()) | ||
531 | + .add(reportSalaryDim.getActProbationMoney()) | ||
532 | + .add(reportSalaryDim.getActJobCompensateMoney()) | ||
533 | + .add(reportSalaryDim.getActEvalAwardMoney()) | ||
534 | + ); | ||
535 | + //扣除 | ||
536 | + reportSalaryDim.setActPenaltyMoney(getSalaryTypeEnumMoney(salaryTypeEnumListMap,SalaryTypeEnum.PENALTY)); | ||
537 | + reportSalaryDim.setActNecessaryMoney(getSalaryTypeEnumMoney(salaryTypeEnumListMap,SalaryTypeEnum.NECESSARY)); | ||
538 | + reportSalaryDim.setActPersonTaxMoney(getSalaryTypeEnumMoney(salaryTypeEnumListMap,SalaryTypeEnum.PERSON_TAX)); | ||
539 | + reportSalaryDim.setActAccumulationFundMoney(BigDecimal.ZERO); | ||
540 | + //总扣除合计 | ||
541 | + reportSalaryDim.setActDeductTotalMoney( | ||
542 | + reportSalaryDim.getActPenaltyMoney() | ||
543 | + .add(reportSalaryDim.getActNecessaryMoney()) | ||
544 | + .add(reportSalaryDim.getActPersonTaxMoney()) | ||
545 | + .add(reportSalaryDim.getActAccumulationFundMoney()) | ||
546 | + ); | ||
547 | + //总薪酬 = 总收入合计 - 总扣除合计 | ||
548 | + reportSalaryDim.setTotalReward( | ||
549 | + reportSalaryDim.getActRevenueTotalMoney() | ||
550 | + .subtract(reportSalaryDim.getActDeductTotalMoney())); | ||
551 | + } | ||
552 | + | ||
553 | + | ||
415 | public Long saveManagerDimDB(ManagerDTO manager, | 554 | public Long saveManagerDimDB(ManagerDTO manager, |
416 | LocalDate date, | 555 | LocalDate date, |
417 | Long reportSalaryId, | 556 | Long reportSalaryId, |
418 | Map<Long, StaffBaseInfoDTO> managerMap, | 557 | Map<Long, StaffBaseInfoDTO> managerMap, |
419 | - BigDecimal averageSalary, | ||
420 | - BigDecimal kpiScoreRatio, | ||
421 | - List<Long> manageStaffIds) { | 558 | + List<Long> manageStaffIds, |
559 | + Set<Long> managerStaffDimReportIds, | ||
560 | + List<ReportSalaryDim> userDims) { | ||
422 | ReportSalaryDim reportSalaryDim = new ReportSalaryDim(); | 561 | ReportSalaryDim reportSalaryDim = new ReportSalaryDim(); |
423 | reportSalaryDim.setDimension(ReportDimensionEnum.MANAGER); | 562 | reportSalaryDim.setDimension(ReportDimensionEnum.MANAGER); |
424 | reportSalaryDim.setUserId(manager.getStaffId()); | 563 | reportSalaryDim.setUserId(manager.getStaffId()); |
425 | reportSalaryDim.setUserName(manager.getStaffName()); | 564 | reportSalaryDim.setUserName(manager.getStaffName()); |
426 | - reportSalaryDim.setTotalReward(averageSalary); | ||
427 | - reportSalaryDim.setKpiScoreRatio(kpiScoreRatio); | 565 | + //计算平均值薪酬的额外项 |
566 | + extCalcAverage(userDims, managerStaffDimReportIds, reportSalaryDim); | ||
428 | reportSalaryDim.setDataDate(date); | 567 | reportSalaryDim.setDataDate(date); |
429 | reportSalaryDim.setReportSalaryId(reportSalaryId); | 568 | reportSalaryDim.setReportSalaryId(reportSalaryId); |
430 | if (managerMap.containsKey(manager.getStaffId())) { | 569 | if (managerMap.containsKey(manager.getStaffId())) { |
@@ -550,7 +689,25 @@ public class SalaryReportTask { | @@ -550,7 +689,25 @@ public class SalaryReportTask { | ||
550 | return userGroupIndicatorHitMap; | 689 | return userGroupIndicatorHitMap; |
551 | } | 690 | } |
552 | 691 | ||
553 | - | 692 | + /** |
693 | + * 这个薪酬详情每天6:00 会计算完成,cn.fw.morax.server.task.SalaryCalcTask#cacheCalculableKpiGroup() | ||
694 | + * @param date | ||
695 | + * @param pools | ||
696 | + * @return <薪酬池id: 薪酬池详情list> | ||
697 | + */ | ||
698 | + private Map<Long, List<SalaryPoolDetail>> getSalaryPoolDetailMap(LocalDate date, List<SalaryPool> pools) { | ||
699 | + if (CollectionUtils.isEmpty(pools)){ | ||
700 | + return Collections.emptyMap(); | ||
701 | + } | ||
702 | + List<SalaryPoolDetail> salaryPoolDetailList = salaryPoolDetailService.list(Wrappers.<SalaryPoolDetail>lambdaQuery() | ||
703 | + .in(SalaryPoolDetail::getSalaryPoolId, pools.stream().map(SalaryPool::getId).collect(Collectors.toSet())) | ||
704 | + .eq(SalaryPoolDetail::getSalaryDate, date) | ||
705 | + .eq(SalaryPoolDetail::getYn, Boolean.TRUE)); | ||
706 | + if (CollectionUtils.isEmpty(salaryPoolDetailList)){ | ||
707 | + return Collections.emptyMap(); | ||
708 | + } | ||
709 | + return salaryPoolDetailList.stream().collect(Collectors.groupingBy(SalaryPoolDetail::getSalaryPoolId)); | ||
710 | + } | ||
554 | 711 | ||
555 | public Map<Long, SalaryGroupProjectTargetHitLog> queryUserTargetValue(Long referId, Long userId, LocalDate dataDate) { | 712 | public Map<Long, SalaryGroupProjectTargetHitLog> queryUserTargetValue(Long referId, Long userId, LocalDate dataDate) { |
556 | List<SalaryGroupProjectTargetHitLog> targetHitLogs = salaryGroupProjectTargetHitLogService.list(Wrappers.<SalaryGroupProjectTargetHitLog>lambdaQuery() | 713 | List<SalaryGroupProjectTargetHitLog> targetHitLogs = salaryGroupProjectTargetHitLogService.list(Wrappers.<SalaryGroupProjectTargetHitLog>lambdaQuery() |
@@ -701,7 +858,8 @@ public class SalaryReportTask { | @@ -701,7 +858,8 @@ public class SalaryReportTask { | ||
701 | projectBO.setCodeType(codeType); | 858 | projectBO.setCodeType(codeType); |
702 | break; | 859 | break; |
703 | } | 860 | } |
704 | - case FIXATION: CAR_SERIES: { | 861 | + case FIXATION: |
862 | + case CAR_SERIES: { | ||
705 | projectBO.setCode(project.getCommissionCode()); | 863 | projectBO.setCode(project.getCommissionCode()); |
706 | projectBO.setCodeType(IndicatorCodeTypeEnum.COMBINE_INDICATOR); | 864 | projectBO.setCodeType(IndicatorCodeTypeEnum.COMBINE_INDICATOR); |
707 | break; | 865 | break; |
@@ -721,7 +879,7 @@ public class SalaryReportTask { | @@ -721,7 +879,7 @@ public class SalaryReportTask { | ||
721 | return projects; | 879 | return projects; |
722 | } | 880 | } |
723 | 881 | ||
724 | - public ReportSalaryDim saveStaffDim(SalaryPool pool, LocalDate date, Long reportSalaryRankId){ | 882 | + public ReportSalaryDim saveStaffDim(SalaryPool pool, LocalDate date, Long reportSalaryRankId,List<SalaryPoolDetail> salaryPoolDetails){ |
725 | ReportSalaryDim reportSalaryDim = new ReportSalaryDim(); | 883 | ReportSalaryDim reportSalaryDim = new ReportSalaryDim(); |
726 | reportSalaryDim.setDimension(ReportDimensionEnum.STAFF); | 884 | reportSalaryDim.setDimension(ReportDimensionEnum.STAFF); |
727 | reportSalaryDim.setReferId(pool.getUserId()); | 885 | reportSalaryDim.setReferId(pool.getUserId()); |
@@ -735,14 +893,32 @@ public class SalaryReportTask { | @@ -735,14 +893,32 @@ public class SalaryReportTask { | ||
735 | reportSalaryDim.setDataDate(date); | 893 | reportSalaryDim.setDataDate(date); |
736 | reportSalaryDim.setReportSalaryId(reportSalaryRankId); | 894 | reportSalaryDim.setReportSalaryId(reportSalaryRankId); |
737 | reportSalaryDim.setStarLevel(pool.getStarLevel()); | 895 | reportSalaryDim.setStarLevel(pool.getStarLevel()); |
738 | - reportSalaryDim.setTotalReward(pool.getReward()); | ||
739 | // KpiPool kpiPool = kpiPoolCommonService.queryPool(pool); | 896 | // KpiPool kpiPool = kpiPoolCommonService.queryPool(pool); |
740 | // if (PublicUtil.isNotEmpty(kpiPool)) { | 897 | // if (PublicUtil.isNotEmpty(kpiPool)) { |
741 | // BigDecimal kpiScoreRatio = Optional.ofNullable(kpiPool.getKpiScoreRatio()).orElse(BigDecimal.ZERO); | 898 | // BigDecimal kpiScoreRatio = Optional.ofNullable(kpiPool.getKpiScoreRatio()).orElse(BigDecimal.ZERO); |
742 | // reportSalaryDim.setKpiScoreRatio(kpiScoreRatio.multiply(Constant.ONE_HUNDRED)); | 899 | // reportSalaryDim.setKpiScoreRatio(kpiScoreRatio.multiply(Constant.ONE_HUNDRED)); |
743 | // } | 900 | // } |
901 | + //薪资类型相关项目处理 | ||
902 | + extCaleUserMoney(salaryPoolDetails, reportSalaryDim); | ||
744 | reportSalaryDimService.save(reportSalaryDim); | 903 | reportSalaryDimService.save(reportSalaryDim); |
745 | return reportSalaryDim; | 904 | return reportSalaryDim; |
746 | } | 905 | } |
747 | 906 | ||
907 | + /** | ||
908 | + * 获取 SalaryTypeEnum 对应的薪酬总值 | ||
909 | + * @param salaryTypeEnumListMap | ||
910 | + * @param salaryTypeEnum | ||
911 | + * @return | ||
912 | + */ | ||
913 | + private BigDecimal getSalaryTypeEnumMoney(Map<SalaryTypeEnum, List<SalaryPoolDetail>> salaryTypeEnumListMap,SalaryTypeEnum salaryTypeEnum){ | ||
914 | + if (CollectionUtils.isEmpty(salaryTypeEnumListMap)){ | ||
915 | + return BigDecimal.ZERO; | ||
916 | + } | ||
917 | + List<SalaryPoolDetail> list = salaryTypeEnumListMap.get(salaryTypeEnum); | ||
918 | + if (CollectionUtils.isEmpty(list)){ | ||
919 | + return BigDecimal.ZERO; | ||
920 | + } | ||
921 | + return list.stream().filter(Objects::nonNull).map(SalaryPoolDetail::getSalaryAmount).reduce(BigDecimal.ZERO, BigDecimal::add); | ||
922 | + } | ||
923 | + | ||
748 | } | 924 | } |