五院分段计算
This commit is contained in:
parent
d93236c0c0
commit
2ae00ca581
|
|
@ -1,6 +1,8 @@
|
|||
package com.engine.salary.entity.salaryacct.bo;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.engine.kq.service.KQGroupService;
|
||||
import com.engine.salary.annotation.SalaryFormulaVar;
|
||||
import com.engine.salary.common.LocalDateRange;
|
||||
import com.engine.salary.constant.SalaryFormulaFieldConstant;
|
||||
|
|
@ -24,16 +26,22 @@ import com.engine.salary.enums.UserStatusEnum;
|
|||
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
|
||||
import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum;
|
||||
import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum;
|
||||
import com.engine.salary.mapper.SQLMapper;
|
||||
import com.engine.salary.util.JsonUtil;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mzlion.core.lang.CollectionUtils;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -66,6 +74,8 @@ public class CalculateFormulaVarBO {
|
|||
*/
|
||||
private List<SalaryArchiveDataDTO> salaryArchiveData;
|
||||
|
||||
private List<SalaryArchiveDataDTO> lastMonthSalaryArchiveData;
|
||||
|
||||
/**
|
||||
* 累计情况
|
||||
*/
|
||||
|
|
@ -106,6 +116,11 @@ public class CalculateFormulaVarBO {
|
|||
*/
|
||||
List<SalaryAcctResultPO> lastMonthResultPOS;
|
||||
|
||||
private SQLMapper getSQLMapper() {
|
||||
return MapperProxyFactory.getProxy(SQLMapper.class);
|
||||
}
|
||||
|
||||
|
||||
public CalculateFormulaVarBO(List<DataCollectionEmployee> simpleEmployees,
|
||||
List<SalaryArchiveDataDTO> salaryArchiveData,
|
||||
List<AddUpSituation> addUpSituationPOS,
|
||||
|
|
@ -115,7 +130,8 @@ public class CalculateFormulaVarBO {
|
|||
List<AttendQuoteDataDTO> attendQuoteDataDTOS,
|
||||
List<SalaryAcctResultPO> salaryAcctResultPOS,
|
||||
List<Map<String, Object>> variableArchiveList,
|
||||
List<SalaryAcctResultPO> lastMonthResultPOS) {
|
||||
List<SalaryAcctResultPO> lastMonthResultPOS,
|
||||
List<SalaryArchiveDataDTO> lastMonthSalaryArchiveData) {
|
||||
this.simpleEmployees = simpleEmployees;
|
||||
this.salaryArchiveData = salaryArchiveData;
|
||||
this.addUpSituationPOS = addUpSituationPOS;
|
||||
|
|
@ -126,6 +142,7 @@ public class CalculateFormulaVarBO {
|
|||
this.salaryAcctResultPOS = salaryAcctResultPOS;
|
||||
this.variableArchiveList = variableArchiveList;
|
||||
this.lastMonthResultPOS = lastMonthResultPOS;
|
||||
this.lastMonthSalaryArchiveData = lastMonthSalaryArchiveData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -134,12 +151,12 @@ public class CalculateFormulaVarBO {
|
|||
* @param salaryAcctCalculateBO 核算参数
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<FormulaVarValue>> convert2FormulaVar(SalaryAcctCalculateBO salaryAcctCalculateBO) {
|
||||
public Map<String, List<FormulaVarValue>> convert2FormulaVar(SalaryAcctCalculateBO salaryAcctCalculateBO, KQGroupService kqGroupService) {
|
||||
Map<String, List<FormulaVarValue>> resultMap = Maps.newHashMapWithExpectedSize(salaryAcctCalculateBO.getSalaryAcctEmployeePOS().size());
|
||||
// 处理薪资核算结果
|
||||
handleSalaryAcctResult(salaryAcctCalculateBO, resultMap);
|
||||
// 处理薪资档案
|
||||
handleSalaryArchiveData(salaryAcctCalculateBO, resultMap);
|
||||
handleSalaryArchiveData(salaryAcctCalculateBO, resultMap, kqGroupService);
|
||||
// 处理浮动薪资档案
|
||||
handleVariableArchiveData(salaryAcctCalculateBO, resultMap);
|
||||
// 处理往期累计情况
|
||||
|
|
@ -267,16 +284,33 @@ public class CalculateFormulaVarBO {
|
|||
* @param salaryAcctCalculateBO 薪资核算参数
|
||||
* @param resultMap 返回结果集
|
||||
*/
|
||||
private void handleSalaryArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map<String, List<FormulaVarValue>> resultMap) {
|
||||
private void handleSalaryArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map<String, List<FormulaVarValue>> resultMap, KQGroupService kqGroupService) {
|
||||
// 调薪计薪规则
|
||||
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobAdjustRulePOS(),
|
||||
SalarySobAdjustRulePO::getSalaryItemId);
|
||||
Map<Long, SalaryArchiveDataDTO> lastMonthSalaryArchiveDataMap = SalaryEntityUtil.convert2Map(lastMonthSalaryArchiveData, SalaryArchiveDataDTO::getEmployeeId);
|
||||
// 获取3个档案的薪资项目id
|
||||
BaseBean baseBean = new BaseBean();
|
||||
Long jbgzItemId = NumberUtils.isCreatable(baseBean.getPropValue("wyhzzxSalary", "jbgz_item_id")) ? Long.valueOf(baseBean.getPropValue("wyhzzxSalary", "jbgz_item_id")) : 0L;
|
||||
Long gwgzItemId = NumberUtils.isCreatable(baseBean.getPropValue("wyhzzxSalary", "gwgz_item_id")) ? Long.valueOf(baseBean.getPropValue("wyhzzxSalary", "gwgz_item_id")) : 0L;
|
||||
Long jxgzItemId = NumberUtils.isCreatable(baseBean.getPropValue("wyhzzxSalary", "jxgz_item_id")) ? Long.valueOf(baseBean.getPropValue("wyhzzxSalary", "jxgz_item_id")) : 0L;
|
||||
|
||||
for (SalaryArchiveDataDTO salaryArchiveDataDTO : salaryArchiveData) {
|
||||
SalaryArchiveDataDTO lastMonthSalaryArchiveDataDTO = lastMonthSalaryArchiveDataMap.get(salaryArchiveDataDTO.getEmployeeId()) == null
|
||||
? SalaryArchiveDataDTO.builder().taxAgents(new ArrayList<>()).build() : lastMonthSalaryArchiveDataMap.get(salaryArchiveDataDTO.getEmployeeId());
|
||||
List<SalaryArchiveTaxAgentDataDTO> lastMonthSalaryArchiveTaxAgentDataList = lastMonthSalaryArchiveDataDTO.getTaxAgents() == null ? new ArrayList<>() : lastMonthSalaryArchiveDataDTO.getTaxAgents();
|
||||
|
||||
for (SalaryArchiveTaxAgentDataDTO salaryArchiveTaxAgentDataDTO : salaryArchiveDataDTO.getTaxAgents()) {
|
||||
String key = salaryArchiveDataDTO.getEmployeeId() + "_" + salaryArchiveTaxAgentDataDTO.getTaxAgentId();
|
||||
List<FormulaVarValue> formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList());
|
||||
|
||||
Optional<SalaryArchiveTaxAgentDataDTO> lastMonthDataDTOOptional = lastMonthSalaryArchiveTaxAgentDataList.stream().filter(dto -> dto.getTaxAgentId().equals(salaryArchiveTaxAgentDataDTO.getTaxAgentId())).findFirst();
|
||||
List<SalaryArchiveItemDataDTO> lastMonthSalaryItemValues = new ArrayList<>();
|
||||
if (lastMonthDataDTOOptional.isPresent()) {
|
||||
lastMonthSalaryItemValues = lastMonthDataDTOOptional.get().getSalaryItemValues();
|
||||
}
|
||||
// 将薪资档案的值转换成公式中的变量,填充到返回结果集中
|
||||
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap));
|
||||
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap, lastMonthSalaryItemValues, kqGroupService, salaryArchiveDataDTO.getEmployeeId(), jbgzItemId, gwgzItemId, jxgzItemId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -312,7 +346,11 @@ public class CalculateFormulaVarBO {
|
|||
*/
|
||||
private List<FormulaVarValue> handleSalaryArchiveItemVal(SalaryAcctCalculateBO salaryAcctCalculateBO,
|
||||
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataList,
|
||||
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap) {
|
||||
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap,
|
||||
List<SalaryArchiveItemDataDTO> lastMonthSalaryItemValues,
|
||||
KQGroupService kqGroupService, Long employeeId,
|
||||
Long jbgzItemId, Long gwgzItemId, Long jxgzItemId) {
|
||||
DataCollectionEmployee employee = simpleEmployees.stream().filter(emp -> emp.getEmployeeId().equals(employeeId)).findFirst().orElse(null);
|
||||
// 薪资周期
|
||||
LocalDateRange salaryCycle = salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle();
|
||||
// key:薪资项目的id、value:薪资项目的code
|
||||
|
|
@ -323,6 +361,16 @@ public class CalculateFormulaVarBO {
|
|||
Collectors.collectingAndThen(Collectors.toList(), salaryArchiveItemDataDTOS -> salaryArchiveItemDataDTOS.stream()
|
||||
.sorted(Comparator.comparing(salaryArchiveItemDataDTO -> salaryArchiveItemDataDTO.getEffectiveDateRange().getFromDate()))
|
||||
.collect(Collectors.toList()))));
|
||||
|
||||
// 上月薪资周期
|
||||
LocalDateRange lastMonthSalaryCycle = salaryAcctCalculateBO.getLastMonthSalarySobCycleDTO().getSalaryCycle();
|
||||
// 将薪资档案的调薪记录按照薪资项目id聚合(同一个薪资项目可能存在多次调薪,按照生效日期对调薪记录排序)
|
||||
Map<Long, List<SalaryArchiveItemDataDTO>> lastMonthdataMap = lastMonthSalaryItemValues.stream()
|
||||
.collect(Collectors.groupingBy(SalaryArchiveItemDataDTO::getSalaryItemId,
|
||||
Collectors.collectingAndThen(Collectors.toList(), salaryArchiveItemDataDTOS -> salaryArchiveItemDataDTOS.stream()
|
||||
.sorted(Comparator.comparing(salaryArchiveItemDataDTO -> salaryArchiveItemDataDTO.getEffectiveDateRange().getFromDate()))
|
||||
.collect(Collectors.toList()))));
|
||||
|
||||
// 将薪资档案的值转换成公式编辑器中的变量
|
||||
List<FormulaVarValue> formulaVarValues = Lists.newArrayListWithExpectedSize(dataMap.size());
|
||||
for (Map.Entry<Long, List<SalaryArchiveItemDataDTO>> entry : dataMap.entrySet()) {
|
||||
|
|
@ -344,6 +392,20 @@ public class CalculateFormulaVarBO {
|
|||
// 根据调薪计薪规则处理薪资档案的调薪
|
||||
value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue());
|
||||
}
|
||||
|
||||
if (entry.getKey().equals(jbgzItemId) || entry.getKey().equals(gwgzItemId) || entry.getKey().equals(jxgzItemId)) {
|
||||
List<SalaryArchiveItemDataDTO> lastMonthEntryValue = lastMonthdataMap.get(entry.getKey());
|
||||
// 绩效工资是需要获取上月的值(调薪前)
|
||||
if (entry.getKey().equals(jxgzItemId)) {
|
||||
value = CollectionUtils.isEmpty(lastMonthEntryValue) ? "0" : lastMonthEntryValue.get(0).getValue();
|
||||
}
|
||||
// 获取上月是否发生了调薪,并计算需要补的金额
|
||||
BigDecimal supplementValue = getNeedSupplementValue(entry.getKey(), employeeId, employee,
|
||||
lastMonthEntryValue, lastMonthSalaryCycle, kqGroupService, jxgzItemId);
|
||||
if (supplementValue != null) {
|
||||
value = (NumberUtils.isCreatable(value) ? new BigDecimal(value) : new BigDecimal("0")).add(supplementValue).toString();
|
||||
}
|
||||
}
|
||||
String fieldId = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue()
|
||||
+ SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR
|
||||
+ salaryItemCodeMap.getOrDefault(entry.getKey(), StringUtils.EMPTY);
|
||||
|
|
@ -352,6 +414,170 @@ public class CalculateFormulaVarBO {
|
|||
return formulaVarValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ClassName CalculateFormulaVarBO
|
||||
* @author Harryxzy
|
||||
* @date 2025/5/14 13:58
|
||||
* @description 获取上月是否发生了调薪,并计算需要补的金额
|
||||
*/
|
||||
private BigDecimal getNeedSupplementValue(Long salaryItemId, Long employeeId, DataCollectionEmployee employee,
|
||||
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataDTOS,
|
||||
LocalDateRange lastMonthSalaryCycle, KQGroupService kqGroupService,
|
||||
Long jxgzItemId) {
|
||||
if (CollectionUtils.isEmpty(salaryArchiveItemDataDTOS) || salaryArchiveItemDataDTOS.size() < 2) {
|
||||
// 上月没有值,或没有发生调薪
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 绩效工资,只有是入职月、离职月才计算
|
||||
if (salaryItemId.equals(jxgzItemId)) {
|
||||
if (employee == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
Date fromDate = lastMonthSalaryCycle.getFromDate();
|
||||
Date endDate = lastMonthSalaryCycle.getEndDate();
|
||||
Date dismissDate = SalaryDateUtil.stringToDate(employee.getDismissdate());
|
||||
Date companystartdate = SalaryDateUtil.stringToDate(employee.getCompanystartdate());
|
||||
boolean needAccount = false;
|
||||
if (dismissDate != null && DateUtil.isIn(dismissDate, fromDate, endDate)) {
|
||||
needAccount = true;
|
||||
}
|
||||
if (companystartdate != null && DateUtil.isIn(companystartdate, fromDate, endDate)) {
|
||||
needAccount = true;
|
||||
}
|
||||
if (!needAccount) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
// 可能存在多次调薪
|
||||
// = (第一段的值*第一段的自然日+第二段的值*第二段的自然日+……)/薪资所属月自然日
|
||||
// BigDecimal valueSum = BigDecimal.ZERO;
|
||||
BigDecimal firstValue = BigDecimal.ZERO;
|
||||
BigDecimal baseValue = new BigDecimal("21.75");
|
||||
// 调薪补差金额
|
||||
BigDecimal needAddValue = new BigDecimal(0);
|
||||
if (CollectionUtils.isNotEmpty(salaryArchiveItemDataDTOS)) {
|
||||
firstValue = SalaryEntityUtil.empty2Zero(salaryArchiveItemDataDTOS.get(0).getValue());
|
||||
}
|
||||
BaseBean baseBean = new BaseBean();
|
||||
baseBean.writeLog("wysize"+salaryArchiveItemDataDTOS.size());
|
||||
for (int i = 1; i < salaryArchiveItemDataDTOS.size(); i++) {
|
||||
// 五院二开:调薪前工资+(调薪后工资-调薪前工资)/21.75*(调薪后的应出勤天数+调薪后的法定节假日天数)
|
||||
SalaryArchiveItemDataDTO dataDTO = salaryArchiveItemDataDTOS.get(i);
|
||||
// 获取应出勤日期+法定节假日
|
||||
BigDecimal ycq = new BigDecimal("0");
|
||||
BigDecimal fdjjr = new BigDecimal("0");
|
||||
if (Objects.equals(i, salaryArchiveItemDataDTOS.size() - 1)) {
|
||||
ycq = getKQScq(dataDTO.getEffectiveDateRange().getFromDate(), dataDTO.getEffectiveDateRange().getEndDate(), employeeId);
|
||||
fdjjr = getFdjjr(SalaryDateUtil.getFormatDate(dataDTO.getEffectiveDateRange().getFromDate()), SalaryDateUtil.getFormatDate(dataDTO.getEffectiveDateRange().getEndDate()), employeeId.toString(), kqGroupService);
|
||||
} else {
|
||||
// 不是最后一个,需要往前挪1天
|
||||
Date endDate = SalaryDateUtil.localDateToDate(SalaryDateUtil.dateToLocalDate(dataDTO.getEffectiveDateRange().getEndDate()).minusDays(1));
|
||||
ycq = getKQScq(dataDTO.getEffectiveDateRange().getFromDate(), endDate, employeeId);
|
||||
fdjjr = getFdjjr(SalaryDateUtil.getFormatDate(dataDTO.getEffectiveDateRange().getFromDate()), SalaryDateUtil.getFormatDate(endDate), employeeId.toString(), kqGroupService);
|
||||
}
|
||||
baseBean.writeLog("wy-ycq" +ycq);
|
||||
BigDecimal days = ycq.add(fdjjr);
|
||||
if (days.compareTo(baseValue) > 0) {
|
||||
days = baseValue;
|
||||
}
|
||||
needAddValue = needAddValue.add(SalaryEntityUtil.empty2Zero(dataDTO.getValue()).subtract(firstValue).divide(baseValue, 15, RoundingMode.HALF_UP).multiply(days));
|
||||
|
||||
}
|
||||
baseBean.writeLog("wy-ycq" +needAddValue);
|
||||
return needAddValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取应出勤时数
|
||||
* @param fromDate
|
||||
* @param endDate
|
||||
* @param userId
|
||||
*/
|
||||
private BigDecimal getKQScq(Date fromDate, Date endDate, Long userId) {
|
||||
double scq = 0;
|
||||
BaseBean baseBean = new BaseBean();
|
||||
try {;
|
||||
scq = 0.00;
|
||||
String sql = "SELECT sum(attendancedays) as a FROM kq_format_total WHERE workdays is not null and resourceid = "+userId+" and kqdate >= '" +SalaryDateUtil.getFormatDate(fromDate)+"' and kqdate <= '"+ SalaryDateUtil.getFormatDate(endDate)+"'";
|
||||
baseBean.writeLog("wy-1" + sql);
|
||||
List<Map> list = getSQLMapper().runSQL(sql);
|
||||
baseBean.writeLog("wy-list" +list);
|
||||
if (CollectionUtils.isNotEmpty(list) && list.get(0) != null) {
|
||||
Object value = list.get(0).get("a");
|
||||
if (value != null) {
|
||||
baseBean.writeLog("wy-value" +value);
|
||||
scq = NumberUtils.isCreatable(value.toString()) ? Double.valueOf(value.toString()) : Double.valueOf("0");
|
||||
}
|
||||
}
|
||||
return new BigDecimal(String.valueOf(scq));
|
||||
} catch (Exception e) {
|
||||
baseBean.writeLog("获取实出勤出错" + e);
|
||||
return new BigDecimal("0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取法定节假日天数
|
||||
*/
|
||||
public BigDecimal getFdjjr(String fromDate, String toDate, String userId, KQGroupService kqGroupService) {
|
||||
BaseBean baseBean = new BaseBean();
|
||||
try {
|
||||
if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(fromDate) || StringUtils.isEmpty(toDate)) {
|
||||
baseBean.writeLog("userId or fromDate or toDate is null!" + fromDate + toDate + userId);
|
||||
return new BigDecimal("0");
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("viewScope", 3);
|
||||
params.put("resourceId", userId);
|
||||
params.put("groupType", 0);
|
||||
params.put("pageSize", 10);
|
||||
params.put("pageIndex", 1);
|
||||
User tmpUser = new User();
|
||||
tmpUser.setUid(1);
|
||||
tmpUser.setLoginid("sysadmin");
|
||||
|
||||
//获取当前人员的生效考勤组
|
||||
String activeGroupId = null;
|
||||
List<Map<String, Object>> dataSource = null;
|
||||
Map<String, Object> groupInfo = kqGroupService.getGroupMemberList(params, tmpUser);
|
||||
if (groupInfo != null && groupInfo.size() > 0) {
|
||||
if (groupInfo.get("dataSource") != null) {
|
||||
dataSource = (List<Map<String, Object>>) groupInfo.get("dataSource");
|
||||
if (dataSource != null && dataSource.size() > 0) {
|
||||
Map<String, Object> dataMap = dataSource.get(0);
|
||||
activeGroupId = dataMap.get("activeGroupId") + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (activeGroupId == null && activeGroupId.length() > 0) {
|
||||
baseBean.writeLog("activeGroupId is null:" + params + dataSource);
|
||||
return new BigDecimal("0");
|
||||
}
|
||||
|
||||
// 计算公共假期
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql ="select count(1) from kq_HolidaySet where changeType =1 and holidayDate>= '"+ fromDate + "' and holidayDate<= '"+toDate+"' and groupId = "+ activeGroupId;
|
||||
rs.execute(sql);
|
||||
int jq =0;
|
||||
if(rs.next()){
|
||||
jq = rs.getInt(1);
|
||||
}
|
||||
if(jq == -1) {
|
||||
jq = 0;
|
||||
}
|
||||
return new BigDecimal(String.valueOf(jq));
|
||||
} catch (Exception e) {
|
||||
baseBean.writeLog("获取法定节假日出错" + e);
|
||||
return new BigDecimal("0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据调薪计薪规则计算调薪后的值
|
||||
*
|
||||
|
|
|
|||
|
|
@ -123,6 +123,8 @@ public class SalaryAcctCalculateBO {
|
|||
*/
|
||||
private List<VariableItemPO> variableItems;
|
||||
|
||||
private SalarySobCycleDTO lastMonthSalarySobCycleDTO;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class Result {
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ public interface SalaryAcctRecordService {
|
|||
*/
|
||||
SalarySobCycleDTO getSalarySobCycleById(Long id);
|
||||
|
||||
SalarySobCycleDTO getLastMonthSalarySobCycleById(Long id);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.kq.service.KQGroupService;
|
||||
import com.engine.kq.service.impl.KQGroupServiceImpl;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.push.dto.PushRecordDTO;
|
||||
|
|
@ -299,8 +301,12 @@ public class PushServiceImpl extends Service implements PushService {
|
|||
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList());
|
||||
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
||||
|
||||
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), salaryAcctResultPOS, new ArrayList<>(), new ArrayList<>());
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO);
|
||||
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), salaryAcctResultPOS, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||
User tempUser = new User();
|
||||
tempUser.setUid(1);
|
||||
tempUser.setLoginid("sysadmin");
|
||||
KQGroupService kqGroupService = ServiceUtil.getService(KQGroupServiceImpl.class, tempUser);
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService);
|
||||
|
||||
//推送记录id
|
||||
List<Long> recordIds = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.engine.salary.service.impl;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.kq.service.KQGroupService;
|
||||
import com.engine.kq.service.impl.KQGroupServiceImpl;
|
||||
import com.engine.salary.cache.SalaryCacheKey;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.constant.SalaryFormulaFieldConstant;
|
||||
|
|
@ -131,6 +133,8 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
// 2、查询薪资档案的数据
|
||||
sw.start("查询薪资档案的数据");
|
||||
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
|
||||
// 获取上月的薪资档案值
|
||||
List<SalaryArchiveDataDTO> lastMonthSalaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salaryAcctCalculateBO.getLastMonthSalarySobCycleDTO().getSalaryCycle(), employeeIds, taxAgentIds);
|
||||
sw.stop();
|
||||
// 3、查询往期累计情况(查询的是上个税款所属期的的累计情况)
|
||||
sw.start("查询往期累计情况");
|
||||
|
|
@ -196,8 +200,12 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
sw.stop();
|
||||
// 10、转换成公式编辑器中的变量
|
||||
sw.start("转换成公式编辑器中的变量");
|
||||
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList,lastMonthResultPOS);
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO);
|
||||
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList,lastMonthResultPOS, lastMonthSalaryArchiveData);
|
||||
User tempUser = new User();
|
||||
tempUser.setUid(1);
|
||||
tempUser.setLoginid("sysadmin");
|
||||
KQGroupService kqGroupService = ServiceUtil.getService(KQGroupServiceImpl.class, tempUser);
|
||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService);
|
||||
sw.stop();
|
||||
sw.start("数据结构准备");
|
||||
// 本次薪资核算所用的薪资账套下的薪资项目
|
||||
|
|
|
|||
|
|
@ -279,6 +279,17 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalarySobCycleDTO getLastMonthSalarySobCycleById(Long id) {
|
||||
// 查询薪资核算
|
||||
SalaryAcctRecordPO salaryAcctRecordPO = getById(id);
|
||||
if (Objects.isNull(salaryAcctRecordPO)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
||||
}
|
||||
// 查询薪资核算所用薪资账套的薪资周期、考勤周期……
|
||||
return getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).minusMonths(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(SalaryAcctRecordSaveParam saveParam) {
|
||||
ValidUtil.doValidator(saveParam);
|
||||
|
|
|
|||
|
|
@ -899,6 +899,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
}
|
||||
// 2、查询薪资核算记录的薪资周期、考勤周期等
|
||||
SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(calculateParam.getSalaryAcctRecordId());
|
||||
SalarySobCycleDTO lastMonthSalarySobCycleDTO = getSalaryAcctRecordService(user).getLastMonthSalarySobCycleById(calculateParam.getSalaryAcctRecordId());
|
||||
// 3、查询薪资核算记录所用薪资账套的薪资项目副本
|
||||
List<SalarySobItemPO> salarySobItemPOS = salaryAcctSobConfig.getSalarySobItems();
|
||||
if (CollectionUtils.isEmpty(salarySobItemPOS)) {
|
||||
|
|
@ -983,7 +984,8 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
.setResults(calculateResults)
|
||||
.setCalculateKey(calculateKey)
|
||||
.setVariableItems(variableItemPOS)
|
||||
.setTaxDeclarationFunction(taxDeclarationFunction);
|
||||
.setTaxDeclarationFunction(taxDeclarationFunction)
|
||||
.setLastMonthSalarySobCycleDTO(lastMonthSalarySobCycleDTO);
|
||||
List<SalarySobBackItemPO> finalSalarySobBackItems = salarySobBackItems;
|
||||
if (isSync) {
|
||||
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);
|
||||
|
|
|
|||
Loading…
Reference in New Issue