联特 季度绩效分段计算
This commit is contained in:
parent
ec2d5f6a36
commit
2bd545964a
|
|
@ -21,6 +21,7 @@ import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO;
|
|||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO;
|
||||
import com.engine.salary.enums.SalaryCycleTypeEnum;
|
||||
import com.engine.salary.enums.UserStatusEnum;
|
||||
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
|
||||
import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum;
|
||||
|
|
@ -142,12 +143,12 @@ public class CalculateFormulaVarBO {
|
|||
* @param salaryAcctCalculateBO 核算参数
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<FormulaVarValue>> convert2FormulaVar(SalaryAcctCalculateBO salaryAcctCalculateBO, KQGroupService kqGroupService) {
|
||||
public Map<String, List<FormulaVarValue>> convert2FormulaVar(SalaryAcctCalculateBO salaryAcctCalculateBO, KQGroupService kqGroupService, Integer attendCycleType) {
|
||||
Map<String, List<FormulaVarValue>> resultMap = Maps.newHashMapWithExpectedSize(salaryAcctCalculateBO.getSalaryAcctEmployeePOS().size());
|
||||
// 处理薪资核算结果
|
||||
handleSalaryAcctResult(salaryAcctCalculateBO, resultMap);
|
||||
// 处理薪资档案
|
||||
handleSalaryArchiveData(salaryAcctCalculateBO, resultMap, kqGroupService);
|
||||
handleSalaryArchiveData(salaryAcctCalculateBO, resultMap, kqGroupService, attendCycleType);
|
||||
// 处理浮动薪资档案
|
||||
handleVariableArchiveData(salaryAcctCalculateBO, resultMap);
|
||||
// 处理往期累计情况
|
||||
|
|
@ -275,16 +276,21 @@ public class CalculateFormulaVarBO {
|
|||
* @param salaryAcctCalculateBO 薪资核算参数
|
||||
* @param resultMap 返回结果集
|
||||
*/
|
||||
private void handleSalaryArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map<String, List<FormulaVarValue>> resultMap, KQGroupService kqGroupService) {
|
||||
private void handleSalaryArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map<String, List<FormulaVarValue>> resultMap, KQGroupService kqGroupService,Integer attendCycleType) {
|
||||
// 调薪计薪规则
|
||||
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobAdjustRulePOS(),
|
||||
SalarySobAdjustRulePO::getSalaryItemId);
|
||||
boolean isSeasonSob = false;
|
||||
if (attendCycleType != null && (attendCycleType.equals(SalaryCycleTypeEnum.THIS_SEASON.getValue()) || attendCycleType.equals(SalaryCycleTypeEnum.LAST_SEASON.getValue()) )) {
|
||||
// 联特 是季度账套
|
||||
isSeasonSob = true;
|
||||
}
|
||||
for (SalaryArchiveDataDTO salaryArchiveDataDTO : salaryArchiveData) {
|
||||
for (SalaryArchiveTaxAgentDataDTO salaryArchiveTaxAgentDataDTO : salaryArchiveDataDTO.getTaxAgents()) {
|
||||
String key = salaryArchiveDataDTO.getEmployeeId() + "_" + salaryArchiveTaxAgentDataDTO.getTaxAgentId();
|
||||
List<FormulaVarValue> formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList());
|
||||
// 将薪资档案的值转换成公式中的变量,填充到返回结果集中
|
||||
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap, kqGroupService, salaryArchiveDataDTO.getEmployeeId()));
|
||||
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap, kqGroupService, salaryArchiveDataDTO.getEmployeeId(), isSeasonSob));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -322,7 +328,8 @@ public class CalculateFormulaVarBO {
|
|||
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataList,
|
||||
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap,
|
||||
KQGroupService kqGroupService,
|
||||
Long employeeId) {
|
||||
Long employeeId,
|
||||
boolean isSeasonSob) {
|
||||
// 薪资周期
|
||||
LocalDateRange salaryCycle = salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle();
|
||||
// key:薪资项目的id、value:薪资项目的code
|
||||
|
|
@ -341,18 +348,18 @@ public class CalculateFormulaVarBO {
|
|||
SalarySobAdjustRulePO salaryAdjustmentRulePO = salarySobAdjustRulePOMap.get(entry.getKey());
|
||||
if (entry.getValue().size() > 2) {
|
||||
// 如果薪资项目在薪资周期内经历了多次调薪,则默认分段计薪
|
||||
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.PARTITION, entry.getValue(), kqGroupService, employeeId);
|
||||
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.PARTITION, entry.getValue(), kqGroupService, employeeId, isSeasonSob);
|
||||
} else if (salaryAdjustmentRulePO == null || entry.getValue().size() < 2) {
|
||||
// 如果薪资项目没有设置调薪计薪规则,默认取薪资周期内薪资档案中最新的值
|
||||
// 如果薪资项目在薪资周期内没有调薪,默认取薪资周期内薪资档案中最新的值
|
||||
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_AFTER_ADJUSTMENT, entry.getValue(), kqGroupService, employeeId);
|
||||
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_AFTER_ADJUSTMENT, entry.getValue(), kqGroupService, employeeId, isSeasonSob);
|
||||
} else {
|
||||
// 如果薪资项目在薪资周期内只有一次调薪,则根据调薪计薪规则处理
|
||||
SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum = salaryAdjustmentRulePO.getDayOfMonth() < SalaryDateUtil.dateToLocalDate(entry.getValue().get(0).getEffectiveDateRange().getEndDate()).getDayOfMonth()
|
||||
? SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getAfterAdjustmentType())
|
||||
: SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getBeforeAdjustmentType());
|
||||
// 根据调薪计薪规则处理薪资档案的调薪
|
||||
value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue(), kqGroupService, employeeId);
|
||||
value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue(), kqGroupService, employeeId, isSeasonSob);
|
||||
}
|
||||
String fieldId = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue()
|
||||
+ SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR
|
||||
|
|
@ -373,7 +380,8 @@ public class CalculateFormulaVarBO {
|
|||
SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum,
|
||||
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataDTOS,
|
||||
KQGroupService kqGroupService,
|
||||
Long employeeId) {
|
||||
Long employeeId,
|
||||
boolean isSeasonSob) {
|
||||
if (Objects.isNull(adjustRuleTypeEnum)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
|
@ -392,6 +400,9 @@ public class CalculateFormulaVarBO {
|
|||
// BigDecimal valueSum = BigDecimal.ZERO;
|
||||
BigDecimal firstValue = BigDecimal.ZERO;
|
||||
BigDecimal baseValue = new BigDecimal("21.75");
|
||||
if (isSeasonSob) {
|
||||
baseValue = baseValue.multiply(new BigDecimal(3));
|
||||
}
|
||||
// 调薪补差金额
|
||||
BigDecimal needAddValue = new BigDecimal(0);
|
||||
if (CollectionUtils.isNotEmpty(salaryArchiveItemDataDTOS)) {
|
||||
|
|
@ -400,7 +411,7 @@ public class CalculateFormulaVarBO {
|
|||
BaseBean baseBean = new BaseBean();
|
||||
baseBean.writeLog("ltsize"+salaryArchiveItemDataDTOS.size());
|
||||
for (int i = 1; i < salaryArchiveItemDataDTOS.size(); i++) {
|
||||
// 科蓝柏二开:调薪前工资+(调薪后工资-调薪前工资)/21.75*(调薪后的应出勤天数+调薪后的法定节假日天数)
|
||||
// 联特二开:调薪前工资+(调薪后工资-调薪前工资)/21.75*(调薪后的应出勤天数+调薪后的法定节假日天数)
|
||||
SalaryArchiveItemDataDTO dataDTO = salaryArchiveItemDataDTOS.get(i);
|
||||
// 获取应出勤日期+法定节假日
|
||||
Double ycq = new Double(0);
|
||||
|
|
|
|||
|
|
@ -47,9 +47,22 @@ public class SalarySobCycleBO {
|
|||
LocalDateRange salaryCycle = salarySobCycleDTO.getSalaryCycle();
|
||||
salarySobCycleDTO.setSalaryCycleFromDate(salaryCycle.getFromDate());
|
||||
salarySobCycleDTO.setSalaryCycleEndDate(salaryCycle.getEndDate());
|
||||
// 联特 处理季度考勤周期
|
||||
if (salarySob.getAttendCycleType().equals(SalaryCycleTypeEnum.THIS_SEASON.getValue())) {
|
||||
LocalDateRange attendCycle = SalaryDateUtil.getSeasonRangeByDate(salaryMonth, 0);
|
||||
salarySobCycleDTO.setAttendCycle(attendCycle);
|
||||
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());
|
||||
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate());
|
||||
} else if (salarySob.getAttendCycleType().equals(SalaryCycleTypeEnum.LAST_SEASON.getValue())) {
|
||||
LocalDateRange attendCycle = SalaryDateUtil.getSeasonRangeByDate(salaryMonth, -1);
|
||||
salarySobCycleDTO.setAttendCycle(attendCycle);
|
||||
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());
|
||||
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate());
|
||||
} else {
|
||||
LocalDateRange attendCycle = salarySobCycleDTO.getAttendCycle();
|
||||
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());
|
||||
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate());
|
||||
}
|
||||
|
||||
return salarySobCycleDTO;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ public enum SalaryCycleTypeEnum implements BaseEnum<Integer> {
|
|||
LAST_MONTH(2, "上月", 86074),
|
||||
THIS_MONTH(3, "本月", 86072),
|
||||
NEXT_MONTH(4, "下月", 86073),
|
||||
AFTER_NEXT_MONTH(5, "下下月", 0);
|
||||
AFTER_NEXT_MONTH(5, "下下月", 0),
|
||||
THIS_SEASON(10, "本季度", 0),
|
||||
LAST_SEASON(11, "上季度", 0);
|
||||
|
||||
private int value;
|
||||
|
||||
|
|
|
|||
|
|
@ -283,6 +283,9 @@ public class PushServiceImpl extends Service implements PushService {
|
|||
//查询薪资核算记录的薪资周期、考勤周期等
|
||||
SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordPO.getId());
|
||||
|
||||
// 获取薪资账套
|
||||
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
|
||||
|
||||
SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO()
|
||||
.setSalaryAcctRecordPO(salaryAcctRecordPO)
|
||||
.setSalarySobPO(new SalarySobPO())
|
||||
|
|
@ -312,7 +315,7 @@ public class PushServiceImpl extends Service implements PushService {
|
|||
|
||||
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), salaryAcctResultPOS, new ArrayList<>(), new ArrayList<>());
|
||||
KQGroupService kqGroupService = getKQGroupService();
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService);
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService, salarySobPO.getAttendCycleType());
|
||||
|
||||
//推送记录id
|
||||
List<Long> recordIds = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
|||
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
||||
import com.engine.salary.enums.SalaryCycleTypeEnum;
|
||||
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
|
||||
import com.engine.salary.formlua.entity.standard.ExcelResult;
|
||||
import com.engine.salary.service.*;
|
||||
|
|
@ -140,6 +141,12 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
// 2、查询薪资档案的数据
|
||||
sw.start("查询薪资档案的数据");
|
||||
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
|
||||
// 联特二开,需要判断考勤周期是不是设置的季度
|
||||
Integer attendCycleType = salaryAcctCalculateBO.getSalarySobPO().getAttendCycleType();
|
||||
if (attendCycleType.equals(SalaryCycleTypeEnum.THIS_SEASON.getValue()) || attendCycleType.equals(SalaryCycleTypeEnum.LAST_SEASON.getValue())) {
|
||||
salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getAttendCycle(), employeeIds, taxAgentIds);
|
||||
}
|
||||
|
||||
sw.stop();
|
||||
// 3、查询往期累计情况(查询的是上个税款所属期的的累计情况)
|
||||
sw.start("查询往期累计情况");
|
||||
|
|
@ -207,7 +214,7 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
sw.start("转换成公式编辑器中的变量");
|
||||
KQGroupService kqGroupService = getKQGroupService();
|
||||
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList,lastMonthResultPOS);
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService);
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService, attendCycleType);
|
||||
sw.stop();
|
||||
sw.start("数据结构准备");
|
||||
// 本次薪资核算所用的薪资账套下的薪资项目
|
||||
|
|
|
|||
|
|
@ -617,6 +617,33 @@ public class SalaryDateUtil {
|
|||
LocalDate localDate = SalaryDateUtil.dateToLocalDate(date).plusMonths(i);
|
||||
return SalaryDateUtil.localDateToDate(localDate);
|
||||
}
|
||||
|
||||
|
||||
public static LocalDateRange getSeasonRangeByDate(YearMonth yearMonth, int i) {
|
||||
if (yearMonth == null) {
|
||||
return LocalDateRange.builder().build();
|
||||
}
|
||||
int month = yearMonth.getMonthValue();
|
||||
int year = yearMonth.getYear();
|
||||
|
||||
// 计算季度开始月份
|
||||
int startMonth = ((month - 1) / 3) * 3 + 1;
|
||||
// 计算季度结束月份
|
||||
int endMonth = startMonth + 2;
|
||||
|
||||
LocalDate startDate = LocalDate.of(year, startMonth, 1);
|
||||
LocalDate endDate = LocalDate.of(year, endMonth, Month.of(endMonth).maxLength());
|
||||
if (i != 0) {
|
||||
startDate = startDate.plusMonths(3 * i);
|
||||
endDate = endDate.plusMonths(3 * i);
|
||||
endDate = endDate.withDayOfMonth(Month.of(endDate.getMonthValue()).maxLength());
|
||||
}
|
||||
|
||||
return LocalDateRange.builder()
|
||||
.fromDate(localDateToDate(startDate))
|
||||
.endDate(localDateToDate(endDate))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue