Merge remote-tracking branch 'origin/custom/联特' into custom/联特

This commit is contained in:
钱涛 2025-04-29 09:20:26 +08:00
commit cc510db3cc
6 changed files with 79 additions and 16 deletions

View File

@ -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.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; 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.UserStatusEnum;
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum;
@ -142,12 +143,12 @@ public class CalculateFormulaVarBO {
* @param salaryAcctCalculateBO 核算参数 * @param salaryAcctCalculateBO 核算参数
* @return * @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()); Map<String, List<FormulaVarValue>> resultMap = Maps.newHashMapWithExpectedSize(salaryAcctCalculateBO.getSalaryAcctEmployeePOS().size());
// 处理薪资核算结果 // 处理薪资核算结果
handleSalaryAcctResult(salaryAcctCalculateBO, resultMap); handleSalaryAcctResult(salaryAcctCalculateBO, resultMap);
// 处理薪资档案 // 处理薪资档案
handleSalaryArchiveData(salaryAcctCalculateBO, resultMap, kqGroupService); handleSalaryArchiveData(salaryAcctCalculateBO, resultMap, kqGroupService, attendCycleType);
// 处理浮动薪资档案 // 处理浮动薪资档案
handleVariableArchiveData(salaryAcctCalculateBO, resultMap); handleVariableArchiveData(salaryAcctCalculateBO, resultMap);
// 处理往期累计情况 // 处理往期累计情况
@ -275,16 +276,21 @@ public class CalculateFormulaVarBO {
* @param salaryAcctCalculateBO 薪资核算参数 * @param salaryAcctCalculateBO 薪资核算参数
* @param resultMap 返回结果集 * @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(), Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobAdjustRulePOS(),
SalarySobAdjustRulePO::getSalaryItemId); 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 (SalaryArchiveDataDTO salaryArchiveDataDTO : salaryArchiveData) {
for (SalaryArchiveTaxAgentDataDTO salaryArchiveTaxAgentDataDTO : salaryArchiveDataDTO.getTaxAgents()) { for (SalaryArchiveTaxAgentDataDTO salaryArchiveTaxAgentDataDTO : salaryArchiveDataDTO.getTaxAgents()) {
String key = salaryArchiveDataDTO.getEmployeeId() + "_" + salaryArchiveTaxAgentDataDTO.getTaxAgentId(); String key = salaryArchiveDataDTO.getEmployeeId() + "_" + salaryArchiveTaxAgentDataDTO.getTaxAgentId();
List<FormulaVarValue> formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); 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, List<SalaryArchiveItemDataDTO> salaryArchiveItemDataList,
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap, Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap,
KQGroupService kqGroupService, KQGroupService kqGroupService,
Long employeeId) { Long employeeId,
boolean isSeasonSob) {
// 薪资周期 // 薪资周期
LocalDateRange salaryCycle = salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle(); LocalDateRange salaryCycle = salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle();
// key:薪资项目的idvalue:薪资项目的code // key:薪资项目的idvalue:薪资项目的code
@ -341,18 +348,18 @@ public class CalculateFormulaVarBO {
SalarySobAdjustRulePO salaryAdjustmentRulePO = salarySobAdjustRulePOMap.get(entry.getKey()); SalarySobAdjustRulePO salaryAdjustmentRulePO = salarySobAdjustRulePOMap.get(entry.getKey());
if (entry.getValue().size() > 2) { 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) { } 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 { } else {
// 如果薪资项目在薪资周期内只有一次调薪则根据调薪计薪规则处理 // 如果薪资项目在薪资周期内只有一次调薪则根据调薪计薪规则处理
SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum = salaryAdjustmentRulePO.getDayOfMonth() < SalaryDateUtil.dateToLocalDate(entry.getValue().get(0).getEffectiveDateRange().getEndDate()).getDayOfMonth() SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum = salaryAdjustmentRulePO.getDayOfMonth() < SalaryDateUtil.dateToLocalDate(entry.getValue().get(0).getEffectiveDateRange().getEndDate()).getDayOfMonth()
? SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getAfterAdjustmentType()) ? SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getAfterAdjustmentType())
: SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getBeforeAdjustmentType()); : 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() String fieldId = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue()
+ SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR
@ -373,7 +380,8 @@ public class CalculateFormulaVarBO {
SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum, SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum,
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataDTOS, List<SalaryArchiveItemDataDTO> salaryArchiveItemDataDTOS,
KQGroupService kqGroupService, KQGroupService kqGroupService,
Long employeeId) { Long employeeId,
boolean isSeasonSob) {
if (Objects.isNull(adjustRuleTypeEnum)) { if (Objects.isNull(adjustRuleTypeEnum)) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@ -392,6 +400,9 @@ public class CalculateFormulaVarBO {
// BigDecimal valueSum = BigDecimal.ZERO; // BigDecimal valueSum = BigDecimal.ZERO;
BigDecimal firstValue = BigDecimal.ZERO; BigDecimal firstValue = BigDecimal.ZERO;
BigDecimal baseValue = new BigDecimal("21.75"); BigDecimal baseValue = new BigDecimal("21.75");
if (isSeasonSob) {
baseValue = baseValue.multiply(new BigDecimal(3));
}
// 调薪补差金额 // 调薪补差金额
BigDecimal needAddValue = new BigDecimal(0); BigDecimal needAddValue = new BigDecimal(0);
if (CollectionUtils.isNotEmpty(salaryArchiveItemDataDTOS)) { if (CollectionUtils.isNotEmpty(salaryArchiveItemDataDTOS)) {
@ -400,7 +411,7 @@ public class CalculateFormulaVarBO {
BaseBean baseBean = new BaseBean(); BaseBean baseBean = new BaseBean();
baseBean.writeLog("ltsize"+salaryArchiveItemDataDTOS.size()); baseBean.writeLog("ltsize"+salaryArchiveItemDataDTOS.size());
for (int i = 1; i < salaryArchiveItemDataDTOS.size(); i++) { for (int i = 1; i < salaryArchiveItemDataDTOS.size(); i++) {
// 科蓝柏二开调薪前工资+调薪后工资-调薪前工资/21.75*调薪后的应出勤天数+调薪后的法定节假日天数 // 联特二开调薪前工资+调薪后工资-调薪前工资/21.75*调薪后的应出勤天数+调薪后的法定节假日天数
SalaryArchiveItemDataDTO dataDTO = salaryArchiveItemDataDTOS.get(i); SalaryArchiveItemDataDTO dataDTO = salaryArchiveItemDataDTOS.get(i);
// 获取应出勤日期+法定节假日 // 获取应出勤日期+法定节假日
Double ycq = new Double(0); Double ycq = new Double(0);

View File

@ -47,9 +47,22 @@ public class SalarySobCycleBO {
LocalDateRange salaryCycle = salarySobCycleDTO.getSalaryCycle(); LocalDateRange salaryCycle = salarySobCycleDTO.getSalaryCycle();
salarySobCycleDTO.setSalaryCycleFromDate(salaryCycle.getFromDate()); salarySobCycleDTO.setSalaryCycleFromDate(salaryCycle.getFromDate());
salarySobCycleDTO.setSalaryCycleEndDate(salaryCycle.getEndDate()); salarySobCycleDTO.setSalaryCycleEndDate(salaryCycle.getEndDate());
LocalDateRange attendCycle = salarySobCycleDTO.getAttendCycle(); // 联特 处理季度考勤周期
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate()); if (salarySob.getAttendCycleType().equals(SalaryCycleTypeEnum.THIS_SEASON.getValue())) {
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate()); 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; return salarySobCycleDTO;
} }

View File

@ -17,7 +17,9 @@ public enum SalaryCycleTypeEnum implements BaseEnum<Integer> {
LAST_MONTH(2, "上月", 86074), LAST_MONTH(2, "上月", 86074),
THIS_MONTH(3, "本月", 86072), THIS_MONTH(3, "本月", 86072),
NEXT_MONTH(4, "下月", 86073), 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; private int value;

View File

@ -283,6 +283,9 @@ public class PushServiceImpl extends Service implements PushService {
//查询薪资核算记录的薪资周期考勤周期等 //查询薪资核算记录的薪资周期考勤周期等
SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordPO.getId()); SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordPO.getId());
// 获取薪资账套
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO() SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO()
.setSalaryAcctRecordPO(salaryAcctRecordPO) .setSalaryAcctRecordPO(salaryAcctRecordPO)
.setSalarySobPO(new SalarySobPO()) .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<>()); 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(); 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 //推送记录id
List<Long> recordIds = new ArrayList<>(); List<Long> recordIds = new ArrayList<>();

View File

@ -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.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO; 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.enums.salaryformula.SalaryFormulaReferenceEnum;
import com.engine.salary.formlua.entity.standard.ExcelResult; import com.engine.salary.formlua.entity.standard.ExcelResult;
import com.engine.salary.service.*; import com.engine.salary.service.*;
@ -140,6 +141,12 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
// 2查询薪资档案的数据 // 2查询薪资档案的数据
sw.start("查询薪资档案的数据"); sw.start("查询薪资档案的数据");
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); 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(); sw.stop();
// 3查询往期累计情况(查询的是上个税款所属期的的累计情况) // 3查询往期累计情况(查询的是上个税款所属期的的累计情况)
sw.start("查询往期累计情况"); sw.start("查询往期累计情况");
@ -207,7 +214,7 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
sw.start("转换成公式编辑器中的变量"); sw.start("转换成公式编辑器中的变量");
KQGroupService kqGroupService = getKQGroupService(); KQGroupService kqGroupService = getKQGroupService();
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList,lastMonthResultPOS); 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.stop();
sw.start("数据结构准备"); sw.start("数据结构准备");
// 本次薪资核算所用的薪资账套下的薪资项目 // 本次薪资核算所用的薪资账套下的薪资项目

View File

@ -617,6 +617,33 @@ public class SalaryDateUtil {
LocalDate localDate = SalaryDateUtil.dateToLocalDate(date).plusMonths(i); LocalDate localDate = SalaryDateUtil.dateToLocalDate(date).plusMonths(i);
return SalaryDateUtil.localDateToDate(localDate); 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();
}
} }