有向无环拓扑排序
This commit is contained in:
parent
464bb9d623
commit
02100c2ee3
|
|
@ -68,7 +68,7 @@ public class SalaryAcctCalculateBO {
|
|||
/**
|
||||
* 本次运算的薪资项目(已排好运算优先级)
|
||||
*/
|
||||
private List<List<Long>> salaryItemIdWithPriorityList;
|
||||
private List<Long> salaryItemIdWithPriorityList;
|
||||
|
||||
/**
|
||||
* 本次运算涉及的所有公式
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.engine.salary.entity.salaryacct.bo;
|
||||
|
||||
import com.engine.salary.constant.SalaryFormulaFieldConstant;
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
|
|
@ -21,9 +20,10 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.engine.salary.constant.SalaryFormulaFieldConstant.SALARY_PATTERN;
|
||||
|
||||
/**
|
||||
* 薪资核算-薪资项目运算优先级
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
|
|
@ -34,16 +34,6 @@ import java.util.stream.Collectors;
|
|||
**/
|
||||
public class SalaryAcctCalculatePriorityBO {
|
||||
|
||||
/**
|
||||
* 公式中变量的fieldId的正则表达式
|
||||
*/
|
||||
private static final String SALARY_REGEX = "(\\w+)" + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + "(\\w+)";
|
||||
|
||||
/**
|
||||
* 解析公式中变量的fieldId的正则表达式
|
||||
*/
|
||||
private static final Pattern SALARY_PATTERN = Pattern.compile(SALARY_REGEX);
|
||||
|
||||
/**
|
||||
* 计算优先级
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,15 +3,18 @@ package com.engine.salary.entity.salaryacct.bo;
|
|||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.enums.SalaryRoundingModeEnum;
|
||||
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @description: 薪资核算涉及的薪资项目
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 2023/5/19 16:00
|
||||
* @version:v1.0
|
||||
*/
|
||||
* 薪资核算涉及的薪资项目
|
||||
* <p>Copyright: Copyright (c) 2023</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SalaryCalcItem {
|
||||
|
||||
|
|
@ -53,81 +56,4 @@ public class SalaryCalcItem {
|
|||
private ExpressFormula expressFormula;
|
||||
|
||||
|
||||
public Long getSalaryItemId() {
|
||||
return salaryItemId;
|
||||
}
|
||||
|
||||
public void setSalaryItemId(Long salaryItemId) {
|
||||
this.salaryItemId = salaryItemId;
|
||||
}
|
||||
|
||||
public String getSalaryItemCode() {
|
||||
return salaryItemCode;
|
||||
}
|
||||
|
||||
public void setSalaryItemCode(String salaryItemCode) {
|
||||
this.salaryItemCode = salaryItemCode;
|
||||
}
|
||||
|
||||
public String getIncomeCategory() {
|
||||
return incomeCategory;
|
||||
}
|
||||
|
||||
public void setIncomeCategory(String incomeCategory) {
|
||||
this.incomeCategory = incomeCategory;
|
||||
}
|
||||
|
||||
public Integer getUseInEmployeeSalary() {
|
||||
return useInEmployeeSalary;
|
||||
}
|
||||
|
||||
public void setUseInEmployeeSalary(Integer useInEmployeeSalary) {
|
||||
this.useInEmployeeSalary = useInEmployeeSalary;
|
||||
}
|
||||
|
||||
public String getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(String dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public Integer getRoundingMode() {
|
||||
return roundingMode;
|
||||
}
|
||||
|
||||
public void setRoundingMode(Integer roundingMode) {
|
||||
this.roundingMode = roundingMode;
|
||||
}
|
||||
|
||||
public Integer getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(Integer pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public ExpressFormula getExpressFormula() {
|
||||
return expressFormula;
|
||||
}
|
||||
|
||||
public void setExpressFormula(ExpressFormula expressFormula) {
|
||||
this.expressFormula = expressFormula;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SalaryCalcItem{" +
|
||||
"salaryItemId=" + salaryItemId +
|
||||
", salaryItemCode='" + salaryItemCode + '\'' +
|
||||
", incomeCategory='" + incomeCategory + '\'' +
|
||||
", useInEmployeeSalary=" + useInEmployeeSalary +
|
||||
", dataType='" + dataType + '\'' +
|
||||
", roundingMode=" + roundingMode +
|
||||
", pattern=" + pattern +
|
||||
", expressFormula=" + expressFormula +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package com.engine.salary.entity.salaryacct.bo;
|
|||
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
||||
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
|
||||
import com.engine.salary.report.common.constant.SalaryConstant;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
|
|
@ -13,12 +15,13 @@ import java.util.*;
|
|||
import java.util.concurrent.LinkedTransferQueue;
|
||||
|
||||
/**
|
||||
* @description: 对薪资核算时涉及的薪资项目进行排序
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 2023/5/19 16:01
|
||||
* @version:v1.0
|
||||
*/
|
||||
* 对薪资核算时涉及的薪资项目进行排序
|
||||
* <p>Copyright: Copyright (c) 2023</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public class SalaryCalcItemGraph {
|
||||
|
||||
private List<SalaryCalcItemGraphNode> nodes;
|
||||
|
|
@ -29,8 +32,9 @@ public class SalaryCalcItemGraph {
|
|||
* @param salarySobItems 薪资账套的薪资项目
|
||||
* @param expressFormulas 公式详情
|
||||
*/
|
||||
public SalaryCalcItemGraph(List<SalarySobItemPO> salarySobItems, List<ExpressFormula> expressFormulas) {
|
||||
Map<String, SalarySobItemPO> salaryItemMap = SalaryEntityUtil.convert2Map(salarySobItems, SalarySobItemPO::getSalaryItemCode);
|
||||
public SalaryCalcItemGraph(List<SalarySobItemPO> salarySobItems, List<SalaryItemPO> salaryItemPOS, List<ExpressFormula> expressFormulas) {
|
||||
Map<String, SalarySobItemPO> salarySobItemMap = SalaryEntityUtil.convert2Map(salarySobItems, SalarySobItemPO::getSalaryItemCode);
|
||||
Map<String, SalaryItemPO> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItemPOS, SalaryItemPO::getCode);
|
||||
Map<Long, ExpressFormula> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId);
|
||||
Map<Long, List<FormulaVar>> formulaVarMap = ExpressFormulaBO.buildFormulaVar(expressFormulas);
|
||||
|
||||
|
|
@ -40,14 +44,20 @@ public class SalaryCalcItemGraph {
|
|||
SalaryCalcItemGraphNode node = nodeMap.computeIfAbsent(salarySobItem.getSalaryItemId(), key -> new SalaryCalcItemGraphNode(salarySobItem, expressFormula));
|
||||
List<FormulaVar> formulaVars = expressFormula == null ? Collections.emptyList() : formulaVarMap.getOrDefault(expressFormula.getId(), Collections.emptyList());
|
||||
for (FormulaVar formulaVar : formulaVars) {
|
||||
if (StringUtils.isNotEmpty(formulaVar.getFieldId())) {
|
||||
if (StringUtils.isNotEmpty(formulaVar.getFieldId()) && StringUtils.startsWith(formulaVar.getFieldId(), SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() + SalaryConstant.FORMULA_VAR_SEPARATOR)) {
|
||||
String salaryItemCode = formulaVar.getFieldId().split(SalaryConstant.FORMULA_VAR_SEPARATOR)[1];
|
||||
SalarySobItemPO subSalarySobItem = salaryItemMap.get(salaryItemCode);
|
||||
SalarySobItemPO subSalarySobItem = salarySobItemMap.get(salaryItemCode);
|
||||
if (subSalarySobItem == null) {
|
||||
SalaryItemPO salaryItemPO = salaryItemMap.get(salaryItemCode);
|
||||
if (salaryItemPO == null) {
|
||||
continue;
|
||||
}else {
|
||||
subSalarySobItem = SalarySobItemPO.builder().salaryItemId(salaryItemPO.getId()).salaryItemCode(salaryItemPO.getCode()).build();
|
||||
}
|
||||
}
|
||||
ExpressFormula subExpressFormula = expressFormulaMap.get(subSalarySobItem.getFormulaId());
|
||||
SalaryCalcItemGraphNode destNode = nodeMap.computeIfAbsent(subSalarySobItem.getSalaryItemId(), key -> new SalaryCalcItemGraphNode(subSalarySobItem, subExpressFormula));
|
||||
SalarySobItemPO finalSubSalarySobItem = subSalarySobItem;
|
||||
SalaryCalcItemGraphNode destNode = nodeMap.computeIfAbsent(subSalarySobItem.getSalaryItemId(), key -> new SalaryCalcItemGraphNode(finalSubSalarySobItem, subExpressFormula));
|
||||
node.getDestNodes().add(destNode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class TaxDeclarationValueList {
|
|||
dataMap.put("username", employeeDeclare.getEmployeeName());
|
||||
dataMap.put("cardType", SalaryI18nUtil.getI18nLabel(CardTypeEnum.RESIDENT_IDENTITY_CARDS.getLabelId(), CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel()));
|
||||
dataMap.put("cardNum", employeeDeclare.getCardNum());
|
||||
} else if (Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) {
|
||||
} else if (taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) {
|
||||
DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(taxDeclarationValue.getEmployeeId());
|
||||
DataCollectionEmployee simpleUserInfo = simpleUserInfoMap.get(taxDeclarationValue.getEmployeeId());
|
||||
dataMap.put("jobNum", simpleEmployee.getWorkcode());
|
||||
|
|
|
|||
|
|
@ -4,20 +4,23 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO;
|
||||
import com.engine.salary.entity.progress.ProgressDTO;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryCalcItem;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryCalcItemGraph;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO;
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
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.entity.salarysob.po.SalarySobBackItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
||||
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper;
|
||||
import com.engine.salary.service.*;
|
||||
|
|
@ -38,6 +41,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import weaver.hrm.User;
|
||||
|
|
@ -47,8 +51,11 @@ import java.util.*;
|
|||
import java.util.concurrent.BlockingDeque;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.engine.salary.constant.SalaryFormulaFieldConstant.SALARY_PATTERN;
|
||||
|
||||
/**
|
||||
* 薪资核算维护类
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
|
|
@ -294,9 +301,10 @@ public class SalaryAcctManager extends Service {
|
|||
formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId));
|
||||
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds);
|
||||
// 本次运算的回算薪资项目所涉及的变量
|
||||
Set<String> issuedFieldIds = new HashSet<>();
|
||||
Set<String> issuedFieldIds = getIssuedFieldIds(salarySobBackItems);
|
||||
// 9、计算薪资项目的运算优先级
|
||||
List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas, salarySobBackItems, issuedFieldIds);
|
||||
// List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas, salarySobBackItems, issuedFieldIds);
|
||||
List<Long> salarySobItemsWithPriority = sortItems(salarySobItemPOS, salarySobBackItems, salaryItemPOS, expressFormulas);
|
||||
// 10、根据id查询其他合并计税的薪资核算记录
|
||||
List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAcctRecordPO.getId());
|
||||
// 11、查询本次核算人员
|
||||
|
|
@ -396,5 +404,43 @@ public class SalaryAcctManager extends Service {
|
|||
getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Long> sortItems(List<SalarySobItemPO> salarySobItemPOS, List<SalarySobBackItemPO> salarySobBackItems, List<SalaryItemPO> salaryItemPOS, List<ExpressFormula> expressFormulas) {
|
||||
List<SalarySobItemPO> temp = salarySobBackItems.stream()
|
||||
.map(e -> {
|
||||
SalarySobItemPO salarySobItem = new SalarySobItemPO();
|
||||
BeanUtils.copyProperties(e, salarySobItem);
|
||||
return salarySobItem;
|
||||
}).collect(Collectors.toList());
|
||||
salarySobItemPOS.addAll(temp);
|
||||
|
||||
SalaryCalcItemGraph salaryCalcItemGraph = new SalaryCalcItemGraph(salarySobItemPOS, salaryItemPOS, expressFormulas);
|
||||
List<SalaryCalcItem> salaryCalcItems = salaryCalcItemGraph.sort();
|
||||
return SalaryEntityUtil.properties(salaryCalcItems, SalaryCalcItem::getSalaryItemId, Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取回算变量
|
||||
*
|
||||
* @param salarySobBackItems
|
||||
* @return
|
||||
*/
|
||||
@NotNull
|
||||
private Set<String> getIssuedFieldIds(List<SalarySobBackItemPO> salarySobBackItems) {
|
||||
Set<String> issuedFieldIds;
|
||||
Set<Long> issuedFormulaIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId);
|
||||
List<ExpressFormula> expressFormulas1 = getSalaryFormulaService(user).listExpressFormula(issuedFormulaIds);
|
||||
List<FormulaVar> issuedFormulaVars = new ArrayList<>();
|
||||
expressFormulas1.forEach(f -> issuedFormulaVars.addAll(f.getParameters()));
|
||||
issuedFieldIds = issuedFormulaVars.stream()
|
||||
.map(FormulaVar::getFieldId)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.filter(v -> v.startsWith(SalaryFormulaReferenceEnum.ISSUED.getValue() + "_"))
|
||||
.map(SALARY_PATTERN::matcher)
|
||||
.filter(Matcher::find)
|
||||
.map(m -> m.group(2))
|
||||
.collect(Collectors.toSet());
|
||||
return issuedFieldIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,9 +183,8 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
formulaVarValues.addAll(empInfo);
|
||||
Map<String, String> formulaVarValueMap = SalaryEntityUtil.convert2Map(formulaVarValues, CalculateFormulaVarBO.FormulaVarValue::getFieldId, CalculateFormulaVarBO.FormulaVarValue::getFieldValue);
|
||||
// 按照计算好的优先级计算薪资项目的值
|
||||
for (List<Long> salaryItemIds : salaryAcctCalculateBO.getSalaryItemIdWithPriorityList()) {
|
||||
for (Long salaryItemId : salaryAcctCalculateBO.getSalaryItemIdWithPriorityList()) {
|
||||
// 同一运算优先级下的薪资项目逐个独立运算
|
||||
for (Long salaryItemId : salaryItemIds) {
|
||||
String resultValue;
|
||||
SalaryItemPO salaryItemPO = salaryItemMap.get(salaryItemId);
|
||||
ExpressFormula expressFormula;
|
||||
|
|
@ -261,7 +260,6 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 保存新的薪资核算结果(临时存储)
|
||||
getSalaryAcctResultTempService(user).batchSave(salaryAcctResultTempPOS);
|
||||
// 更新薪资核算进度
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO;
|
|||
import com.engine.salary.entity.salaryacct.param.*;
|
||||
import com.engine.salary.entity.salaryacct.po.*;
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.salarysob.dto.*;
|
||||
import com.engine.salary.entity.salarysob.po.*;
|
||||
|
|
@ -26,6 +27,7 @@ import com.engine.salary.enums.SalaryValueTypeEnum;
|
|||
import com.engine.salary.enums.salaryaccounting.LockStatusEnum;
|
||||
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
|
||||
import com.engine.salary.enums.salaryaccounting.SalaryAcctResultDataSourceEnum;
|
||||
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
|
||||
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
||||
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
|
|
@ -54,6 +56,8 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -62,8 +66,11 @@ import java.util.*;
|
|||
import java.util.concurrent.BlockingDeque;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.engine.salary.constant.SalaryFormulaFieldConstant.SALARY_PATTERN;
|
||||
|
||||
/**
|
||||
* 薪资核算结果
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
|
|
@ -623,6 +630,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
|
||||
/**
|
||||
* 存储薪资核算结果数据来源日志
|
||||
*
|
||||
* @param salaryAcctResultPOSOld
|
||||
* @param salaryAcctResultPOS
|
||||
*/
|
||||
|
|
@ -731,14 +739,10 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId));
|
||||
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds);
|
||||
// 本次运算的回算薪资项目所涉及的变量
|
||||
Set<String> issuedFieldIds = new HashSet<>();
|
||||
Set<String> issuedFieldIds = getIssuedFieldIds(salarySobBackItems);
|
||||
// 9、计算薪资项目的运算优先级
|
||||
List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas, salarySobBackItems, issuedFieldIds);
|
||||
// List<List<Long>> salarySobItemsWithPriority = new ArrayList<>();
|
||||
SalaryCalcItemGraph salaryCalcItemGraph = new SalaryCalcItemGraph(salarySobItemPOS, expressFormulas);
|
||||
List<SalaryCalcItem> salaryCalcItems = salaryCalcItemGraph.sort();
|
||||
List<Long> properties = SalaryEntityUtil.properties(salaryCalcItems, SalaryCalcItem::getSalaryItemId, Collectors.toList());
|
||||
// salarySobItemsWithPriority.add(properties);
|
||||
// List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas, salarySobBackItems, issuedFieldIds);
|
||||
List<Long> salarySobItemsWithPriority = sortItems(salarySobItemPOS, salarySobBackItems, salaryItemPOS, expressFormulas);
|
||||
|
||||
// 10、根据id查询其他合并计税的薪资核算记录
|
||||
List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAcctRecordPO.getId());
|
||||
|
|
@ -849,6 +853,46 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Long> sortItems(List<SalarySobItemPO> salarySobItemPOS, List<SalarySobBackItemPO> salarySobBackItems, List<SalaryItemPO> salaryItemPOS, List<ExpressFormula> expressFormulas) {
|
||||
|
||||
List<SalarySobItemPO> temp = salarySobBackItems.stream()
|
||||
.map(e -> {
|
||||
SalarySobItemPO salarySobItem = new SalarySobItemPO();
|
||||
BeanUtils.copyProperties(e, salarySobItem);
|
||||
return salarySobItem;
|
||||
}).collect(Collectors.toList());
|
||||
salarySobItemPOS.addAll(temp);
|
||||
|
||||
SalaryCalcItemGraph salaryCalcItemGraph = new SalaryCalcItemGraph(salarySobItemPOS, salaryItemPOS, expressFormulas);
|
||||
List<SalaryCalcItem> salaryCalcItems = salaryCalcItemGraph.sort();
|
||||
return SalaryEntityUtil.properties(salaryCalcItems, SalaryCalcItem::getSalaryItemId, Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取回算变量
|
||||
*
|
||||
* @param salarySobBackItems
|
||||
* @return
|
||||
*/
|
||||
@NotNull
|
||||
private Set<String> getIssuedFieldIds(List<SalarySobBackItemPO> salarySobBackItems) {
|
||||
Set<String> issuedFieldIds;
|
||||
Set<Long> issuedFormulaIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId);
|
||||
List<ExpressFormula> expressFormulas1 = getSalaryFormulaService(user).listExpressFormula(issuedFormulaIds);
|
||||
List<FormulaVar> issuedFormulaVars = new ArrayList<>();
|
||||
expressFormulas1.forEach(f -> issuedFormulaVars.addAll(f.getParameters()));
|
||||
issuedFieldIds = issuedFormulaVars.stream()
|
||||
.map(FormulaVar::getFieldId)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.filter(v -> v.startsWith(SalaryFormulaReferenceEnum.ISSUED.getValue() + "_"))
|
||||
.map(SALARY_PATTERN::matcher)
|
||||
.filter(Matcher::find)
|
||||
.map(m -> m.group(2))
|
||||
.collect(Collectors.toSet());
|
||||
return issuedFieldIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理薪资核算临时存储表中的数据
|
||||
*
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
|
|||
List<EmployeeDeclarePO> employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentIdAndEmployeeIds(taxDeclaration.getTaxCycle(), taxDeclaration.getTaxAgentId(), employeeIds);
|
||||
// 查询人员信息
|
||||
List<Long> simpleEmployeeIds = taxDeclarationValues.stream()
|
||||
.filter(taxDeclarationValue -> Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))
|
||||
.filter(taxDeclarationValue -> taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))
|
||||
.map(TaxDeclarationValuePO::getEmployeeId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
|
|
|||
|
|
@ -368,6 +368,9 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
getAddUpSituationService(user).batchSave(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//更新核算记录状态
|
||||
getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED);
|
||||
}
|
||||
|
||||
private TaxDeclarationResult generateReportPerRecord(TaxDeclareRecordPO taxDeclareRecord, List<SalaryAcctEmployeePO> salaryAcctEmployees) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue