2022-04-08 19:08:59 +08:00
|
|
|
|
package com.engine.salary.entity.salaryacct.bo;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
|
|
|
|
|
import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
|
|
|
|
|
import com.engine.salary.enums.SalaryRoundingModeEnum;
|
|
|
|
|
|
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;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资核算公式变量
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SalaryAcctFormulaBO {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 对核算结果做舍入操作
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param value
|
|
|
|
|
|
* @param salaryItem
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String roundResultValue(String value, SalaryItemPO salaryItem) {
|
|
|
|
|
|
// 值为空,不需要四舍五入
|
|
|
|
|
|
if (StringUtils.isEmpty(value) || salaryItem == null) {
|
|
|
|
|
|
return StringUtils.EMPTY;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 薪资项目字段类型为string,无需四舍五入
|
|
|
|
|
|
SalaryDataTypeEnum dataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItem.getDataType());
|
|
|
|
|
|
if (dataTypeEnum == SalaryDataTypeEnum.STRING) {
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
BigDecimal bigDecimalValue = SalaryEntityUtil.empty2Zero(value);
|
|
|
|
|
|
RoundingMode roundingMode = RoundingMode.HALF_UP;
|
|
|
|
|
|
if (Objects.equals(salaryItem.getRoundingMode(), SalaryRoundingModeEnum.ROUND_UP.getValue())) {
|
|
|
|
|
|
roundingMode = RoundingMode.UP;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Objects.equals(salaryItem.getRoundingMode(), SalaryRoundingModeEnum.ROUND_DOWN.getValue())) {
|
|
|
|
|
|
roundingMode = RoundingMode.DOWN;
|
|
|
|
|
|
}
|
2022-08-17 18:33:46 +08:00
|
|
|
|
//见分取角(只取保留小数后一位向上舍入)
|
|
|
|
|
|
if (Objects.equals(salaryItem.getRoundingMode(), SalaryRoundingModeEnum.CEILING.getValue())) {
|
|
|
|
|
|
bigDecimalValue = bigDecimalValue.setScale(salaryItem.getPattern() + 1, RoundingMode.FLOOR);
|
|
|
|
|
|
roundingMode = RoundingMode.UP;
|
|
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
return bigDecimalValue.setScale(salaryItem.getPattern(), roundingMode).toPlainString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 变量中的人员信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param simpleEmployee
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static Map<String, String> convert2FormulaEmployee(DataCollectionEmployee simpleEmployee) {
|
|
|
|
|
|
if (simpleEmployee == null) {
|
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
|
}
|
|
|
|
|
|
String sexName = Optional.ofNullable(simpleEmployee.getSex())
|
|
|
|
|
|
.map(sex -> StringUtils.equals(sex,"0") ? SalaryI18nUtil.getI18nLabel(102440, "男")
|
|
|
|
|
|
: SalaryI18nUtil.getI18nLabel(102442, "女"))
|
|
|
|
|
|
.orElse(StringUtils.EMPTY);
|
|
|
|
|
|
SalaryFormulaEmployeeDTO formulaEmployee = SalaryFormulaEmployeeDTO.builder()
|
|
|
|
|
|
.employeeId(simpleEmployee.getEmployeeId())
|
|
|
|
|
|
.username(simpleEmployee.getUsername())
|
|
|
|
|
|
.email(simpleEmployee.getEmail())
|
|
|
|
|
|
.mobile(simpleEmployee.getMobile())
|
|
|
|
|
|
.telephone(simpleEmployee.getTelephone())
|
|
|
|
|
|
.sex(sexName)
|
|
|
|
|
|
.status(simpleEmployee.getStatus())
|
|
|
|
|
|
.departmentName(simpleEmployee.getDepartmentName())
|
2022-08-29 14:50:26 +08:00
|
|
|
|
.subcompanyName(simpleEmployee.getSubcompanyName())
|
2022-04-29 14:17:31 +08:00
|
|
|
|
.jobtitleName(simpleEmployee.getJobtitleName())
|
|
|
|
|
|
.jobcall(simpleEmployee.getJobcall())
|
|
|
|
|
|
.companystartdate(simpleEmployee.getCompanystartdate())
|
2022-04-08 19:08:59 +08:00
|
|
|
|
.birthday(simpleEmployee.getBirthday())
|
2022-07-04 18:58:49 +08:00
|
|
|
|
.workcode(simpleEmployee.getWorkcode())
|
2022-04-08 19:08:59 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
return JsonUtil.parseMap(JsonUtil.toJsonString(formulaEmployee), String.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|