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;
|
|
|
|
|
|
}
|
|
|
|
|
|
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())
|
|
|
|
|
|
.positionName(simpleEmployee.getJobtitleName())
|
|
|
|
|
|
.gradeName(simpleEmployee.getJobcall())
|
2022-04-28 10:05:27 +08:00
|
|
|
|
.hireDate(simpleEmployee.getCompanystartdate())
|
2022-04-08 19:08:59 +08:00
|
|
|
|
.birthday(simpleEmployee.getBirthday())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
return JsonUtil.parseMap(JsonUtil.toJsonString(formulaEmployee), String.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|