2022-04-08 19:08:59 +08:00
|
|
|
|
package com.engine.salary.entity.salaryacct.bo;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2024-07-25 17:51:38 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
2022-12-13 16:39:39 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
|
2023-07-25 16:46:57 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
2024-12-06 16:00:05 +08:00
|
|
|
|
import com.engine.salary.enums.UserStatusEnum;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
|
|
|
|
|
import com.engine.salary.util.JsonUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2023-07-25 16:46:57 +08:00
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2024-12-06 16:00:05 +08:00
|
|
|
|
import weaver.general.Util;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
2024-05-14 14:27:19 +08:00
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.Optional;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资核算公式变量
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SalaryAcctFormulaBO {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 对核算结果做舍入操作
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param value
|
|
|
|
|
|
* @param salaryItem
|
2024-05-14 14:27:19 +08:00
|
|
|
|
* @param salarySobBackItems 薪资账套回算项目List
|
|
|
|
|
|
* @param salarySobBackItemMap 薪资账套回算项目Map
|
2023-07-25 16:46:57 +08:00
|
|
|
|
* @param salaryItemIdKeySalarySobItemPOMap 薪资账套下薪资项目Map
|
2022-04-08 19:08:59 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-07-25 16:46:57 +08:00
|
|
|
|
public static String roundResultValue(String value, SalaryItemPO salaryItem,
|
|
|
|
|
|
List<SalarySobBackItemPO> salarySobBackItems,
|
|
|
|
|
|
Map<Long, SalarySobBackItemPO> salarySobBackItemMap,
|
|
|
|
|
|
Map<Long, SalarySobItemPO> salaryItemIdKeySalarySobItemPOMap) {
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 值为空,不需要四舍五入
|
|
|
|
|
|
if (StringUtils.isEmpty(value) || salaryItem == null) {
|
|
|
|
|
|
return StringUtils.EMPTY;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 薪资项目字段类型为string,无需四舍五入
|
|
|
|
|
|
SalaryDataTypeEnum dataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItem.getDataType());
|
|
|
|
|
|
if (dataTypeEnum == SalaryDataTypeEnum.STRING) {
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
2023-07-25 16:46:57 +08:00
|
|
|
|
// 获取薪资账套副本中的舍入规则和保留位数,拿不到再去薪资项目中取
|
2023-07-26 13:43:53 +08:00
|
|
|
|
Integer salaryItemRoundingMode = Optional.ofNullable(salaryItemIdKeySalarySobItemPOMap.get(salaryItem.getId())).map(SalarySobItemPO::getRoundingMode)
|
2023-07-25 16:46:57 +08:00
|
|
|
|
.orElse(salaryItem.getRoundingMode());
|
2023-07-26 13:43:53 +08:00
|
|
|
|
Integer salaryItemPattern = Optional.ofNullable(salaryItemIdKeySalarySobItemPOMap.get(salaryItem.getId())).map(SalarySobItemPO::getPattern)
|
2023-07-25 16:46:57 +08:00
|
|
|
|
.orElse(salaryItem.getPattern());
|
2024-05-14 14:27:19 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(salarySobBackItems) && salarySobBackItemMap.containsKey(salaryItem.getId())) {
|
2023-07-25 16:46:57 +08:00
|
|
|
|
// 薪资项目是回算项目
|
2022-12-13 16:39:39 +08:00
|
|
|
|
salaryItemRoundingMode = salarySobBackItemMap.get(salaryItem.getId()).getRoundingMode();
|
|
|
|
|
|
salaryItemPattern = salarySobBackItemMap.get(salaryItem.getId()).getPattern();
|
|
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
BigDecimal bigDecimalValue = SalaryEntityUtil.empty2Zero(value);
|
2024-06-28 14:42:23 +08:00
|
|
|
|
return SalaryEntityUtil.carryRule(salaryItemPattern, salaryItemRoundingMode, bigDecimalValue).toPlainString();
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 变量中的人员信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param simpleEmployee
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-07-25 17:51:38 +08:00
|
|
|
|
public static Map<String, String> convert2FormulaEmployee(DataCollectionEmployee simpleEmployee, SalaryAcctEmployeePO salaryAcctEmployeePO, boolean dynamicEmpInfo) {
|
2022-04-08 19:08:59 +08:00
|
|
|
|
if (simpleEmployee == null) {
|
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
|
}
|
|
|
|
|
|
String sexName = Optional.ofNullable(simpleEmployee.getSex())
|
2022-09-01 16:17:27 +08:00
|
|
|
|
.map(sex -> StringUtils.equals(sex, "0") ? SalaryI18nUtil.getI18nLabel(102440, "男")
|
2022-04-08 19:08:59 +08:00
|
|
|
|
: SalaryI18nUtil.getI18nLabel(102442, "女"))
|
|
|
|
|
|
.orElse(StringUtils.EMPTY);
|
2024-07-25 17:51:38 +08:00
|
|
|
|
|
|
|
|
|
|
SalaryFormulaEmployeeDTO formulaEmployee = null;
|
|
|
|
|
|
if (dynamicEmpInfo) {
|
|
|
|
|
|
formulaEmployee = SalaryFormulaEmployeeDTO.builder()
|
|
|
|
|
|
.employeeId(simpleEmployee.getEmployeeId())
|
|
|
|
|
|
.username(simpleEmployee.getUsername())
|
|
|
|
|
|
.email(simpleEmployee.getEmail())
|
|
|
|
|
|
.mobile(simpleEmployee.getMobile())
|
|
|
|
|
|
.telephone(simpleEmployee.getTelephone())
|
|
|
|
|
|
.sex(sexName)
|
|
|
|
|
|
.status(simpleEmployee.getStatus())
|
|
|
|
|
|
.statusName(simpleEmployee.getStatusName())
|
2024-10-16 15:25:48 +08:00
|
|
|
|
.accountType(simpleEmployee.getAccountType())
|
|
|
|
|
|
.accountTypeName(simpleEmployee.getAccountTypeName())
|
2024-07-25 17:51:38 +08:00
|
|
|
|
.departmentName(simpleEmployee.getDepartmentName())
|
|
|
|
|
|
.departmentId(simpleEmployee.getDepartmentId())
|
|
|
|
|
|
.subcompanyName(simpleEmployee.getSubcompanyName())
|
|
|
|
|
|
.subcompanyId(simpleEmployee.getSubcompanyid())
|
|
|
|
|
|
.jobtitleName(simpleEmployee.getJobtitleName())
|
|
|
|
|
|
.jobtitleId(simpleEmployee.getJobtitleId())
|
|
|
|
|
|
.jobcall(simpleEmployee.getJobcall())
|
|
|
|
|
|
.jobcallId(simpleEmployee.getJobcallId())
|
|
|
|
|
|
.companystartdate(simpleEmployee.getCompanystartdate())
|
|
|
|
|
|
.birthday(simpleEmployee.getBirthday())
|
|
|
|
|
|
.workcode(simpleEmployee.getWorkcode())
|
|
|
|
|
|
.idNo(simpleEmployee.getIdNo())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
formulaEmployee = SalaryFormulaEmployeeDTO.builder()
|
|
|
|
|
|
.employeeId(simpleEmployee.getEmployeeId())
|
|
|
|
|
|
.username(simpleEmployee.getUsername())
|
|
|
|
|
|
.email(simpleEmployee.getEmail())
|
|
|
|
|
|
.mobile(simpleEmployee.getMobile())
|
|
|
|
|
|
.telephone(simpleEmployee.getTelephone())
|
|
|
|
|
|
.sex(sexName)
|
2024-12-06 16:00:05 +08:00
|
|
|
|
.status(salaryAcctEmployeePO.getStatus())
|
|
|
|
|
|
.statusName(UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(salaryAcctEmployeePO.getStatus(), "1"))))
|
2024-10-16 15:25:48 +08:00
|
|
|
|
.accountType(simpleEmployee.getAccountType())
|
|
|
|
|
|
.accountTypeName(simpleEmployee.getAccountTypeName())
|
2024-07-25 17:51:38 +08:00
|
|
|
|
.departmentName(salaryAcctEmployeePO.getDepartmentName())
|
|
|
|
|
|
.departmentId(salaryAcctEmployeePO.getDepartmentId())
|
|
|
|
|
|
.subcompanyName(salaryAcctEmployeePO.getSubcompanyName())
|
|
|
|
|
|
.subcompanyId(salaryAcctEmployeePO.getSubcompanyId())
|
|
|
|
|
|
.jobtitleName(salaryAcctEmployeePO.getJobtitleName())
|
|
|
|
|
|
.jobtitleId(salaryAcctEmployeePO.getJobtitleId())
|
|
|
|
|
|
.jobcall(salaryAcctEmployeePO.getJobcall())
|
|
|
|
|
|
.jobcallId(salaryAcctEmployeePO.getJobcallId())
|
|
|
|
|
|
.companystartdate(simpleEmployee.getCompanystartdate())
|
|
|
|
|
|
.birthday(simpleEmployee.getBirthday())
|
|
|
|
|
|
.workcode(simpleEmployee.getWorkcode())
|
|
|
|
|
|
.idNo(simpleEmployee.getIdNo())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
return JsonUtil.parseMap(JsonUtil.toJsonString(formulaEmployee), String.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|